Class: Trepan::Frame
- Inherits:
-
Object
- Object
- Trepan::Frame
- Defined in:
- app/frame.rb
Overview
Call-Stack frame methods
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#vm_location ⇒ Object
readonly
Returns the value of attribute vm_location.
Instance Method Summary collapse
- #binding ⇒ Object
- #describe(opts = {}) ⇒ Object
- #eval? ⇒ Boolean
- #eval_string ⇒ Object
- #file ⇒ Object
-
#initialize(dbgr, number, vm_location) ⇒ Frame
constructor
A new instance of Frame.
- #ip ⇒ Object
- #line ⇒ Object
- #local_variables ⇒ Object
- #method ⇒ Object
- #next_ip ⇒ Object
- #run(code, filename = nil) ⇒ Object
- #scope ⇒ Object
- #stack_size ⇒ Object
Constructor Details
#initialize(dbgr, number, vm_location) ⇒ Frame
Returns a new instance of Frame.
6 7 8 9 10 |
# File 'app/frame.rb', line 6 def initialize(dbgr, number, vm_location) @debugger = dbgr @number = number @vm_location = vm_location end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
12 13 14 |
# File 'app/frame.rb', line 12 def number @number end |
#vm_location ⇒ Object (readonly)
Returns the value of attribute vm_location.
12 13 14 |
# File 'app/frame.rb', line 12 def vm_location @vm_location end |
Instance Method Details
#binding ⇒ Object
18 19 20 21 22 |
# File 'app/frame.rb', line 18 def binding @binding ||= Binding.setup(@vm_location.variables, @vm_location.method, @vm_location.static_scope) end |
#describe(opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/frame.rb', line 24 def describe(opts = {}) if method.required_args > 0 locals = [] 0.upto(method.required_args-1) do |arg| locals << method.local_names[arg].to_s end arg_str = locals.join(", ") else arg_str = "" end loc = @vm_location if loc.is_block if arg_str.empty? recv = "{ } in #{loc.describe_receiver}#{loc.name}" else recv = "{|#{arg_str}| } in #{loc.describe_receiver}#{loc.name}" end else if arg_str.empty? recv = loc.describe else recv = "#{loc.describe}(#{arg_str})" end end filename = loc.method.active_path filename = File.basename(filename) if opts[:basename] str = "#{recv} at #{filename}:#{loc.line}" if opts[:show_ip] str << " (@#{loc.ip})" end str end |
#eval? ⇒ Boolean
95 96 97 98 |
# File 'app/frame.rb', line 95 def eval? static = @vm_location.static_scope static && static.script && static.script.eval_source end |
#eval_string ⇒ Object
100 101 102 103 104 |
# File 'app/frame.rb', line 100 def eval_string return nil unless eval? static = @vm_location.static_scope static.script.eval_source end |
#file ⇒ Object
62 63 64 |
# File 'app/frame.rb', line 62 def file @vm_location.file end |
#ip ⇒ Object
66 67 68 |
# File 'app/frame.rb', line 66 def ip @vm_location.ip end |
#line ⇒ Object
74 75 76 77 |
# File 'app/frame.rb', line 74 def line line_no = @vm_location.line line_no == 0 ? ISeq::tail_code_line(method, next_ip) : line_no end |
#local_variables ⇒ Object
79 80 81 |
# File 'app/frame.rb', line 79 def local_variables method.local_names end |
#method ⇒ Object
83 84 85 |
# File 'app/frame.rb', line 83 def method @vm_location.method end |
#next_ip ⇒ Object
70 71 72 |
# File 'app/frame.rb', line 70 def next_ip @vm_location.next_ip end |
#run(code, filename = nil) ⇒ Object
14 15 16 |
# File 'app/frame.rb', line 14 def run(code, filename=nil) eval(code, self.binding, filename) end |
#scope ⇒ Object
87 88 89 |
# File 'app/frame.rb', line 87 def scope @vm_location.variables end |
#stack_size ⇒ Object
91 92 93 |
# File 'app/frame.rb', line 91 def stack_size @debugger.vm_locations.size end |