Class: AdLint::Cc1::BitfieldType

Inherits:
IntegerType show all
Defined in:
lib/adlint/cc1/type.rb

Instance Attribute Summary collapse

Attributes inherited from ScalarDataType

#bit_alignment, #bit_size

Attributes inherited from Type

#declarations, #name, #type_table

Instance Method Summary collapse

Methods inherited from IntegerType

#argument_promoted_type, #brief_image, #compatible?, #explicitly_signed?, #floating?, #image, #integer?, #location, #max, #min, #signed?

Methods inherited from ScalarDataType

#_arithmetic_type_with_array, #_arithmetic_type_with_bitfield, #_arithmetic_type_with_char, #_arithmetic_type_with_double, #_arithmetic_type_with_enum, #_arithmetic_type_with_extended_big_int, #_arithmetic_type_with_float, #_arithmetic_type_with_function, #_arithmetic_type_with_int, #_arithmetic_type_with_long, #_arithmetic_type_with_long_double, #_arithmetic_type_with_long_int, #_arithmetic_type_with_long_long, #_arithmetic_type_with_long_long_int, #_arithmetic_type_with_pointer, #_arithmetic_type_with_short, #_arithmetic_type_with_short_int, #_arithmetic_type_with_signed, #_arithmetic_type_with_signed_char, #_arithmetic_type_with_signed_int, #_arithmetic_type_with_signed_long, #_arithmetic_type_with_signed_long_int, #_arithmetic_type_with_signed_long_long, #_arithmetic_type_with_signed_long_long_int, #_arithmetic_type_with_signed_short, #_arithmetic_type_with_signed_short_int, #_arithmetic_type_with_struct, #_arithmetic_type_with_undeclared, #_arithmetic_type_with_union, #_arithmetic_type_with_unresolved, #_arithmetic_type_with_unsigned, #_arithmetic_type_with_unsigned_char, #_arithmetic_type_with_unsigned_int, #_arithmetic_type_with_unsigned_long, #_arithmetic_type_with_unsigned_long_int, #_arithmetic_type_with_unsigned_long_long, #_arithmetic_type_with_unsigned_long_long_int, #_arithmetic_type_with_unsigned_short, #_arithmetic_type_with_unsigned_short_int, #_arithmetic_type_with_void, #arbitrary_value, #argument_promoted_type, #array?, #brief_image, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #const?, #explicitly_signed?, #floating?, #function?, #have_va_list?, #image, #impl_length, #integer?, #length, #location, #max, #member_named, #members, #min, #nil_value, #parameter_types, #parameter_value, #qualified?, #real_type, #restrict?, #return_type, #return_value, #scalar?, #signed?, #struct?, #undefined_value, #union?, #unqualify, #user?, #void?, #volatile?, #zero_value

Methods included from UsualArithmeticTypeConversion

#do_usual_arithmetic_type_conversion

Methods inherited from Type

#==, #_arithmetic_type_with_array, #_arithmetic_type_with_bitfield, #_arithmetic_type_with_char, #_arithmetic_type_with_double, #_arithmetic_type_with_enum, #_arithmetic_type_with_extended_big_int, #_arithmetic_type_with_float, #_arithmetic_type_with_function, #_arithmetic_type_with_int, #_arithmetic_type_with_long, #_arithmetic_type_with_long_double, #_arithmetic_type_with_long_int, #_arithmetic_type_with_long_long, #_arithmetic_type_with_long_long_int, #_arithmetic_type_with_pointer, #_arithmetic_type_with_short, #_arithmetic_type_with_short_int, #_arithmetic_type_with_signed, #_arithmetic_type_with_signed_char, #_arithmetic_type_with_signed_int, #_arithmetic_type_with_signed_long, #_arithmetic_type_with_signed_long_int, #_arithmetic_type_with_signed_long_long, #_arithmetic_type_with_signed_long_long_int, #_arithmetic_type_with_signed_short, #_arithmetic_type_with_signed_short_int, #_arithmetic_type_with_struct, #_arithmetic_type_with_undeclared, #_arithmetic_type_with_union, #_arithmetic_type_with_unresolved, #_arithmetic_type_with_unsigned, #_arithmetic_type_with_unsigned_char, #_arithmetic_type_with_unsigned_int, #_arithmetic_type_with_unsigned_long, #_arithmetic_type_with_unsigned_long_int, #_arithmetic_type_with_unsigned_long_long, #_arithmetic_type_with_unsigned_long_long_int, #_arithmetic_type_with_unsigned_short, #_arithmetic_type_with_unsigned_short_int, #_arithmetic_type_with_void, #aligned_bit_size, #aligned_byte_size, #arbitrary_value, #argument_promoted_type, #array?, #bit_alignment, #bit_size, #brief_image, #byte_alignment, #byte_size, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #composite?, #const?, #convertible?, #explicitly_signed?, #floating?, #function?, #have_va_list?, #image, #impl_length, #inspect, #integer?, #length, #length=, #location, #max, #member_named, #members, #min, #more_cv_qualified?, #nil_value, #parameter?, #parameter_types, #parameter_value, #qualified?, #real_type, #restrict?, #return_type, #return_value, #same_as?, #scalar?, #signed?, #struct?, #undefined_value, #union?, #unqualify, #unsigned?, #user?, #void?, #volatile?, #zero_value

Methods included from StandardTypesAccessor

#char_alignment, #char_as_unsigned_char?, #char_size, #code_ptr_alignment, #code_ptr_size, #data_ptr_alignment, #data_ptr_size, #double_alignment, #double_size, #float_alignment, #float_size, #int_alignment, #int_size, #long_alignment, #long_double_alignment, #long_double_size, #long_long_alignment, #long_long_size, #long_size, #short_alignment, #short_size, #standard_types

Methods included from ArithmeticAccessor

#arithmetic, #logical_right_shift?

Methods included from Visitable

#accept

Constructor Details

#initialize(type_tbl, base_type, field_width) ⇒ BitfieldType

Returns a new instance of BitfieldType.



4840
4841
4842
4843
4844
4845
# File 'lib/adlint/cc1/type.rb', line 4840

def initialize(type_tbl, base_type, field_width)
  super(type_tbl, "#{base_type.real_type.name}:#{field_width}",
        field_width, base_type.bit_alignment,
        base_type.signed?, base_type.explicitly_signed?)
  @base_type = base_type
end

Instance Attribute Details

#base_typeObject (readonly)

Returns the value of attribute base_type.



4847
4848
4849
# File 'lib/adlint/cc1/type.rb', line 4847

def base_type
  @base_type
end

Instance Method Details

#arithmetic_type_with(type) ⇒ Object



4923
4924
4925
# File 'lib/adlint/cc1/type.rb', line 4923

def arithmetic_type_with(type)
  type._arithmetic_type_with_bitfield(self)
end

#bitfield?Boolean

Returns:

  • (Boolean)


4873
4874
4875
# File 'lib/adlint/cc1/type.rb', line 4873

def bitfield?
  true
end

#corresponding_signed_typeObject



4927
4928
4929
# File 'lib/adlint/cc1/type.rb', line 4927

def corresponding_signed_type
  self # NOTREACHED
end

#corresponding_unsigned_typeObject



4931
4932
4933
# File 'lib/adlint/cc1/type.rb', line 4931

def corresponding_unsigned_type
  self # NOTREACHED
end

#dupObject



4935
4936
4937
# File 'lib/adlint/cc1/type.rb', line 4935

def dup
  BitfieldType.new(type_table, @base_type.dup, bit_size)
end

#enum?Boolean

Returns:

  • (Boolean)


4865
4866
4867
# File 'lib/adlint/cc1/type.rb', line 4865

def enum?
  false
end

#enumeratorsObject



4885
4886
4887
# File 'lib/adlint/cc1/type.rb', line 4885

def enumerators
  []
end

#idObject



4849
4850
4851
# File 'lib/adlint/cc1/type.rb', line 4849

def id
  @id ||= BitfieldTypeId.new(@base_type, bit_size)
end

#incomplete?Boolean

Returns:

  • (Boolean)


4857
4858
4859
# File 'lib/adlint/cc1/type.rb', line 4857

def incomplete?
  @base_type.incomplete?
end

#integer_conversion_rankObject



4889
4890
4891
# File 'lib/adlint/cc1/type.rb', line 4889

def integer_conversion_rank
  -1
end

#integer_promoted_typeObject



4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
# File 'lib/adlint/cc1/type.rb', line 4893

def integer_promoted_type
  # TODO: Should support the C99 _Bool type.
  # NOTE: The ISO C99 standard says;
  #
  # 6.3.1 Arithmetic operands
  # 6.3.1.1 Boolean, characters, and integers
  #
  # 2 The following may be used in an expression wherever an int or
  #   unsigned int may be used:
  #
  #     -- An object or expression with an integer type whose integer
  #        conversion rank is less than or equal to the rank of int and
  #        unsigned int.
  #     -- A bit-field of type _Bool, int, signed int, or unsigned int.
  #
  #   If an int can represent all values of the original type, the value is
  #   converted to an int; otherwise, it is converted to an unsigned int.
  #   These are called the integer promotions.  All other types are
  #   unchanged by the integer promotions.
  if self.undeclared? || self.unresolved?
    self
  else
    if @base_type.same_as?(int_t) || @base_type.same_as?(unsigned_int_t)
      self.compatible?(int_t) ? int_t : unsigned_int_t
    else
      self
    end
  end
end

#named?Boolean

Returns:

  • (Boolean)


4853
4854
4855
# File 'lib/adlint/cc1/type.rb', line 4853

def named?
  true
end

#pointer?Boolean

Returns:

  • (Boolean)


4861
4862
4863
# File 'lib/adlint/cc1/type.rb', line 4861

def pointer?
  false
end

#standard?Boolean

Returns:

  • (Boolean)


4869
4870
4871
# File 'lib/adlint/cc1/type.rb', line 4869

def standard?
  false
end

#undeclared?Boolean

Returns:

  • (Boolean)


4877
4878
4879
# File 'lib/adlint/cc1/type.rb', line 4877

def undeclared?
  @base_type.undeclared?
end

#unresolved?Boolean

Returns:

  • (Boolean)


4881
4882
4883
# File 'lib/adlint/cc1/type.rb', line 4881

def unresolved?
  @base_type.unresolved?
end