public object Visit(Stmt.Function stmt) { Declare(stmt.name); Define(stmt.name); ResolveFunction(stmt, FunctionType.Function); return(null); }
public object Visit(Stmt.Function _function) { LoxFunction function = new LoxFunction(_function, m_Enviroment); m_Enviroment.Define(_function.name.lexeme, function); return(null); }
private void ResolveFunction(Stmt.Function stmt, FunctionType functionType) { FunctionType enclosingFunction = m_CurrentFunction; m_CurrentFunction = functionType; BeginScope(); { foreach (Token paramter in stmt.parameters) { Declare(paramter); Define(paramter); } Resolve(stmt.body); } EndScope(); m_CurrentFunction = enclosingFunction; }
public LoxFunction(Stmt.Function declaration, Environment closure) { m_Declaration = declaration; m_Closure = closure; }