visitIdentifierExpression method

  1. @override
Future<Element> visitIdentifierExpression(
  1. IdentifierExpression node
)
override

Implementation

@override
Future<Element> visitIdentifierExpression(IdentifierExpression node) async {
  final definition = _environment.getDefinition(node.identifier.lexeme);

  if (definition == null) {
    throw SymbolNotInScopeError(node.identifier);
  }

  final constant = definition is LetVariableDeclaration && definition.body.constant;

  // TODO (mateusfccp): Deal with recursive definitions?

  return IdentifierElement(
    name: node.identifier.lexeme,
    constant: constant,
    type: definition.type,
  );
}