class RubyVM::RJIT::CPointer::BitField
公共类方法
define(width, offset) 点击切换源代码
@param width [Integer] @param offset [Integer]
调用父类方法
# File ruby_vm/rjit/c_pointer.rb, line 364 def self.define(width, offset) Class.new(self) do define_method(:initialize) do |addr| super(addr, width, offset) end end end
new(addr, width, offset) 点击切换源代码
@param addr [Integer] @param width [Integer] @param offset [Integer]
# File ruby_vm/rjit/c_pointer.rb, line 342 def initialize(addr, width, offset) @addr = addr @width = width @offset = offset end
公共实例方法
*() 点击切换源代码
解引用
# File ruby_vm/rjit/c_pointer.rb, line 349 def * byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first if @width == 1 bit = (1 & (byte >> @offset)) bit == 1 elsif @width <= 8 && @offset == 0 bitmask = @width.times.map { |i| 1 << i }.sum byte & bitmask else raise NotImplementedError.new("not-implemented bit field access: width=#{@width} offset=#{@offset}") end end