class RPicSim::SymbolSet
This class is used internally by {Sim} to manage the symbols from the simulated firmware's symbol table. @api private
Attributes
symbols[R]
Public Class Methods
new()
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 7 def initialize @memory_types = [] @symbols = {} @symbols_for_memory = {} @callbacks = [] end
Public Instance Methods
def_memory_type(name)
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 14 def def_memory_type(name) name = name.to_sym @memory_types << name @symbols_for_memory[name] = {} end
def_symbol(name, address, memory_type = nil)
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 20 def def_symbol(name, address, memory_type = nil) name = name.to_sym address = address.to_i if memory_type hash = @symbols_for_memory[memory_type.to_sym] raise "Invalid memory type: #{memory_type}." if !hash hash[name] = address end @symbols[name] = address @callbacks.each do |callback| callback.call name, address, memory_type end end
def_symbols(symbols, memory_type = nil)
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 36 def def_symbols(symbols, memory_type = nil) symbols.each do |name, address| def_symbol name, address, memory_type end end
on_symbol_definition(&proc)
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 48 def on_symbol_definition(&proc) raise 'Block required' if !proc @callbacks << proc end
symbols_in_memory(memory_type)
click to toggle source
# File lib/rpicsim/symbol_set.rb, line 44 def symbols_in_memory(memory_type) @symbols_for_memory[memory_type.to_sym] end