Moved operator helpers
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<ProjectVersion>20.3</ProjectVersion>
|
<ProjectVersion>20.3</ProjectVersion>
|
||||||
<FrameworkType>FMX</FrameworkType>
|
<FrameworkType>FMX</FrameworkType>
|
||||||
<Base>True</Base>
|
<Base>True</Base>
|
||||||
<Config Condition="'$(Config)'==''">Release</Config>
|
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||||
<Platform Condition="'$(Platform)'==''">Win64</Platform>
|
<Platform Condition="'$(Platform)'==''">Win64</Platform>
|
||||||
<ProjectName Condition="'$(ProjectName)'==''">ASTPlayground</ProjectName>
|
<ProjectName Condition="'$(ProjectName)'==''">ASTPlayground</ProjectName>
|
||||||
<TargetedPlatforms>2</TargetedPlatforms>
|
<TargetedPlatforms>2</TargetedPlatforms>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ uses
|
|||||||
System.SysUtils,
|
System.SysUtils,
|
||||||
System.Classes,
|
System.Classes,
|
||||||
System.Generics.Collections,
|
System.Generics.Collections,
|
||||||
|
Myc.Data.Scalar,
|
||||||
Myc.Data.Value,
|
Myc.Data.Value,
|
||||||
Myc.Ast.Nodes,
|
Myc.Ast.Nodes,
|
||||||
Myc.Ast.Scope,
|
Myc.Ast.Scope,
|
||||||
|
|||||||
@@ -9,14 +9,6 @@ uses
|
|||||||
Myc.Data.Value;
|
Myc.Data.Value;
|
||||||
|
|
||||||
type
|
type
|
||||||
TBinaryOperatorHelper = record helper for TBinaryOperator
|
|
||||||
function ToString: string;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TUnaryOperatorHelper = record helper for TUnaryOperator
|
|
||||||
function ToString: string;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// --- Forward Declarations to break cycles ---
|
// --- Forward Declarations to break cycles ---
|
||||||
IAstVisitor = interface;
|
IAstVisitor = interface;
|
||||||
IAstNode = interface;
|
IAstNode = interface;
|
||||||
@@ -284,36 +276,4 @@ begin
|
|||||||
Dest.SlotIndex := -1;
|
Dest.SlotIndex := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TBinaryOperatorHelper }
|
|
||||||
|
|
||||||
function TBinaryOperatorHelper.ToString: string;
|
|
||||||
begin
|
|
||||||
case Self of
|
|
||||||
boAdd: Result := '+';
|
|
||||||
boSubtract: Result := '-';
|
|
||||||
boMultiply: Result := '*';
|
|
||||||
boDivide: Result := '/';
|
|
||||||
boEqual: Result := '==';
|
|
||||||
boNotEqual: Result := '!=';
|
|
||||||
boLess: Result := '<';
|
|
||||||
boGreater: Result := '>';
|
|
||||||
boLessOrEqual: Result := '<=';
|
|
||||||
boGreaterOrEqual: Result := '>=';
|
|
||||||
else
|
|
||||||
Result := '?';
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TUnaryOperatorHelper }
|
|
||||||
|
|
||||||
function TUnaryOperatorHelper.ToString: string;
|
|
||||||
begin
|
|
||||||
case Self of
|
|
||||||
uoNegate: Result := '-';
|
|
||||||
uoNot: Result := 'not';
|
|
||||||
else
|
|
||||||
Result := '?';
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@@ -239,6 +239,14 @@ type
|
|||||||
property TotalCount: Int64 read FTotalCount;
|
property TotalCount: Int64 read FTotalCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TBinaryOperatorHelper = record helper for TBinaryOperator
|
||||||
|
function ToString: string;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TUnaryOperatorHelper = record helper for TUnaryOperator
|
||||||
|
function ToString: string;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TScalarValue }
|
{ TScalarValue }
|
||||||
@@ -1555,6 +1563,38 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBinaryOperatorHelper }
|
||||||
|
|
||||||
|
function TBinaryOperatorHelper.ToString: string;
|
||||||
|
begin
|
||||||
|
case Self of
|
||||||
|
boAdd: Result := '+';
|
||||||
|
boSubtract: Result := '-';
|
||||||
|
boMultiply: Result := '*';
|
||||||
|
boDivide: Result := '/';
|
||||||
|
boEqual: Result := '==';
|
||||||
|
boNotEqual: Result := '!=';
|
||||||
|
boLess: Result := '<';
|
||||||
|
boGreater: Result := '>';
|
||||||
|
boLessOrEqual: Result := '<=';
|
||||||
|
boGreaterOrEqual: Result := '>=';
|
||||||
|
else
|
||||||
|
Result := '?';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TUnaryOperatorHelper }
|
||||||
|
|
||||||
|
function TUnaryOperatorHelper.ToString: string;
|
||||||
|
begin
|
||||||
|
case Self of
|
||||||
|
uoNegate: Result := '-';
|
||||||
|
uoNot: Result := 'not';
|
||||||
|
else
|
||||||
|
Result := '?';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
Assert(sizeof(TScalarValue) = 8);
|
Assert(sizeof(TScalarValue) = 8);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user