Example #1
0
        public object visitStmtFunctionStmt(StmtFunction stmt)
        {
            LoxFunction func = new LoxFunction(stmt, enviroment);

            enviroment.define(stmt.name.lexeme, func);
            return(null);
        }
Example #2
0
        public object visitStmtFunctionStmt(StmtFunction stmt)
        {
            declare(stmt.name);
            define(stmt.name);

            resolveFunction(stmt, FunctionType.FUNCTION);
            return(null);
        }
Example #3
0
        void resolveFunction(StmtFunction stmt, FunctionType fType)
        {
            FunctionType encFunction = currentFunction;

            currentFunction = fType;

            beginScope();
            foreach (Token param in stmt.arguments)
            {
                declare(param);
                define(param);
            }
            resolve(stmt.body);
            endScope();

            currentFunction = encFunction;
        }
Example #4
0
 public LoxFunction(StmtFunction _declaration, Enviroment _closure)
 {
     closure     = _closure;
     declaration = _declaration;
 }