Class: MrbParser::DebugInfo
- Inherits:
-
Object
- Object
- MrbParser::DebugInfo
- Defined in:
- lib/mrb_parser/debug_info.rb
Constant Summary collapse
- MRB_DEBUG_LINE_ARY =
0
- MRB_DEBUG_LINE_FLAT_MAP =
1
- LINE_TYPE =
["ARY", "FLAT_MAP"]
Instance Attribute Summary collapse
-
#debug_section ⇒ Object
Returns the value of attribute debug_section.
-
#files ⇒ Object
Returns the value of attribute files.
-
#infos ⇒ Object
readonly
Returns the value of attribute infos.
-
#irep_record ⇒ Object
Returns the value of attribute irep_record.
-
#pc_count ⇒ Object
Returns the value of attribute pc_count.
Instance Method Summary collapse
- #dump(n = 2) ⇒ Object
-
#initialize(debug_section, irep_record) ⇒ DebugInfo
constructor
A new instance of DebugInfo.
- #parse_record(parser) ⇒ Object
- #printf_indent(n, *args) ⇒ Object
Constructor Details
#initialize(debug_section, irep_record) ⇒ DebugInfo
Returns a new instance of DebugInfo.
15 16 17 18 19 20 |
# File 'lib/mrb_parser/debug_info.rb', line 15 def initialize(debug_section, irep_record) @debug_section = debug_section @irep_record = irep_record irep_record.debug_info = self @infos = [] end |
Instance Attribute Details
#debug_section ⇒ Object
Returns the value of attribute debug_section.
11 12 13 |
# File 'lib/mrb_parser/debug_info.rb', line 11 def debug_section @debug_section end |
#files ⇒ Object
Returns the value of attribute files.
10 11 12 |
# File 'lib/mrb_parser/debug_info.rb', line 10 def files @files end |
#infos ⇒ Object (readonly)
Returns the value of attribute infos.
13 14 15 |
# File 'lib/mrb_parser/debug_info.rb', line 13 def infos @infos end |
#irep_record ⇒ Object
Returns the value of attribute irep_record.
12 13 14 |
# File 'lib/mrb_parser/debug_info.rb', line 12 def irep_record @irep_record end |
#pc_count ⇒ Object
Returns the value of attribute pc_count.
9 10 11 |
# File 'lib/mrb_parser/debug_info.rb', line 9 def pc_count @pc_count end |
Instance Method Details
#dump(n = 2) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mrb_parser/debug_info.rb', line 65 def dump(n = 2) printf_indent n, "*** DEBUG INFO ***\n" printf_indent n, "count: %d\n", @pc_count printf_indent n, "files: %d\n", @files.size @files.map{|file| file.dump(n+2)} @infos.each do |debug_info| debug_info.dump(n + 2) end printf_indent n, "*** ***\n" end |
#parse_record(parser) ⇒ Object
22 23 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 |
# File 'lib/mrb_parser/debug_info.rb', line 22 def parse_record(parser) @pc_count = parser.read_uint32 flen = parser.read_uint16 @files = [] flen.times do file = DebugInfoFile.new @files << file file.start_pos = parser.read_uint32 filename_idx = parser.read_uint16 file.filename = @debug_section.filenames[filename_idx] file.line_entry_count = parser.read_uint32 file.line_type = parser.read_uint8 case file.line_type when MRB_DEBUG_LINE_ARY ## 0 file.line_ary = [] file.line_entry_count.times do file.line_ary << parser.read_uint16 end when MRB_DEBUG_LINE_FLAT_MAP ## 1 file.line_flat_map = [] file.line_entry_count.times do start_pos = parser.read_uint32 line = parser.read_uint16 file.line_flat_map << {start_pos: start_pos, line: line} end else raise end end @irep_record.recs.each do |irep_record| info = MrbParser::DebugInfo.new(@debug_section, irep_record) @infos << info info.parse_record(parser) end self end |
#printf_indent(n, *args) ⇒ Object
60 61 62 63 |
# File 'lib/mrb_parser/debug_info.rb', line 60 def printf_indent(n, *args) print " "*n printf *args end |