예제 #1
0
 public object Visit(Stmt.Function stmt)
 {
     Declare(stmt.name);
     Define(stmt.name);
     ResolveFunction(stmt, FunctionType.Function);
     return(null);
 }
예제 #2
0
        public object Visit(Stmt.Function _function)
        {
            LoxFunction function = new LoxFunction(_function, m_Enviroment);

            m_Enviroment.Define(_function.name.lexeme, function);
            return(null);
        }
예제 #3
0
        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;
        }
예제 #4
0
 public LoxFunction(Stmt.Function declaration, Environment closure)
 {
     m_Declaration = declaration;
     m_Closure     = closure;
 }