Class: Dwarves::Parser::DIE

Inherits:
AST
  • Object
show all
Defined in:
lib/dwarves/parser/4/ast.rb

Overview

The basic DWARF descriptive unit, the Debugging Information Entry (DIE).

This is a node in the parse tree that DWARF generates.

These represent types, variables, and functions.

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DIE



23
24
25
26
27
28
29
30
31
# File 'lib/dwarves/parser/4/ast.rb', line 23

def initialize opts = {}
  @tag = opts[:tag]
  @children = opts[:children] || []
  @siblings = opts[:siblings] || []
  @attributes = opts[:attributes] || []
  @address = opts[:address]
  @depth = opts[:depth]
  @abbrev_number = opts[:abbrev_number]
end

Instance Method Details

#to_sObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dwarves/parser/4/ast.rb', line 33

def to_s
  attrs = if @attributes.empty?
            ""
          else
            %(\n#{@attributes.map(&:to_s).join("\n")})
          end
  depth_addr =
    "<#{@depth}><#{@address}>: Abbrev Number: #{@abbrev_number}"

  if @tag
    " #{depth_addr} (#{@tag})#{attrs}"
  else
    " #{depth_addr}#{attrs}"
  end
end