示例#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);
        }
示例#2
0
 public object Visit_VariableExpr(VariableExpr expr)
 {
     return(LookUpVariable(expr.name, expr));
 }
示例#3
0
文件: Gen_Stmt.cs 项目: sirgru/CsLox
 public ClassStmt(Token name, VariableExpr superclass, List <FunctionStmt> methods)
 {
     this.name       = name;
     this.superclass = superclass;
     this.methods    = methods;
 }
示例#4
0
 public string Visit_VariableExpr(VariableExpr expr)
 {
     return("(Var " + (string)expr.name.value + ")");
 }