class AdLint::Cc1::BitfieldType

Attributes

base_type[R]

Public Class Methods

new(type_tbl, base_type, field_width) click to toggle source
Calls superclass method AdLint::Cc1::IntegerType::new
# 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

Public Instance Methods

arithmetic_type_with(type) click to toggle source
# File lib/adlint/cc1/type.rb, line 4923
def arithmetic_type_with(type)
  type._arithmetic_type_with_bitfield(self)
end
bitfield?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4873
def bitfield?
  true
end
corresponding_signed_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 4927
def corresponding_signed_type
  self # NOTREACHED
end
corresponding_unsigned_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 4931
def corresponding_unsigned_type
  self # NOTREACHED
end
dup() click to toggle source
# File lib/adlint/cc1/type.rb, line 4935
def dup
  BitfieldType.new(type_table, @base_type.dup, bit_size)
end
enum?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4865
def enum?
  false
end
enumerators() click to toggle source
# File lib/adlint/cc1/type.rb, line 4885
def enumerators
  []
end
id() click to toggle source
# File lib/adlint/cc1/type.rb, line 4849
def id
  @id ||= BitfieldTypeId.new(@base_type, bit_size)
end
incomplete?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4857
def incomplete?
  @base_type.incomplete?
end
integer_conversion_rank() click to toggle source
# File lib/adlint/cc1/type.rb, line 4889
def integer_conversion_rank
  -1
end
integer_promoted_type() click to toggle source
# 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?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4853
def named?
  true
end
pointer?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4861
def pointer?
  false
end
standard?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4869
def standard?
  false
end
undeclared?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4877
def undeclared?
  @base_type.undeclared?
end
unresolved?() click to toggle source
# File lib/adlint/cc1/type.rb, line 4881
def unresolved?
  @base_type.unresolved?
end