evaluateNode method
dynamic
evaluateNode(
- AstNode node
)
Implementation
dynamic evaluateNode(AstNode node) {
return switch (node) {
VariableDeclaration() => _evaluateVariableDeclaration(node),
AnonymousFunction() => _evaluateAnonymousFunction(node),
FunctionDeclaration() => _evaluateFunctionDeclaration(node),
ExpressionStatement() => evaluateNode(node.expression),
IfStatement() => _evaluateIfStatement(node),
WhileStatement() => _evaluateWhileStatement(node),
ForStatement() => _evaluateForStatement(node),
ReturnStatement() => _evaluateReturnStatement(node),
Block() => _evaluateBlock(node),
BinaryExpression() => _evaluateBinaryExpression(node),
UnaryExpression() => _evaluateUnaryExpression(node),
CallExpression() => _evaluateCallExpression(node),
Literal() => node.value,
Variable() => _environment.get(node.name),
Assignment() => _evaluateAssignment(node),
AstWidget() => _evaluateWidget(node),
EndOfFile() => null,
LengthAccess() => _evaluateLengthAccess(node),
IndexAccess() => _evaluateIndexAccess(node),
MemberAccess() => _evaluateMemberAccess(node),
ListLiteral() => _evaluateListLiteral(node),
BreakStatement() => throw BreakException(),
ToString() => _evaluateToString(node),
_ => throw EvaluationError('Unknown node type: ${node.runtimeType}'),
};
}