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 MultipleClassCaller extends CodeBlock {
 
     public MultipleClassCaller(final String classNamefinal int numChunks) {
         LabelNode abrupt = new LabelNode();
         LabelNode end = new LabelNode();
 
         invokestatic(p(Completion.class), "createNormal"sig(Completion.class));
         // completion
         astore(.);
         // <empty>
 
         for (int i = 0; i < numChunks; ++i) {
             LabelNode nonAbrupt = new LabelNode();
             LabelNode bringForwardValue = new LabelNode();
             LabelNode nextStatement = new LabelNode();
 
             // <empty>
             aload(.);
             // this
             getfield(className.replace('.''/'), "chunk" + ici(BasicBlock.class));
             // block
             aload(.);
             // block context
             invokeinterface(p(BasicBlock.class), "call"sig(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