Пример #1
0
        public object visitFunctionStmt(Stmt.Function stmt)
        {
            var function = new RosellaFunction(stmt, environment);

            environment.define(stmt.name.lexeme, function);
            return(null);
        }
Пример #2
0
        public object visitFunctionStmt(Stmt.Function stmt)
        {
            declare(stmt.name);
            define(stmt.name);

            resolveFunction(stmt, FunctionType.FUNCTION);
            return(null);
        }
Пример #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;
        }
Пример #4
0
 public RosellaFunction(Stmt.Function declaration, RosellaEnvironment closure)
 {
     this.declaration = declaration;
     this.closure     = closure;
 }