Class: Rubycc::Type::Member

Inherits:
Data
  • Object
show all
Defined in:
lib/rubycc/type.rb

Overview

One laid-out member of a struct: its name, its declared Type and the byte offset of its first byte from the start of the enclosing struct.

A bit-field member carries two extra fields (both nil for a plain member): bit_width, the declared width in bits, and bit_offset, the field's bit position measured from the start of the enclosing aggregate. offset for a bit-field is the byte containing its first bit (bit_offset / 8), kept only so ABI classification and diagnostics have a byte anchor — this subset diagnoses every bit-field access, so no read or write ever consults these bit fields to extract a value (recorded M2 debt). An unnamed bit-field declares no member and is never recorded here; it only shapes the layout.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, offset:, bit_width: nil, bit_offset: nil) ⇒ Member

Returns a new instance of Member.



758
759
760
# File 'lib/rubycc/type.rb', line 758

def initialize(name:, type:, offset:, bit_width: nil, bit_offset: nil)
  super
end

Instance Attribute Details

#bit_offsetObject (readonly)

Returns the value of attribute bit_offset

Returns:

  • (Object)

    the current value of bit_offset



757
758
759
# File 'lib/rubycc/type.rb', line 757

def bit_offset
  @bit_offset
end

#bit_widthObject (readonly)

Returns the value of attribute bit_width

Returns:

  • (Object)

    the current value of bit_width



757
758
759
# File 'lib/rubycc/type.rb', line 757

def bit_width
  @bit_width
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



757
758
759
# File 'lib/rubycc/type.rb', line 757

def name
  @name
end

#offsetObject (readonly)

Returns the value of attribute offset

Returns:

  • (Object)

    the current value of offset



757
758
759
# File 'lib/rubycc/type.rb', line 757

def offset
  @offset
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



757
758
759
# File 'lib/rubycc/type.rb', line 757

def type
  @type
end

Instance Method Details

#bitfield?Boolean

Whether this member is a bit-field, distinguishing it from a plain member occupying whole bytes; the generator consults it to diagnose an access.

Returns:

  • (Boolean)


764
765
766
# File 'lib/rubycc/type.rb', line 764

def bitfield?
  !bit_width.nil?
end