Cardinal + record stuff
This commit is contained in:
parent
cc33cd02d5
commit
a4ab7a1990
|
@ -4087,3 +4087,5 @@
|
|||
+ The ALT-U local Sysop command has been removed (moved to user editor).
|
||||
Alt-E now opens a local user editor for the user which also contains the
|
||||
Upgrade option.
|
||||
|
||||
+ Added CARDINAL (Unsigned 32-bit Integer) type to MPL
|
||||
|
|
|
@ -53,6 +53,7 @@ Begin
|
|||
iWord : Result := 2;
|
||||
iInteger : Result := 2;
|
||||
iLongInt : Result := 4;
|
||||
iCardinal : Result := 4;
|
||||
iReal : Result := SizeOf(Real); // {$IFDEF FPC}8{$ELSE}6{$ENDIF};
|
||||
iBool : Result := 1;
|
||||
iFile : Result := SizeOf(File); // was 128;
|
||||
|
|
|
@ -70,6 +70,7 @@ Type
|
|||
NumVars : Word;
|
||||
StrLen : Byte;
|
||||
VarSize : LongInt;
|
||||
DataSize : LongInt;
|
||||
End;
|
||||
|
||||
PRecordRec = ^TRecordRec;
|
||||
|
@ -133,6 +134,7 @@ Type
|
|||
Function FindConst (Str: String) : Integer;
|
||||
Function FindIdent (Str: String) : Boolean;
|
||||
// CODE PROCESSING
|
||||
Function GetDataSize (Info: TParserVarInfoRec) : LongInt;
|
||||
Procedure CreateVariable (Var Info: TParserVarInfoRec);
|
||||
Procedure ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var Info: TParserVarInfoRec);
|
||||
Procedure ParseIdent;
|
||||
|
@ -1348,6 +1350,7 @@ Procedure TParserEngine.ParseVarBoolean;
|
|||
iWord,
|
||||
iInteger,
|
||||
iLongInt,
|
||||
iCardinal,
|
||||
iReal : ParseVarNumber;
|
||||
iBool : NewBooleanCrap;
|
||||
Else
|
||||
|
@ -1432,6 +1435,26 @@ Begin
|
|||
If VT = iFile Then Error(mpsInStatement,'');
|
||||
End;
|
||||
|
||||
Function TParserEngine.GetDataSize (Info: TParserVarInfoRec) : LongInt;
|
||||
Var
|
||||
DimSize : LongInt;
|
||||
OneSize : LongInt;
|
||||
Count : Byte;
|
||||
Begin
|
||||
OneSize := Info.VarSize;
|
||||
|
||||
If Info.ArrDem = 0 Then
|
||||
DimSize := OneSize
|
||||
Else Begin
|
||||
DimSize := (Info.ArrEnd[Info.ArrDem] - Info.ArrStart[Info.ArrDem] + 1) * OneSize;
|
||||
|
||||
For Count := Pred(Info.ArrDem) DownTo 1 Do
|
||||
DimSize := DimSize * (Info.ArrEnd[Count] - Info.ArrStart[Count] + 1);
|
||||
End;
|
||||
|
||||
Result := DimSize;
|
||||
End;
|
||||
|
||||
Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var Info: TParserVarInfoRec);
|
||||
|
||||
Function ParseNum : LongInt;
|
||||
|
@ -1499,26 +1522,6 @@ Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var I
|
|||
Until (UpdateInfo.ErrorType <> 0) Or (Not GetStr(tkw[wVarSep], False, False));
|
||||
End;
|
||||
|
||||
Function GetDataSize : LongInt;
|
||||
Var
|
||||
DimSize : LongInt;
|
||||
OneSize : LongInt;
|
||||
Count : Byte;
|
||||
Begin
|
||||
OneSize := Info.VarSize;
|
||||
|
||||
If Info.ArrDem = 0 Then
|
||||
DimSize := OneSize
|
||||
Else Begin
|
||||
DimSize := (Info.ArrEnd[Info.ArrDem] - Info.ArrStart[Info.ArrDem] + 1) * OneSize;
|
||||
|
||||
For Count := Pred(Info.ArrDem) DownTo 1 Do
|
||||
DimSize := DimSize * (Info.ArrEnd[Count] - Info.ArrStart[Count] + 1);
|
||||
End;
|
||||
|
||||
Result := DimSize;
|
||||
End;
|
||||
|
||||
Procedure ParseVarType;
|
||||
Var
|
||||
Count : LongInt;
|
||||
|
@ -1535,8 +1538,9 @@ Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var I
|
|||
If IdentStr = tkv[iByte ] Then Info.vType := iByte Else
|
||||
If IdentStr = tkv[iShort ] Then Info.vType := iShort Else
|
||||
If IdentStr = tkv[iWord ] Then Info.vType := iWord Else
|
||||
If IdentStr = tkv[iInteger] Then Info.vType := iInteger Else
|
||||
If IdentStr = tkv[iLongInt] Then Info.vType := iLongInt Else
|
||||
If IdentStr = tkv[iInteger ] Then Info.vType := iInteger Else
|
||||
If IdentStr = tkv[iLongInt ] Then Info.vType := iLongInt Else
|
||||
If IdentStr = tkv[iCardinal] Then Info.vType := iCardinal Else
|
||||
If IdentStr = tkv[iReal ] Then Info.vType := iReal Else
|
||||
If IdentStr = tkv[iBool ] Then Info.vType := iBool Else
|
||||
If IdentStr = tkv[iFile ] Then Begin
|
||||
|
@ -1544,6 +1548,7 @@ Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var I
|
|||
Info.vType := iFile;
|
||||
End Else Begin
|
||||
Count := FindRecord(IdentStr);
|
||||
|
||||
If Count = 0 Then
|
||||
Error(mpsUnknownIdent, IdentStr)
|
||||
Else If IsRec Then
|
||||
|
@ -1552,6 +1557,8 @@ Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var I
|
|||
Info.vType := iRecord;
|
||||
Info.Prefix := Info.Ident[1] + '.';
|
||||
Info.StrLen := Count;
|
||||
|
||||
// this crap needs to go?
|
||||
End;
|
||||
End;
|
||||
|
||||
|
@ -1570,7 +1577,7 @@ Procedure TParserEngine.ParseVariableInfo (Param: Boolean; IsRec: Boolean; Var I
|
|||
Info.VarSize := GetVarSize(Info.vType);
|
||||
|
||||
If Info.ArrDem > 0 Then
|
||||
Info.VarSize := GetDataSize;
|
||||
Info.VarSize := GetDataSize(Info);
|
||||
|
||||
If Info.VarSize > mplMaxDataSize Then
|
||||
Error (mpsDataTooBig, '');
|
||||
|
@ -1739,7 +1746,6 @@ Var
|
|||
Info : TParserVarInfoRec;
|
||||
BaseRec : TParserVarInfoRec;
|
||||
Count : LongInt;
|
||||
RecSize : LongInt;
|
||||
Begin
|
||||
ParseVariableInfo(False, False, Info);
|
||||
|
||||
|
@ -1747,33 +1753,30 @@ Begin
|
|||
OutString (Char(opTypeRec));
|
||||
OutWord (RecData[Info.StrLen]^.NumFields);
|
||||
|
||||
RecSize := 0;
|
||||
BaseRec := Info;
|
||||
|
||||
BaseRec.VarSize := 0;
|
||||
BaseRec.ArrDem := Info.ArrDem;
|
||||
BaseRec.ArrStart := Info.ArrStart;
|
||||
BaseRec.ArrEnd := Info.ArrEnd;
|
||||
BaseRec.Prefix := '';
|
||||
BaseRec.NumVars := 1;
|
||||
BaseRec.StrLen := 0;
|
||||
|
||||
For Count := 1 to RecData[Info.StrLen]^.NumFields Do
|
||||
Inc (RecSize, RecData[Info.StrLen]^.Fields[Count].VarSize);
|
||||
Inc (BaseRec.VarSize, RecData[Info.StrLen]^.Fields[Count].VarSize);
|
||||
|
||||
If RecSize > mplMaxDataSize Then Begin
|
||||
If BaseRec.VarSize > mplMaxDataSize Then Begin
|
||||
Error (mpsDataTooBig, '');
|
||||
Exit;
|
||||
End;
|
||||
|
||||
OutWord (RecSize);
|
||||
BaseRec.DataSize := GetDataSize(BaseRec);
|
||||
|
||||
BaseRec := Info;
|
||||
|
||||
BaseRec.Prefix := '';
|
||||
BaseRec.NumVars := 1;
|
||||
BaseRec.StrLen := 0;
|
||||
BaseRec.ArrDem := 0;
|
||||
OutWord (BaseRec.DataSize);
|
||||
|
||||
CreateVariable(BaseRec);
|
||||
|
||||
// how do we support an array here with this terrible idea of
|
||||
// a record system? redone data system is complete but i dont have
|
||||
// the drive to implement it into MPL just yet
|
||||
|
||||
// IRECORD should be whatever it is... same as anything.
|
||||
|
||||
For Count := 1 to RecData[Info.StrLen]^.NumFields Do Begin
|
||||
RecData[Info.StrLen]^.Fields[Count].Prefix := Info.Prefix;
|
||||
CreateVariable(RecData[Info.StrLen]^.Fields[Count]);
|
||||
|
@ -1797,6 +1800,7 @@ Begin
|
|||
Else Begin
|
||||
OutString (Char(opArrDef));
|
||||
OutWord (Info.ArrDem);
|
||||
|
||||
For Count := 1 to Info.ArrDem Do
|
||||
OutString (Char(opOpenNum) + strI2S(Info.ArrEnd[Count]) + Char(opCloseNum));
|
||||
End;
|
||||
|
@ -1980,8 +1984,9 @@ Begin
|
|||
If IdentStr = tkv[iByte ] Then VarType := iByte Else
|
||||
If IdentStr = tkv[iShort ] Then VarType := iShort Else
|
||||
If IdentStr = tkv[iWord ] Then VarType := iWord Else
|
||||
If IdentStr = tkv[iInteger] Then VarType := iInteger Else
|
||||
If IdentStr = tkv[iLongInt] Then VarType := iLongInt Else
|
||||
If IdentStr = tkv[iInteger ] Then VarType := iInteger Else
|
||||
If IdentStr = tkv[iLongInt ] Then VarType := iLongInt Else
|
||||
If IdentStr = tkv[iCardinal] Then VarType := iCardinal Else
|
||||
If IdentStr = tkv[iReal ] Then VarType := iReal Else
|
||||
If IdentStr = tkv[iBool ] Then VarType := iBool Else
|
||||
If IdentStr = tkv[iFile ] Then
|
||||
|
@ -2038,6 +2043,7 @@ Begin
|
|||
// if = '*' and type iString then...do the string index
|
||||
End Else Begin
|
||||
// use setvariable here?? cant cuz ifile isnt processed in setvariable...
|
||||
// need irecord
|
||||
If Char2VarType(VarData[VN]^.Params[Count]) in vNums Then ParseVarNumber Else
|
||||
If Char2VarType(VarData[VN]^.Params[Count]) = iString Then ParseVarString Else
|
||||
If Char2VarType(VarData[VN]^.Params[Count]) = iChar Then ParseVarChar Else
|
||||
|
@ -2204,6 +2210,7 @@ Begin
|
|||
iWord,
|
||||
iInteger,
|
||||
iLongInt,
|
||||
iCardinal,
|
||||
iReal : Repeat
|
||||
ParseVarNumber;
|
||||
|
||||
|
|
|
@ -423,6 +423,7 @@ Begin
|
|||
iWord : Result := Word(GetDataPtr(VN, A)^);
|
||||
iInteger : Result := Integer(GetDataPtr(VN, A)^);
|
||||
iLongInt : Result := LongInt(GetDataPtr(VN, A)^);
|
||||
iCardinal : Result := Cardinal(GetDataPtr(VN, A)^);
|
||||
iReal : Result := Real(GetDataPtr(VN, A)^);
|
||||
End;
|
||||
End;
|
||||
|
@ -435,6 +436,7 @@ Begin
|
|||
iWord : Result := Word(Num);
|
||||
iInteger : Result := Integer(Num);
|
||||
iLongInt : Result := LongInt(Num);
|
||||
iCardinal : Result := Cardinal(Num);
|
||||
iReal : Result := Real(Num);
|
||||
End;
|
||||
End;
|
||||
|
@ -511,6 +513,7 @@ Var
|
|||
|
||||
While CheckChar = '^' Do Begin
|
||||
ParseNext;
|
||||
|
||||
If Result <> 0 Then
|
||||
Result := Exp(Ln(Abs(Result)) * SignedOp)
|
||||
Else
|
||||
|
@ -520,14 +523,18 @@ Var
|
|||
|
||||
Begin
|
||||
Result := Power;
|
||||
|
||||
While CheckChar in ['%','*','/'] Do Begin
|
||||
OpChar := CheckChar;
|
||||
|
||||
ParseNext;
|
||||
|
||||
Case OpChar of
|
||||
'%' : Result := Trunc(Result) MOD Trunc(Power);
|
||||
'*' : Result := Result * Power;
|
||||
'/' : Begin
|
||||
PowerRes := Power;
|
||||
|
||||
If PowerRes = 0 Then
|
||||
Error (mpxDivisionByZero, '')
|
||||
Else
|
||||
|
@ -542,7 +549,9 @@ Var
|
|||
|
||||
While CheckChar in ['+','-','&','|','@','<','>'] Do Begin
|
||||
OpChar := CheckChar;
|
||||
|
||||
ParseNext;
|
||||
|
||||
Case OpChar of
|
||||
'+' : Result := Result + MultiplyDivide;
|
||||
'-' : Result := Result - MultiplyDivide;
|
||||
|
@ -554,9 +563,12 @@ Var
|
|||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
Begin
|
||||
NextChar;
|
||||
|
||||
ParseNext;
|
||||
|
||||
Result := AddSubtract;
|
||||
End;
|
||||
|
||||
|
@ -872,7 +884,7 @@ Begin
|
|||
|
||||
Case VarData[VarNum]^.vType of
|
||||
iChar,
|
||||
iString: Begin
|
||||
iString : Begin
|
||||
NextChar;
|
||||
|
||||
If Ch = Char(opStrArray) Then Begin
|
||||
|
@ -891,6 +903,7 @@ Begin
|
|||
iWord : Word(GetDataPtr(VarNum, ArrayData)^) := Trunc(EvaluateNumber);
|
||||
iInteger : Integer(GetDataPtr(VarNum, ArrayData)^) := Trunc(EvaluateNumber);
|
||||
iLongInt : LongInt(GetDataPtr(VarNum, ArrayData)^) := Trunc(EvaluateNumber);
|
||||
iCardinal : Cardinal(GetDataPtr(VarNum, ArrayData)^) := Trunc(EvaluateNumber);
|
||||
iReal : Real(GetDataPtr(VarNum, ArrayData)^) := EvaluateNumber;
|
||||
iBool : ByteBool(GetDataPtr(VarNum, ArrayData)^) := EvaluateBoolean;
|
||||
End;
|
||||
|
@ -904,6 +917,7 @@ Begin
|
|||
iWord : Word(GetDataPtr(VN, A)^) := Trunc(R);
|
||||
iInteger : Integer(GetDataPtr(VN, A)^) := Trunc(R);
|
||||
iLongInt : LongInt(GetDataPtr(VN, A)^) := Trunc(R);
|
||||
iCardinal : Cardinal(GetDataPtr(VN, A)^) := Trunc(R);
|
||||
iReal : Real(GetDataPtr(VN, A)^) := R;
|
||||
end;
|
||||
end;
|
||||
|
@ -914,6 +928,7 @@ Var
|
|||
Begin
|
||||
With VarData[VarNum]^ Do Begin
|
||||
Result := VarSize;
|
||||
|
||||
For Count := 1 To ArrPos Do
|
||||
Result := Result * ArrDim[Count];
|
||||
End;
|
||||
|
@ -949,7 +964,9 @@ Begin
|
|||
|
||||
If Ch = Char(opArrDef) Then Begin
|
||||
NextWord;
|
||||
|
||||
ArrayPos := W;
|
||||
|
||||
For Count := 1 to ArrayPos Do ArrayData[Count] := Trunc(EvaluateNumber);
|
||||
End;
|
||||
|
||||
|
@ -1089,6 +1106,7 @@ Type
|
|||
iWord : (W : Word);
|
||||
iInteger : (I : Integer);
|
||||
iLongInt : (L : LongInt);
|
||||
iCardinal : (A : Cardinal);
|
||||
iReal : (R : Real);
|
||||
iBool : (O : Boolean);
|
||||
End;
|
||||
|
|
Loading…
Reference in New Issue