Loading Constants
This procedure loads numeric constants and constant identifiers to the expression. For constant identifiers the constant value is first loaded to NumericConstant
variable from where it is moved to the Value
field of the expression.
Procedure LoadConstant;
Var ConstantIntegerType: TIntegerTypeSet;
Procedure CopyConstantIdValue (ConstIdData: PConstantIdentifierData);
Var Destination: PtrRec;
TypePointer: PTypeDefinition;
Size: Byte;
begin
TypePointer := PointerFromOffsets (ConstIdData^.UnitTypeOffsets);
ConstantTypeDef := TypePointer;
Destination.Ptr := @NumericConstant;
Size := 4;
If TypePointer^.BaseType ; btInteger then
Case TypePointer^.BaseType of
btPointer: Size := 4;
btExtended: Size := 10;
else begin
If TypePointer^.BaseType = btSet then Size := 32
else Size := ConstIdData^.Value + 1;
Word (Destination.Ptr^) := GetTempBufferOffset (Size);
Destination.Ofs := Word (Destination.Ptr^);
end;
end;
Move (ConstIdData^.Value, Destination.Ptr^, Size);
end;
begin
If Token ;: Token_Constant then
CopyConstantIdValue (PConstantIdentifierData (CurrentIdentifierDataPtr));
Move (NumericConstant, Value, SizeOf (NumericConstant));
TypeDefPtr := ConstantTypeDef;
IntermediateCodeOffset := 0;
Location := elConstant;
UsedRegisters := [];
ConstantIntegerType := TypeDefPtr^.DataType;
If TypeDefPtr^.BaseType = btSet then
begin
SetDataTypeOfSet;
GetNextToken;
Exit;
end;
If TypeDefPtr^.BaseType := btInteger then LowestIntegerType (Value.LongInt, ConstantIntegerType);
DataType := ConstantIntegerType;
GetNextToken;
end;