Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/irb
File: frame.rb
# frozen_string_literal: false
[0] Fix | Delete
#
[1] Fix | Delete
# frame.rb -
[2] Fix | Delete
# $Release Version: 0.9$
[3] Fix | Delete
# $Revision$
[4] Fix | Delete
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
[5] Fix | Delete
#
[6] Fix | Delete
# --
[7] Fix | Delete
#
[8] Fix | Delete
#
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
module IRB
[12] Fix | Delete
class Frame
[13] Fix | Delete
class FrameOverflow < StandardError
[14] Fix | Delete
def initialize
[15] Fix | Delete
super("frame overflow")
[16] Fix | Delete
end
[17] Fix | Delete
end
[18] Fix | Delete
class FrameUnderflow < StandardError
[19] Fix | Delete
def initialize
[20] Fix | Delete
super("frame underflow")
[21] Fix | Delete
end
[22] Fix | Delete
end
[23] Fix | Delete
[24] Fix | Delete
# Default number of stack frames
[25] Fix | Delete
INIT_STACK_TIMES = 3
[26] Fix | Delete
# Default number of frames offset
[27] Fix | Delete
CALL_STACK_OFFSET = 3
[28] Fix | Delete
[29] Fix | Delete
# Creates a new stack frame
[30] Fix | Delete
def initialize
[31] Fix | Delete
@frames = [TOPLEVEL_BINDING] * INIT_STACK_TIMES
[32] Fix | Delete
end
[33] Fix | Delete
[34] Fix | Delete
# Used by Kernel#set_trace_func to register each event in the call stack
[35] Fix | Delete
def trace_func(event, file, line, id, binding)
[36] Fix | Delete
case event
[37] Fix | Delete
when 'call', 'class'
[38] Fix | Delete
@frames.push binding
[39] Fix | Delete
when 'return', 'end'
[40] Fix | Delete
@frames.pop
[41] Fix | Delete
end
[42] Fix | Delete
end
[43] Fix | Delete
[44] Fix | Delete
# Returns the +n+ number of frames on the call stack from the last frame
[45] Fix | Delete
# initialized.
[46] Fix | Delete
#
[47] Fix | Delete
# Raises FrameUnderflow if there are no frames in the given stack range.
[48] Fix | Delete
def top(n = 0)
[49] Fix | Delete
bind = @frames[-(n + CALL_STACK_OFFSET)]
[50] Fix | Delete
fail FrameUnderflow unless bind
[51] Fix | Delete
bind
[52] Fix | Delete
end
[53] Fix | Delete
[54] Fix | Delete
# Returns the +n+ number of frames on the call stack from the first frame
[55] Fix | Delete
# initialized.
[56] Fix | Delete
#
[57] Fix | Delete
# Raises FrameOverflow if there are no frames in the given stack range.
[58] Fix | Delete
def bottom(n = 0)
[59] Fix | Delete
bind = @frames[n]
[60] Fix | Delete
fail FrameOverflow unless bind
[61] Fix | Delete
bind
[62] Fix | Delete
end
[63] Fix | Delete
[64] Fix | Delete
# Convenience method for Frame#bottom
[65] Fix | Delete
def Frame.bottom(n = 0)
[66] Fix | Delete
@backtrace.bottom(n)
[67] Fix | Delete
end
[68] Fix | Delete
[69] Fix | Delete
# Convenience method for Frame#top
[70] Fix | Delete
def Frame.top(n = 0)
[71] Fix | Delete
@backtrace.top(n)
[72] Fix | Delete
end
[73] Fix | Delete
[74] Fix | Delete
# Returns the binding context of the caller from the last frame initialized
[75] Fix | Delete
def Frame.sender
[76] Fix | Delete
eval "self", @backtrace.top
[77] Fix | Delete
end
[78] Fix | Delete
[79] Fix | Delete
@backtrace = Frame.new
[80] Fix | Delete
set_trace_func proc{|event, file, line, id, binding, klass|
[81] Fix | Delete
@backtrace.trace_func(event, file, line, id, binding)
[82] Fix | Delete
}
[83] Fix | Delete
end
[84] Fix | Delete
end
[85] Fix | Delete
[86] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function