Default number of frames offset
Default number of stack frames
Convenience method for #bottom
# File irb/frame.rb, line 61
def Frame.bottom(n = 0)
@backtrace.bottom(n)
end
Creates a new stack frame
# File irb/frame.rb, line 26
def initialize
@frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
end
Returns the binding context of the caller from the last frame initialized
# File irb/frame.rb, line 71
def Frame.sender
eval "self", @backtrace.top
end
Convenience method for #top
# File irb/frame.rb, line 66
def Frame.top(n = 0)
@backtrace.top(n)
end
Returns the n number of frames on the call stack from the
first frame initialized.
Raises FrameOverflow if there are no frames in the given stack range.
# File irb/frame.rb, line 54
def bottom(n = 0)
bind = @frames[n]
Fail FrameOverflow unless bind
bind
end
Returns the n number of frames on the call stack from the last
frame initialized.
Raises FrameUnderflow if there are no frames in the given stack range.
# File irb/frame.rb, line 44
def top(n = 0)
bind = @frames[-(n + CALL_STACK_OFFSET)]
Fail FrameUnderflow unless bind
bind
end
Used by Kernel#set_trace_func to register each event in the call stack
# File irb/frame.rb, line 31
def trace_func(event, file, line, id, binding)
case event
when 'call', 'class'
@frames.push binding
when 'return', 'end'
@frames.pop
end
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.