Class: Unarm::Data
Constant Summary
Constants included from UnarmBind
UnarmBind::ARGUMENT_KIND, UnarmBind::ARGUMENT_KIND_MAP, UnarmBind::Arg, UnarmBind::Args, UnarmBind::CONDITION, UnarmBind::CONDITION_MAP, UnarmBind::CO_REG, UnarmBind::CO_REG_MAP, UnarmBind::ENDIAN, UnarmBind::ENDIAN_MAP, UnarmBind::OPCODE, UnarmBind::OPCODE_MNEMONIC, UnarmBind::REGISTER, UnarmBind::REGISTER_MAP, UnarmBind::SHIFT, UnarmBind::SHIFT_MAP, UnarmBind::STATUS_REG, UnarmBind::STATUS_REG_MAP
Instance Attribute Summary collapse
-
#address ⇒ Object
(also: #addr)
readonly
Returns the value of attribute address.
-
#location ⇒ Object
(also: #loc)
readonly
Returns the value of attribute location.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#string ⇒ Object
(also: #str)
readonly
Returns the value of attribute string.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #get_directive(size) ⇒ Object
-
#initialize(raw, size: 4, addr: 0, loc: Unarm.cpu.to_s, might_be_ptr: true) ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize(raw, size: 4, addr: 0, loc: Unarm.cpu.to_s, might_be_ptr: true) ⇒ Data
Returns a new instance of Data.
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
# File 'lib/unarm/unarm.rb', line 808 def initialize(raw, size: 4, addr: 0, loc: Unarm.cpu.to_s, might_be_ptr: true) @raw = raw @address = addr @location = loc if raw.is_a? String @size = raw.length + 1 @string = ".asciiz \"#{raw}\"" else @size = size if size == 4 && might_be_ptr syms = Unarm.get_raw_syms(loc) raw_str = CStr.new(get_sym_for_addr(raw, syms.ptr, syms.count)) value = raw_str.null? ? raw.to_hex : raw_str.to_s else value = raw.to_hex end @string = "#{get_directive(size)} #{value}" @value = value end end |
Instance Attribute Details
#address ⇒ Object (readonly) Also known as: addr
Returns the value of attribute address.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def address @address end |
#location ⇒ Object (readonly) Also known as: loc
Returns the value of attribute location.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def location @location end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def raw @raw end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def size @size end |
#string ⇒ Object (readonly) Also known as: str
Returns the value of attribute string.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def string @string end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
789 790 791 |
# File 'lib/unarm/unarm.rb', line 789 def value @value end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
829 830 831 |
# File 'lib/unarm/unarm.rb', line 829 def eql?(other) @raw == other.raw end |
#get_directive(size) ⇒ Object
795 796 797 798 799 800 801 802 803 804 805 806 |
# File 'lib/unarm/unarm.rb', line 795 def get_directive(size) case size when 4 '.word' when 2 '.hword' when 1 '.byte' else raise "Could not determine directive from data size: #{size}" end end |