@Override public void RescueEQQInstr(RescueEQQInstr rescueeqqinstr) { jvmMethod().loadContext(); visit(rescueeqqinstr.getArg1()); visit(rescueeqqinstr.getArg2()); jvmMethod().invokeIRHelper("isExceptionHandled", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, Object.class)); jvmStoreLocal(rescueeqqinstr.getResult()); }
@Override public void ThrowExceptionInstr(ThrowExceptionInstr throwexceptioninstr) { visit(throwexceptioninstr.getException()); jvmAdapter().athrow(); }
@Override public void AsString(AsString asstring) { visit(asstring.getSource()); jvmAdapter().invokeinterface(p(IRubyObject.class), "asString", sig(RubyString.class)); }
@Override public void ToAryInstr(ToAryInstr toaryinstr) { jvm.method().loadContext(); visit(toaryinstr.getArrayArg()); jvm.method().adapter.ldc(toaryinstr.dontToAryArrays()); jvm.method().invokeHelper("irToAry", IRubyObject.class, ThreadContext.class, IRubyObject.class, boolean.class); jvmStoreLocal(toaryinstr.getResult()); }
@Override public void SValue(SValue svalue) { visit(svalue.getArray()); jvmAdapter().dup(); jvmAdapter().instance_of(p(RubyArray.class)); org.objectweb.asm.Label after = new org.objectweb.asm.Label(); jvmAdapter().iftrue(after); jvmAdapter().pop(); jvmMethod().pushNil(); jvmAdapter().label(after); }
@Override public void ProcessModuleBodyInstr(ProcessModuleBodyInstr processmodulebodyinstr) { jvmMethod().loadContext(); visit(processmodulebodyinstr.getModuleBody()); visit(processmodulebodyinstr.getBlock()); jvmMethod().invokeIRHelper("invokeModuleBody", sig(IRubyObject.class, ThreadContext.class, DynamicMethod.class, Block.class)); jvmStoreLocal(processmodulebodyinstr.getResult()); }
@Override public void ToAryInstr(ToAryInstr toaryinstr) { jvm.method().loadContext(); visit(toaryinstr.getArrayArg()); jvm.method().adapter.ldc(toaryinstr.dontToAryArrays()); jvm.method().invokeHelper("irToAry", IRubyObject.class, ThreadContext.class, IRubyObject.class, boolean.class); jvmStoreLocal(toaryinstr.getResult()); }
@Override public void AsString(AsString asstring) { visit(asstring.getSource()); jvmAdapter().invokeinterface(p(IRubyObject.class), "asString", sig(RubyString.class)); }
@Override public void BUndefInstr(BUndefInstr bundefinstr) { visit(bundefinstr.getArg1()); jvmMethod().pushUndefined(); jvmAdapter().if_acmpeq(getJVMLabel(bundefinstr.getJumpTarget())); }
@Override public void ProcessModuleBodyInstr(ProcessModuleBodyInstr processmodulebodyinstr) { jvmMethod().loadContext(); visit(processmodulebodyinstr.getModuleBody()); visit(processmodulebodyinstr.getBlock()); jvmMethod().invokeIRHelper("invokeModuleBody", sig(IRubyObject.class, ThreadContext.class, DynamicMethod.class, Block.class)); jvmStoreLocal(processmodulebodyinstr.getResult()); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvm.method().loadContext(); visit(reqdargmultipleasgninstr.getArrayArg()); jvm.method().adapter.checkcast("org/jruby/RubyArray"); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getIndex()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvm.method().invokeHelper("irReqdArgMultipleAsgn", IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
@Override public void PutClassVariableInstr(PutClassVariableInstr putclassvariableinstr) { visit(putclassvariableinstr.getValue()); visit(putclassvariableinstr.getTarget()); // don't understand this logic; duplicated from interpreter if (putclassvariableinstr.getValue() instanceof CurrentScope) { jvmAdapter().pop2(); return; } // hmm. jvmAdapter().checkcast(p(RubyModule.class)); jvmAdapter().swap(); jvmAdapter().ldc(putclassvariableinstr.getId()); jvmAdapter().swap(); jvmAdapter().invokevirtual(p(RubyModule.class), "setClassVar", sig(IRubyObject.class, String.class, IRubyObject.class)); jvmAdapter().pop(); }
@Override public void BUndefInstr(BUndefInstr bundefinstr) { visit(bundefinstr.getArg1()); jvmMethod().pushUndefined(); jvmAdapter().if_acmpeq(getJVMLabel(bundefinstr.getJumpTarget())); }
@Override public void RescueEQQInstr(RescueEQQInstr rescueeqqinstr) { jvmMethod().loadContext(); visit(rescueeqqinstr.getArg1()); visit(rescueeqqinstr.getArg2()); jvmMethod().invokeIRHelper("isExceptionHandled", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, Object.class)); jvmStoreLocal(rescueeqqinstr.getResult()); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvm.method().loadContext(); visit(reqdargmultipleasgninstr.getArrayArg()); jvm.method().adapter.checkcast("org/jruby/RubyArray"); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getIndex()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvm.method().invokeHelper("irReqdArgMultipleAsgn", IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
@Override public void SValue(SValue svalue) { visit(svalue.getArray()); jvmAdapter().dup(); jvmAdapter().instance_of(p(RubyArray.class)); org.objectweb.asm.Label after = new org.objectweb.asm.Label(); jvmAdapter().iftrue(after); jvmAdapter().pop(); jvmMethod().pushNil(); jvmAdapter().label(after); }
@Override public void ToAryInstr(ToAryInstr toaryinstr) { jvmMethod().loadContext(); visit(toaryinstr.getArray()); jvmMethod().invokeIRHelper("irToAry", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class)); jvmStoreLocal(toaryinstr.getResult()); }
@Override public void RecordEndBlockInstr(RecordEndBlockInstr recordEndBlockInstr) { jvmMethod().loadContext(); jvmMethod().loadContext(); visit(recordEndBlockInstr.getEndBlockClosure()); jvmMethod().invokeIRHelper("getBlockFromObject", sig(Block.class, ThreadContext.class, Object.class)); jvmMethod().invokeIRHelper("pushExitBlock", sig(void.class, ThreadContext.class, Block.class)); }
@Override public void RecordEndBlockInstr(RecordEndBlockInstr recordEndBlockInstr) { jvmMethod().loadContext(); jvmMethod().loadContext(); visit(recordEndBlockInstr.getEndBlockClosure()); jvmMethod().invokeIRHelper("getBlockFromObject", sig(Block.class, ThreadContext.class, Object.class)); jvmMethod().invokeIRHelper("pushExitBlock", sig(void.class, ThreadContext.class, Block.class)); }
@Override public void ToAryInstr(ToAryInstr toaryinstr) { jvmMethod().loadContext(); visit(toaryinstr.getArray()); jvmMethod().invokeIRHelper("irToAry", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class)); jvmStoreLocal(toaryinstr.getResult()); }