public override Value VisitVariableExpression([NotNull] VariableExpressionContext context) { string varName = context.Name; if (!NamedValues.TryGetValue(varName, out Value value)) { throw new ArgumentException("Unknown variable name", nameof(context)); } return(value); }
public override IAstNode VisitVariableExpression([NotNull] VariableExpressionContext context) { string varName = context.Name; if (!NamedValues.TryGetValue(varName, out IVariableDeclaration declaration)) { throw new CodeGeneratorException($"Unknown variable name: {varName}"); } return(new VariableReferenceExpression(context.GetSourceSpan( ), declaration)); }
public override IAstNode VisitVariableExpression(VariableExpressionContext context) { string varName = context.Name; if (!NamedValues.TryGetValue(varName, out IVariableDeclaration? declaration)) { return(new ErrorNode(context.GetSourceSpan( ), $"Unknown variable name: {varName}")); } return(new VariableReferenceExpression(context.GetSourceSpan( ), declaration)); }
public override Value VisitVariableExpression([NotNull] VariableExpressionContext context) { string varName = context.Name; if (!NamedValues.TryGetValue(varName, out Alloca value)) { throw new ArgumentException("Unknown variable name", nameof(context)); } return(InstructionBuilder.Load(value) .RegisterName(varName)); }
public override Expression VisitVariableExpression([NotNull] VariableExpressionContext context) { var index = GetIndexNumber(context.index()); return(Variables[index]); }
public override Node VisitVariableExpression(VariableExpressionContext context) { return(new VariableNode(context.Start, context.LABEL().GetText())); }