public object visitFunctionStmt(Stmt.Function stmt) { LoxFunction function = new LoxFunction(stmt, environment, false); environment.define(stmt.name.lexeme, function); return(null); }
public object visitFunctionStmt(Stmt.Function stmt) { declare(stmt.name); define(stmt.name); resolveFunction(stmt, FunctionType.FUNCTION); return(null); }
private void resolveFunction(Stmt.Function function, FunctionType type) { FunctionType enclosingFunction = currentFunction; currentFunction = type; beginScope(); foreach (Token param in function.params_) { declare(param); define(param); } resolve(function.body); endScope(); currentFunction = enclosingFunction; }
public LoxFunction(Stmt.Function declaration, Environment closure, bool isInitializer) { this.isInitializer = isInitializer; this.closure = closure; this.declaration = declaration; }