module Byebug::Helpers::FrameHelper
Utilities to assist frame navigation
Public Instance Methods
jump_frames(steps)
click to toggle source
# File lib/byebug/helpers/frame.rb, line 14 def jump_frames(steps) adjust_frame(navigate_to_frame(steps)) end
switch_to_frame(frame)
click to toggle source
# File lib/byebug/helpers/frame.rb, line 7 def switch_to_frame(frame) new_frame = index_from_start(frame) return frame_err('c_frame') if Frame.new(context, new_frame).c_frame? adjust_frame(new_frame) end
Private Instance Methods
adjust_frame(new_frame)
click to toggle source
# File lib/byebug/helpers/frame.rb, line 20 def adjust_frame(new_frame) return frame_err('too_low') if new_frame >= context.stack_size return frame_err('too_high') if new_frame < 0 context.frame = new_frame processor.prev_line = nil end
direction(step)
click to toggle source
@param step [Integer] A positive or negative integer
@return [Integer] +1 if step is positive / -1 if negative
# File lib/byebug/helpers/frame.rb, line 58 def direction(step) step / step.abs end
frame_err(msg)
click to toggle source
# File lib/byebug/helpers/frame.rb, line 49 def frame_err(msg) errmsg(pr("frame.errors.#{msg}")) end
index_from_start(i)
click to toggle source
Convert a possibly negative index to a positive index from the start of the callstack. -1 is the last position in the stack and so on.
@param i [Integer] Integer to be converted in a proper positive index.
# File lib/byebug/helpers/frame.rb, line 68 def index_from_start(i) i >= 0 ? i : context.stack_size + i end
out_of_bounds?(pos)
click to toggle source
# File lib/byebug/helpers/frame.rb, line 45 def out_of_bounds?(pos) !(0...context.stack_size).cover?(pos) end