Class: AdLint::Cc1::PointerType

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, #compatible?, #explicitly_signed?, #floating?, #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?, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #const?, #explicitly_signed?, #floating?, #function?, #have_va_list?, #impl_length, #integer?, #length, #location, #max, #member_named, #members, #min, #nil_value, #parameter_types, #parameter_value, #qualified?, #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, #byte_alignment, #byte_size, #coerce_array_value, #coerce_composite_value, #coerce_scalar_value, #coercible?, #compatible?, #composite?, #const?, #explicitly_signed?, #floating?, #function?, #have_va_list?, #impl_length, #inspect, #integer?, #length, #length=, #location, #max, #member_named, #members, #min, #more_cv_qualified?, #nil_value, #parameter?, #parameter_types, #parameter_value, #qualified?, #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) ⇒ PointerType

Returns a new instance of PointerType.



5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
# File 'lib/adlint/cc1/type.rb', line 5086

def initialize(type_tbl, base_type)
  # FIXME: StandardTypesAccessor is not ready until @type_table is
  #        initialized.
  @type_table = type_tbl
  super(type_tbl, create_name(base_type),
        base_type.function? ? code_ptr_size : data_ptr_size,
        base_type.function? ? code_ptr_alignment : data_ptr_alignment,
        false, true, base_type.declarations)
  @base_type = base_type
end

Instance Attribute Details

#base_typeObject (readonly)

Returns the value of attribute base_type.



5097
5098
5099
# File 'lib/adlint/cc1/type.rb', line 5097

def base_type
  @base_type
end

Instance Method Details

#arithmetic_type_with(type) ⇒ Object



5183
5184
5185
# File 'lib/adlint/cc1/type.rb', line 5183

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

#bitfield?Boolean

Returns:

  • (Boolean)


5165
5166
5167
# File 'lib/adlint/cc1/type.rb', line 5165

def bitfield?
  false
end

#brief_imageObject



5107
5108
5109
# File 'lib/adlint/cc1/type.rb', line 5107

def brief_image
  create_brief_image(@base_type)
end

#convertible?(to_type) ⇒ Boolean

Returns:

  • (Boolean)


5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
# File 'lib/adlint/cc1/type.rb', line 5123

def convertible?(to_type)
  lhs_unqualified = self.real_type.unqualify
  rhs_unqualified = to_type.real_type.unqualify

  if rhs_unqualified.pointer? || rhs_unqualified.array?
    lhs_base = lhs_unqualified.base_type
    rhs_base = rhs_unqualified.base_type

    unless lhs_base.more_cv_qualified?(rhs_base)
      rhs_base.void? || lhs_base.convertible?(rhs_base)
    else
      false
    end
  else
    false
  end
end

#corresponding_signed_typeObject



5187
5188
5189
# File 'lib/adlint/cc1/type.rb', line 5187

def corresponding_signed_type
  self # NOTREACHED
end

#corresponding_unsigned_typeObject



5191
5192
5193
# File 'lib/adlint/cc1/type.rb', line 5191

def corresponding_unsigned_type
  self # NOTREACHED
end

#dupObject



5195
5196
5197
# File 'lib/adlint/cc1/type.rb', line 5195

def dup
  PointerType.new(type_table, @base_type.dup)
end

#enum?Boolean

Returns:

  • (Boolean)


5145
5146
5147
# File 'lib/adlint/cc1/type.rb', line 5145

def enum?
  false
end

#enumeratorsObject



5169
5170
5171
# File 'lib/adlint/cc1/type.rb', line 5169

def enumerators
  []
end

#idObject



5099
5100
5101
# File 'lib/adlint/cc1/type.rb', line 5099

def id
  @id ||= PointerTypeId.new(@base_type)
end

#imageObject



5103
5104
5105
# File 'lib/adlint/cc1/type.rb', line 5103

def image
  create_image(@base_type)
end

#incomplete?Boolean

Returns:

  • (Boolean)


5119
5120
5121
# File 'lib/adlint/cc1/type.rb', line 5119

def incomplete?
  false
end

#integer_conversion_rankObject



5173
5174
5175
5176
# File 'lib/adlint/cc1/type.rb', line 5173

def integer_conversion_rank
  # NOTE: Pointer variables must not be converted implicitly.
  100
end

#integer_promoted_typeObject



5178
5179
5180
5181
# File 'lib/adlint/cc1/type.rb', line 5178

def integer_promoted_type
  # NOTE: Pointer variables must not be converted implicitly.
  self
end

#named?Boolean

Returns:

  • (Boolean)


5111
5112
5113
# File 'lib/adlint/cc1/type.rb', line 5111

def named?
  true
end

#pointer?Boolean

Returns:

  • (Boolean)


5141
5142
5143
# File 'lib/adlint/cc1/type.rb', line 5141

def pointer?
  true
end

#real_typeObject



5115
5116
5117
# File 'lib/adlint/cc1/type.rb', line 5115

def real_type
  type_table.pointer_type(@base_type.real_type)
end

#standard?Boolean

Returns:

  • (Boolean)


5149
5150
5151
# File 'lib/adlint/cc1/type.rb', line 5149

def standard?
  false
end

#undeclared?Boolean

Returns:

  • (Boolean)


5153
5154
5155
5156
5157
# File 'lib/adlint/cc1/type.rb', line 5153

def undeclared?
  # NOTE: To avoid the infinite recursive call of #undeclared? when the
  #       composite type contains the pointer to it's owner type.
  @base_type.kind_of?(UndeclaredType)
end

#unresolved?Boolean

Returns:

  • (Boolean)


5159
5160
5161
5162
5163
# File 'lib/adlint/cc1/type.rb', line 5159

def unresolved?
  # NOTE: To avoid the infinite recursive call of #unresolved? when the
  #       composite type contains the pointer to it's owner type.
  @base_type.kind_of?(UnresolvedType)
end