Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package org.jruby.javasupport.util;
   
   import org.jruby.*;
  
  
  import static org.jruby.runtime.invokedynamic.MethodNames.EQL;
  import static org.jruby.runtime.invokedynamic.MethodNames.OP_EQUAL;

Helper methods which are called by the compiler. Note: These will show no consumers, but generated code does call these so don't remove them thinking they are dead code.
  
  public class RuntimeHelpers {
      public static CallSite selectAttrAsgnCallSite(IRubyObject receiverIRubyObject selfCallSite normalSiteCallSite variableSite) {
          if (receiver == selfreturn variableSite;
          return normalSite;
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject valueThreadContext contextIRubyObject caller) {
          callSite.call(contextcallerreceivervalue);
          return value;
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject arg0IRubyObject valueThreadContext contextIRubyObject caller) {
          callSite.call(contextcallerreceiverarg0value);
          return value;
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject arg0IRubyObject arg1IRubyObject valueThreadContext contextIRubyObject caller) {
          callSite.call(contextcallerreceiverarg0arg1value);
          return value;
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject arg0IRubyObject arg1IRubyObject arg2IRubyObject valueThreadContext contextIRubyObject caller) {
          callSite.call(contextcallerreceiverarg0arg1arg2value);
          return value;
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject[] argsThreadContext contextIRubyObject caller) {
          callSite.call(contextcallerreceiverargs);
          return args[args.length - 1];
      }
      public static IRubyObject doAttrAsgn(IRubyObject receiverCallSite callSiteIRubyObject[] argsIRubyObject valueThreadContext contextIRubyObject caller) {
          IRubyObject[] newArgs = new IRubyObject[args.length + 1];
          System.arraycopy(args, 0, newArgs, 0, args.length);
         newArgs[args.length] = value;
         callSite.call(contextcallerreceivernewArgs);
         return value;
     }
 
     public static boolean invokeEqqForCaseWhen(CallSite callSiteThreadContext contextIRubyObject callerIRubyObject argIRubyObject[] receivers) {
         for (int i = 0; i < receivers.lengthi++) {
             IRubyObject receiver = receivers[i];
             if (invokeEqqForCaseWhen(callSitecontextcallerargreceiver)) return true;
         }
         return false;
     }
 
     public static boolean invokeEqqForCaseWhen(CallSite callSiteThreadContext contextIRubyObject callerIRubyObject argIRubyObject receiver) {
         IRubyObject result = callSite.call(contextcallerreceiverarg);
         if (result.isTrue()) return true;
         return false;
     }
 
     public static boolean invokeEqqForCaseWhen(CallSite callSiteThreadContext contextIRubyObject callerIRubyObject argIRubyObject receiver0IRubyObject receiver1) {
         IRubyObject result = callSite.call(contextcallerreceiver0arg);
         if (result.isTrue()) return true;
         return invokeEqqForCaseWhen(callSitecontextcallerargreceiver1);
     }
 
     public static boolean invokeEqqForCaseWhen(CallSite callSiteThreadContext contextIRubyObject callerIRubyObject argIRubyObject receiver0IRubyObject receiver1IRubyObject receiver2) {
         IRubyObject result = callSite.call(contextcallerreceiver0arg);
         if (result.isTrue()) return true;
         return invokeEqqForCaseWhen(callSitecontextcallerargreceiver1receiver2);
     }
 
     public static boolean areAnyTrueForCaselessWhen(IRubyObject[] receivers) {
         for (int i = 0; i < receivers.lengthi++) {
             if (receivers[i].isTrue()) return true;
         }
         return false;
     }
 
     public static boolean invokeEqqForCaselessWhen(IRubyObject receiver) {
         return receiver.isTrue();
     }
 
     public static boolean invokeEqqForCaselessWhen(IRubyObject receiver0IRubyObject receiver1) {
         return receiver0.isTrue() || receiver1.isTrue();
     }
 
     public static boolean invokeEqqForCaselessWhen(IRubyObject receiver0IRubyObject receiver1IRubyObject receiver2) {
         return receiver0.isTrue() || receiver1.isTrue() || receiver2.isTrue();
     }
     
     public static CompiledBlockCallback createBlockCallback(Object scriptObjectString closureMethodString fileint line) {
         Class scriptClass = scriptObject.getClass();
         ClassLoader scriptClassLoader = scriptClass.getClassLoader();
         MethodFactory factory = MethodFactory.createFactory(scriptClassLoader);
         
         return factory.getBlockCallback(closureMethodfilelinescriptObject);
     }
 
     public static CompiledBlockCallback19 createBlockCallback19(Object scriptObjectString closureMethodString fileint line) {
         Class scriptClass = scriptObject.getClass();
         ClassLoader scriptClassLoader = scriptClass.getClassLoader();
         MethodFactory factory = MethodFactory.createFactory(scriptClassLoader);
 
         return factory.getBlockCallback19(closureMethodfilelinescriptObject);
     }
 
     public static byte[] createBlockCallbackOffline(String classPathString closureMethodString fileint line) {
         MethodFactory factory = MethodFactory.createFactory(RuntimeHelpers.class.getClassLoader());
 
         return factory.getBlockCallbackOffline(closureMethodfilelineclassPath);
     }
 
     public static byte[] createBlockCallback19Offline(String classPathString closureMethodString fileint line) {
         MethodFactory factory = MethodFactory.createFactory(RuntimeHelpers.class.getClassLoader());
 
         return factory.getBlockCallback19Offline(closureMethodfilelineclassPath);
     }
 
     public static String buildBlockDescriptor19(
             String closureMethod,
             int arity,
             StaticScope scope,
             String file,
             int line,
             boolean hasMultipleArgsHead,
             NodeType argsNodeId,
             String parameterList,
             ASTInspector inspector) {
         return buildBlockDescriptor(closureMethodarityscopefilelinehasMultipleArgsHeadargsNodeIdinspector) +
                 "," + parameterList;
     }
 
     public static String buildBlockDescriptor(
             String closureMethod,
             int arity,
             StaticScope scope,
             String file,
             int line,
             boolean hasMultipleArgsHead,
             NodeType argsNodeId,
             ASTInspector inspector) {
         
         // build scope names string
         StringBuffer scopeNames = new StringBuffer();
         for (int i = 0; i < scope.getVariables().lengthi++) {
             if (i != 0) scopeNames.append(';');
             scopeNames.append(scope.getVariables()[i]);
         }
 
         // build descriptor string
         String descriptor =
                 closureMethod + ',' +
                 arity + ',' +
                 scopeNames + ',' +
                 hasMultipleArgsHead + ',' +
                 BlockBody.asArgumentType(argsNodeId) + ',' +
                 file + ',' +
                 line + ',' +
                 !(inspector.hasClosure() || inspector.hasScopeAwareMethods());
 
         return descriptor;
     }
     
     public static String[][] parseBlockDescriptor(String descriptor) {
         String[] firstSplit = descriptor.split(",");
         String[] secondSplit;
         if (firstSplit[2].length() == 0) {
             secondSplit = new String[0];
         } else {
             secondSplit = firstSplit[2].split(";");
             // FIXME: Big fat hack here, because scope names are expected to be interned strings by the parser
             for (int i = 0; i < secondSplit.lengthi++) {
                 secondSplit[i] = secondSplit[i].intern();
             }
         }
         return new String[][] {firstSplitsecondSplit};
     }
 
     public static BlockBody createCompiledBlockBody(ThreadContext contextObject scriptObjectString descriptor) {
         String[][] splitDesc = parseBlockDescriptor(descriptor);
         String[] firstSplit = splitDesc[0];
         String[] secondSplit = splitDesc[1];
         return createCompiledBlockBody(contextscriptObjectfirstSplit[0], Integer.parseInt(firstSplit[1]), secondSplit, Boolean.valueOf(firstSplit[3]), Integer.parseInt(firstSplit[4]), firstSplit[5], Integer.parseInt(firstSplit[6]), Boolean.valueOf(firstSplit[7]));
     }
     
     public static BlockBody createCompiledBlockBody(ThreadContext contextObject scriptObjectString closureMethodint arity
             String[] staticScopeNamesboolean hasMultipleArgsHeadint argsNodeTypeString fileint lineboolean light) {
         StaticScope staticScope = context.runtime.getStaticScopeFactory().newBlockScope(context.getCurrentScope().getStaticScope(), staticScopeNames);
         staticScope.determineModule();
         
         if (light) {
             return CompiledBlockLight.newCompiledBlockLight(
                     Arity.createArity(arity), staticScope,
                     createBlockCallback(scriptObjectclosureMethodfileline),
                     hasMultipleArgsHeadargsNodeType);
         } else {
             return CompiledBlock.newCompiledBlock(
                     Arity.createArity(arity), staticScope,
                     createBlockCallback(scriptObjectclosureMethodfileline),
                     hasMultipleArgsHeadargsNodeType);
         }
     }
 
     public static BlockBody createCompiledBlockBody19(ThreadContext contextObject scriptObjectString descriptor) {
         String[][] splitDesc = parseBlockDescriptor(descriptor);
         String[] firstSplit = splitDesc[0];
         String[] secondSplit = splitDesc[1];
         return createCompiledBlockBody19(contextscriptObjectfirstSplit[0], Integer.parseInt(firstSplit[1]), secondSplit, Boolean.valueOf(firstSplit[3]), Integer.parseInt(firstSplit[4]), firstSplit[5], Integer.parseInt(firstSplit[6]), Boolean.valueOf(firstSplit[7]), firstSplit[8]);
     }
 
     public static BlockBody createCompiledBlockBody19(ThreadContext contextObject scriptObjectString closureMethodint arity,
             String[] staticScopeNamesboolean hasMultipleArgsHeadint argsNodeTypeString fileint lineboolean lightString parameterList) {
         StaticScope staticScope = context.runtime.getStaticScopeFactory().newBlockScope(context.getCurrentScope().getStaticScope(), staticScopeNames);
         staticScope.determineModule();
 
         if (light) {
             return CompiledBlockLight19.newCompiledBlockLight(
                     Arity.createArity(arity), staticScope,
                     createBlockCallback19(scriptObjectclosureMethodfileline),
                     hasMultipleArgsHeadargsNodeTypeparameterList.split(";"));
         } else {
             return CompiledBlock19.newCompiledBlock(
                     Arity.createArity(arity), staticScope,
                     createBlockCallback19(scriptObjectclosureMethodfileline),
                     hasMultipleArgsHeadargsNodeTypeparameterList.split(";"));
         }
     }
     
     public static Block createBlock(ThreadContext contextIRubyObject selfBlockBody body) {
         return CompiledBlock.newCompiledClosure(
                 context,
                 self,
                 body);
     }
 
     public static Block createBlock19(ThreadContext contextIRubyObject selfBlockBody body) {
         return CompiledBlock19.newCompiledClosure(
                 context,
                 self,
                 body);
     }
     
     public static IRubyObject runBeginBlock(ThreadContext contextIRubyObject selfString scopeStringCompiledBlockCallback callback) {
         StaticScope staticScope = decodeBlockScope(contextscopeString);
         staticScope.determineModule();
         
         context.preScopedBody(DynamicScope.newDynamicScope(staticScopecontext.getCurrentScope()));
         
         Block block = CompiledBlock.newCompiledClosure(contextself, Arity.createArity(0), staticScopecallbackfalse.);
         
         try {
             block.yield(contextnull);
         } finally {
             context.postScopedBody();
         }
 
         return context.runtime.getNil();
     }
     
     public static Block createSharedScopeBlock(ThreadContext contextIRubyObject selfint arity
             CompiledBlockCallback callbackboolean hasMultipleArgsHeadint argsNodeType) {
         
         return CompiledSharedScopeBlock.newCompiledSharedScopeClosure(contextself, Arity.createArity(arity), 
                 context.getCurrentScope(), callbackhasMultipleArgsHeadargsNodeType);
     }
     
     public static IRubyObject def(ThreadContext contextIRubyObject selfObject scriptObjectString nameString javaNameStaticScope scope,
             int arityString filenameint lineCallConfiguration callConfigString parameterDesc) {
         Class compiledClass = scriptObject.getClass();
         Ruby runtime = context.runtime;
         
         RubyModule containingClass = context.getRubyClass();
         Visibility visibility = context.getCurrentVisibility();
         
         performNormalMethodChecks(containingClassruntimename);
         
         MethodFactory factory = MethodFactory.createFactory(compiledClass.getClassLoader());
         DynamicMethod method = constructNormalMethod(
                 factoryjavaName,
                 namecontainingClassnew SimpleSourcePosition(filenameline), arityscopevisibilityscriptObject,
                 callConfig,
                 parameterDesc);
         
         addInstanceMethod(containingClassnamemethodvisibility,contextruntime);
         
         return runtime.getNil();
     }
     
     public static IRubyObject defs(ThreadContext contextIRubyObject selfIRubyObject receiverObject scriptObjectString nameString javaNameStaticScope scope,
             int arityString filenameint lineCallConfiguration callConfigString parameterDesc) {
         Class compiledClass = scriptObject.getClass();
         Ruby runtime = context.runtime;
 
         RubyClass rubyClass = performSingletonMethodChecks(runtimereceivername);
         
         MethodFactory factory = MethodFactory.createFactory(compiledClass.getClassLoader());
         DynamicMethod method = constructSingletonMethod(
                 factoryjavaNamerubyClass,
                 new SimpleSourcePosition(filenameline), arityscope,
                 scriptObjectcallConfigparameterDesc);
         
         rubyClass.addMethod(namemethod);
         
         callSingletonMethodHook(receiver,contextruntime.fastNewSymbol(name));
         
         return runtime.getNil();
     }
 
     public static byte[] defOffline(String nameString classPathString invokerNameArity arityStaticScope scopeCallConfiguration callConfigString filenameint line) {
         MethodFactory factory = MethodFactory.createFactory(RuntimeHelpers.class.getClassLoader());
         byte[] methodBytes = factory.getCompiledMethodOffline(nameclassPathinvokerNamearityscopecallConfigfilenameline);
 
         return methodBytes;
     }
     
     public static RubyClass getSingletonClass(Ruby runtimeIRubyObject receiver) {
         if (receiver instanceof RubyFixnum || receiver instanceof RubySymbol) {
             throw runtime.newTypeError(runtime.is1_9() ? "can't define singleton" : ("no virtual class for " + receiver.getMetaClass().getBaseName()));
         } else {
             return receiver.getSingletonClass();
         }
     }
 
     // TODO: Only used by interface implementation; eliminate it
     public static IRubyObject invokeMethodMissing(IRubyObject receiverString nameIRubyObject[] args) {
         ThreadContext context = receiver.getRuntime().getCurrentContext();
 
         // store call information so method_missing impl can use it
 
         if (name.equals("method_missing")) {
             return RubyKernel.method_missing(contextreceiverargs.);
         }
 
         IRubyObject[] newArgs = prepareMethodMissingArgs(argscontextname);
 
         return invoke(contextreceiver"method_missing"newArgs.);
     }
 
     public static IRubyObject callMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callTypeIRubyObject[] argsBlock block) {
         return selectMethodMissing(contextreceivervisibilitynamecallType).call(contextreceiverreceiver.getMetaClass(), nameargsblock);
     }
 
     public static IRubyObject callMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callTypeIRubyObject arg0Block block) {
         return selectMethodMissing(contextreceivervisibilitynamecallType).call(contextreceiverreceiver.getMetaClass(), namearg0block);
     }
 
     public static IRubyObject callMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callTypeIRubyObject arg0IRubyObject arg1Block block) {
         return selectMethodMissing(contextreceivervisibilitynamecallType).call(contextreceiverreceiver.getMetaClass(), namearg0arg1block);
     }
 
     public static IRubyObject callMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callTypeIRubyObject arg0IRubyObject arg1IRubyObject arg2Block block) {
         return selectMethodMissing(contextreceivervisibilitynamecallType).call(contextreceiverreceiver.getMetaClass(), namearg0arg1arg2block);
     }
 
     public static IRubyObject callMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callTypeBlock block) {
         return selectMethodMissing(contextreceivervisibilitynamecallType).call(contextreceiverreceiver.getMetaClass(), nameblock);
     }
 
     public static DynamicMethod selectMethodMissing(ThreadContext contextIRubyObject receiverVisibility visibilityString nameCallType callType) {
         Ruby runtime = context.runtime;
 
         if (name.equals("method_missing")) {
             return selectInternalMM(runtimevisibilitycallType);
         }
 
         DynamicMethod methodMissing = receiver.getMetaClass().searchMethod("method_missing");
         if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
             return selectInternalMM(runtimevisibilitycallType);
         }
         return new MethodMissingMethod(methodMissingcallType);
     }
 
     public static DynamicMethod selectMethodMissing(ThreadContext contextRubyClass selfClassVisibility visibilityString nameCallType callType) {
         Ruby runtime = context.runtime;
 
         if (name.equals("method_missing")) {
             return selectInternalMM(runtimevisibilitycallType);
         }
 
         DynamicMethod methodMissing = selfClass.searchMethod("method_missing");
         if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
             return selectInternalMM(runtimevisibilitycallType);
         }
         return new MethodMissingMethod(methodMissingcallType);
     }
 
     public static DynamicMethod selectMethodMissing(RubyClass selfClassVisibility visibilityString nameCallType callType) {
         Ruby runtime = selfClass.getClassRuntime();
 
         if (name.equals("method_missing")) {
             return selectInternalMM(runtimevisibilitycallType);
         }
 
         DynamicMethod methodMissing = selfClass.searchMethod("method_missing");
         if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
             return selectInternalMM(runtimevisibilitycallType);
         }
         return new MethodMissingMethod(methodMissingcallType);
     }
 
     private static class MethodMissingMethod extends DynamicMethod {
         private final DynamicMethod delegate;
         private final CallType lastCallStatus;
 
         public MethodMissingMethod(DynamicMethod delegateCallType lastCallStatus) {
             this. = delegate;
             this. = lastCallStatus;
         }
 
         @Override
         public IRubyObject call(ThreadContext contextIRubyObject selfRubyModule clazzString nameIRubyObject[] argsBlock block) {
             context.setLastCallStatus();
             return this..call(contextselfclazz"method_missing"prepareMethodMissingArgs(argscontextname), block);
         }
 
         @Override
         public DynamicMethod dup() {
             return this;
         }
     }
 
     private static DynamicMethod selectInternalMM(Ruby runtimeVisibility visibilityCallType callType) {
         if (visibility == .) {
             return runtime.getPrivateMethodMissing();
         } else if (visibility == .) {
             return runtime.getProtectedMethodMissing();
         } else if (callType == .) {
             return runtime.getVariableMethodMissing();
         } else if (callType == .) {
             return runtime.getSuperMethodMissing();
         } else {
             return runtime.getNormalMethodMissing();
         }
     }
 
     private static IRubyObject[] prepareMethodMissingArgs(IRubyObject[] argsThreadContext contextString name) {
         IRubyObject[] newArgs = new IRubyObject[args.length + 1];
         System.arraycopy(args, 0, newArgs, 1, args.length);
         newArgs[0] = context.runtime.newSymbol(name);
 
         return newArgs;
     }
     
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameBlock block) {
         return self.getMetaClass().finvoke(contextselfnameblock);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0Block block) {
         return self.getMetaClass().finvoke(contextselfnamearg0block);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0IRubyObject arg1Block block) {
         return self.getMetaClass().finvoke(contextselfnamearg0arg1block);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0IRubyObject arg1IRubyObject arg2Block block) {
         return self.getMetaClass().finvoke(contextselfnamearg0arg1arg2block);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject[] argsBlock block) {
         return self.getMetaClass().finvoke(contextselfnameargsblock);
     }
     
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString name) {
         return self.getMetaClass().finvoke(contextselfname);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0) {
         return self.getMetaClass().finvoke(contextselfnamearg0);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0IRubyObject arg1) {
         return self.getMetaClass().finvoke(contextselfnamearg0arg1);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject arg0IRubyObject arg1IRubyObject arg2) {
         return self.getMetaClass().finvoke(contextselfnamearg0arg1arg2);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject... args) {
         return self.getMetaClass().finvoke(contextselfnameargs);
     }
     
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameCallType callType) {
         return RuntimeHelpers.invoke(contextselfname.callType.);
     }
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject[] argsCallType callTypeBlock block) {
         return self.getMetaClass().invoke(contextselfnameargscallTypeblock);
     }
     
     public static IRubyObject invoke(ThreadContext contextIRubyObject selfString nameIRubyObject argCallType callTypeBlock block) {
         return self.getMetaClass().invoke(contextselfnameargcallTypeblock);
     }
     
     public static IRubyObject invokeAs(ThreadContext contextRubyClass asClassIRubyObject selfString nameIRubyObject[] argsBlock block) {
         return asClass.finvoke(contextselfnameargsblock);
     }
     
     public static IRubyObject invokeAs(ThreadContext contextRubyClass asClassIRubyObject selfString nameBlock block) {
         return asClass.finvoke(contextselfnameblock);
     }
     
     public static IRubyObject invokeAs(ThreadContext contextRubyClass asClassIRubyObject selfString nameIRubyObject arg0Block block) {
         return asClass.finvoke(contextselfnamearg0block);
     }
     
     public static IRubyObject invokeAs(ThreadContext contextRubyClass asClassIRubyObject selfString nameIRubyObject arg0IRubyObject arg1Block block) {
         return asClass.finvoke(contextselfnamearg0arg1block);
     }
     
     public static IRubyObject invokeAs(ThreadContext contextRubyClass asClassIRubyObject selfString nameIRubyObject arg0IRubyObject arg1IRubyObject arg2Block block) {
         return asClass.finvoke(contextselfnamearg0arg1arg2block);
     }
 
     public static IRubyObject invokeChecked(ThreadContext contextIRubyObject selfString name) {
         return self.getMetaClass().finvokeChecked(contextselfname);
     }

    
The protocol for super method invocation is a bit complicated in Ruby. In real terms it involves first finding the real implementation class (the super class), getting the name of the method to call from the frame, and then invoke that on the super class with the current self as the actual object invoking.
 
     public static IRubyObject invokeSuper(ThreadContext contextIRubyObject selfIRubyObject[] argsBlock block) {
         checkSuperDisabledOrOutOfMethod(context);
         RubyModule klazz = context.getFrameKlazz();
         String name = context.getFrameName();
 
         RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
         DynamicMethod method = superClass != null ? superClass.searchMethod(name) : .;
         
         if (method.isUndefined()) {
             return callMethodMissing(contextselfmethod.getVisibility(), name.argsblock);
         }
         return method.call(contextselfsuperClassnameargsblock);
     }
     
     public static IRubyObject invokeSuper(ThreadContext contextIRubyObject selfBlock block) {
         checkSuperDisabledOrOutOfMethod(context);
         RubyModule klazz = context.getFrameKlazz();
         String name = context.getFrameName();
 
         RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
         DynamicMethod method = superClass != null ? superClass.searchMethod(name) : .;
 
         if (method.isUndefined()) {
             return callMethodMissing(contextselfmethod.getVisibility(), name.block);
         }
         return method.call(contextselfsuperClassnameblock);
     }
     
     public static IRubyObject invokeSuper(ThreadContext contextIRubyObject selfIRubyObject arg0Block block) {
         checkSuperDisabledOrOutOfMethod(context);
         RubyModule klazz = context.getFrameKlazz();
         String name = context.getFrameName();
 
         RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
         DynamicMethod method = superClass != null ? superClass.searchMethod(name) : .;
 
         if (method.isUndefined()) {
             return callMethodMissing(contextselfmethod.getVisibility(), name.arg0block);
         }
         return method.call(contextselfsuperClassnamearg0block);
     }
     
     public static IRubyObject invokeSuper(ThreadContext contextIRubyObject selfIRubyObject arg0IRubyObject arg1Block block) {
         checkSuperDisabledOrOutOfMethod(context);
         RubyModule klazz = context.getFrameKlazz();
         String name = context.getFrameName();
 
         RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
         DynamicMethod method = superClass != null ? superClass.searchMethod(name) : .;
 
         if (method.isUndefined()) {
             return callMethodMissing(contextselfmethod.getVisibility(), name.arg0arg1block);
         }
         return method.call(contextselfsuperClassnamearg0arg1block);
     }
     
     public static IRubyObject invokeSuper(ThreadContext contextIRubyObject selfIRubyObject arg0IRubyObject arg1IRubyObject arg2Block block) {
         checkSuperDisabledOrOutOfMethod(context);
         RubyModule klazz = context.getFrameKlazz();
         String name = context.getFrameName();
 
         RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
         DynamicMethod method = superClass != null ? superClass.searchMethod(name) : .;
 
         if (method.isUndefined()) {
             return callMethodMissing(contextselfmethod.getVisibility(), name.arg0arg1arg2block);
         }
         return method.call(contextselfsuperClassnamearg0arg1arg2block);
     }
 
     public static RubyArray ensureRubyArray(IRubyObject value) {
         return ensureRubyArray(value.getRuntime(), value);
     }
 
     public static RubyArray ensureRubyArray(Ruby runtimeIRubyObject value) {
         return value instanceof RubyArray ? (RubyArray)value : RubyArray.newArray(runtimevalue);
     }
 
     public static RubyArray ensureMultipleAssignableRubyArray(IRubyObject valueRuby runtimeboolean masgnHasHead) {
         if (!(value instanceof RubyArray)) {
             if (runtime.is1_9()) {
                 value = ArgsUtil.convertToRubyArray19(runtimevaluemasgnHasHead);
             } else {
                 value = ArgsUtil.convertToRubyArray(runtimevaluemasgnHasHead);                
             }
         }
         return (RubyArrayvalue;
     }
     
     public static IRubyObject fetchClassVariable(ThreadContext contextRuby runtime
             IRubyObject selfString name) {
         RubyModule rubyClass = ASTInterpreter.getClassVariableBase(contextruntime);
    
         if (rubyClass == nullrubyClass = self.getMetaClass();
 
         return rubyClass.getClassVar(name);
     }
     
     @Deprecated
     public static IRubyObject fastFetchClassVariable(ThreadContext contextRuby runtime
             IRubyObject selfString internedName) {
         return fetchClassVariable(contextruntimeselfinternedName);
     }
     
     public static IRubyObject getConstant(ThreadContext contextString internedName) {
         Ruby runtime = context.runtime;
 
         return context.getCurrentScope().getStaticScope().getConstantWithConstMissing(runtimeinternedNameruntime.getObject());
     }
 
     public static IRubyObject nullToNil(IRubyObject valueThreadContext context) {
         return value != null ? value : context.nil;
     }
     
     public static IRubyObject nullToNil(IRubyObject valueRuby runtime) {
         return value != null ? value : runtime.getNil();
     }
     
     public static IRubyObject nullToNil(IRubyObject valueIRubyObject nil) {
         return value != null ? value : nil;
     }
     
     public static RubyClass prepareSuperClass(Ruby runtimeIRubyObject rubyClass) {
         RubyClass.checkInheritable(rubyClass); // use the same logic as in EvaluationState
         return (RubyClass)rubyClass;
     }
     
     public static RubyModule prepareClassNamespace(ThreadContext contextIRubyObject rubyModule) {
         if (rubyModule == null || rubyModule.isNil()) {
             rubyModule = context.getCurrentScope().getStaticScope().getModule();
 
             if (rubyModule == null) {
                 throw context.runtime.newTypeError("no outer class/module");
             }
         }
 
         if (rubyModule instanceof RubyModule) {
             return (RubyModule)rubyModule;
         } else {
             throw context.runtime.newTypeError(rubyModule + " is not a class/module");
         }
     }
     
     public static IRubyObject setClassVariable(ThreadContext contextRuby runtime
             IRubyObject selfString nameIRubyObject value) {
         RubyModule rubyClass = ASTInterpreter.getClassVariableBase(contextruntime);
    
         if (rubyClass == nullrubyClass = self.getMetaClass();
 
         rubyClass.setClassVar(namevalue);
    
         return value;
     }
     
     @Deprecated
     public static IRubyObject fastSetClassVariable(ThreadContext contextRuby runtime
             IRubyObject selfString internedNameIRubyObject value) {
         return setClassVariable(contextruntimeselfinternedNamevalue);
     }
     
     public static IRubyObject declareClassVariable(ThreadContext contextRuby runtimeIRubyObject selfString nameIRubyObject value) {
         // FIXME: This isn't quite right; it shouldn't evaluate the value if it's going to throw the error
         RubyModule rubyClass = ASTInterpreter.getClassVariableBase(contextruntime);
    
         if (rubyClass == nullthrow runtime.newTypeError("no class/module to define class variable");
         
         rubyClass.setClassVar(namevalue);
    
         return value;
     }
     
     @Deprecated
     public static IRubyObject fastDeclareClassVariable(ThreadContext contextRuby runtimeIRubyObject selfString internedNameIRubyObject value) {
         return declareClassVariable(contextruntimeselfinternedNamevalue);
     }
     
     public static void handleArgumentSizes(ThreadContext contextRuby runtimeint givenint requiredint optint rest) {
         if (opt == 0) {
             if (rest < 0) {
                 // no opt, no rest, exact match
                 if (given != required) {
                     throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
                 }
             } else {
                 // only rest, must be at least required
                 if (given < required) {
                     throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
                 }
             }
         } else {
             if (rest < 0) {
                 // opt but no rest, must be at least required and no more than required + opt
                 if (given < required) {
                     throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
                 } else if (given > (required + opt)) {
                     throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + (required + opt) + ")");
                 }
             } else {
                 // opt and rest, must be at least required
                 if (given < required) {
                     throw runtime.newArgumentError("wrong number of arguments (" + given + " for " + required + ")");
                 }
             }
         }
     }
    
    
If it's Redo, Next, or Break, rethrow it as a normal exception for while to handle

Parameters:
re
context
 
     public static Throwable unwrapRedoNextBreakOrJustLocalJump(RaiseException reThreadContext context) {
         RubyException exception = re.getException();
         if (context.runtime.getLocalJumpError().isInstance(exception)) {
             RubyLocalJumpError jumpError = (RubyLocalJumpError)re.getException();
 
             switch (jumpError.getReason()) {
             case :
                 return .;
             case :
                 return new JumpException.NextJump(jumpError.exit_value());
             case :
                 return new JumpException.BreakJump(context.getFrameJumpTarget(), jumpError.exit_value());
             }
         }
         return re;
     }
     
     public static String getLocalJumpTypeOrRethrow(RaiseException re) {
         RubyException exception = re.getException();
         Ruby runtime = exception.getRuntime();
         if (runtime.getLocalJumpError().isInstance(exception)) {
             RubyLocalJumpError jumpError = (RubyLocalJumpError)re.getException();
 
             IRubyObject reason = jumpError.reason();
 
             return reason.asJavaString();
         }
 
         throw re;
     }
     
     public static IRubyObject unwrapLocalJumpErrorValue(RaiseException re) {
         return ((RubyLocalJumpError)re.getException()).exit_value();
     }
     
     public static IRubyObject processBlockArgument(Ruby runtimeBlock block) {
         if (!block.isGiven()) {
             return runt