Module: Debugger::FrameFunctions

Included in:
DownCommand, FrameCommand, UpCommand
Defined in:
lib/ruby-debug-ide/commands/frame.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#adjust_frame(frame_pos, absolute) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby-debug-ide/commands/frame.rb', line 5

def adjust_frame(frame_pos, absolute)
  if absolute
    if frame_pos < 0
      abs_frame_pos = @state.context.stack_size + frame_pos
    else
      abs_frame_pos = frame_pos - 1
    end
  else
    abs_frame_pos = @state.frame_pos + frame_pos
  end

  if abs_frame_pos >= @state.context.stack_size then
    print_error "Adjusting would put us beyond the oldest (initial) frame.\n"
    return
  elsif abs_frame_pos < 0 then
    print_error "Adjusting would put us beyond the newest (innermost) frame.\n"
    return
  end
  if @state.frame_pos != abs_frame_pos then
    @state.previous_line = nil
    @state.frame_pos = abs_frame_pos
  end
  @state.file = @state.context.frame_file(@state.frame_pos)
  @state.line = @state.context.frame_line(@state.frame_pos)
  
  print_current_frame(@state.frame_pos)
end