Esempio n. 1
0
        public object visit_Function_Stmt(GStmt.Function stmt)
        {
            LoxFunction function = new LoxFunction(stmt, environment, false);

            environment.define(stmt.name.lexeme, function);
            return(null);
        }
Esempio n. 2
0
        private void resolveFunction(GStmt.Function function, FunctionType type)
        {
            FunctionType enclosingFunction = currentFunction;

            currentFunction = type;
            beginScope();
            foreach (Token param in function.parameters)
            {
                declare(param);
                define(param);
            }
            resolve(function.body);
            endScope();
            currentFunction = enclosingFunction;
        }
Esempio n. 3
0
 public LoxFunction(GStmt.Function dec, Environment closure, bool isInitializer)
 {
     this.closure       = closure;
     this.declaration   = dec;
     this.isInitializer = isInitializer;
 }