Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        public override Expression VisitVariableExpression([NotNull] VariableExpressionContext context)
        {
            var index = GetIndexNumber(context.index());

            return(Variables[index]);
        }
Exemplo n.º 6
0
 public override Node VisitVariableExpression(VariableExpressionContext context)
 {
     return(new VariableNode(context.Start, context.LABEL().GetText()));
 }