@Override
 public Object call(ThreadContext context, IRubyObject self, IRubyObject receiver, Object[] temp) {
   IRubyObject value1 = (IRubyObject) arg1.retrieve(context, self, temp);
   IRubyObject value2 = (IRubyObject) arg2.retrieve(context, self, temp);
   IRubyObject value3 = (IRubyObject) arg3.retrieve(context, self, temp);
   IRubyObject value4 = (IRubyObject) arg4.retrieve(context, self, temp);
   return callSite.call(context, self, receiver, value1, value2, value3, value4);
 }
示例#2
0
 @Override
 public Object interpret(
     ThreadContext context,
     IRubyObject self,
     IRubyObject[] args,
     Block block,
     Object exception,
     Object[] temp) {
   result.store(context, self, temp, methodHandle.retrieve(context, self, temp));
   return null;
 }
示例#3
0
  @Override
  public Object interpret(
      ThreadContext context,
      IRubyObject self,
      IRubyObject[] args,
      Block block,
      Object exception,
      Object[] temp) {
    IRubyObject receiver = (IRubyObject) arg1.retrieve(context, self, temp);
    IRubyObject value = (IRubyObject) arg2.retrieve(context, self, temp);

    if (value == UndefinedValue.UNDEFINED) {
      result.store(context, self, temp, receiver);
    } else if (receiver instanceof RubyArray) {
      RubyArray testVals = (RubyArray) receiver;
      for (int i = 0, n = testVals.getLength(); i < n; i++) {
        IRubyObject excType = (IRubyObject) testVals.eltInternal(i);
        if (!(excType instanceof RubyModule)) {
          throw context
              .getRuntime()
              .newTypeError("class or module required for rescue clause. Found: " + excType);
        }
        IRubyObject eqqVal = excType.callMethod(context, "===", value);
        if (eqqVal.isTrue()) {
          result.store(context, self, temp, eqqVal);
          return null;
        }
      }
      result.store(context, self, temp, context.getRuntime().newBoolean(false));
    } else {
      if (!(receiver instanceof RubyModule)) {
        throw context
            .getRuntime()
            .newTypeError("class or module required for rescue clause. Found: " + receiver);
      }
      result.store(context, self, temp, receiver.callMethod(context, "===", value));
    }

    return null;
  }
示例#4
0
  @Override
  public Object interpret(
      ThreadContext context,
      DynamicScope currDynScope,
      IRubyObject self,
      Object[] temp,
      Block block) {
    Object receiver = array.retrieve(context, self, currDynScope, temp);

    // Don't call to_ary if we we have an array already and we are asked not to run to_ary on arrays
    if (dontToAryArrays.isTrue() && receiver instanceof RubyArray) {
      return receiver;
    } else {
      return RuntimeHelpers.aryToAry((IRubyObject) receiver);
    }
  }
示例#5
0
 @Override
 public Object interpret(
     ThreadContext context,
     IRubyObject self,
     IRubyObject[] args,
     Block block,
     Object exception,
     Object[] temp) {
   // ENEBO: This seems like a lot of extra work...
   result.store(
       context,
       self,
       temp,
       context
           .getRuntime()
           .newBoolean(((IRubyObject) value.retrieve(context, self, temp)).isTrue()));
   return null;
 }
 public boolean versionMatches(
     ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
   IRubyObject receiver = (IRubyObject) candidateObj.retrieve(context, self, currDynScope, temp);
   // if (module.getGeneration() != expectedVersion) ... replace this instr with a direct jump
   return (receiver.getMetaClass().getGeneration() == expectedVersion);
 }