Ejemplo n.º 1
0
        public object visitFunctionStmt(Stmt.Function stmt)
        {
            JingleFunc function = new JingleFunc(stmt, environment, false);

            environment.define(stmt.name.lexeme, function);
            return(null);
        }
Ejemplo n.º 2
0
        public object visitFunctionStmt(Stmt.Function stmt)
        {
            declare(stmt.name);
            define(stmt.name);

            resolveFunction(stmt, FunctionType.FUNCTION);
            return(null);
        }
Ejemplo n.º 3
0
        private void resolveFunction(Stmt.Function function, FunctionType type)
        {
            FunctionType enclosingFunction = currentFunction;

            currentFunction = type;

            beginScope();
            foreach (Token param in function.params_)
            {
                declare(param);
                define(param);
            }
            resolve(function.body);
            endScope();
            currentFunction = enclosingFunction;
        }
Ejemplo n.º 4
0
 public JingleFunc(Stmt.Function declaration, Environment closure, bool isInitializer)
 {
     this.isInitializer = isInitializer;
     this.closure       = closure;
     this.declaration   = declaration;
 }