@Override public Instr clone(CloneInfo ii) { return new ClassSuperInstr(ii.getScope(), ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), name, cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined(), getCallSite(), getCallSiteId()); }
@Override public void ClassSuperInstr(ClassSuperInstr classsuperinstr) { String name = classsuperinstr.getId(); Operand[] args = classsuperinstr.getCallArgs(); Operand definingModule = classsuperinstr.getDefiningModule(); boolean[] splatMap = classsuperinstr.splatMap(); Operand closure = classsuperinstr.getClosureArg(null); superCommon(name, classsuperinstr, args, definingModule, splatMap, closure); }
public Operand getDefiningModule() { return getReceiver(); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { IRubyObject[] args = prepareArguments(context, self, currScope, currDynScope, temp); Block block = prepareBlock(context, self, currScope, currDynScope, temp); RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.classSuper(context, self, getId(), definingModule, args, block); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new ClassSuperInstr(ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), (MethAddr)getMethodAddr().cloneForInlining(ii), cloneCallArgs(ii), closure == null ? null : closure.cloneForInlining(ii)); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp); Block block = prepareBlock(context, self, currDynScope, temp); String methodName = methAddr.getName(); RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp); RubyClass superClass = definingModule.getMetaClass().getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE; Object rVal = method.isUndefined() ? Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block) : method.call(context, self, superClass, methodName, args, block); return hasUnusedResult() ? null : rVal; }
public static ClassSuperInstr decode(IRReaderDecoder d) { if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super"); int callTypeOrdinal = d.decodeInt(); if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, calltype(ord): "+ callTypeOrdinal); RubySymbol name = d.decodeSymbol(); if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, methaddr: "+ name); Operand receiver = d.decodeOperand(); int argsCount = d.decodeInt(); boolean hasClosureArg = argsCount < 0; int argsLength = hasClosureArg ? (-1 * (argsCount + 1)) : argsCount; if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("ARGS: " + argsLength + ", CLOSURE: " + hasClosureArg); Operand[] args = new Operand[argsLength]; for (int i = 0; i < argsLength; i++) { args[i] = d.decodeOperand(); } Operand closure = hasClosureArg ? d.decodeOperand() : null; return new ClassSuperInstr(d.getCurrentScope(), d.decodeVariable(), receiver, name, args, closure, d.getCurrentScope().maybeUsingRefinements()); }
case CHECK_ARITY: return CheckArityInstr.decode(this); case CHECK_FOR_LJE: return CheckForLJEInstr.decode(this); case CLASS_SUPER: return ClassSuperInstr.decode(this); case CLASS_VAR_MODULE: return GetClassVarContainerModuleInstr.decode(this); case CONST_MISSING: return ConstMissingInstr.decode(this);
@Override public Instr cloneForInlining(InlinerInfo ii) { return new ClassSuperInstr(ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), (MethAddr)getMethodAddr().cloneForInlining(ii), cloneCallArgs(ii), closure == null ? null : closure.cloneForInlining(ii)); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp); Block block = prepareBlock(context, self, currDynScope, temp); String methodName = methAddr.getName(); RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp); RubyClass superClass = definingModule.getMetaClass().getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE; Object rVal = method.isUndefined() ? Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block) : method.call(context, self, superClass, methodName, args, block); return hasUnusedResult() ? null : rVal; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { IRubyObject[] args = prepareArguments(context, self, currScope, currDynScope, temp); Block block = prepareBlock(context, self, currScope, currDynScope, temp); RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.classSuper(context, self, getId(), definingModule, args, block); }
public static ClassSuperInstr decode(IRReaderDecoder d) { if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super"); int callTypeOrdinal = d.decodeInt(); if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, calltype(ord): "+ callTypeOrdinal); RubySymbol name = d.decodeSymbol(); if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, methaddr: "+ name); Operand receiver = d.decodeOperand(); int argsCount = d.decodeInt(); boolean hasClosureArg = argsCount < 0; int argsLength = hasClosureArg ? (-1 * (argsCount + 1)) : argsCount; if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("ARGS: " + argsLength + ", CLOSURE: " + hasClosureArg); Operand[] args = new Operand[argsLength]; for (int i = 0; i < argsLength; i++) { args[i] = d.decodeOperand(); } Operand closure = hasClosureArg ? d.decodeOperand() : null; return new ClassSuperInstr(d.getCurrentScope(), d.decodeVariable(), receiver, name, args, closure, d.getCurrentScope().maybeUsingRefinements()); }
case CHECK_ARITY: return CheckArityInstr.decode(this); case CHECK_FOR_LJE: return CheckForLJEInstr.decode(this); case CLASS_SUPER: return ClassSuperInstr.decode(this); case CLASS_VAR_MODULE: return GetClassVarContainerModuleInstr.decode(this); case CONST_MISSING: return ConstMissingInstr.decode(this);
@Override public Instr clone(CloneInfo ii) { return new ClassSuperInstr(ii.getScope(), ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), name, cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined(), getCallSite(), getCallSiteId()); }
@Override public void ClassSuperInstr(ClassSuperInstr classsuperinstr) { String name = classsuperinstr.getId(); Operand[] args = classsuperinstr.getCallArgs(); Operand definingModule = classsuperinstr.getDefiningModule(); boolean[] splatMap = classsuperinstr.splatMap(); Operand closure = classsuperinstr.getClosureArg(null); superCommon(name, classsuperinstr, args, definingModule, splatMap, closure); }
private Operand buildSuperInstr(Operand block, Operand[] args) { CallInstr superInstr; Variable ret = createTemporaryVariable(); if (scope instanceof IRMethod && scope.getLexicalParent() instanceof IRClassBody) { if (((IRMethod) scope).isInstanceMethod) { superInstr = new InstanceSuperInstr(scope, ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements()); } else { superInstr = new ClassSuperInstr(scope, ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements()); } } else { // We dont always know the method name we are going to be invoking if the super occurs in a closure. // This is because the super can be part of a block that will be used by 'define_method' to define // a new method. In that case, the method called by super will be determined by the 'name' argument // to 'define_method'. superInstr = new UnresolvedSuperInstr(scope, ret, buildSelf(), args, block, scope.maybeUsingRefinements()); } receiveBreakException(block, superInstr); return ret; }
public Operand getDefiningModule() { return getReceiver(); }
private Operand buildSuperInstr(Operand block, Operand[] args) { CallInstr superInstr; Variable ret = createTemporaryVariable(); if (scope instanceof IRMethod && scope.getLexicalParent() instanceof IRClassBody) { if (((IRMethod) scope).isInstanceMethod) { superInstr = new InstanceSuperInstr(scope, ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements()); } else { superInstr = new ClassSuperInstr(scope, ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements()); } } else { // We dont always know the method name we are going to be invoking if the super occurs in a closure. // This is because the super can be part of a block that will be used by 'define_method' to define // a new method. In that case, the method called by super will be determined by the 'name' argument // to 'define_method'. superInstr = new UnresolvedSuperInstr(scope, ret, buildSelf(), args, block, scope.maybeUsingRefinements()); } receiveBreakException(block, superInstr); return ret; }
public Operand getDefiningModule() { return getReceiver(); }
private Operand buildSuperInstr(IRScope s, Operand block, Operand[] args) { CallInstr superInstr; Variable ret = s.getNewTemporaryVariable(); if ((s instanceof IRMethod) && (s.getLexicalParent() instanceof IRClassBody)) { IRMethod m = (IRMethod)s; if (m.isInstanceMethod) { superInstr = new InstanceSuperInstr(ret, s.getCurrentModuleVariable(), new MethAddr(s.getName()), args, block); } else { superInstr = new ClassSuperInstr(ret, s.getCurrentModuleVariable(), new MethAddr(s.getName()), args, block); } } else { // We dont always know the method name we are going to be invoking if the super occurs in a closure. // This is because the super can be part of a block that will be used by 'define_method' to define // a new method. In that case, the method called by super will be determined by the 'name' argument // to 'define_method'. superInstr = new UnresolvedSuperInstr(ret, getSelf(s), args, block); } receiveBreakException(s, block, superInstr); return ret; }