Example #1
0
  protected Object interpretSuper(
      ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
    // SSS FIXME: We should check in the current module (for instance methods) or the current
    // module's meta class (for class methods)
    //
    // RubyModule currM = context.getCurrentScope().getStaticScope().getModule();
    // RubyModule klazz = (isInstanceMethodSuper) ? currM : currM.getMetaClass();
    //
    // The question is how do we know what this 'super' ought to do?
    // For 'super' that occurs in a method scope, this is easy to figure out.
    // But, what about 'super' that occurs in block scope?  How do we figure that out?
    RubyModule klazz = context.getFrameKlazz();

    // SSS FIXME: Even though we may know the method name in some instances,
    // we are not making use of it here.
    String methodName = context.getCurrentFrame().getName(); // methAddr.getName();

    checkSuperDisabledOrOutOfMethod(context, klazz, methodName);
    RubyClass superClass =
        RuntimeHelpers.findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
    DynamicMethod method =
        superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;

    Object rVal =
        method.isUndefined()
            ? RuntimeHelpers.callMethodMissing(
                context, self, method.getVisibility(), methodName, CallType.SUPER, args, block)
            : method.call(context, self, superClass, methodName, args, block);

    return hasUnusedResult() ? null : rVal;
  }
Example #2
0
  @Override
  public Object interpret(
      ThreadContext context,
      DynamicScope currDynScope,
      IRubyObject self,
      Object[] temp,
      Block aBlock) {
    // FIXME: Receiver is not being used...should we be retrieving it?
    IRubyObject receiver = (IRubyObject) getReceiver().retrieve(context, self, currDynScope, temp);
    IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp);
    Block block = prepareBlock(context, self, currDynScope, temp);
    RubyModule klazz = context.getFrameKlazz();
    // SSS FIXME: Even though we may know the method name in some instances,
    // we are not making use of it here.  It is cleaner in the sense of not
    // relying on implicit information whose data flow doesn't show up in the IR.
    String methodName = context.getCurrentFrame().getName(); // methAddr.getName();

    checkSuperDisabledOrOutOfMethod(context, klazz, methodName);
    RubyClass superClass =
        RuntimeHelpers.findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass();
    DynamicMethod method =
        superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;

    Object rVal =
        method.isUndefined()
            ? RuntimeHelpers.callMethodMissing(
                context, self, method.getVisibility(), methodName, CallType.SUPER, args, block)
            : method.call(context, self, superClass, methodName, args, block);

    return hasUnusedResult() ? null : rVal;
  }