private static IRScope getEvalContainerScope(Ruby runtime, StaticScope evalScope) { // SSS FIXME: Weirdness here. We cannot get the containing IR scope from evalScope because of static-scope wrapping // that is going on // 1. In all cases, DynamicScope.getEvalScope wraps the executing static scope in a new local scope. // 2. For instance-eval (module-eval, class-eval) scenarios, there is an extra scope that is added to // the stack in ThreadContext.java:preExecuteUnder // I dont know what rule to apply when. However, in both these cases, since there is no IR-scope associated, // I have used the hack below where I first unwrap once and see if I get a non-null IR scope. If that doesn't // work, I unwarp once more and I am guaranteed to get the IR scope I want. IRScope containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope()).getIRScope(); if (containingIRScope == null) containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope().getEnclosingScope()).getIRScope(); return containingIRScope; }
private static IRScope getEvalContainerScope(Ruby runtime, StaticScope evalScope) { // SSS FIXME: Weirdness here. We cannot get the containing IR scope from evalScope because of static-scope wrapping // that is going on // 1. In all cases, DynamicScope.getEvalScope wraps the executing static scope in a new local scope. // 2. For instance-eval (module-eval, class-eval) scenarios, there is an extra scope that is added to // the stack in ThreadContext.java:preExecuteUnder // I dont know what rule to apply when. However, in both these cases, since there is no IR-scope associated, // I have used the hack below where I first unwrap once and see if I get a non-null IR scope. If that doesn't // work, I unwarp once more and I am guaranteed to get the IR scope I want. IRScope containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope()).getIRScope(); if (containingIRScope == null) containingIRScope = ((IRStaticScope)evalScope.getEnclosingScope().getEnclosingScope()).getIRScope(); return containingIRScope; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { DynamicScope argsDynScope = currDynScope; // Find args that need to be passed into super while (!argsDynScope.getStaticScope().isArgumentScope()) argsDynScope = argsDynScope.getNextCapturedScope(); IRScope argsIRScope = ((IRStaticScope)argsDynScope.getStaticScope()).getIRScope(); Operand[] superArgs = (argsIRScope instanceof IRMethod) ? ((IRMethod)argsIRScope).getCallArgs() : ((IRClosure)argsIRScope).getBlockArgs(); // Prepare args -- but look up in 'argsDynScope', not 'currDynScope' IRubyObject[] args = prepareArguments(context, self, superArgs, argsDynScope, temp); // Prepare block -- fetching from the frame stack, if necessary Block block = prepareBlock(context, self, currDynScope, temp); if (block == null || !block.isGiven()) block = context.getFrameBlock(); return interpretSuper(context, self, args, block); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { DynamicScope argsDynScope = currDynScope; // Find args that need to be passed into super while (!argsDynScope.getStaticScope().isArgumentScope()) argsDynScope = argsDynScope.getNextCapturedScope(); IRScope argsIRScope = ((IRStaticScope)argsDynScope.getStaticScope()).getIRScope(); Operand[] superArgs = (argsIRScope instanceof IRMethod) ? ((IRMethod)argsIRScope).getCallArgs() : ((IRClosure)argsIRScope).getBlockArgs(); // Prepare args -- but look up in 'argsDynScope', not 'currDynScope' IRubyObject[] args = prepareArguments(context, self, superArgs, argsDynScope, temp); // Prepare block -- fetching from the frame stack, if necessary Block block = prepareBlock(context, self, currDynScope, temp); if (block == null || !block.isGiven()) block = context.getFrameBlock(); return interpretSuper(context, self, args, block); }