コード例 #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;
 }