Exemplo n.º 1
0
        public object visitFunctionStmt(Stmt.Function stmt)
        {
            var function = new RosellaFunction(stmt, environment);

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

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

            currentFunction = type;

            beginScope();
            foreach (var param in function.@params)
            {
                declare(param);
                define(param);
            }
            resolve(function.body);
            endScope();
            currentFunction = enclosingFunction;
        }
Exemplo n.º 4
0
 public RosellaFunction(Stmt.Function declaration, RosellaEnvironment closure)
 {
     this.declaration = declaration;
     this.closure     = closure;
 }