public Void Visit_FunctionStmt(FunctionStmt stmt) { LoxFunction function = new LoxFunction(stmt, _environment); _environment.Define((string)stmt.name.value, function); return(null); }
public Void Visit_FunctionStmt(FunctionStmt stmt) { Declare(stmt.name); Define(stmt.name); ResolveFunction(stmt, FunctionType.Function); return(null); }
public object VisitFunctionStmt(FunctionStmt stmt) { var func = new LoxFunction(stmt, _scope, false); _scope.Define(stmt.Name.Lexeme, func); return(null); }
public object VisitFunctionStmt(FunctionStmt stmt) { // Defining the name before resolving the function // allows the function to refer to itself. Declare(stmt.Name); Define(stmt.Name); ResolveFunction(stmt, FunctionType.FUNCTION); return(null); }
public string Visit_FunctionStmt(FunctionStmt stmt) { StringBuilder sb = new StringBuilder(); sb.Append("(FnDecl "); sb.Append("'" + (string)stmt.name.value + "'"); sb.Append(' '); foreach (var item in stmt.parameters) { sb.Append("'" + (string)item.value + "'"); sb.Append(' '); } sb.Append(Parenthesize("Body", stmt.body.ToArray())); sb.Append(')'); return(sb.ToString()); }
private void ResolveFunction(FunctionStmt func, FunctionType type) { var enclosingFuncType = _currentFuncType; _currentFuncType = type; BeginScope(); foreach (var param in func.Parameters) { Declare(param); Define(param); } Resolve(func.Body); EndScope(); _currentFuncType = enclosingFuncType; }
void ResolveFunction(FunctionStmt function, FunctionType functionType) { FunctionType enclosingFunctionType = _currentFunctionType; _currentFunctionType = functionType; BeginScope(); foreach (var param in function.parameters) { Declare(param); Define(param); } Resolve(function.body); EndScope(); _currentFunctionType = enclosingFunctionType; }
public LoxFunction(FunctionStmt declaration, Environment closure, bool isInitializer = false) { _declaration = declaration; _closure = closure; _isInitializer = isInitializer; }
public LoxFunction(FunctionStmt declaration, Scope closure, bool isInitializer) { _declaration = declaration; _closure = closure; _isInitializer = isInitializer; }