TDataValue as new global variant type
This commit is contained in:
+72
-71
@@ -8,6 +8,7 @@ uses
|
||||
System.Generics.Collections,
|
||||
System.Generics.Defaults,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Value,
|
||||
Myc.Ast.Nodes,
|
||||
Myc.Ast.Scope;
|
||||
|
||||
@@ -44,22 +45,22 @@ type
|
||||
// TAstTraverser provides a default AST traversal implementation.
|
||||
TAstTraverser = class abstract(TInterfacedObject, IAstVisitor)
|
||||
public
|
||||
function VisitConstant(const Node: IConstantNode): TAstValue; virtual;
|
||||
function VisitIdentifier(const Node: IIdentifierNode): TAstValue; virtual;
|
||||
function VisitBinaryExpression(const Node: IBinaryExpressionNode): TAstValue; virtual;
|
||||
function VisitUnaryExpression(const Node: IUnaryExpressionNode): TAstValue; virtual;
|
||||
function VisitIfExpression(const Node: IIfExpressionNode): TAstValue; virtual;
|
||||
function VisitTernaryExpression(const Node: ITernaryExpressionNode): TAstValue; virtual;
|
||||
function VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstValue; virtual;
|
||||
function VisitFunctionCall(const Node: IFunctionCallNode): TAstValue; virtual;
|
||||
function VisitBlockExpression(const Node: IBlockExpressionNode): TAstValue; virtual;
|
||||
function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstValue; virtual;
|
||||
function VisitAssignment(const Node: IAssignmentNode): TAstValue; virtual;
|
||||
function VisitIndexer(const Node: IIndexerNode): TAstValue; virtual;
|
||||
function VisitMemberAccess(const Node: IMemberAccessNode): TAstValue; virtual;
|
||||
function VisitCreateSeries(const Node: ICreateSeriesNode): TAstValue; virtual;
|
||||
function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstValue; virtual;
|
||||
function VisitSeriesLength(const Node: ISeriesLengthNode): TAstValue; virtual;
|
||||
function VisitConstant(const Node: IConstantNode): TDataValue; virtual;
|
||||
function VisitIdentifier(const Node: IIdentifierNode): TDataValue; virtual;
|
||||
function VisitBinaryExpression(const Node: IBinaryExpressionNode): TDataValue; virtual;
|
||||
function VisitUnaryExpression(const Node: IUnaryExpressionNode): TDataValue; virtual;
|
||||
function VisitIfExpression(const Node: IIfExpressionNode): TDataValue; virtual;
|
||||
function VisitTernaryExpression(const Node: ITernaryExpressionNode): TDataValue; virtual;
|
||||
function VisitLambdaExpression(const Node: ILambdaExpressionNode): TDataValue; virtual;
|
||||
function VisitFunctionCall(const Node: IFunctionCallNode): TDataValue; virtual;
|
||||
function VisitBlockExpression(const Node: IBlockExpressionNode): TDataValue; virtual;
|
||||
function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TDataValue; virtual;
|
||||
function VisitAssignment(const Node: IAssignmentNode): TDataValue; virtual;
|
||||
function VisitIndexer(const Node: IIndexerNode): TDataValue; virtual;
|
||||
function VisitMemberAccess(const Node: IMemberAccessNode): TDataValue; virtual;
|
||||
function VisitCreateSeries(const Node: ICreateSeriesNode): TDataValue; virtual;
|
||||
function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TDataValue; virtual;
|
||||
function VisitSeriesLength(const Node: ISeriesLengthNode): TDataValue; virtual;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -86,7 +87,7 @@ type
|
||||
// Common base class for AST nodes to reduce boilerplate.
|
||||
TAstNode = class(TInterfacedObject, IAstNode)
|
||||
public
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; virtual; abstract;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TConstantNode }
|
||||
@@ -96,7 +97,7 @@ type
|
||||
function GetValue: TScalar;
|
||||
public
|
||||
constructor Create(AValue: TScalar);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TIdentifierNode }
|
||||
@@ -111,7 +112,7 @@ type
|
||||
function GetAddress: TResolvedAddress; inline;
|
||||
public
|
||||
constructor Create(AName: string);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
property IsResolved: Boolean read GetIsResolved;
|
||||
property Name: string read FName;
|
||||
property Address: TResolvedAddress read GetAddress;
|
||||
@@ -128,7 +129,7 @@ type
|
||||
function GetRight: IAstNode;
|
||||
public
|
||||
constructor Create(ALeft: IAstNode; AOperator: TBinaryOperator; ARight: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TUnaryExpressionNode }
|
||||
@@ -140,7 +141,7 @@ type
|
||||
function GetRight: IAstNode;
|
||||
public
|
||||
constructor Create(const AOperator: TUnaryOperator; const ARight: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TIfExpressionNode }
|
||||
@@ -154,7 +155,7 @@ type
|
||||
function GetElseBranch: IAstNode;
|
||||
public
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TTernaryExpressionNode }
|
||||
@@ -168,7 +169,7 @@ type
|
||||
function GetElseBranch: IAstNode;
|
||||
public
|
||||
constructor Create(const ACondition, AThenBranch, AElseBranch: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TLambdaExpressionNode }
|
||||
@@ -184,7 +185,7 @@ type
|
||||
function GetUpvalues: TArray<TResolvedAddress>;
|
||||
public
|
||||
constructor Create(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
property ScopeDescriptor: IScopeDescriptor read GetScopeDescriptor;
|
||||
end;
|
||||
|
||||
@@ -198,7 +199,7 @@ type
|
||||
public
|
||||
constructor Create(const ACallee: IAstNode; const AArguments: array of IAstNode);
|
||||
destructor Destroy; override;
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TBlockExpressionNode }
|
||||
@@ -209,7 +210,7 @@ type
|
||||
public
|
||||
constructor Create(const AExpressions: array of IAstNode);
|
||||
destructor Destroy; override;
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TVariableDeclarationNode }
|
||||
@@ -221,7 +222,7 @@ type
|
||||
function GetInitializer: IAstNode;
|
||||
public
|
||||
constructor Create(const AIdentifier: IIdentifierNode; AInitializer: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TAssignmentNode }
|
||||
@@ -233,7 +234,7 @@ type
|
||||
function GetValue: IAstNode;
|
||||
public
|
||||
constructor Create(const AIdentifier: IIdentifierNode; const AValue: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TIndexerNode }
|
||||
@@ -245,7 +246,7 @@ type
|
||||
function GetIndex: IAstNode;
|
||||
public
|
||||
constructor Create(const ABase: IAstNode; const AIndex: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TMemberAccessNode }
|
||||
@@ -257,7 +258,7 @@ type
|
||||
function GetMember: IIdentifierNode;
|
||||
public
|
||||
constructor Create(const ABase: IAstNode; const AMember: IIdentifierNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TCreateSeriesNode }
|
||||
@@ -267,7 +268,7 @@ type
|
||||
function GetDefinition: String;
|
||||
public
|
||||
constructor Create(const ADefinition: String);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TAddSeriesItemNode }
|
||||
@@ -281,7 +282,7 @@ type
|
||||
function GetLookback: IAstNode;
|
||||
public
|
||||
constructor Create(const ASeries: IIdentifierNode; const AValue: IAstNode; const ALookback: IAstNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
{ TSeriesLengthNode }
|
||||
@@ -291,7 +292,7 @@ type
|
||||
function GetSeries: IIdentifierNode;
|
||||
public
|
||||
constructor Create(const ASeries: IIdentifierNode);
|
||||
function Accept(const Visitor: IAstVisitor): TAstValue; override;
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
TResolvedAddressComparer = class(TEqualityComparer<TResolvedAddress>)
|
||||
@@ -312,9 +313,9 @@ type
|
||||
public
|
||||
constructor Create(const AInitialScope: IExecutionScope);
|
||||
destructor Destroy; override;
|
||||
function VisitIdentifier(const Node: IIdentifierNode): TAstValue; override;
|
||||
function VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstValue; override;
|
||||
function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstValue; override;
|
||||
function VisitIdentifier(const Node: IIdentifierNode): TDataValue; override;
|
||||
function VisitLambdaExpression(const Node: ILambdaExpressionNode): TDataValue; override;
|
||||
function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TDataValue; override;
|
||||
property CurrentDescriptor: IScopeDescriptor read FCurrentDescriptor;
|
||||
end;
|
||||
|
||||
@@ -406,7 +407,7 @@ begin
|
||||
FValue := AValue;
|
||||
end;
|
||||
|
||||
function TConstantNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TConstantNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitConstant(Self);
|
||||
end;
|
||||
@@ -424,7 +425,7 @@ begin
|
||||
FName := AName;
|
||||
end;
|
||||
|
||||
function TIdentifierNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TIdentifierNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitIdentifier(Self);
|
||||
end;
|
||||
@@ -457,7 +458,7 @@ begin
|
||||
FRight := ARight;
|
||||
end;
|
||||
|
||||
function TBinaryExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TBinaryExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitBinaryExpression(Self);
|
||||
end;
|
||||
@@ -486,7 +487,7 @@ begin
|
||||
FRight := ARight;
|
||||
end;
|
||||
|
||||
function TUnaryExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TUnaryExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitUnaryExpression(Self);
|
||||
end;
|
||||
@@ -511,7 +512,7 @@ begin
|
||||
FElseBranch := AElseBranch;
|
||||
end;
|
||||
|
||||
function TIfExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TIfExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitIfExpression(Self);
|
||||
end;
|
||||
@@ -541,7 +542,7 @@ begin
|
||||
FElseBranch := AElseBranch;
|
||||
end;
|
||||
|
||||
function TTernaryExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TTernaryExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitTernaryExpression(Self);
|
||||
end;
|
||||
@@ -576,7 +577,7 @@ begin
|
||||
Result := FUpvalues;
|
||||
end;
|
||||
|
||||
function TLambdaExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TLambdaExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitLambdaExpression(Self);
|
||||
end;
|
||||
@@ -615,7 +616,7 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TFunctionCallNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TFunctionCallNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitFunctionCall(Self);
|
||||
end;
|
||||
@@ -648,7 +649,7 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TBlockExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TBlockExpressionNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitBlockExpression(Self);
|
||||
end;
|
||||
@@ -667,7 +668,7 @@ begin
|
||||
FInitializer := AInitializer;
|
||||
end;
|
||||
|
||||
function TVariableDeclarationNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TVariableDeclarationNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitVariableDeclaration(Self);
|
||||
end;
|
||||
@@ -691,7 +692,7 @@ begin
|
||||
FValue := AValue;
|
||||
end;
|
||||
|
||||
function TAssignmentNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TAssignmentNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitAssignment(Self);
|
||||
end;
|
||||
@@ -715,7 +716,7 @@ begin
|
||||
FIndex := AIndex;
|
||||
end;
|
||||
|
||||
function TIndexerNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TIndexerNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitIndexer(Self);
|
||||
end;
|
||||
@@ -739,7 +740,7 @@ begin
|
||||
FMember := AMember;
|
||||
end;
|
||||
|
||||
function TMemberAccessNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TMemberAccessNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitMemberAccess(Self);
|
||||
end;
|
||||
@@ -762,7 +763,7 @@ begin
|
||||
FDefinition := ADefinition;
|
||||
end;
|
||||
|
||||
function TCreateSeriesNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TCreateSeriesNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitCreateSeries(Self);
|
||||
end;
|
||||
@@ -782,7 +783,7 @@ begin
|
||||
FLookback := ALookback;
|
||||
end;
|
||||
|
||||
function TAddSeriesItemNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TAddSeriesItemNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitAddSeriesItem(Self);
|
||||
end;
|
||||
@@ -810,7 +811,7 @@ begin
|
||||
FSeries := ASeries;
|
||||
end;
|
||||
|
||||
function TSeriesLengthNode.Accept(const Visitor: IAstVisitor): TAstValue;
|
||||
function TSeriesLengthNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
begin
|
||||
Result := Visitor.VisitSeriesLength(Self);
|
||||
end;
|
||||
@@ -853,7 +854,7 @@ begin
|
||||
FCurrentDescriptor := FCurrentDescriptor.Parent;
|
||||
end;
|
||||
|
||||
function TBinder.VisitIdentifier(const Node: IIdentifierNode): TAstValue;
|
||||
function TBinder.VisitIdentifier(const Node: IIdentifierNode): TDataValue;
|
||||
var
|
||||
depth, idx: Integer;
|
||||
identNode: TIdentifierNode;
|
||||
@@ -894,7 +895,7 @@ begin
|
||||
raise Exception.CreateFmt('Undefined identifier: "%s"', [identNode.Name]);
|
||||
end;
|
||||
|
||||
function TBinder.VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstValue;
|
||||
function TBinder.VisitLambdaExpression(const Node: ILambdaExpressionNode): TDataValue;
|
||||
var
|
||||
param: IIdentifierNode;
|
||||
upvalueMap: TDictionary<TResolvedAddress, Integer>;
|
||||
@@ -943,7 +944,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBinder.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstValue;
|
||||
function TBinder.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TDataValue;
|
||||
var
|
||||
slotIndex: Integer;
|
||||
identNode: TIdentifierNode;
|
||||
@@ -1078,7 +1079,7 @@ end;
|
||||
|
||||
{ TAstTraverser }
|
||||
|
||||
function TAstTraverser.VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstValue;
|
||||
function TAstTraverser.VisitAddSeriesItem(const Node: IAddSeriesItemNode): TDataValue;
|
||||
begin
|
||||
Node.Series.Accept(Self);
|
||||
Node.Value.Accept(Self);
|
||||
@@ -1086,19 +1087,19 @@ begin
|
||||
Node.Lookback.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitAssignment(const Node: IAssignmentNode): TAstValue;
|
||||
function TAstTraverser.VisitAssignment(const Node: IAssignmentNode): TDataValue;
|
||||
begin
|
||||
Node.Value.Accept(Self);
|
||||
Node.Identifier.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitBinaryExpression(const Node: IBinaryExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitBinaryExpression(const Node: IBinaryExpressionNode): TDataValue;
|
||||
begin
|
||||
Node.Left.Accept(Self);
|
||||
Node.Right.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitBlockExpression(const Node: IBlockExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitBlockExpression(const Node: IBlockExpressionNode): TDataValue;
|
||||
var
|
||||
expr: IAstNode;
|
||||
begin
|
||||
@@ -1106,15 +1107,15 @@ begin
|
||||
expr.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitConstant(const Node: IConstantNode): TAstValue;
|
||||
function TAstTraverser.VisitConstant(const Node: IConstantNode): TDataValue;
|
||||
begin
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitCreateSeries(const Node: ICreateSeriesNode): TAstValue;
|
||||
function TAstTraverser.VisitCreateSeries(const Node: ICreateSeriesNode): TDataValue;
|
||||
begin
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitFunctionCall(const Node: IFunctionCallNode): TAstValue;
|
||||
function TAstTraverser.VisitFunctionCall(const Node: IFunctionCallNode): TDataValue;
|
||||
var
|
||||
arg: IAstNode;
|
||||
begin
|
||||
@@ -1123,11 +1124,11 @@ begin
|
||||
arg.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitIdentifier(const Node: IIdentifierNode): TAstValue;
|
||||
function TAstTraverser.VisitIdentifier(const Node: IIdentifierNode): TDataValue;
|
||||
begin
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitIfExpression(const Node: IIfExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitIfExpression(const Node: IIfExpressionNode): TDataValue;
|
||||
begin
|
||||
Node.Condition.Accept(Self);
|
||||
Node.ThenBranch.Accept(Self);
|
||||
@@ -1135,13 +1136,13 @@ begin
|
||||
Node.ElseBranch.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitIndexer(const Node: IIndexerNode): TAstValue;
|
||||
function TAstTraverser.VisitIndexer(const Node: IIndexerNode): TDataValue;
|
||||
begin
|
||||
Node.Base.Accept(Self);
|
||||
Node.Index.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitLambdaExpression(const Node: ILambdaExpressionNode): TDataValue;
|
||||
var
|
||||
param: IIdentifierNode;
|
||||
begin
|
||||
@@ -1150,30 +1151,30 @@ begin
|
||||
Node.Body.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitMemberAccess(const Node: IMemberAccessNode): TAstValue;
|
||||
function TAstTraverser.VisitMemberAccess(const Node: IMemberAccessNode): TDataValue;
|
||||
begin
|
||||
// Do not visit the member identifier, as it's not a variable in the current scope.
|
||||
Node.Base.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitSeriesLength(const Node: ISeriesLengthNode): TAstValue;
|
||||
function TAstTraverser.VisitSeriesLength(const Node: ISeriesLengthNode): TDataValue;
|
||||
begin
|
||||
Node.Series.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitTernaryExpression(const Node: ITernaryExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitTernaryExpression(const Node: ITernaryExpressionNode): TDataValue;
|
||||
begin
|
||||
Node.Condition.Accept(Self);
|
||||
Node.ThenBranch.Accept(Self);
|
||||
Node.ElseBranch.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitUnaryExpression(const Node: IUnaryExpressionNode): TAstValue;
|
||||
function TAstTraverser.VisitUnaryExpression(const Node: IUnaryExpressionNode): TDataValue;
|
||||
begin
|
||||
Node.Right.Accept(Self);
|
||||
end;
|
||||
|
||||
function TAstTraverser.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstValue;
|
||||
function TAstTraverser.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TDataValue;
|
||||
begin
|
||||
if Assigned(Node.Initializer) then
|
||||
Node.Initializer.Accept(Self);
|
||||
|
||||
Reference in New Issue
Block a user