Class: Zemu::Debug::Symbols

Inherits:
Object
  • Object
show all
Defined in:
lib/zemu/debug.rb

Overview

Contains a set of symbols. Allows for various lookup operations.

Instance Method Summary collapse

Constructor Details

#initialize(syms) ⇒ Symbols

Constructor.



25
26
27
28
29
30
# File 'lib/zemu/debug.rb', line 25

def initialize(syms)
    @syms = []
    syms.each do |s|
        @syms << s
    end
end

Instance Method Details

#[](address) ⇒ Object

Access all symbols with a given address.



33
34
35
36
37
38
39
40
41
42
# File 'lib/zemu/debug.rb', line 33

def [](address)
    at_address = []
    @syms.each do |s|
        if s.address == address
            at_address << s
        end
    end

    return at_address.sort_by(&:label)
end

#find_by_name(name) ⇒ Object

Find a symbol with a given name.



45
46
47
48
49
50
51
# File 'lib/zemu/debug.rb', line 45

def find_by_name(name)
    @syms.each do |s|
        return s if s.label == name
    end

    return nil
end

#hashObject

Get symbols as a hash.



54
55
56
# File 'lib/zemu/debug.rb', line 54

def hash
    return @syms
end