object Stmt.Visitor <object> .VisitVarStmt(Stmt.Var stmt) { Object value = null; if (stmt.initializer != null) { value = Evaluate(stmt.initializer); } environment.Define(stmt.name._lexeme, value); return(null); }
public object Call(Interpreter interpreter, List <object> args) { Environment.Environment environment = new Environment.Environment().SetParentEnvironment(closure); for (int i = 0; i < Declaration.Parameters.Count; ++i) { environment.Define(Declaration.Parameters[i].Lexeme, args[i]); } try { interpreter.ExecuteBlock(Declaration.Body, environment); } catch (ReturnException e) { return(e.Value); } return(null); }