Examples of DynamicScope


Examples of org.cx4a.rsense.ruby.DynamicScope

        Block block = null;
        if (iterNode != null) {
            switch (iterNode.getNodeType()) {
            case ITERNODE: {
                IterNode inode = (IterNode) iterNode;
                DynamicScope scope = new DynamicScope(context.getCurrentScope().getModule(), context.getCurrentScope());
                block = new Proc(graph.getRuntime(), inode.getVarNode(), inode.getBodyNode(), context.getCurrentFrame(), scope);
                break;
            }
            case BLOCKPASSNODE:
                block = context.getFrameBlock();
View Full Code Here

Examples of org.impalaframework.spring.dynamic.DynamicScope

    // create the bean factory
    DynamicBeanFactory beanFactory = new DynamicBeanFactory();
    beanFactory.setBeanClassLoader(classLoader);

    // create the scope, and register with the bean factory
    DynamicScope dynamicScope = new DynamicScope();
    dynamicScope.setClassLoader(classLoader);
    beanFactory.registerScope("dynamic", dynamicScope);

    // create the application context, and set the class loader
    GenericApplicationContext context = new GenericApplicationContext(beanFactory);
    context.setClassLoader(classLoader);
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

    }
   
    public static void preLoad(ThreadContext context, String[] varNames) {
        StaticScope staticScope = new LocalStaticScope(null, varNames);
        staticScope.setModule(context.getRuntime().getObject());
        DynamicScope scope = DynamicScope.newDynamicScope(staticScope);
       
        // Each root node has a top-level scope that we need to push
        context.preScopedBody(scope);
    }
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

            context.preBsfApply(names);
           
            // FIXME: This is broken.  We are assigning BSF globals as local vars in the top-level
            // scope.  This may be ok, but we are overwriting $~ and $_.  Leaving for now.
            DynamicScope scope = context.getCurrentScope();

            // set global variables
            for (int i = 0, size = args.size(); i < size; i++) {
                scope.setValue(i, JavaEmbedUtils.javaToRuby(runtime, args.get(i)), 0);
            }

          // See eval todo about why this is commented out
            //runtime.setPosition(file, line);
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

                throw runtime.newTypeError("wrong argument type " + scope.getMetaClass() + " (expected Proc/Binding)");
            }
        }

        Binding binding = ((RubyBinding)scope).getBinding();
        DynamicScope evalScope = binding.getDynamicScope().getEvalScope();

        // If no explicit file passed in we will use the bindings location
        if (file == null) file = binding.getFrame().getFile();
        if (lineNumber == -1) lineNumber = binding.getFrame().getLine();
       
        // FIXME:  This determine module is in a strange location and should somehow be in block
        evalScope.getStaticScope().determineModule();

        Frame lastFrame = context.preEvalWithBinding(binding);
        try {
            // Binding provided for scope, use it
            IRubyObject newSelf = binding.getSelf();
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

        int savedLine = context.getLine();

        // no binding, just eval in "current" frame (caller's frame)
        RubyString source = src.convertToString();
       
        DynamicScope evalScope = context.getCurrentScope().getEvalScope();
        evalScope.getStaticScope().determineModule();
       
        try {
            Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);
           
            return node.interpret(runtime, context, self, Block.NULL_BLOCK);
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

     * @param script The scriptlet to run
     * @returns The result of the eval
     */
    public IRubyObject evalScriptlet(String script) {
        ThreadContext context = getCurrentContext();
        DynamicScope currentScope = context.getCurrentScope();
        ManyVarsDynamicScope newScope = new ManyVarsDynamicScope(new EvalStaticScope(currentScope.getStaticScope()), currentScope);
        Node node = parseEval(script, "<script>", newScope, 0);
       
        try {
            context.preEvalScriptlet(newScope);
            return node.interpret(this, context, context.getFrameSelf(), Block.NULL_BLOCK);
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

        return Node.createList(beginNode, endNode);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        DynamicScope scope = context.getCurrentScope();
        IRubyObject nil = runtime.getNil();
        int index = getIndex();

        // Make sure the appropriate scope has proper size. See JRUBY-2046.
        DynamicScope flipScope = scope.getFlipScope();
        flipScope.growIfNeeded();
       
        IRubyObject result = flipScope.getValueDepthZeroOrNil(index, nil);
  
        if (exclusive) {
            if (result == null || !result.isTrue()) {
                result = trueIfTrue(runtime, beginNode.interpret(runtime, context, self, aBlock));
                flipScope.setValueDepthZero(result, index);
                return result;
            } else {
                if (endNode.interpret(runtime, context, self, aBlock).isTrue()) {
                    flipScope.setValueDepthZero(runtime.getFalse(), index);
                }
               
                return runtime.getTrue();
            }
        } else {
            if (result == null || !result.isTrue()) {
                if (beginNode.interpret(runtime, context, self, aBlock).isTrue()) {
                    flipScope.setValueDepthZero(falseIfTrue(runtime, endNode.interpret(runtime, context, self, aBlock)), index);
                    return runtime.getTrue();
                }

                return runtime.getFalse();
            } else {
                if (endNode.interpret(runtime, context, self, aBlock).isTrue()) {
                    flipScope.setValueDepthZero(runtime.getFalse(), index);
                }
                return runtime.getTrue();
            }
        }
    }
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

        return iVisitor.visitPreExeNode(this);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        DynamicScope scope = DynamicScope.newDynamicScope(getScope());
        // Each root node has a top-level scope that we need to push
        context.preScopedBody(scope);

        // FIXME: I use a for block to implement END node because we need a proc which captures
        // its enclosing scope.   ForBlock now represents these node and should be renamed.
View Full Code Here

Examples of org.jruby.runtime.DynamicScope

     *
     */
    public void remove() {
        ThreadContext context = receiver.getRuntime().getCurrentContext();
        try {
            DynamicScope currentScope = context.getCurrentScope();
            ManyVarsDynamicScope scope = (ManyVarsDynamicScope) context.getCurrentScope();
            scope = new ManyVarsDynamicScope(new EvalStaticScope(currentScope.getStaticScope()), currentScope);
        } catch (ArrayIndexOutOfBoundsException e) {
            //no context is left.
            //no operation is needed.
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.