class IRB::Frame

def bottom(n = 0)

Raises FrameOverflow if there are no frames in the given stack range.

initialized.
Returns the +n+ number of frames on the call stack from the first frame
def bottom(n = 0)
  bind = @frames[n]
  fail FrameOverflow unless bind
  bind
end

def initialize

Creates a new stack frame
def initialize
  @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
end

def top(n = 0)

Raises FrameUnderflow if there are no frames in the given stack range.

initialized.
Returns the +n+ number of frames on the call stack from the last frame
def top(n = 0)
  bind = @frames[-(n + CALL_STACK_OFFSET)]
  fail FrameUnderflow unless bind
  bind
end

def trace_func(event, file, line, id, binding)

Used by Kernel#set_trace_func to register each event in the call stack
def trace_func(event, file, line, id, binding)
  case event
  when 'call', 'class'
    @frames.push binding
  when 'return', 'end'
    @frames.pop
  end
end