Class: MrbParser

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/mrb_parser.rb,
lib/mrb_parser/crc.rb,
lib/mrb_parser/error.rb,
lib/mrb_parser/utils.rb,
lib/mrb_parser/header.rb,
lib/mrb_parser/section.rb,
lib/mrb_parser/version.rb,
lib/mrb_parser/code_dump.rb,
lib/mrb_parser/debug_info.rb,
lib/mrb_parser/end_section.rb,
lib/mrb_parser/irep_record.rb,
lib/mrb_parser/irep_section.rb,
lib/mrb_parser/debug_section.rb,
lib/mrb_parser/lineno_section.rb,
lib/mrb_parser/debug_info_file.rb

Defined Under Namespace

Modules: Utils Classes: CRC, CodeDump, DebugInfo, DebugInfoFile, DebugSection, EndSection, Error, Header, IrepRecord, IrepSection, LinenoSection, Section

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#pos, #read, #read_chars, #read_format, #read_n16string, #read_uint16, #read_uint32, #read_uint8, #seek

Constructor Details

#initialize(filename) ⇒ MrbParser

Returns a new instance of MrbParser.



19
20
21
22
23
24
# File 'lib/mrb_parser.rb', line 19

def initialize(filename)
  @filename = filename
  @data = nil
  @irep_section = nil
  @sections = []
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



12
13
14
# File 'lib/mrb_parser.rb', line 12

def header
  @header
end

#irep_sectionObject

Returns the value of attribute irep_section.



11
12
13
# File 'lib/mrb_parser.rb', line 11

def irep_section
  @irep_section
end

#sectionsObject (readonly)

Returns the value of attribute sections.



12
13
14
# File 'lib/mrb_parser.rb', line 12

def sections
  @sections
end

#verboseObject

Returns the value of attribute verbose.



10
11
12
# File 'lib/mrb_parser.rb', line 10

def verbose
  @verbose
end

Class Method Details

.parse(filename) ⇒ Object



14
15
16
17
# File 'lib/mrb_parser.rb', line 14

def self.parse(filename)
  parser = MrbParser.new(filename)
  parser.parse
end

Instance Method Details

#dumpObject



37
38
39
40
41
42
# File 'lib/mrb_parser.rb', line 37

def dump
  @header.dump
  @sections.each do |section|
    section.dump
  end
end

#parseObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/mrb_parser.rb', line 26

def parse
  @data = File.open(@filename)
  @header = MrbParser::Header.parse(self)

  while true
    section = MrbParser::Section.parse(self)
    @sections << section
    break if section.end?
  end
end