Class: Squash::Symbolicator::Lines
- Inherits:
-
Object
- Object
- Squash::Symbolicator::Lines
- Includes:
- Enumerable, SerialBox
- Defined in:
- lib/squash/symbolicator/lines.rb
Overview
An aggregation of the ‘Symbolicator::Line`s of a binary class. This class is enumerable.
Instance Method Summary collapse
-
#[](*args) ⇒ Object
Delegated to ‘Array`.
-
#add(start_address, file, lineno, col) ⇒ Object
Adds a line definition to the aggregation.
-
#clear(*args) ⇒ Object
Delegated to ‘Array`.
-
#each(*args) ⇒ Object
Delegated to ‘Array`.
-
#for(address) ⇒ Symbol?
Returns the nearest ‘Symbolicator::Line` to a given program counter address.
-
#initialize ⇒ Lines
constructor
Creates a new empty aggregation.
- #inspect ⇒ Object
-
#size(*args) ⇒ Object
Delegated to ‘Array`.
Constructor Details
#initialize ⇒ Lines
Creates a new empty aggregation.
48 49 50 |
# File 'lib/squash/symbolicator/lines.rb', line 48 def initialize @lines = Array.new end |
Instance Method Details
#[](*args) ⇒ Object
Delegated to ‘Array`.
87 |
# File 'lib/squash/symbolicator/lines.rb', line 87 def [](*args) @lines[*args] end |
#add(start_address, file, lineno, col) ⇒ Object
Adds a line definition to the aggregation.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/squash/symbolicator/lines.rb', line 60 def add(start_address, file, lineno, col) index = @lines.find_index { |line| line.start_address > start_address } new_line = Squash::Symbolicator::Line.new(start_address, file, lineno, col) if index @lines.insert index, new_line else @lines << new_line end end |
#clear(*args) ⇒ Object
Delegated to ‘Array`.
89 |
# File 'lib/squash/symbolicator/lines.rb', line 89 def clear(*args) @lines.clear(*args) end |
#each(*args) ⇒ Object
Delegated to ‘Array`.
85 |
# File 'lib/squash/symbolicator/lines.rb', line 85 def each(*args) @lines.each(*args) end |
#for(address) ⇒ Symbol?
Returns the nearest ‘Symbolicator::Line` to a given program counter address.
77 78 79 80 81 82 |
# File 'lib/squash/symbolicator/lines.rb', line 77 def for(address) return @lines.last if @lines.last && @lines.last.start_address == address idx = @lines.find_index { |line| address < line.start_address } return nil unless idx return @lines[idx - 1] end |
#inspect ⇒ Object
94 |
# File 'lib/squash/symbolicator/lines.rb', line 94 def inspect() "#<#{self.class} [#{size} lines]>" end |
#size(*args) ⇒ Object
Delegated to ‘Array`.
91 |
# File 'lib/squash/symbolicator/lines.rb', line 91 def size(*args) @lines.size(*args) end |