Class: ArrayType
Instance Method Summary
collapse
Methods included from HasType
#clone_type, #initHasType
Methods inherited from Type
#cast, #clear_max, #equal?, #get_ID_str, #get_bit_size, #get_original_type, #is_void?, #print_info, print_info_post, #print_info_post, reset_print_info, #set_scs
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
Returns a new instance of ArrayType.
[View source]
1207
1208
1209
1210
1211
|
# File 'lib/tecsgen/core/types.rb', line 1207
def initialize(subscript = nil)
super()
@subscript = subscript
initHasType
end
|
Instance Method Details
[View source]
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
|
# File 'lib/tecsgen/core/types.rb', line 1259
def check if @type.class == FuncType return "array of function"
elsif @type.class == ArrayType unless @type.get_subscript
return "subscript not specified"
end
end
return @type.check end
|
permalink
#check_init(locale, ident, initializer, kind, attribute = nil) ⇒ Object
[View source]
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
|
# File 'lib/tecsgen/core/types.rb', line 1275
def check_init(locale, ident, initializer, kind, attribute = nil)
if initializer.instance_of?(Array)
if @subscript
n_sub = @subscript.eval_const(nil)
if n_sub
if initializer.length > n_sub
cdl_error2(locale, "T9999 $1: too many initializer, $2 for $3", ident, initializer.length, n_sub)
end
end
end
index = 0
initializer.each{|i|
@type.check_init(locale, "#{ident}[#{index}]", i, kind, attribute = nil)
index += 1
}
else
cdl_error2(locale, "T1031 $1: unsuitable initializer for array", ident)
end
end
|
[View source]
1271
1272
1273
|
# File 'lib/tecsgen/core/types.rb', line 1271
def check_struct_tag(kind)
@type.check_struct_tag kind
end
|
[View source]
1242
1243
1244
|
# File 'lib/tecsgen/core/types.rb', line 1242
def get_subscript
@subscript
end
|
[View source]
1238
1239
1240
|
# File 'lib/tecsgen/core/types.rb', line 1238
def get_type
@type
end
|
[View source]
1246
1247
1248
|
# File 'lib/tecsgen/core/types.rb', line 1246
def get_type_str
return @type.get_type_str.to_s
end
|
[View source]
1250
1251
1252
1253
1254
1255
1256
1257
|
# File 'lib/tecsgen/core/types.rb', line 1250
def get_type_str_post
if @subscript
"[#{@subscript.eval_const(nil)}]#{@type.get_type_str_post}"
else
"[]#{@type.get_type_str_post}"
end
end
|
permalink
#has_pointer? ⇒ Boolean
[View source]
1296
1297
1298
|
# File 'lib/tecsgen/core/types.rb', line 1296
def has_pointer?
@type.has_pointer?
end
|
permalink
#has_sized_pointer? ⇒ Boolean
[View source]
1300
1301
1302
|
# File 'lib/tecsgen/core/types.rb', line 1300
def has_sized_pointer?
@type.has_sized_pointer?
end
|
permalink
#has_unsized_string? ⇒ Boolean
[View source]
1304
1305
1306
|
# File 'lib/tecsgen/core/types.rb', line 1304
def has_unsized_string?
@type.has_unsized_string?
end
|
permalink
#is_const? ⇒ Boolean
[View source]
1229
1230
1231
|
# File 'lib/tecsgen/core/types.rb', line 1229
def is_const?
@type.is_const?
end
|
permalink
#is_volatile? ⇒ Boolean
配列要素が volatile なら volatile
[View source]
1234
1235
1236
|
# File 'lib/tecsgen/core/types.rb', line 1234
def is_volatile?
@type.is_volatile?
end
|
Array#qualifier(const, volatile) の設定
[View source]
1222
1223
1224
1225
1226
|
# File 'lib/tecsgen/core/types.rb', line 1222
def set_qualifier(qualifier)
clone_type
@type.set_qualifier(qualifier)
super
end
|
[View source]
1213
1214
1215
1216
1217
1218
1219
|
# File 'lib/tecsgen/core/types.rb', line 1213
def set_type(type)
unless @type
@type = type
else
@type.set_type(type)
end
end
|
[View source]
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
|
# File 'lib/tecsgen/core/types.rb', line 1308
def show_tree(indent)
indent.times { print " " }
puts "ArrayType: #{locale_str}"
super(indent + 1)
(indent + 1).times { print " " }
puts "type:"
@type.show_tree(indent + 2)
(indent + 1).times { print " " }
puts "subscript:"
if @subscript
@subscript.show_tree(indent + 2)
else
(indent + 2).times { print " " }
puts "no subscript"
end
end
|