Class: AdLint::Cc1::ArrayType

Inherits:
Type
  • Object
show all
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

#==, #aligned_byte_size, #byte_alignment, #byte_size, #composite?, #inspect, #more_cv_qualified?, #parameter?, #unsigned?

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, len = nil) ⇒ ArrayType

Returns a new instance of ArrayType.



5528
5529
5530
5531
5532
# File 'lib/adlint/cc1/type.rb', line 5528

def initialize(type_tbl, base_type, len = nil)
  super(type_tbl, create_name(base_type, len))
  @base_type = base_type
  @length = len
end

Instance Attribute Details

#base_typeObject (readonly)

Returns the value of attribute base_type.



5534
5535
5536
# File 'lib/adlint/cc1/type.rb', line 5534

def base_type
  @base_type
end

#lengthObject

NOTE: Length of the array type may be deducted by the size of the

initializer in interpret phase.


5538
5539
5540
# File 'lib/adlint/cc1/type.rb', line 5538

def length
  @length
end

Instance Method Details

#_arithmetic_type_with_array(lhs_type, rhs_type = self) ⇒ Object



6067
6068
6069
6070
# File 'lib/adlint/cc1/type.rb', line 6067

def _arithmetic_type_with_array(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_bitfield(lhs_type, rhs_type = self) ⇒ Object



6047
6048
6049
6050
6051
6052
# File 'lib/adlint/cc1/type.rb', line 6047

def _arithmetic_type_with_bitfield(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with BitfieldType and ArrayType
  #       makes integer-promoted type of BitfieldType.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_char(lhs_type, rhs_type = self) ⇒ Object



5851
5852
5853
5854
5855
5856
# File 'lib/adlint/cc1/type.rb', line 5851

def _arithmetic_type_with_char(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `char' and ArrayType
  #       makes integer-promoted type of `char'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_double(lhs_type, rhs_type = self) ⇒ Object



6034
6035
6036
6037
6038
# File 'lib/adlint/cc1/type.rb', line 6034

def _arithmetic_type_with_double(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `double' and ArrayType makes `double'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_enum(lhs_type, rhs_type = self) ⇒ Object



6054
6055
6056
6057
6058
# File 'lib/adlint/cc1/type.rb', line 6054

def _arithmetic_type_with_enum(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with EnumType and ArrayType makes EnumType.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_extended_big_int(lhs_type, rhs_type = self) ⇒ Object



6082
6083
6084
6085
6086
6087
# File 'lib/adlint/cc1/type.rb', line 6082

def _arithmetic_type_with_extended_big_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with ExtendedBigIntType and ArrayType
  #       makes ExtendedBigIntType.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_float(lhs_type, rhs_type = self) ⇒ Object



6028
6029
6030
6031
6032
# File 'lib/adlint/cc1/type.rb', line 6028

def _arithmetic_type_with_float(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `float' and ArrayType makes `float'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_function(lhs_type, rhs_type = self) ⇒ Object



5847
5848
5849
# File 'lib/adlint/cc1/type.rb', line 5847

def _arithmetic_type_with_function(lhs_type, rhs_type = self)
  rhs_type.arithmetic_type_with(lhs_type)
end

#_arithmetic_type_with_int(lhs_type, rhs_type = self) ⇒ Object



5914
5915
5916
5917
5918
# File 'lib/adlint/cc1/type.rb', line 5914

def _arithmetic_type_with_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `int' and ArrayType makes `int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_long(lhs_type, rhs_type = self) ⇒ Object



5946
5947
5948
5949
5950
# File 'lib/adlint/cc1/type.rb', line 5946

def _arithmetic_type_with_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `long' and ArrayType makes `long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_long_double(lhs_type, rhs_type = self) ⇒ Object



6040
6041
6042
6043
6044
6045
# File 'lib/adlint/cc1/type.rb', line 6040

def _arithmetic_type_with_long_double(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `long double' and ArrayType
  #       makes `long double'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_long_int(lhs_type, rhs_type = self) ⇒ Object



5966
5967
5968
5969
5970
# File 'lib/adlint/cc1/type.rb', line 5966

def _arithmetic_type_with_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `long int' and ArrayType makes `long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_long_long(lhs_type, rhs_type = self) ⇒ Object



5986
5987
5988
5989
5990
5991
# File 'lib/adlint/cc1/type.rb', line 5986

def _arithmetic_type_with_long_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `long long' and ArrayType makes
  #       `long long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_long_long_int(lhs_type, rhs_type = self) ⇒ Object



6007
6008
6009
6010
6011
6012
# File 'lib/adlint/cc1/type.rb', line 6007

def _arithmetic_type_with_long_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `long long int' and ArrayType
  #       makes `long long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_pointer(lhs_type, rhs_type = self) ⇒ Object



6060
6061
6062
6063
6064
6065
# File 'lib/adlint/cc1/type.rb', line 6060

def _arithmetic_type_with_pointer(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with PointerType and ArrayType makes
  #       PointerType.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_short(lhs_type, rhs_type = self) ⇒ Object



5872
5873
5874
5875
5876
5877
# File 'lib/adlint/cc1/type.rb', line 5872

def _arithmetic_type_with_short(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `short' and ArrayType
  #       makes integer-promoted type of `short'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_short_int(lhs_type, rhs_type = self) ⇒ Object



5893
5894
5895
5896
5897
5898
# File 'lib/adlint/cc1/type.rb', line 5893

def _arithmetic_type_with_short_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `short int' and ArrayType
  #       makes integer-promoted type of `short int'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_signed(lhs_type, rhs_type = self) ⇒ Object



5920
5921
5922
5923
5924
# File 'lib/adlint/cc1/type.rb', line 5920

def _arithmetic_type_with_signed(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed' and ArrayType makes `signed'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_char(lhs_type, rhs_type = self) ⇒ Object



5858
5859
5860
5861
5862
5863
# File 'lib/adlint/cc1/type.rb', line 5858

def _arithmetic_type_with_signed_char(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed char' and ArrayType
  #       makes integer-promoted type of `signed char'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_signed_int(lhs_type, rhs_type = self) ⇒ Object



5926
5927
5928
5929
5930
5931
# File 'lib/adlint/cc1/type.rb', line 5926

def _arithmetic_type_with_signed_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed int' and ArrayType
  #       makes `signed int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_long(lhs_type, rhs_type = self) ⇒ Object



5952
5953
5954
5955
5956
5957
# File 'lib/adlint/cc1/type.rb', line 5952

def _arithmetic_type_with_signed_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed long' and ArrayType
  #       makes `signed long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_long_int(lhs_type, rhs_type = self) ⇒ Object



5972
5973
5974
5975
5976
5977
# File 'lib/adlint/cc1/type.rb', line 5972

def _arithmetic_type_with_signed_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed long int' and ArrayType
  #       makes `signed long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_long_long(lhs_type, rhs_type = self) ⇒ Object



5993
5994
5995
5996
5997
5998
# File 'lib/adlint/cc1/type.rb', line 5993

def _arithmetic_type_with_signed_long_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed long long' and ArrayType
  #       makes `signed long long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_long_long_int(lhs_type, rhs_type = self) ⇒ Object



6014
6015
6016
6017
6018
6019
# File 'lib/adlint/cc1/type.rb', line 6014

def _arithmetic_type_with_signed_long_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed long long int' and ArrayType
  #       makes `signed long long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_signed_short(lhs_type, rhs_type = self) ⇒ Object



5879
5880
5881
5882
5883
5884
# File 'lib/adlint/cc1/type.rb', line 5879

def _arithmetic_type_with_signed_short(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed short' and ArrayType
  #       makes integer-promoted type of `signed short'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_signed_short_int(lhs_type, rhs_type = self) ⇒ Object



5900
5901
5902
5903
5904
5905
# File 'lib/adlint/cc1/type.rb', line 5900

def _arithmetic_type_with_signed_short_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `signed short int' and ArrayType
  #       makes integer-promoted type of `signed short int'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_struct(lhs_type, rhs_type = self) ⇒ Object



6072
6073
6074
6075
# File 'lib/adlint/cc1/type.rb', line 6072

def _arithmetic_type_with_struct(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_undeclared(lhs_type, rhs_type = self) ⇒ Object



5835
5836
5837
# File 'lib/adlint/cc1/type.rb', line 5835

def _arithmetic_type_with_undeclared(lhs_type, rhs_type = self)
  rhs_type.arithmetic_type_with(lhs_type)
end

#_arithmetic_type_with_union(lhs_type, rhs_type = self) ⇒ Object



6077
6078
6079
6080
# File 'lib/adlint/cc1/type.rb', line 6077

def _arithmetic_type_with_union(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unresolved(lhs_type, rhs_type = self) ⇒ Object



5839
5840
5841
# File 'lib/adlint/cc1/type.rb', line 5839

def _arithmetic_type_with_unresolved(lhs_type, rhs_type = self)
  rhs_type.arithmetic_type_with(lhs_type)
end

#_arithmetic_type_with_unsigned(lhs_type, rhs_type = self) ⇒ Object



5933
5934
5935
5936
5937
# File 'lib/adlint/cc1/type.rb', line 5933

def _arithmetic_type_with_unsigned(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned' and ArrayType makes `unsigned'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_char(lhs_type, rhs_type = self) ⇒ Object



5865
5866
5867
5868
5869
5870
# File 'lib/adlint/cc1/type.rb', line 5865

def _arithmetic_type_with_unsigned_char(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned char' and ArrayType
  #       makes integer-promoted type of `unsigned char'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_int(lhs_type, rhs_type = self) ⇒ Object



5939
5940
5941
5942
5943
5944
# File 'lib/adlint/cc1/type.rb', line 5939

def _arithmetic_type_with_unsigned_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned int' and ArrayType
  #       makes `unsigned int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_long(lhs_type, rhs_type = self) ⇒ Object



5959
5960
5961
5962
5963
5964
# File 'lib/adlint/cc1/type.rb', line 5959

def _arithmetic_type_with_unsigned_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned long' and ArrayType
  #       makes `unsigned long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_long_int(lhs_type, rhs_type = self) ⇒ Object



5979
5980
5981
5982
5983
5984
# File 'lib/adlint/cc1/type.rb', line 5979

def _arithmetic_type_with_unsigned_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned long int' and ArrayType
  #       makes `unsigned long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_long_long(lhs_type, rhs_type = self) ⇒ Object



6000
6001
6002
6003
6004
6005
# File 'lib/adlint/cc1/type.rb', line 6000

def _arithmetic_type_with_unsigned_long_long(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned long long' and ArrayType
  #       makes `unsigned long long'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_long_long_int(lhs_type, rhs_type = self) ⇒ Object



6021
6022
6023
6024
6025
6026
# File 'lib/adlint/cc1/type.rb', line 6021

def _arithmetic_type_with_unsigned_long_long_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned long long int' and ArrayType
  #       makes `unsigned long long int'.
  lhs_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_short(lhs_type, rhs_type = self) ⇒ Object



5886
5887
5888
5889
5890
5891
# File 'lib/adlint/cc1/type.rb', line 5886

def _arithmetic_type_with_unsigned_short(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned short' and ArrayType
  #       makes integer-promoted type of `unsigned short'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_unsigned_short_int(lhs_type, rhs_type = self) ⇒ Object



5907
5908
5909
5910
5911
5912
# File 'lib/adlint/cc1/type.rb', line 5907

def _arithmetic_type_with_unsigned_short_int(lhs_type, rhs_type = self)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  # NOTE: Binary operation with `unsigned short int' and ArrayType
  #       makes integer-promoted type of `unsigned short int'.
  lhs_type.integer_promoted_type # NOTREACHED
end

#_arithmetic_type_with_void(lhs_type, rhs_type = self) ⇒ Object



5843
5844
5845
# File 'lib/adlint/cc1/type.rb', line 5843

def _arithmetic_type_with_void(lhs_type, rhs_type = self)
  rhs_type.arithmetic_type_with(lhs_type)
end

#aligned_bit_sizeObject



5576
5577
5578
# File 'lib/adlint/cc1/type.rb', line 5576

def aligned_bit_size
  @length ? @base_type.aligned_bit_size * @length : 0
end

#arbitrary_valueObject



5761
5762
5763
# File 'lib/adlint/cc1/type.rb', line 5761

def arbitrary_value
  ArrayValue.new(impl_length.times.map { @base_type.arbitrary_value })
end

#argument_promoted_typeObject



5826
5827
5828
# File 'lib/adlint/cc1/type.rb', line 5826

def argument_promoted_type
  self # NOTREACHED
end

#arithmetic_type_with(type) ⇒ Object



5830
5831
5832
5833
# File 'lib/adlint/cc1/type.rb', line 5830

def arithmetic_type_with(type)
  # NOTE: An arithmetic operation with ArrayType must not be executed!
  type._arithmetic_type_with_array(self) # NOTREACHED
end

#array?Boolean

Returns:

  • (Boolean)


5649
5650
5651
# File 'lib/adlint/cc1/type.rb', line 5649

def array?
  true
end

#bit_alignmentObject



5572
5573
5574
# File 'lib/adlint/cc1/type.rb', line 5572

def bit_alignment
  aligned_bit_size
end

#bit_sizeObject



5568
5569
5570
# File 'lib/adlint/cc1/type.rb', line 5568

def bit_size
  @length ? @base_type.bit_size * @length : 0
end

#bitfield?Boolean

Returns:

  • (Boolean)


5709
5710
5711
# File 'lib/adlint/cc1/type.rb', line 5709

def bitfield?
  false
end

#brief_imageObject



5556
5557
5558
# File 'lib/adlint/cc1/type.rb', line 5556

def brief_image
  create_brief_image(@base_type, @length)
end

#coerce_array_value(val) ⇒ Object



5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
# File 'lib/adlint/cc1/type.rb', line 5782

def coerce_array_value(val)
  # NOTE: The ISO C99 standard says;
  #
  # 6.7.8 Initialization
  #
  # Semantics
  #
  # 10 If an object that has automatic storage duration is not initialized
  #    explicitly, its value is indeterminate.  If an object that has
  #    static storage duration is not initialized explicitly, then:
  #
  #    -- if it has pointer type, it is initialized to a null pointer;
  #    -- if it has arithmetic type, it is initialized to (positive or
  #       unsigned) zero;
  #    -- if it is an aggregate, every member is initialized (recursively)
  #       according to these rules;
  #    -- if it is a union, the first named member is initialized
  #       (recursively) according to these rules.
  #
  # 21 If there are fewer initializers in a brace-enclosed list than there
  #    are elements or members of an aggregate, or fewer characters in a
  #    string literal used to initialize an array of known size that there
  #    are elements in the array, the remainder of the aggregate shall be
  #    initialized implicitly the same as objects that have static storage
  #    duration.
  vals = ([@base_type] * impl_length).zip(val.values).map { |type, v|
    v ? v.coerce_to(type) : type.arbitrary_value
  }
  ArrayValue.new(vals)
end

#coerce_composite_value(val) ⇒ Object



5813
5814
5815
5816
# File 'lib/adlint/cc1/type.rb', line 5813

def coerce_composite_value(val)
  # NOTE: Cannot coerce composite value into array in C language.
  undefined_value # NOTREACHED
end

#coerce_scalar_value(val) ⇒ Object



5777
5778
5779
5780
# File 'lib/adlint/cc1/type.rb', line 5777

def coerce_scalar_value(val)
  # NOTE: Cannot coerce scalar value into array in C language.
  undefined_value # NOTREACHED
end

#coercible?(to_type) ⇒ Boolean

Returns:

  • (Boolean)


5597
5598
5599
# File 'lib/adlint/cc1/type.rb', line 5597

def coercible?(to_type)
  to_type.array? && @base_type.coercible?(to_type.base_type)
end

#compatible?(to_type) ⇒ Boolean

Returns:

  • (Boolean)


5592
5593
5594
5595
# File 'lib/adlint/cc1/type.rb', line 5592

def compatible?(to_type)
  to_type.array? &&
    @length == to_type.length && @base_type.compatible?(to_type.base_type)
end

#const?Boolean

Returns:

  • (Boolean)


5697
5698
5699
# File 'lib/adlint/cc1/type.rb', line 5697

def const?
  @base_type.const?
end

#convertible?(to_type) ⇒ Boolean

Returns:

  • (Boolean)


5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
# File 'lib/adlint/cc1/type.rb', line 5601

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



6089
6090
6091
# File 'lib/adlint/cc1/type.rb', line 6089

def corresponding_signed_type
  self # NOTREACHED
end

#corresponding_unsigned_typeObject



6093
6094
6095
# File 'lib/adlint/cc1/type.rb', line 6093

def corresponding_unsigned_type
  self # NOTREACHED
end

#dupObject



6097
6098
6099
# File 'lib/adlint/cc1/type.rb', line 6097

def dup
  ArrayType.new(type_table, @base_type.dup, @length)
end

#enum?Boolean

Returns:

  • (Boolean)


5673
5674
5675
# File 'lib/adlint/cc1/type.rb', line 5673

def enum?
  false
end

#enumeratorsObject



5733
5734
5735
# File 'lib/adlint/cc1/type.rb', line 5733

def enumerators
  []
end

#explicitly_signed?Boolean

Returns:

  • (Boolean)


5717
5718
5719
# File 'lib/adlint/cc1/type.rb', line 5717

def explicitly_signed?
  false
end

#floating?Boolean

Returns:

  • (Boolean)


5645
5646
5647
# File 'lib/adlint/cc1/type.rb', line 5645

def floating?
  false
end

#function?Boolean

Returns:

  • (Boolean)


5669
5670
5671
# File 'lib/adlint/cc1/type.rb', line 5669

def function?
  false
end

#have_va_list?Boolean

Returns:

  • (Boolean)


5721
5722
5723
# File 'lib/adlint/cc1/type.rb', line 5721

def have_va_list?
  false
end

#idObject



5545
5546
5547
5548
5549
5550
# File 'lib/adlint/cc1/type.rb', line 5545

def id
  # NOTE: ID of the array type cannot be cached.
  #       Length of the variable length array will be deducted in the
  #       interpret phase.
  ArrayTypeId.new(@base_type, @length)
end

#imageObject



5552
5553
5554
# File 'lib/adlint/cc1/type.rb', line 5552

def image
  create_image(@base_type, @length)
end

#impl_lengthObject



5540
5541
5542
5543
# File 'lib/adlint/cc1/type.rb', line 5540

def impl_length
  # NOTE: Implementation defined length of this array.
  @length ? [[0, @length].max, MAX_LENGTH].min : 0
end

#incomplete?Boolean

Returns:

  • (Boolean)


5588
5589
5590
# File 'lib/adlint/cc1/type.rb', line 5588

def incomplete?
  @base_type.incomplete? || @length.nil?
end

#integer?Boolean

Returns:

  • (Boolean)


5641
5642
5643
# File 'lib/adlint/cc1/type.rb', line 5641

def integer?
  false
end

#integer_conversion_rankObject



5818
5819
5820
# File 'lib/adlint/cc1/type.rb', line 5818

def integer_conversion_rank
  0 # NOTREACHED
end

#integer_promoted_typeObject



5822
5823
5824
# File 'lib/adlint/cc1/type.rb', line 5822

def integer_promoted_type
  self # NOTREACHED
end

#locationObject



5560
5561
5562
# File 'lib/adlint/cc1/type.rb', line 5560

def location
  nil
end

#maxObject



5749
5750
5751
# File 'lib/adlint/cc1/type.rb', line 5749

def max
  0
end

#member_named(name) ⇒ Object



5741
5742
5743
# File 'lib/adlint/cc1/type.rb', line 5741

def member_named(name)
  nil
end

#membersObject



5737
5738
5739
# File 'lib/adlint/cc1/type.rb', line 5737

def members
  []
end

#minObject



5745
5746
5747
# File 'lib/adlint/cc1/type.rb', line 5745

def min
  0
end

#named?Boolean

Returns:

  • (Boolean)


5564
5565
5566
# File 'lib/adlint/cc1/type.rb', line 5564

def named?
  true
end

#nil_valueObject



5753
5754
5755
# File 'lib/adlint/cc1/type.rb', line 5753

def nil_value
  ArrayValue.new(impl_length.times.map { @base_type.nil_value })
end

#parameter_typesObject



5729
5730
5731
# File 'lib/adlint/cc1/type.rb', line 5729

def parameter_types
  []
end

#parameter_valueObject



5769
5770
5771
# File 'lib/adlint/cc1/type.rb', line 5769

def parameter_value
  ArrayValue.new(impl_length.times.map { @base_type.parameter_value })
end

#pointer?Boolean

Returns:

  • (Boolean)


5661
5662
5663
# File 'lib/adlint/cc1/type.rb', line 5661

def pointer?
  false
end

#qualified?Boolean

Returns:

  • (Boolean)


5665
5666
5667
# File 'lib/adlint/cc1/type.rb', line 5665

def qualified?
  false
end

#real_typeObject



5580
5581
5582
# File 'lib/adlint/cc1/type.rb', line 5580

def real_type
  type_table.array_type(@base_type.real_type, @length)
end

#restrict?Boolean

Returns:

  • (Boolean)


5705
5706
5707
# File 'lib/adlint/cc1/type.rb', line 5705

def restrict?
  @base_type.restrict?
end

#return_typeObject



5725
5726
5727
# File 'lib/adlint/cc1/type.rb', line 5725

def return_type
  nil
end

#return_valueObject



5773
5774
5775
# File 'lib/adlint/cc1/type.rb', line 5773

def return_value
  ArrayValue.new(impl_length.times.map { @base_type.return_value })
end

#same_as?(type) ⇒ Boolean

Returns:

  • (Boolean)


5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
# File 'lib/adlint/cc1/type.rb', line 5619

def same_as?(type)
  lhs_unqualified = self.real_type.unqualify
  rhs_unqualified = type.real_type.unqualify

  case
  when rhs_unqualified.array?
    if lhs_unqualified.length
      lhs_unqualified.length == rhs_unqualified.length
    else
      lhs_unqualified.base_type.same_as?(rhs_unqualified.base_type)
    end
  when rhs_unqualified.pointer?
    lhs_unqualified.base_type.same_as?(rhs_unqualified.base_type)
  else
    false
  end
end

#scalar?Boolean

Returns:

  • (Boolean)


5637
5638
5639
# File 'lib/adlint/cc1/type.rb', line 5637

def scalar?
  false
end

#signed?Boolean

Returns:

  • (Boolean)


5713
5714
5715
# File 'lib/adlint/cc1/type.rb', line 5713

def signed?
  false
end

#standard?Boolean

Returns:

  • (Boolean)


5685
5686
5687
# File 'lib/adlint/cc1/type.rb', line 5685

def standard?
  false
end

#struct?Boolean

Returns:

  • (Boolean)


5653
5654
5655
# File 'lib/adlint/cc1/type.rb', line 5653

def struct?
  false
end

#undeclared?Boolean

Returns:

  • (Boolean)


5689
5690
5691
# File 'lib/adlint/cc1/type.rb', line 5689

def undeclared?
  @base_type.undeclared?
end

#undefined_valueObject



5765
5766
5767
# File 'lib/adlint/cc1/type.rb', line 5765

def undefined_value
  ArrayValue.new(impl_length.times.map { @base_type.undefined_value })
end

#union?Boolean

Returns:

  • (Boolean)


5657
5658
5659
# File 'lib/adlint/cc1/type.rb', line 5657

def union?
  false
end

#unqualifyObject



5584
5585
5586
# File 'lib/adlint/cc1/type.rb', line 5584

def unqualify
  self
end

#unresolved?Boolean

Returns:

  • (Boolean)


5693
5694
5695
# File 'lib/adlint/cc1/type.rb', line 5693

def unresolved?
  @base_type.unresolved?
end

#user?Boolean

Returns:

  • (Boolean)


5677
5678
5679
# File 'lib/adlint/cc1/type.rb', line 5677

def user?
  false
end

#void?Boolean

Returns:

  • (Boolean)


5681
5682
5683
# File 'lib/adlint/cc1/type.rb', line 5681

def void?
  false
end

#volatile?Boolean

Returns:

  • (Boolean)


5701
5702
5703
# File 'lib/adlint/cc1/type.rb', line 5701

def volatile?
  @base_type.volatile?
end

#zero_valueObject



5757
5758
5759
# File 'lib/adlint/cc1/type.rb', line 5757

def zero_value
  ArrayValue.new(impl_length.times.map { @base_type.zero_value })
end