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

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