AST refactoring

This commit is contained in:
Michael Schimmel
2025-08-28 16:26:48 +02:00
parent 9419f5cd03
commit 9a5f2c1b1d
10 changed files with 866 additions and 810 deletions
+23
View File
@@ -118,6 +118,8 @@ type
function GetKind: TScalarKind; inline;
function GetValue: TScalarValue; inline;
function ToString: String;
property Kind: TScalarKind read GetKind;
property Value: TScalarValue read GetValue;
@@ -463,6 +465,27 @@ begin
Result := FValue;
end;
function TScalar.ToString: String;
begin
case FKind of
skInteger: Result := IntToStr(FValue.AsInteger);
skInt64: Result := IntToStr(FValue.AsInt64);
skUInt64: Result := UIntToStr(FValue.AsUInt64);
skSingle: Result := FloatToStr(FValue.AsSingle);
skDouble: Result := FloatToStr(FValue.AsDouble);
skDateTime: Result := DateTimeToStr(FValue.AsDateTime);
skTimestamp: Result := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', TimeStampToDateTime(FValue.AsTimestamp));
skBoolean: Result := BoolToStr(FValue.AsBoolean, True);
skChar: Result := '''' + FValue.AsChar + '''';
skPChar: Result := FValue.AsPChar; // Already null-terminated
skString: Result := '''' + string(FValue.AsString) + '''';
skBytes: Result := '(Bytes)';
skDecimal: Result := FloatToStr(Double(FValue.AsDecimal));
else
Result := '[Unknown Scalar]';
end;
end;
{ TScalarArray }
constructor TScalarArray.Create(AKind: TScalarKind; const AItems: TArray<TScalarValue>);