Class: AdLint::Cc1::ArrayValue
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from SingleValue
#multiple?, #test_may_be_undefined, #test_must_be_undefined, #to_single_value
Methods inherited from Value
#multiple?, #test_may_be_undefined, #test_must_be_undefined, #to_single_value
#unique_sample
Constructor Details
Returns a new instance of ArrayValue.
883
884
885
|
# File 'lib/adlint/cc1/value.rb', line 883
def initialize(vals)
@values = vals
end
|
Instance Attribute Details
Returns the value of attribute values.
887
888
889
|
# File 'lib/adlint/cc1/value.rb', line 887
def values
@values
end
|
Instance Method Details
1077
1078
1079
1080
1081
1082
|
# File 'lib/adlint/cc1/value.rb', line 1077
def !
scalar_value_of_false end
|
#!=(rhs_val) ⇒ Object
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
|
# File 'lib/adlint/cc1/value.rb', line 1144
def !=(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs != rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#%(rhs_val) ⇒ Object
1035
1036
1037
1038
1039
1040
|
# File 'lib/adlint/cc1/value.rb', line 1035
def %(rhs_val)
dup end
|
#&(rhs_val) ⇒ Object
1042
1043
1044
1045
1046
1047
|
# File 'lib/adlint/cc1/value.rb', line 1042
def &(rhs_val)
dup end
|
#*(rhs_val) ⇒ Object
1021
1022
1023
1024
1025
1026
|
# File 'lib/adlint/cc1/value.rb', line 1021
def *(rhs_val)
dup end
|
#+(rhs_val) ⇒ Object
1007
1008
1009
1010
1011
1012
|
# File 'lib/adlint/cc1/value.rb', line 1007
def +(rhs_val)
dup end
|
993
994
995
996
997
998
|
# File 'lib/adlint/cc1/value.rb', line 993
def +@
dup end
|
#-(rhs_val) ⇒ Object
1014
1015
1016
1017
1018
1019
|
# File 'lib/adlint/cc1/value.rb', line 1014
def -(rhs_val)
dup end
|
1000
1001
1002
1003
1004
1005
|
# File 'lib/adlint/cc1/value.rb', line 1000
def -@
dup end
|
#/(rhs_val) ⇒ Object
1028
1029
1030
1031
1032
1033
|
# File 'lib/adlint/cc1/value.rb', line 1028
def /(rhs_val)
dup end
|
#<(rhs_val) ⇒ Object
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
|
# File 'lib/adlint/cc1/value.rb', line 1084
def <(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs < rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#<<(rhs_val) ⇒ Object
1063
1064
1065
1066
1067
1068
|
# File 'lib/adlint/cc1/value.rb', line 1063
def <<(rhs_val)
dup end
|
#<=(rhs_val) ⇒ Object
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
|
# File 'lib/adlint/cc1/value.rb', line 1164
def <=(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs <= rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#==(rhs_val) ⇒ Object
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
|
# File 'lib/adlint/cc1/value.rb', line 1124
def ==(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs == rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#>(rhs_val) ⇒ Object
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
|
# File 'lib/adlint/cc1/value.rb', line 1104
def >(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs > rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#>=(rhs_val) ⇒ Object
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
|
# File 'lib/adlint/cc1/value.rb', line 1184
def >=(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs >= rhs)
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#>>(rhs_val) ⇒ Object
1070
1071
1072
1073
1074
1075
|
# File 'lib/adlint/cc1/value.rb', line 1070
def >>(rhs_val)
dup end
|
#^(rhs_val) ⇒ Object
1056
1057
1058
1059
1060
1061
|
# File 'lib/adlint/cc1/value.rb', line 1056
def ^(rhs_val)
dup end
|
#ambiguous? ⇒ Boolean
926
927
928
|
# File 'lib/adlint/cc1/value.rb', line 926
def ambiguous?
@values.empty? ? false : @values.all? { |val| val.ambiguous? }
end
|
#array? ⇒ Boolean
893
894
895
|
# File 'lib/adlint/cc1/value.rb', line 893
def array?
true
end
|
#coerce_to(type) ⇒ Object
1357
1358
1359
|
# File 'lib/adlint/cc1/value.rb', line 1357
def coerce_to(type)
type.coerce_array_value(self)
end
|
#composite? ⇒ Boolean
897
898
899
|
# File 'lib/adlint/cc1/value.rb', line 897
def composite?
false
end
|
#contain?(val) ⇒ Boolean
909
910
911
912
913
914
915
916
917
918
919
920
|
# File 'lib/adlint/cc1/value.rb', line 909
def contain?(val)
case sval = val.to_single_value
when ArrayValue
if @values.size == sval.values.size
@values.zip(sval.values).all? { |lhs, rhs| lhs.contain?(rhs) }
else
false
end
else
false
end
end
|
#definite? ⇒ Boolean
905
906
907
|
# File 'lib/adlint/cc1/value.rb', line 905
def definite?
@values.empty? ? true : @values.all? { |val| val.definite? }
end
|
1378
1379
1380
|
# File 'lib/adlint/cc1/value.rb', line 1378
def dup
ArrayValue.new(@values.map { |val| val.dup })
end
|
#eql?(rhs_val) ⇒ Boolean
1370
1371
1372
|
# File 'lib/adlint/cc1/value.rb', line 1370
def eql?(rhs_val)
rhs_val.kind_of?(ArrayValue) && @values.eql?(rhs_val.values)
end
|
#exist? ⇒ Boolean
901
902
903
|
# File 'lib/adlint/cc1/value.rb', line 901
def exist?
@values.empty? ? true : @values.all? { |val| val.exist? }
end
|
1374
1375
1376
|
# File 'lib/adlint/cc1/value.rb', line 1374
def hash
@values.hash
end
|
#invert_domain! ⇒ Object
971
972
973
|
# File 'lib/adlint/cc1/value.rb', line 971
def invert_domain!
@values.each { |val| val.invert_domain! }
end
|
#logical_and(rhs_val) ⇒ Object
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
|
# File 'lib/adlint/cc1/value.rb', line 1204
def logical_and(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs.logical_and(rhs))
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#logical_or(rhs_val) ⇒ Object
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
|
# File 'lib/adlint/cc1/value.rb', line 1224
def logical_or(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
if @values.size == rhs_sval.values.size
zipped = @values.zip(rhs_sval.values)
zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
rslt_val.single_value_unified_with(lhs.logical_or(rhs))
end
else
scalar_value_of_false
end
else
raise TypeError, "comparison between array and non-array."
end
end
|
#narrow_domain!(op, ope_val) ⇒ Object
941
942
943
944
945
946
947
948
949
950
951
952
953
954
|
# File 'lib/adlint/cc1/value.rb', line 941
def narrow_domain!(op, ope_val)
case ope_sval = ope_val.to_single_value
when ArrayValue
@values.zip(ope_sval.values).each do |lhs, rhs|
if rhs
lhs.narrow_domain!(op, rhs)
else
next
end
end
else
raise TypeError, "cannot narrow array value domain with non-array."
end
end
|
#overwrite!(val, tag) ⇒ Object
930
931
932
933
934
935
936
937
938
939
|
# File 'lib/adlint/cc1/value.rb', line 930
def overwrite!(val, tag)
case sval = val.to_single_value
when ArrayValue
@values.zip(sval.values).each do |lhs, rhs|
rhs && lhs.overwrite!(rhs, tag)
end
else
raise TypeError, "cannot overwrite array with non-array."
end
end
|
#scalar? ⇒ Boolean
889
890
891
|
# File 'lib/adlint/cc1/value.rb', line 889
def scalar?
false
end
|
#single_value_unified_with(rhs_val) ⇒ Object
975
976
977
978
979
980
981
982
983
984
|
# File 'lib/adlint/cc1/value.rb', line 975
def single_value_unified_with(rhs_val)
case rhs_sval = rhs_val.to_single_value
when ArrayValue
ArrayValue.new(@values.zip(rhs_sval.values).map { |lhs, rhs|
lhs.single_value_unified_with(rhs)
})
else
raise TypeError, "cannot unify array value with non-array."
end
end
|
#test_may_be_equal_to(val) ⇒ Object
1253
1254
1255
1256
1257
1258
1259
1260
|
# File 'lib/adlint/cc1/value.rb', line 1253
def test_may_be_equal_to(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self == sval).test_may_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_may_be_false ⇒ Object
1349
1350
1351
1352
1353
1354
1355
|
# File 'lib/adlint/cc1/value.rb', line 1349
def test_may_be_false
TrivialValueTest.new(@values.all? { |val| val.test_may_be_false.result })
end
|
#test_may_be_greater_than(val) ⇒ Object
1307
1308
1309
1310
1311
1312
1313
1314
|
# File 'lib/adlint/cc1/value.rb', line 1307
def test_may_be_greater_than(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self > sval).test_may_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_may_be_less_than(val) ⇒ Object
1289
1290
1291
1292
1293
1294
1295
1296
|
# File 'lib/adlint/cc1/value.rb', line 1289
def test_may_be_less_than(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self < sval).test_may_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_may_be_null ⇒ Object
1320
1321
1322
|
# File 'lib/adlint/cc1/value.rb', line 1320
def test_may_be_null
TrivialValueTest.new(@values.all? { |val| val.test_may_be_null.result })
end
|
#test_may_be_true ⇒ Object
1332
1333
1334
1335
1336
1337
1338
|
# File 'lib/adlint/cc1/value.rb', line 1332
def test_may_be_true
TrivialValueTest.new(@values.all? { |val| val.test_may_be_true.result })
end
|
#test_may_not_be_equal_to(val) ⇒ Object
1271
1272
1273
1274
1275
1276
1277
1278
|
# File 'lib/adlint/cc1/value.rb', line 1271
def test_may_not_be_equal_to(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self != sval).test_may_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_must_be_equal_to(val) ⇒ Object
1244
1245
1246
1247
1248
1249
1250
1251
|
# File 'lib/adlint/cc1/value.rb', line 1244
def test_must_be_equal_to(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self == sval).test_must_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_must_be_false ⇒ Object
1340
1341
1342
1343
1344
1345
1346
1347
|
# File 'lib/adlint/cc1/value.rb', line 1340
def test_must_be_false
TrivialValueTest.new(
@values.all? { |val| val.test_must_be_false.result })
end
|
#test_must_be_greater_than(val) ⇒ Object
1298
1299
1300
1301
1302
1303
1304
1305
|
# File 'lib/adlint/cc1/value.rb', line 1298
def test_must_be_greater_than(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self > sval).test_must_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_must_be_less_than(val) ⇒ Object
1280
1281
1282
1283
1284
1285
1286
1287
|
# File 'lib/adlint/cc1/value.rb', line 1280
def test_must_be_less_than(val)
case sval = value.to_single_value
when ArrayValue
TrivialValueTest.new((self < sval).test_must_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#test_must_be_null ⇒ Object
1316
1317
1318
|
# File 'lib/adlint/cc1/value.rb', line 1316
def test_must_be_null
TrivialValueTest.new(@values.all? { |val| val.test_must_be_null.result })
end
|
#test_must_be_true ⇒ Object
1324
1325
1326
1327
1328
1329
1330
|
# File 'lib/adlint/cc1/value.rb', line 1324
def test_must_be_true
TrivialValueTest.new(@values.all? { |val| val.test_must_be_true.result })
end
|
#test_must_not_be_equal_to(val) ⇒ Object
1262
1263
1264
1265
1266
1267
1268
1269
|
# File 'lib/adlint/cc1/value.rb', line 1262
def test_must_not_be_equal_to(val)
case sval = val.to_single_value
when ArrayValue
TrivialValueTest.new((self != sval).test_must_be_true.result)
else
raise TypeError, "comparison between array and non-array."
end
end
|
#to_defined_value ⇒ Object
1366
1367
1368
|
# File 'lib/adlint/cc1/value.rb', line 1366
def to_defined_value
ArrayValue.new(@values.map { |val| val.to_defined_value })
end
|
1361
1362
1363
1364
|
# File 'lib/adlint/cc1/value.rb', line 1361
def to_enum
@values.map { |val| val.to_enum.first }
end
|
#undefined? ⇒ Boolean
922
923
924
|
# File 'lib/adlint/cc1/value.rb', line 922
def undefined?
@values.empty? ? false : @values.all? { |val| val.undefined? }
end
|
#widen_domain!(op, ope_val) ⇒ Object
956
957
958
959
960
961
962
963
964
965
966
967
968
969
|
# File 'lib/adlint/cc1/value.rb', line 956
def widen_domain!(op, ope_val)
case ope_sval = ope_val.to_single_value
when ArrayValue
@values.zip(ope_sval.values).each do |lhs, rhs|
if rhs
lhs.widen_domain!(op, rhs)
else
next
end
end
else
raise TypeError, "cannot widen array value domain with non-array."
end
end
|
#|(rhs_val) ⇒ Object
1049
1050
1051
1052
1053
1054
|
# File 'lib/adlint/cc1/value.rb', line 1049
def |(rhs_val)
dup end
|
986
987
988
989
990
991
|
# File 'lib/adlint/cc1/value.rb', line 986
def ~
dup end
|