Class: Elf::Writer2::StringTable

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/mithril/writer2.rb

Defined Under Namespace

Classes: OutputLayout

Instance Method Summary collapse

Constructor Details

#initializeStringTable

Returns a new instance of StringTable.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mithril/writer2.rb', line 8

def initialize 
  @strings = {} #TODO: Do substring matching, compress the string
  #table.
  def add_string(string) 
    unless @strings.include? string
      @strings[string] = self.strtab.num_bytes
      self.strtab << BinData::Stringz(string)
    end
    @strings[string]
  end
end

Instance Method Details

#add_string(string) ⇒ Object

table.



11
12
13
14
15
16
17
# File 'lib/mithril/writer2.rb', line 11

def add_string(string) 
  unless @strings.include? string
    @strings[string] = self.strtab.num_bytes
    self.strtab << BinData::Stringz(string)
  end
  @strings[string]
end