Package org.jruby.parser

Examples of org.jruby.parser.LocalStaticScope


        YARVMachine ym = new YARVMachine();
       
        Ruby runtime = Ruby.newInstance(System.in, System.out, System.err);
        ThreadContext context = runtime.getCurrentContext();
       
        StaticScope scope = new LocalStaticScope(null);
        scope.setVariables(new String[] {"n", "i", "j", "cur", "k"});
        assertEquals("55", ym.exec(context, scope, getFib(runtime,10)).toString());
       
        IRubyObject fib5k = ym.exec(context, scope, getFib(runtime,5000));
        assertEquals("38789684543883256337019163083259053120821277146462451061605972148955501390440370" +
                "9701082291646221066947929345285888297381348310200895498294036143015691147893836421656" +
View Full Code Here


        this.runtimeCache = runtime.getRuntimeCache();
       
        // TOPLEVEL self and a few others want a top-level scope.  We create this one right
        // away and then pass it into top-level parse so it ends up being the top level.
        StaticScope topStaticScope = new LocalStaticScope(null);
        pushScope(new ManyVarsDynamicScope(topStaticScope, null));

        Frame[] stack = frameStack;
        int length = stack.length;
        for (int i = 0; i < length; i++) {
View Full Code Here

        popFrame();
    }
   
    public void preBsfApply(String[] names) {
        // FIXME: I think we need these pushed somewhere?
        LocalStaticScope staticScope = new LocalStaticScope(null);
        staticScope.setVariables(names);
        pushFrame();
    }
View Full Code Here

        return (IRModule) scope;
    }

    @Override
    protected StaticScope constructStaticScope(StaticScope unused) {
        LocalStaticScope newScope = new LocalStaticScope(null); // method scopes cannot see any lower

        this.requiredArgs = 0;
        this.optionalArgs = 0;
        this.restArg = -1;
View Full Code Here

    static ManyVarsDynamicScope getManyVarsDynamicScope(ScriptingContainer container, int depth) {
        ManyVarsDynamicScope scope;

        // root our parsing scope with a dummy scope
        StaticScope topStaticScope = new LocalStaticScope(null);
        topStaticScope.setModule(container.getProvider().getRuntime().getObject());

        DynamicScope currentScope = new ManyVarsDynamicScope(topStaticScope, null);
        String[] names4Injection = container.getVarMap().getLocalVarNames();
        if (names4Injection == null || names4Injection.length == 0) {
            scope =
View Full Code Here

        }
    }
   
    @JRubyMethod
    public IRubyObject to_proc(ThreadContext context) {
        StaticScope scope = new LocalStaticScope(null);
       
        BlockBody body = new ContextAwareBlockBody(scope, Arity.OPTIONAL, BlockBody.SINGLE_RESTARG) {
            @Override
            public IRubyObject yield(ThreadContext context, IRubyObject value, Binding binding, Type type) {
                RubyArray array = ArgsUtil.convertToRubyArray(context.getRuntime(), value, false);
View Full Code Here

        //    class Foo
        //      def m2; ...; end
        //    end
        //
        String n = ROOT_METHOD_PREFIX + getName();
        rootMethod = new IRMethod(this, MetaObject.create(this), n, false, new LocalStaticScope(null));
        rootMethod.addInstr(new ReceiveSelfInstruction(rootMethod.getSelf()));   // Set up self!
    }
View Full Code Here

        if (value == null) return context.nil;
        return RubyString.newStringShared(context.runtime, value);
    }
   
    public static void preLoad(ThreadContext context, String[] varNames) {
        StaticScope staticScope = new LocalStaticScope(null, varNames);
        preLoadCommon(context, staticScope);
    }
View Full Code Here

        return namesBuilder.toString();
    }

    public static LocalStaticScope decodeRootScope(ThreadContext context, String scopeString) {
        String[][] decodedScope = decodeScopeDescriptor(scopeString);
        LocalStaticScope scope = new LocalStaticScope(null, decodedScope[1]);
        setAritiesFromDecodedScope(scope, decodedScope[0]);
        return scope;
    }
View Full Code Here

        return scope;
    }

    public static LocalStaticScope decodeLocalScope(ThreadContext context, String scopeString) {
        String[][] decodedScope = decodeScopeDescriptor(scopeString);
        LocalStaticScope scope = new LocalStaticScope(context.getCurrentScope().getStaticScope(), decodedScope[1]);
        setAritiesFromDecodedScope(scope, decodedScope[0]);
        return scope;
    }
View Full Code Here

TOP

Related Classes of org.jruby.parser.LocalStaticScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.