123456789_123456789_123456789_123456789_123456789_

Class: IRB::Frame

Relationships & Source Files
Namespace Children
Exceptions:
Inherits: Object
Defined in: lib/irb/frame.rb

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.newFrame

Creates a new stack frame

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 32

def initialize
  @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
end

Class Method Details

.bottom(n = 0)

Convenience method for #bottom

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 67

def Frame.bottom(n = 0)
  @backtrace.bottom(n)
end

.sender

Returns the binding context of the caller from the last frame initialized

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 77

def Frame.sender
  eval "self", @backtrace.top
end

.top(n = 0)

Convenience method for #top

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 72

def Frame.top(n = 0)
  @backtrace.top(n)
end

Instance Method Details

#bottom(n = 0)

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.

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 60

def bottom(n = 0)
  bind = @frames[n]
  fail FrameOverflow unless bind
  bind
end

#top(n = 0)

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.

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 50

def top(n = 0)
  bind = @frames[-(n + CALL_STACK_OFFSET)]
  fail FrameUnderflow unless bind
  bind
end

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

Used by Kernel.set_trace_func to register each event in the call stack

[ GitHub ]

  
# File 'lib/irb/frame.rb', line 37

def trace_func(event, file, line, id, binding)
  case event
  when 'call', 'class'
    @frames.push binding
  when 'return', 'end'
    @frames.pop
  end
end