private object EvaluateFunctionStatement(FunctionStatement expr) { var function = new LoxFunction(expr, _environment, false); _environment.Define(expr.Name.Lexeme, function); return(null); }
private void ResolveFunction(FunctionStatement expr, FunctionType type) { var enclosingFunction = _currentFunction; _currentFunction = type; BeginScope(); foreach (var param in expr.Parameters) { Declare(param); Define(param); } Resolve(expr.Body); EndScope(); _currentFunction = enclosingFunction; }
public LoxFunction(FunctionStatement declaration, Environment closure, bool isInitializer) { _declaration = declaration; _closure = closure; _isInitializer = isInitializer; }
private void ResolveFunctionStatement(FunctionStatement expr) { Declare(expr.Name); Define(expr.Name); ResolveFunction(expr, FunctionType.Function); }