Class: AdLint::Cc1::CharType

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

Instance Attribute Summary

Attributes inherited from ScalarDataType

#bit_alignment, #bit_size

Attributes inherited from Type

#declarations, #name, #type_table

Instance Method Summary collapse

Methods inherited from StandardIntegerType

#bitfield?, #dup, #enum?, #enumerators, #incomplete?, #named?, #pointer?, #standard?

Methods inherited from IntegerType

#argument_promoted_type, #bitfield?, #brief_image, #compatible?, #dup, #enum?, #enumerators, #explicitly_signed?, #floating?, #image, #integer?, #integer_promoted_type, #location, #max, #min, #pointer?, #signed?, #standard?

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?, #base_type, #bitfield?, #brief_image, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #const?, #dup, #enum?, #enumerators, #explicitly_signed?, #floating?, #function?, #have_va_list?, #image, #impl_length, #integer?, #integer_promoted_type, #length, #location, #max, #member_named, #members, #min, #named?, #nil_value, #parameter_types, #parameter_value, #pointer?, #qualified?, #real_type, #restrict?, #return_type, #return_value, #scalar?, #signed?, #standard?, #struct?, #undeclared?, #undefined_value, #union?, #unqualify, #unresolved?, #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?, #base_type, #bit_alignment, #bit_size, #bitfield?, #brief_image, #byte_alignment, #byte_size, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #composite?, #const?, #convertible?, #dup, #enum?, #enumerators, #explicitly_signed?, #floating?, #function?, #have_va_list?, #image, #impl_length, #incomplete?, #inspect, #integer?, #integer_promoted_type, #length, #length=, #location, #max, #member_named, #members, #min, #more_cv_qualified?, #named?, #nil_value, #parameter?, #parameter_types, #parameter_value, #pointer?, #qualified?, #real_type, #restrict?, #return_type, #return_value, #same_as?, #scalar?, #signed?, #standard?, #struct?, #undeclared?, #undefined_value, #union?, #unqualify, #unresolved?, #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) ⇒ CharType

Returns a new instance of CharType.



3617
3618
3619
3620
3621
3622
3623
# File 'lib/adlint/cc1/type.rb', line 3617

def initialize(type_tbl)
  # FIXME: StandardTypesAccessor is not ready until @type_table is
  #        initialized.
  @type_table = type_tbl
  super(type_tbl, "char",
        char_size, char_alignment, !char_as_unsigned_char?, false)
end

Instance Method Details

#arithmetic_type_with(type) ⇒ Object



3670
3671
3672
# File 'lib/adlint/cc1/type.rb', line 3670

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

#corresponding_signed_typeObject



3674
3675
3676
# File 'lib/adlint/cc1/type.rb', line 3674

def corresponding_signed_type
  signed_char_t
end

#corresponding_unsigned_typeObject



3678
3679
3680
# File 'lib/adlint/cc1/type.rb', line 3678

def corresponding_unsigned_type
  unsigned_char_t
end

#idObject



3625
3626
3627
3628
3629
3630
# File 'lib/adlint/cc1/type.rb', line 3625

def id
  # NOTE: `char' type may be treated as `unsigned char'.
  #       Specialized type comparison is implemented in CharTypeId,
  #       SignedCharTypeId and UnsignedCharTypeId.
  @id ||= CharTypeId.new(char_as_unsigned_char?)
end

#integer_conversion_rankObject



3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
# File 'lib/adlint/cc1/type.rb', line 3632

def integer_conversion_rank
  # NOTE: The ISO C99 standard says;
  #
  # 6.3.1 Arithmetic operands
  # 6.3.1.1 Boolean, characters, and integers
  #
  # 1 Every integer type has an integer conversion rank defined as follows:
  #
  #     -- No two signed integer types shall have the same rank, even if
  #        they have the same representation.
  #     -- The rank of a signed integer type shall be greater than the rank
  #        of any signed integer type with less precision.
  #     -- The rank of long long int shall be greater than the rank of long
  #        int, which shall be greater than the rank of int, which shall be
  #        greater than the rank of short int, which shall be greater than
  #        the rank of signed char.
  #     -- The rank of any unsigned integer type shall equal the rank of
  #        the corresponding signed integer type, if any.
  #     -- The rank of any standard integer type shall be greater than the
  #        rank of any extended integer type with the same width.
  #     -- The rank of char shall equal the rank of signed char and
  #        unsigned char.
  #     -- The rank of _Bool shall be less than the rank of all other
  #        standard integer types.
  #     -- The rank of any enumerated type shall equal the rank of the
  #        compatible integer type.
  #     -- The rank of any extended signed integer type relative to another
  #        extended signed integer type with the same precision is
  #        implementation-defined, but still subject to the other rules for
  #        determining the integer conversion rank.
  #     -- For all integer types T1, T2, and T3, if T1 has greater rank
  #        than T2 and T2 has greater rank than T3, then T1 has greater
  #        rank than T3.
  #
  # NOTE: char = 1, short int = 2, int = 3, long int = 4, long long int = 5
  1
end