Class: AdLint::Cc1::QualifiedType

Inherits:
Type
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/adlint/cc1/type.rb

Instance Attribute Summary collapse

Attributes inherited from Type

#declarations, #name, #type_table

Instance Method Summary collapse

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, #arithmetic_type_with, #array?, #bit_alignment, #bit_size, #bitfield?, #byte_alignment, #byte_size, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #composite?, #corresponding_signed_type, #corresponding_unsigned_type, #enum?, #enumerators, #explicitly_signed?, #floating?, #function?, #have_va_list?, #impl_length, #incomplete?, #inspect, #integer?, #integer_conversion_rank, #integer_promoted_type, #length, #length=, #location, #max, #member_named, #members, #min, #named?, #nil_value, #parameter?, #parameter_types, #parameter_value, #pointer?, #return_type, #return_value, #same_as?, #scalar?, #signed?, #standard?, #struct?, #undeclared?, #undefined_value, #union?, #unqualify, #unresolved?, #unsigned?, #user?, #void?, #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, *cvr_quals) ⇒ QualifiedType

Returns a new instance of QualifiedType.



1687
1688
1689
1690
1691
# File 'lib/adlint/cc1/type.rb', line 1687

def initialize(type_tbl, base_type, *cvr_quals)
  super(type_tbl, create_name(base_type, cvr_quals))
  @base_type = base_type
  @cvr_qualifiers = cvr_quals
end

Instance Attribute Details

#base_typeObject (readonly)

Returns the value of attribute base_type.



1693
1694
1695
# File 'lib/adlint/cc1/type.rb', line 1693

def base_type
  @base_type
end

Instance Method Details

#brief_imageObject



1703
1704
1705
# File 'lib/adlint/cc1/type.rb', line 1703

def brief_image
  @brief_image ||= create_brief_image(@base_type, @cvr_qualifiers)
end

#const?Boolean

Returns:

  • (Boolean)


1770
1771
1772
# File 'lib/adlint/cc1/type.rb', line 1770

def const?
  @cvr_qualifiers.include?(:const)
end

#convertible?(to_type) ⇒ Boolean

Returns:

  • (Boolean)


1724
1725
1726
# File 'lib/adlint/cc1/type.rb', line 1724

def convertible?(to_type)
  real_type.unqualify.convertible?(to_type.real_type.unqualify)
end

#dupObject



1854
1855
1856
# File 'lib/adlint/cc1/type.rb', line 1854

def dup
  QualifiedType.new(type_table, @base_type.dup, *@cvr_qualifiers)
end

#idObject



1695
1696
1697
# File 'lib/adlint/cc1/type.rb', line 1695

def id
  @id ||= QualifiedTypeId.new(@base_type, @cvr_qualifiers)
end

#imageObject



1699
1700
1701
# File 'lib/adlint/cc1/type.rb', line 1699

def image
  @image ||= create_image(@base_type, @cvr_qualifiers)
end

#more_cv_qualified?(than_type) ⇒ Boolean

Returns:

  • (Boolean)


1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
# File 'lib/adlint/cc1/type.rb', line 1728

def more_cv_qualified?(than_type)
  # NOTE: The term `more cv-qualified' means:
  #         const          > none
  #         volatile       > none
  #         const volatile > none
  #         const volatile > const
  #         const volatile > volatile
  if than_type.qualified?
    if than_type.const? && than_type.volatile?
      false
    else
      if self.const? && self.volatile?
        true
      else
        false
      end
    end
  else
    true
  end
end

#qualified?Boolean

Returns:

  • (Boolean)


1758
1759
1760
# File 'lib/adlint/cc1/type.rb', line 1758

def qualified?
  true
end

#real_typeObject



1715
1716
1717
# File 'lib/adlint/cc1/type.rb', line 1715

def real_type
  type_table.qualified_type(@base_type.real_type, *@cvr_qualifiers)
end

#restrict?Boolean

Returns:

  • (Boolean)


1778
1779
1780
# File 'lib/adlint/cc1/type.rb', line 1778

def restrict?
  @cvr_qualifiers.include?(:restrict)
end

#volatile?Boolean

Returns:

  • (Boolean)


1774
1775
1776
# File 'lib/adlint/cc1/type.rb', line 1774

def volatile?
  @cvr_qualifiers.include?(:volatile)
end