Beginning Editor
This commit is contained in:
+120
-134
@@ -17,38 +17,28 @@ type
|
||||
// --- Existing factory functions ---
|
||||
class function Constant(AValue: TScalar): IConstantNode; static;
|
||||
class function Identifier(AName: string): IIdentifierNode; static;
|
||||
class function BinaryExpr(
|
||||
ALeft: IExpressionNode;
|
||||
AOperator: TBinaryOperator;
|
||||
ARight: IExpressionNode
|
||||
): IBinaryExpressionNode; static;
|
||||
class function UnaryExpr(const AOperator: TUnaryOperator; const ARight: IExpressionNode): IUnaryExpressionNode; static;
|
||||
class function IfExpr(
|
||||
const ACondition: IExpressionNode;
|
||||
const AThenBranch, AElseBranch: IExpressionNode
|
||||
): IIfExpressionNode; static;
|
||||
class function TernaryExpr(
|
||||
const ACondition: IExpressionNode;
|
||||
const AThenBranch, AElseBranch: IExpressionNode
|
||||
): ITernaryExpressionNode; static;
|
||||
class function LambdaExpr(const AParameters: TArray<IIdentifierNode>; const ABody: IExpressionNode): ILambdaExpressionNode; static;
|
||||
class function FunctionCall(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode; static;
|
||||
class function Block(const AExpressions: array of IExpressionNode): IBlockExpressionNode; static;
|
||||
class function VarDecl(const AIdentifier: IIdentifierNode; AInitializer: IExpressionNode): IVariableDeclarationNode; static;
|
||||
class function Assign(const AIdentifier: IIdentifierNode; const AValue: IExpressionNode): IAssignmentNode; static;
|
||||
class function AssignResult(const AValue: IExpressionNode): IAssignmentNode; static; deprecated;
|
||||
class function Indexer(const ABase: IExpressionNode; const AIndex: IExpressionNode): IIndexerNode; static;
|
||||
class function MemberAccess(const ABase: IExpressionNode; const AMember: IIdentifierNode): IMemberAccessNode; static;
|
||||
class function BinaryExpr(ALeft: IAstNode; AOperator: TBinaryOperator; ARight: IAstNode): IBinaryExpressionNode; static;
|
||||
class function UnaryExpr(const AOperator: TUnaryOperator; const ARight: IAstNode): IUnaryExpressionNode; static;
|
||||
class function IfExpr(const ACondition: IAstNode; const AThenBranch, AElseBranch: IAstNode): IIfExpressionNode; static;
|
||||
class function TernaryExpr(const ACondition: IAstNode; const AThenBranch, AElseBranch: IAstNode): ITernaryExpressionNode; static;
|
||||
class function LambdaExpr(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode): ILambdaExpressionNode; static;
|
||||
class function FunctionCall(const ACallee: IAstNode; const AArguments: array of IAstNode): IFunctionCallNode; static;
|
||||
class function Block(const AExpressions: array of IAstNode): IBlockExpressionNode; static;
|
||||
class function VarDecl(const AIdentifier: IIdentifierNode; AInitializer: IAstNode): IVariableDeclarationNode; static;
|
||||
class function Assign(const AIdentifier: IIdentifierNode; const AValue: IAstNode): IAssignmentNode; static;
|
||||
class function AssignResult(const AValue: IAstNode): IAssignmentNode; static; deprecated;
|
||||
class function Indexer(const ABase: IAstNode; const AIndex: IAstNode): IIndexerNode; static;
|
||||
class function MemberAccess(const ABase: IAstNode; const AMember: IIdentifierNode): IMemberAccessNode; static;
|
||||
class function CreateSeries(const ADefinition: String): ICreateSeriesNode; static;
|
||||
class function AddSeriesItem(
|
||||
const ASeries: IIdentifierNode;
|
||||
const AValue: IExpressionNode;
|
||||
const ALookback: IExpressionNode = nil
|
||||
const AValue: IAstNode;
|
||||
const ALookback: IAstNode = nil
|
||||
): IAddSeriesItemNode; static;
|
||||
class function SeriesLength(const ASeries: IIdentifierNode): ISeriesLengthNode; static;
|
||||
|
||||
class function CreateDescriptor(const Scope: IExecutionScope): IScopeDescriptor; static;
|
||||
class function Bind(const RootNode: IExpressionNode; const ParentScope: IExecutionScope): IExecutionScope; static;
|
||||
class function Bind(const RootNode: IAstNode; const ParentScope: IExecutionScope): IExecutionScope; static;
|
||||
end;
|
||||
|
||||
// TAstTraverser provides a default AST traversal implementation.
|
||||
@@ -94,7 +84,7 @@ type
|
||||
|
||||
{ TAstNode }
|
||||
// Common base class for AST nodes to reduce boilerplate.
|
||||
TAstNode = class(TInterfacedObject, IExpressionNode)
|
||||
TAstNode = class(TInterfacedObject, IAstNode)
|
||||
public
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; virtual; abstract;
|
||||
end;
|
||||
@@ -130,14 +120,14 @@ type
|
||||
{ TBinaryExpressionNode }
|
||||
TBinaryExpressionNode = class(TAstNode, IBinaryExpressionNode)
|
||||
private
|
||||
FLeft: IExpressionNode;
|
||||
FLeft: IAstNode;
|
||||
FOperator: TBinaryOperator;
|
||||
FRight: IExpressionNode;
|
||||
function GetLeft: IExpressionNode;
|
||||
FRight: IAstNode;
|
||||
function GetLeft: IAstNode;
|
||||
function GetOperator: TBinaryOperator;
|
||||
function GetRight: IExpressionNode;
|
||||
function GetRight: IAstNode;
|
||||
public
|
||||
constructor Create(ALeft: IExpressionNode; AOperator: TBinaryOperator; ARight: IExpressionNode);
|
||||
constructor Create(ALeft: IAstNode; AOperator: TBinaryOperator; ARight: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
@@ -145,39 +135,39 @@ type
|
||||
TUnaryExpressionNode = class(TAstNode, IUnaryExpressionNode)
|
||||
private
|
||||
FOperator: TUnaryOperator;
|
||||
FRight: IExpressionNode;
|
||||
FRight: IAstNode;
|
||||
function GetOperator: TUnaryOperator;
|
||||
function GetRight: IExpressionNode;
|
||||
function GetRight: IAstNode;
|
||||
public
|
||||
constructor Create(const AOperator: TUnaryOperator; const ARight: IExpressionNode);
|
||||
constructor Create(const AOperator: TUnaryOperator; const ARight: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
{ TIfExpressionNode }
|
||||
TIfExpressionNode = class(TAstNode, IIfExpressionNode)
|
||||
private
|
||||
FCondition: IExpressionNode;
|
||||
FThenBranch: IExpressionNode;
|
||||
FElseBranch: IExpressionNode;
|
||||
function GetCondition: IExpressionNode;
|
||||
function GetThenBranch: IExpressionNode;
|
||||
function GetElseBranch: IExpressionNode;
|
||||
FCondition: IAstNode;
|
||||
FThenBranch: IAstNode;
|
||||
FElseBranch: IAstNode;
|
||||
function GetCondition: IAstNode;
|
||||
function GetThenBranch: IAstNode;
|
||||
function GetElseBranch: IAstNode;
|
||||
public
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IExpressionNode);
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
{ TTernaryExpressionNode }
|
||||
TTernaryExpressionNode = class(TAstNode, ITernaryExpressionNode)
|
||||
private
|
||||
FCondition: IExpressionNode;
|
||||
FThenBranch: IExpressionNode;
|
||||
FElseBranch: IExpressionNode;
|
||||
function GetCondition: IExpressionNode;
|
||||
function GetThenBranch: IExpressionNode;
|
||||
function GetElseBranch: IExpressionNode;
|
||||
FCondition: IAstNode;
|
||||
FThenBranch: IAstNode;
|
||||
FElseBranch: IAstNode;
|
||||
function GetCondition: IAstNode;
|
||||
function GetThenBranch: IAstNode;
|
||||
function GetElseBranch: IAstNode;
|
||||
public
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IExpressionNode);
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
@@ -185,15 +175,15 @@ type
|
||||
TLambdaExpressionNode = class(TAstNode, ILambdaExpressionNode)
|
||||
private
|
||||
FParameters: TArray<IIdentifierNode>;
|
||||
FBody: IExpressionNode;
|
||||
FBody: IAstNode;
|
||||
FScopeDescriptor: IScopeDescriptor;
|
||||
FUpvalues: TArray<TResolvedAddress>;
|
||||
function GetParameters: TArray<IIdentifierNode>;
|
||||
function GetBody: IExpressionNode;
|
||||
function GetBody: IAstNode;
|
||||
function GetScopeDescriptor: IScopeDescriptor;
|
||||
function GetUpvalues: TArray<TResolvedAddress>;
|
||||
public
|
||||
constructor Create(const AParameters: TArray<IIdentifierNode>; const ABody: IExpressionNode);
|
||||
constructor Create(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
property ScopeDescriptor: IScopeDescriptor read GetScopeDescriptor;
|
||||
end;
|
||||
@@ -201,12 +191,12 @@ type
|
||||
{ TFunctionCallNode }
|
||||
TFunctionCallNode = class(TAstNode, IFunctionCallNode)
|
||||
private
|
||||
FCallee: IExpressionNode;
|
||||
FArguments: TList<IExpressionNode>;
|
||||
function GetCallee: IExpressionNode;
|
||||
function GetArguments: TList<IExpressionNode>;
|
||||
FCallee: IAstNode;
|
||||
FArguments: TList<IAstNode>;
|
||||
function GetCallee: IAstNode;
|
||||
function GetArguments: TList<IAstNode>;
|
||||
public
|
||||
constructor Create(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode);
|
||||
constructor Create(const ACallee: IAstNode; const AArguments: array of IAstNode);
|
||||
destructor Destroy; override;
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
@@ -214,10 +204,10 @@ type
|
||||
{ TBlockExpressionNode }
|
||||
TBlockExpressionNode = class(TAstNode, IBlockExpressionNode)
|
||||
private
|
||||
FExpressions: TList<IExpressionNode>;
|
||||
function GetExpressions: TList<IExpressionNode>;
|
||||
FExpressions: TList<IAstNode>;
|
||||
function GetExpressions: TList<IAstNode>;
|
||||
public
|
||||
constructor Create(const AExpressions: array of IExpressionNode);
|
||||
constructor Create(const AExpressions: array of IAstNode);
|
||||
destructor Destroy; override;
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
@@ -226,11 +216,11 @@ type
|
||||
TVariableDeclarationNode = class(TAstNode, IVariableDeclarationNode)
|
||||
private
|
||||
FIdentifier: IIdentifierNode;
|
||||
FInitializer: IExpressionNode;
|
||||
FInitializer: IAstNode;
|
||||
function GetIdentifier: IIdentifierNode;
|
||||
function GetInitializer: IExpressionNode;
|
||||
function GetInitializer: IAstNode;
|
||||
public
|
||||
constructor Create(const AIdentifier: IIdentifierNode; AInitializer: IExpressionNode);
|
||||
constructor Create(const AIdentifier: IIdentifierNode; AInitializer: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
@@ -238,35 +228,35 @@ type
|
||||
TAssignmentNode = class(TAstNode, IAssignmentNode)
|
||||
private
|
||||
FIdentifier: IIdentifierNode;
|
||||
FValue: IExpressionNode;
|
||||
FValue: IAstNode;
|
||||
function GetIdentifier: IIdentifierNode;
|
||||
function GetValue: IExpressionNode;
|
||||
function GetValue: IAstNode;
|
||||
public
|
||||
constructor Create(const AIdentifier: IIdentifierNode; const AValue: IExpressionNode);
|
||||
constructor Create(const AIdentifier: IIdentifierNode; const AValue: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
{ TIndexerNode }
|
||||
TIndexerNode = class(TAstNode, IIndexerNode)
|
||||
private
|
||||
FBase: IExpressionNode;
|
||||
FIndex: IExpressionNode;
|
||||
function GetBase: IExpressionNode;
|
||||
function GetIndex: IExpressionNode;
|
||||
FBase: IAstNode;
|
||||
FIndex: IAstNode;
|
||||
function GetBase: IAstNode;
|
||||
function GetIndex: IAstNode;
|
||||
public
|
||||
constructor Create(const ABase: IExpressionNode; const AIndex: IExpressionNode);
|
||||
constructor Create(const ABase: IAstNode; const AIndex: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
{ TMemberAccessNode }
|
||||
TMemberAccessNode = class(TAstNode, IMemberAccessNode)
|
||||
private
|
||||
FBase: IExpressionNode;
|
||||
FBase: IAstNode;
|
||||
FMember: IIdentifierNode;
|
||||
function GetBase: IExpressionNode;
|
||||
function GetBase: IAstNode;
|
||||
function GetMember: IIdentifierNode;
|
||||
public
|
||||
constructor Create(const ABase: IExpressionNode; const AMember: IIdentifierNode);
|
||||
constructor Create(const ABase: IAstNode; const AMember: IIdentifierNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
@@ -284,13 +274,13 @@ type
|
||||
TAddSeriesItemNode = class(TAstNode, IAddSeriesItemNode)
|
||||
private
|
||||
FSeries: IIdentifierNode;
|
||||
FValue: IExpressionNode;
|
||||
FLookback: IExpressionNode;
|
||||
FValue: IAstNode;
|
||||
FLookback: IAstNode;
|
||||
function GetSeries: IIdentifierNode;
|
||||
function GetValue: IExpressionNode;
|
||||
function GetLookback: IExpressionNode;
|
||||
function GetValue: IAstNode;
|
||||
function GetLookback: IAstNode;
|
||||
public
|
||||
constructor Create(const ASeries: IIdentifierNode; const AValue: IExpressionNode; const ALookback: IExpressionNode);
|
||||
constructor Create(const ASeries: IIdentifierNode; const AValue: IAstNode; const ALookback: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
end;
|
||||
|
||||
@@ -459,7 +449,7 @@ end;
|
||||
|
||||
{ TBinaryExpressionNode }
|
||||
|
||||
constructor TBinaryExpressionNode.Create(ALeft: IExpressionNode; AOperator: TBinaryOperator; ARight: IExpressionNode);
|
||||
constructor TBinaryExpressionNode.Create(ALeft: IAstNode; AOperator: TBinaryOperator; ARight: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FLeft := ALeft;
|
||||
@@ -472,7 +462,7 @@ begin
|
||||
Result := Visitor.VisitBinaryExpression(Self);
|
||||
end;
|
||||
|
||||
function TBinaryExpressionNode.GetLeft: IExpressionNode;
|
||||
function TBinaryExpressionNode.GetLeft: IAstNode;
|
||||
begin
|
||||
Result := FLeft;
|
||||
end;
|
||||
@@ -482,14 +472,14 @@ begin
|
||||
Result := FOperator;
|
||||
end;
|
||||
|
||||
function TBinaryExpressionNode.GetRight: IExpressionNode;
|
||||
function TBinaryExpressionNode.GetRight: IAstNode;
|
||||
begin
|
||||
Result := FRight;
|
||||
end;
|
||||
|
||||
{ TUnaryExpressionNode }
|
||||
|
||||
constructor TUnaryExpressionNode.Create(const AOperator: TUnaryOperator; const ARight: IExpressionNode);
|
||||
constructor TUnaryExpressionNode.Create(const AOperator: TUnaryOperator; const ARight: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FOperator := AOperator;
|
||||
@@ -506,14 +496,14 @@ begin
|
||||
Result := FOperator;
|
||||
end;
|
||||
|
||||
function TUnaryExpressionNode.GetRight: IExpressionNode;
|
||||
function TUnaryExpressionNode.GetRight: IAstNode;
|
||||
begin
|
||||
Result := FRight;
|
||||
end;
|
||||
|
||||
{ TIfExpressionNode }
|
||||
|
||||
constructor TIfExpressionNode.Create(const ACondition, AThenBranch, AElseBranch: IExpressionNode);
|
||||
constructor TIfExpressionNode.Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FCondition := ACondition;
|
||||
@@ -526,24 +516,24 @@ begin
|
||||
Result := Visitor.VisitIfExpression(Self);
|
||||
end;
|
||||
|
||||
function TIfExpressionNode.GetCondition: IExpressionNode;
|
||||
function TIfExpressionNode.GetCondition: IAstNode;
|
||||
begin
|
||||
Result := FCondition;
|
||||
end;
|
||||
|
||||
function TIfExpressionNode.GetElseBranch: IExpressionNode;
|
||||
function TIfExpressionNode.GetElseBranch: IAstNode;
|
||||
begin
|
||||
Result := FElseBranch;
|
||||
end;
|
||||
|
||||
function TIfExpressionNode.GetThenBranch: IExpressionNode;
|
||||
function TIfExpressionNode.GetThenBranch: IAstNode;
|
||||
begin
|
||||
Result := FThenBranch;
|
||||
end;
|
||||
|
||||
{ TTernaryExpressionNode }
|
||||
|
||||
constructor TTernaryExpressionNode.Create(const ACondition, AThenBranch, AElseBranch: IExpressionNode);
|
||||
constructor TTernaryExpressionNode.Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FCondition := ACondition;
|
||||
@@ -556,24 +546,24 @@ begin
|
||||
Result := Visitor.VisitTernaryExpression(Self);
|
||||
end;
|
||||
|
||||
function TTernaryExpressionNode.GetCondition: IExpressionNode;
|
||||
function TTernaryExpressionNode.GetCondition: IAstNode;
|
||||
begin
|
||||
Result := FCondition;
|
||||
end;
|
||||
|
||||
function TTernaryExpressionNode.GetElseBranch: IExpressionNode;
|
||||
function TTernaryExpressionNode.GetElseBranch: IAstNode;
|
||||
begin
|
||||
Result := FElseBranch;
|
||||
end;
|
||||
|
||||
function TTernaryExpressionNode.GetThenBranch: IExpressionNode;
|
||||
function TTernaryExpressionNode.GetThenBranch: IAstNode;
|
||||
begin
|
||||
Result := FThenBranch;
|
||||
end;
|
||||
|
||||
{ TLambdaExpressionNode }
|
||||
|
||||
constructor TLambdaExpressionNode.Create(const AParameters: TArray<IIdentifierNode>; const ABody: IExpressionNode);
|
||||
constructor TLambdaExpressionNode.Create(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FBody := ABody;
|
||||
@@ -591,7 +581,7 @@ begin
|
||||
Result := Visitor.VisitLambdaExpression(Self);
|
||||
end;
|
||||
|
||||
function TLambdaExpressionNode.GetBody: IExpressionNode;
|
||||
function TLambdaExpressionNode.GetBody: IAstNode;
|
||||
begin
|
||||
Result := FBody;
|
||||
end;
|
||||
@@ -608,13 +598,13 @@ end;
|
||||
|
||||
{ TFunctionCallNode }
|
||||
|
||||
constructor TFunctionCallNode.Create(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode);
|
||||
constructor TFunctionCallNode.Create(const ACallee: IAstNode; const AArguments: array of IAstNode);
|
||||
var
|
||||
arg: IExpressionNode;
|
||||
arg: IAstNode;
|
||||
begin
|
||||
inherited Create;
|
||||
FCallee := ACallee;
|
||||
FArguments := TList<IExpressionNode>.Create;
|
||||
FArguments := TList<IAstNode>.Create;
|
||||
for arg in AArguments do
|
||||
FArguments.Add(arg);
|
||||
end;
|
||||
@@ -630,24 +620,24 @@ begin
|
||||
Result := Visitor.VisitFunctionCall(Self);
|
||||
end;
|
||||
|
||||
function TFunctionCallNode.GetArguments: TList<IExpressionNode>;
|
||||
function TFunctionCallNode.GetArguments: TList<IAstNode>;
|
||||
begin
|
||||
Result := FArguments;
|
||||
end;
|
||||
|
||||
function TFunctionCallNode.GetCallee: IExpressionNode;
|
||||
function TFunctionCallNode.GetCallee: IAstNode;
|
||||
begin
|
||||
Result := FCallee;
|
||||
end;
|
||||
|
||||
{ TBlockExpressionNode }
|
||||
|
||||
constructor TBlockExpressionNode.Create(const AExpressions: array of IExpressionNode);
|
||||
constructor TBlockExpressionNode.Create(const AExpressions: array of IAstNode);
|
||||
var
|
||||
expr: IExpressionNode;
|
||||
expr: IAstNode;
|
||||
begin
|
||||
inherited Create;
|
||||
FExpressions := TList<IExpressionNode>.Create;
|
||||
FExpressions := TList<IAstNode>.Create;
|
||||
for expr in AExpressions do
|
||||
FExpressions.Add(expr);
|
||||
end;
|
||||
@@ -663,14 +653,14 @@ begin
|
||||
Result := Visitor.VisitBlockExpression(Self);
|
||||
end;
|
||||
|
||||
function TBlockExpressionNode.GetExpressions: TList<IExpressionNode>;
|
||||
function TBlockExpressionNode.GetExpressions: TList<IAstNode>;
|
||||
begin
|
||||
Result := FExpressions;
|
||||
end;
|
||||
|
||||
{ TVariableDeclarationNode }
|
||||
|
||||
constructor TVariableDeclarationNode.Create(const AIdentifier: IIdentifierNode; AInitializer: IExpressionNode);
|
||||
constructor TVariableDeclarationNode.Create(const AIdentifier: IIdentifierNode; AInitializer: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FIdentifier := AIdentifier;
|
||||
@@ -687,14 +677,14 @@ begin
|
||||
Result := FIdentifier;
|
||||
end;
|
||||
|
||||
function TVariableDeclarationNode.GetInitializer: IExpressionNode;
|
||||
function TVariableDeclarationNode.GetInitializer: IAstNode;
|
||||
begin
|
||||
Result := FInitializer;
|
||||
end;
|
||||
|
||||
{ TAssignmentNode }
|
||||
|
||||
constructor TAssignmentNode.Create(const AIdentifier: IIdentifierNode; const AValue: IExpressionNode);
|
||||
constructor TAssignmentNode.Create(const AIdentifier: IIdentifierNode; const AValue: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FIdentifier := AIdentifier;
|
||||
@@ -711,14 +701,14 @@ begin
|
||||
Result := FIdentifier;
|
||||
end;
|
||||
|
||||
function TAssignmentNode.GetValue: IExpressionNode;
|
||||
function TAssignmentNode.GetValue: IAstNode;
|
||||
begin
|
||||
Result := FValue;
|
||||
end;
|
||||
|
||||
{ TIndexerNode }
|
||||
|
||||
constructor TIndexerNode.Create(const ABase, AIndex: IExpressionNode);
|
||||
constructor TIndexerNode.Create(const ABase, AIndex: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FBase := ABase;
|
||||
@@ -730,19 +720,19 @@ begin
|
||||
Result := Visitor.VisitIndexer(Self);
|
||||
end;
|
||||
|
||||
function TIndexerNode.GetBase: IExpressionNode;
|
||||
function TIndexerNode.GetBase: IAstNode;
|
||||
begin
|
||||
Result := FBase;
|
||||
end;
|
||||
|
||||
function TIndexerNode.GetIndex: IExpressionNode;
|
||||
function TIndexerNode.GetIndex: IAstNode;
|
||||
begin
|
||||
Result := FIndex;
|
||||
end;
|
||||
|
||||
{ TMemberAccessNode }
|
||||
|
||||
constructor TMemberAccessNode.Create(const ABase: IExpressionNode; const AMember: IIdentifierNode);
|
||||
constructor TMemberAccessNode.Create(const ABase: IAstNode; const AMember: IIdentifierNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FBase := ABase;
|
||||
@@ -754,7 +744,7 @@ begin
|
||||
Result := Visitor.VisitMemberAccess(Self);
|
||||
end;
|
||||
|
||||
function TMemberAccessNode.GetBase: IExpressionNode;
|
||||
function TMemberAccessNode.GetBase: IAstNode;
|
||||
begin
|
||||
Result := FBase;
|
||||
end;
|
||||
@@ -784,7 +774,7 @@ end;
|
||||
|
||||
{ TAddSeriesItemNode }
|
||||
|
||||
constructor TAddSeriesItemNode.Create(const ASeries: IIdentifierNode; const AValue, ALookback: IExpressionNode);
|
||||
constructor TAddSeriesItemNode.Create(const ASeries: IIdentifierNode; const AValue, ALookback: IAstNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FSeries := ASeries;
|
||||
@@ -797,7 +787,7 @@ begin
|
||||
Result := Visitor.VisitAddSeriesItem(Self);
|
||||
end;
|
||||
|
||||
function TAddSeriesItemNode.GetLookback: IExpressionNode;
|
||||
function TAddSeriesItemNode.GetLookback: IAstNode;
|
||||
begin
|
||||
Result := FLookback;
|
||||
end;
|
||||
@@ -807,7 +797,7 @@ begin
|
||||
Result := FSeries;
|
||||
end;
|
||||
|
||||
function TAddSeriesItemNode.GetValue: IExpressionNode;
|
||||
function TAddSeriesItemNode.GetValue: IAstNode;
|
||||
begin
|
||||
Result := FValue;
|
||||
end;
|
||||
@@ -968,7 +958,7 @@ end;
|
||||
|
||||
{ TAst }
|
||||
|
||||
class function TAst.Bind(const RootNode: IExpressionNode; const ParentScope: IExecutionScope): IExecutionScope;
|
||||
class function TAst.Bind(const RootNode: IAstNode; const ParentScope: IExecutionScope): IExecutionScope;
|
||||
var
|
||||
binder: TBinder;
|
||||
visitor: IAstVisitor;
|
||||
@@ -990,26 +980,22 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TAst.AddSeriesItem(
|
||||
const ASeries: IIdentifierNode;
|
||||
const AValue: IExpressionNode;
|
||||
const ALookback: IExpressionNode
|
||||
): IAddSeriesItemNode;
|
||||
class function TAst.AddSeriesItem(const ASeries: IIdentifierNode; const AValue: IAstNode; const ALookback: IAstNode): IAddSeriesItemNode;
|
||||
begin
|
||||
Result := TAddSeriesItemNode.Create(ASeries, AValue, ALookback);
|
||||
end;
|
||||
|
||||
class function TAst.Assign(const AIdentifier: IIdentifierNode; const AValue: IExpressionNode): IAssignmentNode;
|
||||
class function TAst.Assign(const AIdentifier: IIdentifierNode; const AValue: IAstNode): IAssignmentNode;
|
||||
begin
|
||||
Result := TAssignmentNode.Create(AIdentifier, AValue);
|
||||
end;
|
||||
|
||||
class function TAst.AssignResult(const AValue: IExpressionNode): IAssignmentNode;
|
||||
class function TAst.AssignResult(const AValue: IAstNode): IAssignmentNode;
|
||||
begin
|
||||
Result := Assign(TAst.Identifier('Result'), AValue);
|
||||
end;
|
||||
|
||||
class function TAst.Block(const AExpressions: array of IExpressionNode): IBlockExpressionNode;
|
||||
class function TAst.Block(const AExpressions: array of IAstNode): IBlockExpressionNode;
|
||||
begin
|
||||
Result := TBlockExpressionNode.Create(AExpressions);
|
||||
end;
|
||||
@@ -1024,7 +1010,7 @@ begin
|
||||
Result := TCreateSeriesNode.Create(ADefinition);
|
||||
end;
|
||||
|
||||
class function TAst.BinaryExpr(ALeft: IExpressionNode; AOperator: TBinaryOperator; ARight: IExpressionNode): IBinaryExpressionNode;
|
||||
class function TAst.BinaryExpr(ALeft: IAstNode; AOperator: TBinaryOperator; ARight: IAstNode): IBinaryExpressionNode;
|
||||
begin
|
||||
Result := TBinaryExpressionNode.Create(ALeft, AOperator, ARight);
|
||||
end;
|
||||
@@ -1040,7 +1026,7 @@ begin
|
||||
Result := TScopeDescriptor.Create(nil);
|
||||
end;
|
||||
|
||||
class function TAst.FunctionCall(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode;
|
||||
class function TAst.FunctionCall(const ACallee: IAstNode; const AArguments: array of IAstNode): IFunctionCallNode;
|
||||
begin
|
||||
Result := TFunctionCallNode.Create(ACallee, AArguments);
|
||||
end;
|
||||
@@ -1050,17 +1036,17 @@ begin
|
||||
Result := TIdentifierNode.Create(AName);
|
||||
end;
|
||||
|
||||
class function TAst.IfExpr(const ACondition: IExpressionNode; const AThenBranch, AElseBranch: IExpressionNode): IIfExpressionNode;
|
||||
class function TAst.IfExpr(const ACondition: IAstNode; const AThenBranch, AElseBranch: IAstNode): IIfExpressionNode;
|
||||
begin
|
||||
Result := TIfExpressionNode.Create(ACondition, AThenBranch, AElseBranch);
|
||||
end;
|
||||
|
||||
class function TAst.Indexer(const ABase, AIndex: IExpressionNode): IIndexerNode;
|
||||
class function TAst.Indexer(const ABase, AIndex: IAstNode): IIndexerNode;
|
||||
begin
|
||||
Result := TIndexerNode.Create(ABase, AIndex);
|
||||
end;
|
||||
|
||||
class function TAst.MemberAccess(const ABase: IExpressionNode; const AMember: IIdentifierNode): IMemberAccessNode;
|
||||
class function TAst.MemberAccess(const ABase: IAstNode; const AMember: IIdentifierNode): IMemberAccessNode;
|
||||
begin
|
||||
Result := TMemberAccessNode.Create(ABase, AMember);
|
||||
end;
|
||||
@@ -1070,22 +1056,22 @@ begin
|
||||
Result := TSeriesLengthNode.Create(ASeries);
|
||||
end;
|
||||
|
||||
class function TAst.TernaryExpr(const ACondition: IExpressionNode; const AThenBranch, AElseBranch: IExpressionNode): ITernaryExpressionNode;
|
||||
class function TAst.TernaryExpr(const ACondition: IAstNode; const AThenBranch, AElseBranch: IAstNode): ITernaryExpressionNode;
|
||||
begin
|
||||
Result := TTernaryExpressionNode.Create(ACondition, AThenBranch, AElseBranch);
|
||||
end;
|
||||
|
||||
class function TAst.LambdaExpr(const AParameters: TArray<IIdentifierNode>; const ABody: IExpressionNode): ILambdaExpressionNode;
|
||||
class function TAst.LambdaExpr(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode): ILambdaExpressionNode;
|
||||
begin
|
||||
Result := TLambdaExpressionNode.Create(AParameters, ABody);
|
||||
end;
|
||||
|
||||
class function TAst.UnaryExpr(const AOperator: TUnaryOperator; const ARight: IExpressionNode): IUnaryExpressionNode;
|
||||
class function TAst.UnaryExpr(const AOperator: TUnaryOperator; const ARight: IAstNode): IUnaryExpressionNode;
|
||||
begin
|
||||
Result := TUnaryExpressionNode.Create(AOperator, ARight);
|
||||
end;
|
||||
|
||||
class function TAst.VarDecl(const AIdentifier: IIdentifierNode; AInitializer: IExpressionNode): IVariableDeclarationNode;
|
||||
class function TAst.VarDecl(const AIdentifier: IIdentifierNode; AInitializer: IAstNode): IVariableDeclarationNode;
|
||||
begin
|
||||
Result := TVariableDeclarationNode.Create(AIdentifier, AInitializer);
|
||||
end;
|
||||
@@ -1114,7 +1100,7 @@ end;
|
||||
|
||||
function TAstTraverser.VisitBlockExpression(const Node: IBlockExpressionNode): TAstValue;
|
||||
var
|
||||
expr: IExpressionNode;
|
||||
expr: IAstNode;
|
||||
begin
|
||||
for expr in Node.Expressions do
|
||||
expr.Accept(Self);
|
||||
@@ -1130,7 +1116,7 @@ end;
|
||||
|
||||
function TAstTraverser.VisitFunctionCall(const Node: IFunctionCallNode): TAstValue;
|
||||
var
|
||||
arg: IExpressionNode;
|
||||
arg: IAstNode;
|
||||
begin
|
||||
Node.Callee.Accept(Self);
|
||||
for arg in Node.Arguments do
|
||||
|
||||
Reference in New Issue
Block a user