Class: RubyVM::RJIT::CPointer::Pointer
- Inherits:
-
Object
- Object
- RubyVM::RJIT::CPointer::Pointer
- Defined in:
- lib/ruby_vm/rjit/c_pointer.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#* ⇒ Object
Dereference.
-
#+(index) ⇒ Object
Move addr to addess this pointer like an array.
-
#[](index) ⇒ Object
Array access.
-
#[]=(index, value) ⇒ Object
Array set.
-
#initialize(addr, type) ⇒ Pointer
constructor
A new instance of Pointer.
-
#to_i ⇒ Object
Get a raw address.
Constructor Details
#initialize(addr, type) ⇒ Pointer
Returns a new instance of Pointer.
280 281 282 283 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 280 def initialize(addr, type) @addr = addr @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
276 277 278 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 276 def type @type end |
Instance Method Details
#* ⇒ Object
Dereference
292 293 294 295 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 292 def * return nil if dest_addr == 0 @type.new(dest_addr) end |
#+(index) ⇒ Object
Move addr to addess this pointer like an array
286 287 288 289 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 286 def +(index) raise ArgumentError unless index.is_a?(Integer) Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP, @type) end |
#[](index) ⇒ Object
Array access
298 299 300 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 298 def [](index) (self + index).* end |
#[]=(index, value) ⇒ Object
Array set
305 306 307 308 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 305 def []=(index, value) Fiddle::Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP)[0, Fiddle::SIZEOF_VOIDP] = [value.to_i].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP]) end |
#to_i ⇒ Object
Get a raw address
311 312 313 |
# File 'lib/ruby_vm/rjit/c_pointer.rb', line 311 def to_i @addr end |