Class: IRB::Frame

Inherits:
Object show all
Extended by:
Exception2MessageMapper
Defined in:
lib/irb/frame.rb

Constant Summary collapse

INIT_STACK_TIMES =
3
CALL_STACK_OFFSET =
3

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFrame

Returns a new instance of Frame.



24
25
26
# File 'lib/irb/frame.rb', line 24

def initialize
  @frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
end

Class Method Details

.bottom(n = 0) ⇒ Object

singleton functions



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

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

.senderObject



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

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

.top(n = 0) ⇒ Object



54
55
56
# File 'lib/irb/frame.rb', line 54

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

Instance Method Details

#bottom(n = 0) ⇒ Object



43
44
45
46
47
# File 'lib/irb/frame.rb', line 43

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

#top(n = 0) ⇒ Object



37
38
39
40
41
# File 'lib/irb/frame.rb', line 37

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

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



28
29
30
31
32
33
34
35
# File 'lib/irb/frame.rb', line 28

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