Types added to Tuples
This commit is contained in:
+20
-14
@@ -162,14 +162,20 @@ type
|
||||
AOperator: TBinaryOperator;
|
||||
ARight: IExpressionNode
|
||||
): IBinaryExpressionNode; static;
|
||||
class function UnaryExpr(AOperator: TUnaryOperator; ARight: IExpressionNode): IUnaryExpressionNode; static;
|
||||
class function IfExpr(ACondition: IExpressionNode; AThenBranch, AElseBranch: IExpressionNode): IIfExpressionNode; static;
|
||||
class function LambdaExpr(const AParameters: array of IIdentifierNode; ABody: IAstNode): ILambdaExpressionNode; static;
|
||||
class function FunctionCall(ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode; 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 LambdaExpr(const AParameters: array of IIdentifierNode; const ABody: IAstNode): ILambdaExpressionNode; static;
|
||||
class function FunctionCall(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode; static;
|
||||
// Statements
|
||||
class function Block(const AStatements: array of IStatementNode): IBlockStatementNode; static;
|
||||
class function VarDecl(AIdentifier: IIdentifierNode; AInitializer: IExpressionNode): IVariableDeclarationStatementNode; static;
|
||||
class function ExprStmt(AExpression: IExpressionNode): IExpressionStatementNode; static;
|
||||
class function VarDecl(
|
||||
const AIdentifier: IIdentifierNode;
|
||||
AInitializer: IExpressionNode
|
||||
): IVariableDeclarationStatementNode; static;
|
||||
class function ExprStmt(const AExpression: IExpressionNode): IExpressionStatementNode; static;
|
||||
end;
|
||||
|
||||
// Manages the scope of execution, holding variables and their values.
|
||||
@@ -188,7 +194,7 @@ type
|
||||
TEvaluatorVisitor = class(TInterfacedObject, IAstVisitor)
|
||||
private
|
||||
FScope: TExecutionScope;
|
||||
function IsTruthy(AValue: IDataValue): Boolean;
|
||||
function IsTruthy(const AValue: IDataValue): Boolean;
|
||||
public
|
||||
constructor Create(AScope: TExecutionScope);
|
||||
// Expression visitors
|
||||
@@ -335,17 +341,17 @@ begin
|
||||
Result := TBinaryExpressionNodeImpl.Create(ALeft, AOperator, ARight);
|
||||
end;
|
||||
|
||||
class function TAst.UnaryExpr(AOperator: TUnaryOperator; ARight: IExpressionNode): IUnaryExpressionNode;
|
||||
class function TAst.UnaryExpr(const AOperator: TUnaryOperator; const ARight: IExpressionNode): IUnaryExpressionNode;
|
||||
begin
|
||||
Result := TUnaryExpressionNodeImpl.Create(AOperator, ARight);
|
||||
end;
|
||||
|
||||
class function TAst.IfExpr(ACondition: IExpressionNode; AThenBranch, AElseBranch: IExpressionNode): IIfExpressionNode;
|
||||
class function TAst.IfExpr(const ACondition: IExpressionNode; const AThenBranch, AElseBranch: IExpressionNode): IIfExpressionNode;
|
||||
begin
|
||||
Result := TIfExpressionNodeImpl.Create(ACondition, AThenBranch, AElseBranch);
|
||||
end;
|
||||
|
||||
class function TAst.LambdaExpr(const AParameters: array of IIdentifierNode; ABody: IAstNode): ILambdaExpressionNode;
|
||||
class function TAst.LambdaExpr(const AParameters: array of IIdentifierNode; const ABody: IAstNode): ILambdaExpressionNode;
|
||||
var
|
||||
paramList: TList<IIdentifierNode>;
|
||||
param: IIdentifierNode;
|
||||
@@ -356,7 +362,7 @@ begin
|
||||
Result := TLambdaExpressionNodeImpl.Create(paramList, ABody);
|
||||
end;
|
||||
|
||||
class function TAst.FunctionCall(ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode;
|
||||
class function TAst.FunctionCall(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode): IFunctionCallNode;
|
||||
var
|
||||
argList: TList<IExpressionNode>;
|
||||
arg: IExpressionNode;
|
||||
@@ -378,12 +384,12 @@ begin
|
||||
Result := TBlockStatementNodeImpl.Create(stmtList);
|
||||
end;
|
||||
|
||||
class function TAst.VarDecl(AIdentifier: IIdentifierNode; AInitializer: IExpressionNode): IVariableDeclarationStatementNode;
|
||||
class function TAst.VarDecl(const AIdentifier: IIdentifierNode; AInitializer: IExpressionNode): IVariableDeclarationStatementNode;
|
||||
begin
|
||||
Result := TVariableDeclarationStatementNodeImpl.Create(AIdentifier, AInitializer);
|
||||
end;
|
||||
|
||||
class function TAst.ExprStmt(AExpression: IExpressionNode): IExpressionStatementNode;
|
||||
class function TAst.ExprStmt(const AExpression: IExpressionNode): IExpressionStatementNode;
|
||||
begin
|
||||
Result := TExpressionStatementNodeImpl.Create(AExpression);
|
||||
end;
|
||||
@@ -673,7 +679,7 @@ begin
|
||||
FScope := AScope;
|
||||
end;
|
||||
|
||||
function TEvaluatorVisitor.IsTruthy(AValue: IDataValue): Boolean;
|
||||
function TEvaluatorVisitor.IsTruthy(const AValue: IDataValue): Boolean;
|
||||
begin
|
||||
// Defines the language's concept of "truthiness".
|
||||
// For now, only ordinals can be conditions. 0 is false, everything else is true.
|
||||
|
||||
Reference in New Issue
Block a user