Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.dynjs.compiler.bytecode.partial;
 
 import static me.qmx.jitescript.util.CodegenUtils.*;
 
public class SingleClassCaller extends CodeBlock {
    public SingleClassCaller(final String classNamefinal int numBodies) {
        LabelNode abrupt = new LabelNode();
        LabelNode end = new LabelNode();
        invokestatic(p(Completion.class), "createNormal"sig(Completion.class));
        // completion
        astore(.);
        // <empty>
        for (int i = 0; i < numBodies; ++i) {
            LabelNode nonAbrupt = new LabelNode();
            LabelNode bringForwardValue = new LabelNode();
            LabelNode nextStatement = new LabelNode();
            
            // <empty>
            aload. );
            // this
            aload. );
            // this context
            invokevirtual(className.replace(".""/"), "callChunk" + isig(Completion.classExecutionContext.class));
            // completion
            dup();
            // completion completion
            getfield(p(Completion.class), "type"ci(Completion.Type.class));
            // completion type
            invokevirtual(p(Completion.Type.class), "ordinal"sig(int.class));
            // completion type-num
            lookupswitch(nonAbrupt,
                    new int[] { ..ordinal(), ..ordinal(), ..ordinal(), ..ordinal() },
                    new LabelNode[] { nonAbruptabruptabruptabrupt });
            // ----------------------------------------
            // Non-abrupt
            label(nonAbrupt);
            // completion(cur);
            dup();
            // completion(cur) completion(cur)
            getfield(p(Completion.class), "value"ci(Object.class));
            // completion(cur) value
            ifnull(bringForwardValue);
            // completion(cur)
            astore(.);
            // <empty>
            go_to(nextStatement);
            // ----------------------------------------
            label(bringForwardValue);
            // completion(cur)
            dup();
            // completion(cur) completion(cur)
            aload(.);
            // completion(cur) completion(cur) completion(prev)
            getfield(p(Completion.class), "value"ci(Object.class));
            // completion(cur) completion(cur) val(prev)
            putfield(p(Completion.class), "value"ci(Object.class));
            // completion(cur)
            astore(.);
            // <empty>
            label(nextStatement);
        }
        go_to(end);
        // ----------------------------------------
        // ABRUPT
        label(abrupt);
        // completion(cur)
        astore(.);
        // <empty>
        // ----------------------------------------
        // END
        label(end);
        // <empty>
        aload(.);
        // completion
        areturn();
        
    }
New to GrepCode? Check out our FAQ X