Ejemplo n.º 1
0
        public Void Visit_VariableExpr(VariableExpr expr)
        {
            var name = (string)expr.name.value;

            if (_scopes.Count != 0)
            {
                var scope  = _scopes.Peek();
                var hasKey = scope.TryGetValue(name, out bool state);
                if (hasKey && state == false)
                {
                    _errors.Add(new Error(expr.name, ErrorType.InitializerError, "Cannot read local variable in its own initializer."));
                }
            }
            ResolveLocal(expr, expr.name);
            return(null);
        }
Ejemplo n.º 2
0
 public object Visit_VariableExpr(VariableExpr expr)
 {
     return(LookUpVariable(expr.name, expr));
 }
Ejemplo n.º 3
0
 public ClassStmt(Token name, VariableExpr superclass, List <FunctionStmt> methods)
 {
     this.name       = name;
     this.superclass = superclass;
     this.methods    = methods;
 }
Ejemplo n.º 4
0
 public string Visit_VariableExpr(VariableExpr expr)
 {
     return("(Var " + (string)expr.name.value + ")");
 }