Class: Udb::InstructionSubtype
- Inherits:
-
TopLevelDatabaseObject
- Object
- DatabaseObject
- TopLevelDatabaseObject
- Udb::InstructionSubtype
- Defined in:
- lib/udb/obj/instruction.rb
Defined Under Namespace
Classes: Opcode
Instance Attribute Summary
Attributes inherited from DatabaseObject
#arch, #data, #data_path, #long_name, #name
Instance Method Summary collapse
-
#initialize(data, data_path, arch) ⇒ InstructionSubtype
constructor
A new instance of InstructionSubtype.
- #opcodes ⇒ Object
- #type ⇒ Object
- #variables ⇒ Object
Methods inherited from TopLevelDatabaseObject
create_json_schemer_resolver, #key?, #keys, #validate
Methods inherited from DatabaseObject
#<=>, #__source, #cfg_arch, #cfg_arch?, #clone, #defer, #defined_by_condition, #description, #inspect, #kind, #source_line
Constructor Details
#initialize(data, data_path, arch) ⇒ InstructionSubtype
Returns a new instance of InstructionSubtype.
64 65 66 |
# File 'lib/udb/obj/instruction.rb', line 64 def initialize(data, data_path, arch) super(data, data_path, arch) end |
Instance Method Details
#opcodes ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/udb/obj/instruction.rb', line 84 def opcodes @opcodes ||= @data["data"]["opcodes"].map do |opcode_name, opcode_data| next if opcode_name[0] == "$" raise "unexpected: opcode field is not contiguous" if opcode_data["location"].include?("|") loc = opcode_data["location"] range = if loc =~ /^([0-9]+)$/ bit = ::Regexp.last_match(1) bit.to_i..bit.to_i elsif loc =~ /^([0-9]+)-([0-9]+)$/ msb = ::Regexp.last_match(1) lsb = ::Regexp.last_match(2) raise "range must be specified 'msb-lsb'" unless msb.to_i >= lsb.to_i lsb.to_i..msb.to_i else raise "location format error" end Instruction::Encoding::Field.new(opcode_name, range) end.reject(&:nil?) end |
#type ⇒ Object
69 70 71 |
# File 'lib/udb/obj/instruction.rb', line 69 def type @type ||= @arch.ref(@data["data"]["type"]["$ref"]) end |
#variables ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/udb/obj/instruction.rb', line 74 def variables @variables ||= if @data["data"].key?("variables") @data["data"]["variables"].map { |var_name, var_data| Instruction::DecodeVariable.new(var_name, var_data) } else [] end end |