public void Visit(Stmt.Function stmt) { Declare(stmt.name); Define(stmt.name); ResolveFunction(stmt, FunctionType.Function); }
private void ResolveFunction(Stmt.Function function, FunctionType type) { FunctionType enclosingFunction = currentFunction; currentFunction = type; BeginScope(); foreach (Token param in function.parameters) { Declare(param); Define(param); } Resolve(function.body); EndScope(); currentFunction = enclosingFunction; }
public void Visit(Stmt.Function stmt) { LoxFunction function = new LoxFunction(stmt, environment, false); environment.Define(stmt.name.lexeme, function); }
public LoxFunction(Stmt.Function declaration, Environment closure, bool isInitializer) { this.declaration = declaration; this.closure = closure; this.isInitializer = isInitializer; }