Module: ELFTools::Constants::Naming
Overview
Names a value after the constants that define it, for the modules where several of them may define one value.
A machine defines names of its own, and a name may mark where a range of values begins or ends, or how many of them are defined, rather than name one of them.
Constant Summary collapse
- ARCHITECTURES =
Architectures a constant can be named after, the longest first so that a name is read as the architecture it spells out in full.
(R.constants - [:MACHINES]).sort_by { |name| -name.length }.freeze
Instance Method Summary collapse
-
#mapping(machine, value) ⇒ String
Return the name of
value.
Instance Method Details
#mapping(machine, value) ⇒ String
Return the name of value.
Names of a machine other than machine are passed over, as are the
ones that mark a range or a count instead of naming a value.
37 38 39 40 41 42 43 |
# File 'lib/elftools/constants.rb', line 37 def mapping(machine, value) architecture = R::MACHINES[machine] name = names_by_value.fetch(value, []).find do |constant| !marker?(constant) && [nil, architecture].include?(architecture_of(constant)) end name ? name.to_s : format('<unknown>: 0x%x', value) end |