public InterpretedIRBlockBody(IRClosure closure, Arity arity, int argumentType) { super(closure.getStaticScope(), arity, argumentType); this.closure = closure; }
public InterpretedIRBlockBody(IRClosure closure, Arity arity, int argumentType) { super(closure.getStaticScope(), arity, argumentType); this.closure = closure; }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { BlockBody body = closure.getBlockBody(); closure.getStaticScope().determineModule(); Binding binding = context.currentBinding(self, currDynScope); return new Block(body, binding); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { BlockBody body = closure.getBlockBody(); closure.getStaticScope().determineModule(); Binding binding = context.currentBinding(self, currDynScope); return new Block(body, binding); }
public IRMethod convertToMethod(RubySymbol name) { // We want variable scoping to be the same as a method and not see outside itself. if (source == null || getFlags().contains(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES) || // Built methods cannot search down past method scope getFlags().contains(IRFlags.RECEIVES_CLOSURE_ARG) || // we pass in captured block at define_method as block so explicits ones not supported !isNestedClosuresSafeForMethodConversion()) { source = null; return null; } DefNode def = source; source = null; // FIXME: This should be bytelist from param vs being made (see above). return new IRMethod(getManager(), getLexicalParent(), def, name, true, getLine(), getStaticScope(), getFlags().contains(IRFlags.CODE_COVERAGE)); }
public IRMethod convertToMethod(RubySymbol name) { // We want variable scoping to be the same as a method and not see outside itself. if (source == null || getFlags().contains(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES) || // Built methods cannot search down past method scope getFlags().contains(IRFlags.RECEIVES_CLOSURE_ARG) || // we pass in captured block at define_method as block so explicits ones not supported !isNestedClosuresSafeForMethodConversion()) { source = null; return null; } DefNode def = source; source = null; // FIXME: This should be bytelist from param vs being made (see above). return new IRMethod(getManager(), getLexicalParent(), def, name, true, getLine(), getStaticScope(), getFlags().contains(IRFlags.CODE_COVERAGE)); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { BlockBody body = closure.getBlockBody(); closure.getStaticScope().determineModule(); // In non-inlining scenarios, this.self will always be %self. // However, in inlined scenarios, this.self will be the self in the original scope where the closure // was present before inlining. IRubyObject selfVal = (this.self instanceof Self) ? self : (IRubyObject)this.self.retrieve(context, self, currScope, currDynScope, temp); Binding binding = context.currentBinding(selfVal, currDynScope); return new Block(body, binding); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { BlockBody body = closure.getBlockBody(); closure.getStaticScope().determineModule(); // In non-inlining scenarios, this.self will always be %self. // However, in inlined scenarios, this.self will be the self in the original scope where the closure // was present before inlining. IRubyObject selfVal = (this.self instanceof Self) ? self : (IRubyObject)this.self.retrieve(context, self, currScope, currDynScope, temp); Binding binding = context.currentBinding(selfVal, currDynScope); return new Block(body, binding); }
public LocalVariable getNewLocalVariable(RubySymbol name, int depth) { if (depth == 0 && !(this instanceof IRFor)) { LocalVariable lvar = new ClosureLocalVariable(name, 0, getStaticScope().addVariableThisScope(name.idString())); localVars.put(name, lvar); return lvar; } else { // IRFor does not have it's own state if (!(this instanceof IRFor)) flags.add(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES); IRScope s = this; int d = depth; do { // account for for-loops while (s instanceof IRFor) { depth++; s = s.getLexicalParent(); } // walk up d--; if (d >= 0) s = s.getLexicalParent(); } while (d >= 0); return s.getNewLocalVariable(name, 0).cloneForDepth(depth); } }
public LocalVariable getNewLocalVariable(RubySymbol name, int depth) { if (depth == 0 && !(this instanceof IRFor)) { LocalVariable lvar = new ClosureLocalVariable(name, 0, getStaticScope().addVariableThisScope(name.idString())); localVars.put(name, lvar); return lvar; } else { // IRFor does not have it's own state if (!(this instanceof IRFor)) flags.add(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES); IRScope s = this; int d = depth; do { // account for for-loops while (s instanceof IRFor) { depth++; s = s.getLexicalParent(); } // walk up d--; if (d >= 0) s = s.getLexicalParent(); } while (d >= 0); return s.getNewLocalVariable(name, 0).cloneForDepth(depth); } }
public InterpreterContext ensureInstrsReady() { if (IRRuntimeHelpers.isDebug() && !displayedCFG) { LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope); LOG.info(closure.debugOutput()); displayedCFG = true; } if (interpreterContext == null) { if (IRRuntimeHelpers.shouldPrintIR(closure.getStaticScope().getModule().getRuntime())) { ByteArrayOutputStream baos = IRDumper.printIR(closure, false); LOG.info("Printing simple IR for " + closure.getId() + ":\n" + new String(baos.toByteArray())); } interpreterContext = closure.getInterpreterContext(); } return interpreterContext; }
public InterpreterContext ensureInstrsReady() { if (IRRuntimeHelpers.isDebug() && !displayedCFG) { LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope); LOG.info(closure.debugOutput()); displayedCFG = true; } if (interpreterContext == null) { if (IRRuntimeHelpers.shouldPrintIR(closure.getStaticScope().getModule().getRuntime())) { ByteArrayOutputStream baos = IRDumper.printIR(closure, false); LOG.info("Printing simple IR for " + closure.getId() + ":\n" + new String(baos.toByteArray())); } interpreterContext = closure.getInterpreterContext(); fullInterpreterContext = interpreterContext; } return interpreterContext; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { // SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well? // // JRUBY-5686: do this before executing so first time sets cref module getLambdaBody().getStaticScope().determineModule(); IRClosure body = getLambdaBody(); // ENEBO: Now can live nil be passed as block reference? return RubyProc.newProc(context.runtime, (Block) (body == null ? context.runtime.getIRManager().getNil() : operands[0]).retrieve(context, self, currDynScope, temp), Block.Type.LAMBDA, position); }
public InterpreterContext ensureInstrsReady() { if (IRRuntimeHelpers.isDebug() && !displayedCFG) { LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope); LOG.info(closure.debugOutput()); displayedCFG = true; } if (interpreterContext == null) { if (IRRuntimeHelpers.shouldPrintIR(closure.getStaticScope().getModule().getRuntime())) { ByteArrayOutputStream baos = IRDumper.printIR(closure, false); LOG.info("Printing simple IR for " + closure.getId() + ":\n" + new String(baos.toByteArray())); } interpreterContext = closure.getInterpreterContext(); } return interpreterContext; }
public InterpreterContext ensureInstrsReady() { if (IRRuntimeHelpers.isDebug() && !displayedCFG) { LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope); LOG.info(closure.debugOutput()); displayedCFG = true; } if (interpreterContext == null) { if (IRRuntimeHelpers.shouldPrintIR(closure.getStaticScope().getModule().getRuntime())) { ByteArrayOutputStream baos = IRDumper.printIR(closure, false); LOG.info("Printing simple IR for " + closure.getId() + ":\n" + new String(baos.toByteArray())); } interpreterContext = closure.getInterpreterContext(); fullInterpreterContext = interpreterContext; } return interpreterContext; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) { // SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well? // // JRUBY-5686: do this before executing so first time sets cref module getLambdaBody().getStaticScope().determineModule(); IRClosure body = getLambdaBody(); // ENEBO: Now can live nil be passed as block reference? return RubyProc.newProc(context.runtime, (Block) (body == null ? context.runtime.getIRManager().getNil() : operands[0]).retrieve(context, self, currDynScope, temp), Block.Type.LAMBDA, position); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well? // // JRUBY-5686: do this before executing so first time sets cref module ((WrappedIRClosure) getLambdaBody()).getClosure().getStaticScope().determineModule(); // CON: This must not be happening, because nil would never cast to Block // IRClosure body = getLambdaBody().getClosure(); // Block block = (Block) (body == null ? context.runtime.getIRManager().getNil() : getLambdaBody()).retrieve(context, self, currScope, currDynScope, temp); Block block = (Block)getLambdaBody().retrieve(context, self, currScope, currDynScope, temp); // ENEBO: Now can live nil be passed as block reference? // SSS FIXME: Should we do the same %self retrieval as in the case of WrappedIRClosure? Or are lambdas special?? return RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA, getFile(), getLine()); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well? // // JRUBY-5686: do this before executing so first time sets cref module ((WrappedIRClosure) getLambdaBody()).getClosure().getStaticScope().determineModule(); // CON: This must not be happening, because nil would never cast to Block // IRClosure body = getLambdaBody().getClosure(); // Block block = (Block) (body == null ? context.runtime.getIRManager().getNil() : getLambdaBody()).retrieve(context, self, currScope, currDynScope, temp); Block block = (Block)getLambdaBody().retrieve(context, self, currScope, currDynScope, temp); // ENEBO: Now can live nil be passed as block reference? // SSS FIXME: Should we do the same %self retrieval as in the case of WrappedIRClosure? Or are lambdas special?? return RubyProc.newProc(context.runtime, block, Block.Type.LAMBDA, getFile(), getLine()); }