示例#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);
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#5
0
        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()));
 }