class AdLint::Cc1::IntegerType

Public Class Methods

new(type_tbl, name, bit_size, bit_align, signed, explicitly_signed, type_dcls = []) click to toggle source
Calls superclass method AdLint::Cc1::ScalarDataType::new
# File lib/adlint/cc1/type.rb, line 3410
def initialize(type_tbl, name, bit_size, bit_align, signed,
               explicitly_signed, type_dcls = [])
  super(type_tbl, name, bit_size, bit_align, type_dcls)
  @signed = signed
  @explicitly_signed = explicitly_signed
end

Public Instance Methods

argument_promoted_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 3518
def argument_promoted_type
  # NOTE: The ISO C99 standard says;
  #
  # 6.5.2.2 Function calls
  #
  # 6 If the expression that denotes the called function has a type that
  #   does not include a prototype, the integer promotions are performed on
  #   each argument, and arguments that have type float are promoted to
  #   double.  These are called the default argument promotions.  If the
  #   number of arguments does not equal the number of parameters, the
  #   behavior is undefined.  If the function is defined with a type that
  #   includes a prototype, and either the prototype ends with an ellipsis
  #   (, ...) or the types of the arguments after promotion are not
  #   compatible with the types of the parameters, the behavior is
  #   undefined.  If the function is defined with a type that does not
  #   include a prototype, and the types of the arguments after promotion
  #   are not compatible with those of the parameters after promotion, the
  #   behavior is undefined, except for the following cases:
  #
  #     -- one promoted type is a signed integer type, the other promoted
  #        type is the corresponding unsigned integer type, and the value
  #        is representable in both types;
  #     -- both types are pointers to qualified or unqualified versions of
  #        a character type or void.
  self.integer_promoted_type
end
arithmetic_type_with(type) click to toggle source
# File lib/adlint/cc1/type.rb, line 3545
def arithmetic_type_with(type)
  subclass_responsibility
end
bitfield?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3457
def bitfield?
  subclass_responsibility
end
brief_image() click to toggle source
# File lib/adlint/cc1/type.rb, line 3425
def brief_image
  name
end
compatible?(to_type) click to toggle source
# File lib/adlint/cc1/type.rb, line 3433
def compatible?(to_type)
  to_type.integer? && to_type.min <= min && max <= to_type.max
end
corresponding_signed_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 3549
def corresponding_signed_type
  subclass_responsibility
end
corresponding_unsigned_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 3553
def corresponding_unsigned_type
  subclass_responsibility
end
dup() click to toggle source
# File lib/adlint/cc1/type.rb, line 3557
def dup
  subclass_responsibility
end
enum?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3449
def enum?
  subclass_responsibility
end
enumerators() click to toggle source
# File lib/adlint/cc1/type.rb, line 3469
def enumerators
  subclass_responsibility
end
explicitly_signed?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3465
def explicitly_signed?
  @explicitly_signed
end
floating?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3441
def floating?
  false
end
id() click to toggle source
# File lib/adlint/cc1/type.rb, line 3417
def id
  subclass_responsibility
end
image() click to toggle source
# File lib/adlint/cc1/type.rb, line 3421
def image
  name
end
integer?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3437
def integer?
  true
end
integer_conversion_rank() click to toggle source
# File lib/adlint/cc1/type.rb, line 3489
def integer_conversion_rank
  subclass_responsibility
end
integer_promoted_type() click to toggle source
# File lib/adlint/cc1/type.rb, line 3493
def integer_promoted_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.integer_conversion_rank <= int_t.integer_conversion_rank
    self.compatible?(int_t) ? int_t : unsigned_int_t
  else
    self
  end
end
location() click to toggle source
# File lib/adlint/cc1/type.rb, line 3429
def location
  nil
end
max() click to toggle source
# File lib/adlint/cc1/type.rb, line 3481
def max
  if @signed
    2**(@bit_size - 1) - 1
  else
    2**@bit_size - 1
  end
end
min() click to toggle source
# File lib/adlint/cc1/type.rb, line 3473
def min
  if @signed
    -2**(@bit_size - 1)
  else
    0
  end
end
pointer?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3445
def pointer?
  subclass_responsibility
end
signed?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3461
def signed?
  @signed
end
standard?() click to toggle source
# File lib/adlint/cc1/type.rb, line 3453
def standard?
  subclass_responsibility
end