Support for record variables being assigned to record variables

This commit is contained in:
mysticbbs 2012-04-02 04:15:12 -04:00
parent 4a65df60cc
commit ebf17764fe
2 changed files with 55 additions and 30 deletions

View File

@ -134,6 +134,7 @@ Type
Procedure ParseVarFile; Procedure ParseVarFile;
Procedure ParseVarBoolean; Procedure ParseVarBoolean;
Procedure ParseVarChar; Procedure ParseVarChar;
Procedure ParseVarRecord;
Procedure ParseVariable (VT: TIdentTypes); Procedure ParseVariable (VT: TIdentTypes);
Procedure ParseArray (VN: Word); Procedure ParseArray (VN: Word);
Function ParseElement (VN: Word; TypeCheck: Boolean; VT: TIdentTypes) : TIdentTypes; Function ParseElement (VN: Word; TypeCheck: Boolean; VT: TIdentTypes) : TIdentTypes;
@ -822,11 +823,11 @@ Begin
Case RecData[VarData[VN]^.RecID]^.Fields[Count].vType of Case RecData[VarData[VN]^.RecID]^.Fields[Count].vType of
iString : OutWord(RecData[VarData[VN]^.RecID]^.Fields[Count].StrLen); iString : OutWord(RecData[VarData[VN]^.RecID]^.Fields[Count].StrLen);
Else Else
OutWord(GetVarSize(RecData[VarData[VN]^.RecID]^.Fields[Count].vType)); OutWord (GetVarSize(RecData[VarData[VN]^.RecID]^.Fields[Count].vType));
End; End;
OutWord (Offset); OutWord (Offset);
OutWord (RecData[VarData[VN]^.RecID]^.Fields[Count].ArrDem); OutWord (RecData[VarData[VN]^.RecID]^.Fields[Count].ArrDem);
If RecData[VarData[VN]^.RecID]^.Fields[Count].ArrDem > 0 Then Begin If RecData[VarData[VN]^.RecID]^.Fields[Count].ArrDem > 0 Then Begin
GetStr(tkw[wOpenArray], True, False); GetStr(tkw[wOpenArray], True, False);
@ -1289,6 +1290,22 @@ Begin
If VarData[VarNum]^.vType <> iFile Then Error (mpsTypeMismatch, ''); If VarData[VarNum]^.vType <> iFile Then Error (mpsTypeMismatch, '');
End; End;
Procedure TParserEngine.ParseVarRecord;
Var
VarNum : Word;
Begin
GetIdent(True);
If UpdateInfo.ErrorType <> 0 Then Exit;
VarNum := FindVariable(IdentStr);
If VarData[VarNum]^.vType <> iRecord Then
Error (mpsTypeMismatch, '');
OutWord (VarNum);
End;
Procedure TParserEngine.NewBooleanCrap; Procedure TParserEngine.NewBooleanCrap;
Var Var
VarNum : Word; VarNum : Word;
@ -1501,36 +1518,37 @@ begin
GetEvalIdent (VarType1); GetEvalIdent (VarType1);
if updateinfo.errorType <> 0 then Exit; If UpdateInfo.ErrorType <> 0 Then Exit;
if GetStr(tkw[wOpEqual], False, False) then begin OutString(Char(OpEqual)); OpType := topEqual; end else If GetStr(tkw[wOpEqual], False, False) Then Begin OutString(Char(OpEqual)); OpType := topEqual; End Else
if GetStr(tkw[wOpNotEqual], False, False) then begin OutString(Char(OpNotEqual)); OpType := topNotEqual; end else If GetStr(tkw[wOpNotEqual], False, False) Then Begin OutString(Char(OpNotEqual)); OpType := topNotEqual; End Else
if GetStr(tkw[wOpEqGreat], False, False) then begin OutString(Char(OpEqGreat)); OpType := topEqGreat; end else If GetStr(tkw[wOpEqGreat], False, False) Then Begin OutString(Char(OpEqGreat)); OpType := topEqGreat; End Else
if GetStr(tkw[wOpEqLess], False, False) then begin OutString(Char(OpEqLess)); OpType := topEqLess; end else If GetStr(tkw[wOpEqLess], False, False) Then Begin OutString(Char(OpEqLess)); OpType := topEqLess; End Else
if GetStr(tkw[wOpGreater], False, False) then begin OutString(Char(OpGreater)); OpType := topGreater; end else If GetStr(tkw[wOpGreater], False, False) Then Begin OutString(Char(OpGreater)); OpType := topGreater; End Else
if GetStr(tkw[wOpLess], False, False) then begin OutString(Char(OpLess)); OpType := topLess; end else If GetStr(tkw[wOpLess], False, False) Then Begin OutString(Char(OpLess)); OpType := topLess; End Else
if VarType1 <> iBool then Error(mpsExpOperator, ''); If VarType1 <> iBool then Error(mpsExpOperator, '');
if OpType <> tOpNone then begin If OpType <> tOpNone then begin
GetEvalIdent(VarType2); GetEvalIdent(VarType2);
if updateinfo.errorType <> 0 then Exit; If UpdateInfo.ErrorType <> 0 Then Exit;
if ((VarType1 in vStrings) and (Not (VarType2 in vStrings))) or If ((VarType1 in vStrings) and (Not (VarType2 in vStrings))) or
((VarType1 = iBool) and (VarType2 <> iBool)) or ((VarType1 = iBool) and (VarType2 <> iBool)) or
((VarType1 = iFile) and (VarType2 <> iFile)) or ((VarType1 = iFile) and (VarType2 <> iFile)) or
((VarType1 in vNums) and (not (VarType2 in vNums))) Then Error(mpsTypeMismatch, ''); ((VarType1 in vNums) and (not (VarType2 in vNums))) Then
end; Error(mpsTypeMismatch, '');
End;
if GetStr(tkw[wAnd], False, False) then begin If GetStr(tkw[wAnd], False, False) Then Begin
OutString(Char(opAnd)); OutString(Char(opAnd));
ParseVarBoolean; ParseVarBoolean;
end else End Else
if GetStr(tkw[wOr], False, False) then begin If GetStr(tkw[wOr], False, False) Then Begin
OutString(Char(opOr)); OutString(Char(opOr));
ParseVarBoolean; ParseVarBoolean;
end; End;
end; End;
Procedure TParserEngine.ParseVariable (VT: TIdentTypes); Procedure TParserEngine.ParseVariable (VT: TIdentTypes);
Begin Begin
@ -1538,7 +1556,10 @@ Begin
If VT = iString Then ParseVarString Else If VT = iString Then ParseVarString Else
If VT = iChar Then ParseVarChar Else If VT = iChar Then ParseVarChar Else
If VT = iBool Then ParseVarBoolean Else If VT = iBool Then ParseVarBoolean Else
If VT = iRecord Then ParseVarRecord Else
If VT = iFile Then Error(mpsInStatement,''); If VT = iFile Then Error(mpsInStatement,'');
// pointer
End; End;
Function TParserEngine.GetDataSize (Info: TParserVarInfoRec) : LongInt; Function TParserEngine.GetDataSize (Info: TParserVarInfoRec) : LongInt;
@ -2553,13 +2574,12 @@ Begin
If VarData[VarNum]^.Proc Then Begin If VarData[VarNum]^.Proc Then Begin
If Not SetProcResult(VarNum) Then ExecuteProcedure(VarNum, False); If Not SetProcResult(VarNum) Then ExecuteProcedure(VarNum, False);
End Else Begin End Else Begin
OutString (Char(opSetVar)); OutString (Char(opSetVar));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum);
VT := ParseElement (VarNum, False, iNone); VT := ParseElement (VarNum, False, iNone);
//will need to pull vartype from parse array here
GetChar; GetChar;
// prob shoud be iString check here. also need to // prob shoud be iString check here. also need to
@ -2741,9 +2761,9 @@ Begin
FillChar (InFile[CurFile], SizeOf(InFile[CurFile]), 0); FillChar (InFile[CurFile], SizeOf(InFile[CurFile]), 0);
InFile[CurFile].Position := 1; InFile[CurFile].Position := 1;
InFile[CurFile].PosSaved := -1; InFile[CurFile].PosSaved := -1;
InFile[CurFile].Size := 1; InFile[CurFile].Size := 1;
If CurFile = 1 Then If CurFile = 1 Then
UpdateStatus(StatusStart) UpdateStatus(StatusStart)

View File

@ -958,6 +958,11 @@ Begin
iCardinal : Cardinal(GetDataPtr(VarNum, ArrayData, RecInfo)^) := Trunc(EvaluateNumber); iCardinal : Cardinal(GetDataPtr(VarNum, ArrayData, RecInfo)^) := Trunc(EvaluateNumber);
iReal : Real(GetDataPtr(VarNum, ArrayData, RecInfo)^) := EvaluateNumber; iReal : Real(GetDataPtr(VarNum, ArrayData, RecInfo)^) := EvaluateNumber;
iBool : ByteBool(GetDataPtr(VarNum, ArrayData, RecInfo)^) := EvaluateBoolean; iBool : ByteBool(GetDataPtr(VarNum, ArrayData, RecInfo)^) := EvaluateBoolean;
iRecord : Begin
NextWord;
Move (VarData[W]^.Data^, GetDataPtr(VarNum, ArrayData, RecInfo)^, VarData[W]^.DataSize);
End;
End; End;
End; End;