Esempio n. 1
0
        public Void visitFunctionStmt(Stmt.Function stmt)
        {
            Declare(stmt.name);
            Define(stmt.name);

            ResolveFunction(stmt, FunctionType.FUNCTION);

            return(null);
        }
Esempio n. 2
0
        public Void visitFunctionStmt(Stmt.Function stmt)
        {
            Function fn = new Function(stmt, environment);

            if (stmt.name != null)
            {
                environment.Define(stmt.name.lexeme, fn);
            }

            return(null);
        }
Esempio n. 3
0
        private void ResolveFunction(Stmt.Function fn, FunctionType type)
        {
            FunctionType enclosingFunctionType = currentFunction;

            currentFunction = type;

            BeginScope();
            foreach (Token parameter in fn.parameters)
            {
                Declare(parameter);
                Define(parameter);
            }
            Resolve(fn.body);

            EndScope();

            currentFunction = enclosingFunctionType;
        }
Esempio n. 4
0
 public Function(Stmt.Function declaration, Env closure)
 {
     this.declaration = declaration;
     this.closure     = closure;
 }