private void fixReturn(IRScope scope, ReturnBase i, ListIterator<Instr> instrs) { Operand retVal = i.getReturnValue(); if (!(retVal instanceof ImmutableLiteral || retVal instanceof TemporaryVariable)) { TemporaryVariable tmp = scope.createTemporaryVariable(); CopyInstr copy = new CopyInstr(tmp, retVal); i.updateReturnValue(tmp); instrs.previous(); instrs.add(copy); instrs.next(); } }
private void fixReturn(IRScope scope, ReturnBase i, ListIterator<Instr> instrs) { Operand retVal = i.getReturnValue(); if (!(retVal instanceof ImmutableLiteral || retVal instanceof TemporaryVariable)) { TemporaryVariable tmp = scope.createTemporaryVariable(); CopyInstr copy = new CopyInstr(tmp, retVal); i.updateReturnValue(tmp); instrs.previous(); instrs.add(copy); instrs.next(); } }
protected static IRubyObject processReturnOp(ThreadContext context, Block block, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, IRubyObject self, StaticScope currScope) { switch(operation) { // --------- Return flavored instructions -------- case RETURN: { return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, currScope, temp); } case BREAK: { BreakInstr bi = (BreakInstr)instr; IRubyObject rv = (IRubyObject)bi.getReturnValue().retrieve(context, self, currScope, currDynScope, temp); // This also handles breaks in lambdas -- by converting them to a return // // This assumes that scopes with break instr. have a frame / dynamic scope // pushed so that we can get to its static scope. For-loops now always have // a dyn-scope pushed onto stack which makes this work in all scenarios. return IRRuntimeHelpers.initiateBreak(context, currDynScope, rv, block); } case NONLOCAL_RETURN: { NonlocalReturnInstr ri = (NonlocalReturnInstr)instr; IRubyObject rv = (IRubyObject)retrieveOp(ri.getReturnValue(), context, self, currDynScope, currScope, temp); return IRRuntimeHelpers.initiateNonLocalReturn(context, currDynScope, block, rv); } case RETURN_OR_RETHROW_SAVED_EXC: { IRubyObject retVal = (IRubyObject) retrieveOp(((ReturnBase) instr).getReturnValue(), context, self, currDynScope, currScope, temp); return IRRuntimeHelpers.returnOrRethrowSavedException(context, retVal); } } return null; }
protected static IRubyObject processReturnOp(ThreadContext context, Block block, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, IRubyObject self, StaticScope currScope) { switch(operation) { // --------- Return flavored instructions -------- case RETURN: { return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, currScope, temp); } case BREAK: { BreakInstr bi = (BreakInstr)instr; IRubyObject rv = (IRubyObject)bi.getReturnValue().retrieve(context, self, currScope, currDynScope, temp); // This also handles breaks in lambdas -- by converting them to a return // // This assumes that scopes with break instr. have a frame / dynamic scope // pushed so that we can get to its static scope. For-loops now always have // a dyn-scope pushed onto stack which makes this work in all scenarios. return IRRuntimeHelpers.initiateBreak(context, currDynScope, rv, block); } case NONLOCAL_RETURN: { NonlocalReturnInstr ri = (NonlocalReturnInstr)instr; IRubyObject rv = (IRubyObject)retrieveOp(ri.getReturnValue(), context, self, currDynScope, currScope, temp); return IRRuntimeHelpers.initiateNonLocalReturn(context, currDynScope, block, rv); } case RETURN_OR_RETHROW_SAVED_EXC: { IRubyObject retVal = (IRubyObject) retrieveOp(((ReturnBase) instr).getReturnValue(), context, self, currDynScope, currScope, temp); return IRRuntimeHelpers.returnOrRethrowSavedException(context, retVal); } } return null; }
return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, temp);
return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, temp);