class AdLint::Cc1::PointerType

Attributes

base_type[R]

Public Class Methods

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

Public Instance Methods

arithmetic_type_with(type) click to toggle source
# File lib/adlint/cc1/type.rb, line 5183
def arithmetic_type_with(type)
  type._arithmetic_type_with_pointer(self)
end
bitfield?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5165
def bitfield?
  false
end
brief_image() click to toggle source
# File lib/adlint/cc1/type.rb, line 5107
def brief_image
  create_brief_image(@base_type)
end
convertible?(to_type) click to toggle source
# 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_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 5187
def corresponding_signed_type
  self # NOTREACHED
end
corresponding_unsigned_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 5191
def corresponding_unsigned_type
  self # NOTREACHED
end
dup() click to toggle source
# File lib/adlint/cc1/type.rb, line 5195
def dup
  PointerType.new(type_table, @base_type.dup)
end
enum?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5145
def enum?
  false
end
enumerators() click to toggle source
# File lib/adlint/cc1/type.rb, line 5169
def enumerators
  []
end
id() click to toggle source
# File lib/adlint/cc1/type.rb, line 5099
def id
  @id ||= PointerTypeId.new(@base_type)
end
image() click to toggle source
# File lib/adlint/cc1/type.rb, line 5103
def image
  create_image(@base_type)
end
incomplete?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5119
def incomplete?
  false
end
integer_conversion_rank() click to toggle source
# File lib/adlint/cc1/type.rb, line 5173
def integer_conversion_rank
  # NOTE: Pointer variables must not be converted implicitly.
  100
end
integer_promoted_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 5178
def integer_promoted_type
  # NOTE: Pointer variables must not be converted implicitly.
  self
end
named?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5111
def named?
  true
end
pointer?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5141
def pointer?
  true
end
real_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 5115
def real_type
  type_table.pointer_type(@base_type.real_type)
end
standard?() click to toggle source
# File lib/adlint/cc1/type.rb, line 5149
def standard?
  false
end
undeclared?() click to toggle source
# 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?() click to toggle source
# 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

Private Instance Methods

create_brief_image(base_type) click to toggle source
# File lib/adlint/cc1/type.rb, line 5220
def create_brief_image(base_type)
  if base_type.function?
    "#{base_type.return_type.brief_image}(*)(" +
      base_type.parameter_types.map { |type| type.brief_image }.join(",") +
      (base_type.have_va_list? ? ",...)" : ")")
  else
    "#{base_type.brief_image} *"
  end
end
create_image(base_type) click to toggle source
# File lib/adlint/cc1/type.rb, line 5210
def create_image(base_type)
  if base_type.function?
    "#{base_type.return_type.image}(*)(" +
      base_type.parameter_types.map { |type| type.image }.join(",") +
      (base_type.have_va_list? ? ",...)" : ")")
  else
    "#{base_type.image} *"
  end
end
create_name(base_type) click to toggle source
# File lib/adlint/cc1/type.rb, line 5200
def create_name(base_type)
  if base_type.function?
    "#{base_type.return_type.name}(*)(" +
      base_type.parameter_types.map { |type| type.name }.join(",") +
      (base_type.have_va_list? ? ",...)" : ")")
  else
    "#{base_type.name} *"
  end
end