Class: Indis::DataEntity
Overview
DataEntity represens “data bytes” that are directly used e.g. in a load to register instruction. There are four sizes of data: 8, 16, 32 and 64 bits long, namely byte
, word
, dword
and qword
Constant Summary collapse
- KIND =
{ 1 => :byte, 2 => :word, 4 => :dword, 8 => :qword, }
- NAMED_TYPE =
{ byte: 'DCB', word: 'DCW', dword: 'DCD', qword: 'DCQ' }
Instance Attribute Summary collapse
-
#value ⇒ Fixnum
readonly
The value of entity.
Attributes inherited from Entity
Instance Method Summary collapse
-
#initialize(ofs, size, vmmap) ⇒ DataEntity
constructor
A new instance of DataEntity.
-
#kind ⇒ KIND
Entity kind.
- #to_a ⇒ Object
- #to_s ⇒ Object
Methods inherited from Entity
Constructor Details
#initialize(ofs, size, vmmap) ⇒ DataEntity
Returns a new instance of DataEntity.
47 48 49 50 51 52 |
# File 'lib/indis-core/data_entity.rb', line 47 def initialize(ofs, size, vmmap) raise ArgumentError, "Unaligned size" unless KIND[size] super ofs @size = size @value = vmmap.bytes_at(ofs, size).reverse_each.reduce(0) { |v, i| (v << 8) + i } end |
Instance Attribute Details
#value ⇒ Fixnum (readonly)
Returns the value of entity.
41 42 43 |
# File 'lib/indis-core/data_entity.rb', line 41 def value @value end |
Instance Method Details
#kind ⇒ KIND
Returns entity kind.
55 56 57 |
# File 'lib/indis-core/data_entity.rb', line 55 def kind KIND[@size] end |
#to_a ⇒ Object
63 64 65 |
# File 'lib/indis-core/data_entity.rb', line 63 def to_a [NAMED_TYPE[kind], sprintf("%0#{@size*2}X", @value)] end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/indis-core/data_entity.rb', line 59 def to_s "#{NAMED_TYPE[kind]}\t#{sprintf("%0#{@size*2}X", @value)}" end |