public Nothing VisitFunctionStmt(Stmt.Function stmt) { Declare(stmt.Name); Define(stmt.Name); ResolveFunction(stmt, FunctionType.Function); return(Nothing.AtAll); }
public Nothing VisitFunctionStmt(Stmt.Function stmt) { LoxFunction function = new LoxFunction(stmt, environment, false); environment.Define(stmt.Name.Lexeme, function); return(Nothing.AtAll); }
private void ResolveFunction(Stmt.Function function, FunctionType type) { FunctionType enclosingFunction = currentFunction; currentFunction = type; BeginScope(); foreach (var param in function.Parameters) { Declare(param); Define(param); } Resolve(function.Body); EndScope(); currentFunction = enclosingFunction; }
public LoxFunction(Stmt.Function declaration, Environment closure, bool isInitializer) { this.declaration = declaration; this.closure = closure; this.isInitializer = isInitializer; }