class MrbParser::Section

Constants

BINARY_EOF
DEBUG_IDENTIFIER
IREP_IDENTIFIER
LINENO_IDENTIFIER

Attributes

signature[R]
size[R]

Public Class Methods

new(signature = nil, size = nil) click to toggle source
# File lib/mrb_parser/section.rb, line 16
def initialize(signature = nil, size = nil)
  @signature = signature
  @size = size
end
parse(parser) click to toggle source
# File lib/mrb_parser/section.rb, line 21
def self.parse(parser)
  section = MrbParser::Section.new
  section.parse(parser)
end

Public Instance Methods

end?() click to toggle source
# File lib/mrb_parser/section.rb, line 46
def end?
  false
end
parse(parser) click to toggle source
# File lib/mrb_parser/section.rb, line 26
def parse(parser)
  signature = parser.read_chars(4)
  size = parser.read_uint32
  case signature
  when IREP_IDENTIFIER
    section = MrbParser::IrepSection
  when LINENO_IDENTIFIER
    section = MrbParser::LinenoSection
  when DEBUG_IDENTIFIER
    section = MrbParser::DebugSection
  when BINARY_EOF
    section = MrbParser::EndSection
  else
    raise MrbParser::Error, "cannot parse; invalid section signature: '#{signature}'"
  end
  sec = section.new(signature, size)
  sec.parse_body(parser)
  sec
end