public void popFrame() { Frame[] stack = frameStack; int index = frameIndex--; Frame frame = stack[index]; // if the frame was captured, we must replace it but not clear if (frame.isCaptured()) { stack[index] = new Frame(); } else { frame.clear(); } }
public static Binding frameScopeBinding(ThreadContext context, IRubyObject self, DynamicScope scope) { Frame frame = context.getCurrentFrame().capture(); return new Binding(self, frame, frame.getVisibility(), scope); }
/** * Get the value of the $~ (backref) "global". * * @return the value of $~ */ public IRubyObject getBackRef() { return frameStack[frameIndex].getBackRef(nil); }
public Binding(Frame frame, DynamicScope dynamicScope, String method, String filename, int line) { assert frame != null; this.self = frame.getSelf(); this.frame = frame; this.visibility = frame.getVisibility(); this.dynamicScope = dynamicScope; this.method = method; this.filename = filename; this.line = line; }
private void popBackrefFrame() { Frame[] stack = frameStack; int index = frameIndex--; Frame frame = stack[index]; // if the frame was captured, we must replace it but not clear if (frame.isCaptured()) { stack[index] = new Frame(); } else { frame.clearFrameForBackref(); } }
public void preExecuteUnder(RubyModule executeUnderClass, Block block) { Frame frame = getCurrentFrame(); pushRubyClass(executeUnderClass); DynamicScope scope = getCurrentScope(); StaticScope sScope = runtime.getStaticScopeFactory().newBlockScope(scope.getStaticScope()); sScope.setModule(executeUnderClass); pushScope(DynamicScope.newDynamicScope(sScope, scope)); pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block); getCurrentFrame().setVisibility(getPreviousFrame().getVisibility()); }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return context.getCurrentFrame().getBlock().yieldSpecific(context); } }
/** * Clone this frame. * * @return A new frame with duplicate information to the target frame */ public Frame duplicate() { return new Frame(this); }
/** * Return a binding representing the current call's state * @return the current binding */ public Binding currentBinding() { Frame frame = getCurrentFrame().capture(); return new Binding(frame, parentIndex < 0 ? frame.getKlazz() : getRubyClass(), getCurrentScope(), backtrace[backtraceIndex].clone()); }
public Block cloneBlockAndFrame() { Binding oldBinding = binding; Binding binding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getKlass(), oldBinding.getDynamicScope(), oldBinding.getBacktrace()); Block newBlock = new Block(body, binding); newBlock.type = type; newBlock.escapeBlock = this; return newBlock; }
public String getFrameName() { return getCurrentFrame().getName(); }
public IRubyObject getFrameSelf() { return getCurrentFrame().getSelf(); }
public RubyModule getFrameKlazz() { return getCurrentFrame().getKlazz(); }
/** * Return a binding representing the current call's state but with the * specified visibility and self. * @param self the self object to use * @param visibility the visibility to use * @return the current binding using the specified self and visibility */ public Binding currentBinding(IRubyObject self, Visibility visibility) { Frame frame = getCurrentFrame().capture(); return new Binding(self, frame, visibility, getRubyClass(), getCurrentScope(), backtrace[backtraceIndex].clone()); }
/** * Get the value of the $_ (lastline) "global". * * @return the value of $_ */ public IRubyObject getLastLine() { return getCurrentFrame().getLastLine(nil); }
public void preExecuteUnder(RubyModule executeUnderClass, Block block) { Frame frame = getCurrentFrame(); pushRubyClass(executeUnderClass); DynamicScope scope = getCurrentScope(); StaticScope sScope = runtime.getStaticScopeFactory().newBlockScope(scope.getStaticScope()); sScope.setModule(executeUnderClass); pushScope(DynamicScope.newDynamicScope(sScope, scope)); pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block); getCurrentFrame().setVisibility(getPreviousFrame().getVisibility()); }
public Binding(Frame frame, DynamicScope dynamicScope, String method, String filename, int line) { assert frame != null; this.self = frame.getSelf(); this.frame = frame; this.visibility = frame.getVisibility(); this.dynamicScope = dynamicScope; this.method = method; this.filename = filename; this.line = line; }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return context.getCurrentFrame().getBlock().yieldSpecific(context); } }