Class: DefinedType

Inherits:
Type show all
Includes:
HasType
Defined in:
lib/tecsgen/core/types.rb

Direct Known Subclasses

CDefinedType

Instance Method Summary collapse

Methods included from HasType

#clone_type, #initHasType

Methods inherited from Type

#cast, #check_struct_tag, #equal?, #get_ID_str, #get_bit_size, #is_const?, #is_void?, #is_volatile?, #print_info, print_info_post, #print_info_post, reset_print_info

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

#initialize(type_name) ⇒ DefinedType

Returns a new instance of DefinedType.



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/tecsgen/core/types.rb', line 246

def initialize(type_name)
  super()
  @type_name = type_name

  # mikan type_name が path になっていないため暫定
  @typedef = Namespace.find([type_name]) # 1

#    if @type.class != Typedef then
#      raise NotTypedef
  #    end
  if @typedef.nil?
    cdl_error("T1005 \'$1\' not defined", type_name)
  elsif @typedef.class != Typedef
    cdl_error("T1006 \'$1\' not type name. expecting type name here", type_name)
  end
  @type = @typedef.get_declarator.get_type
  initHasType
end

Instance Method Details

#checkObject

意味的誤りがあれば、文字列を返す



307
308
309
# File 'lib/tecsgen/core/types.rb', line 307

def check # 意味的誤りがあれば、文字列を返す
  nil # typedef の段階で意味チェックされている
end

#check_init(locale, ident, initializer, kind, attribute = nil) ⇒ Object



311
312
313
# File 'lib/tecsgen/core/types.rb', line 311

def check_init(locale, ident, initializer, kind, attribute = nil)
  get_type.check_init(locale, ident, initializer, kind, attribute)
end

#clear_maxObject



298
299
300
# File 'lib/tecsgen/core/types.rb', line 298

def clear_max
  @type.clear_max
end

#get_original_typeObject



302
303
304
305
# File 'lib/tecsgen/core/types.rb', line 302

def get_original_type
  clone_type
  return @type.get_original_type
end

#get_sizeObject



278
279
280
# File 'lib/tecsgen/core/types.rb', line 278

def get_size
  return @type.get_size
end

#get_typeObject



265
266
267
268
# File 'lib/tecsgen/core/types.rb', line 265

def get_type
  clone_type
  return @type
end

#get_type_strObject



270
271
272
# File 'lib/tecsgen/core/types.rb', line 270

def get_type_str
  "#{super}#{@type_name}"
end

#get_type_str_postObject



274
275
276
# File 'lib/tecsgen/core/types.rb', line 274

def get_type_str_post
  ""
end

#has_pointer?Boolean

内部にポインタ型を持つ

ポインタ型、またはポインタ型メンバを持つ構造体、または要素がポインタ型を持つ配列

Returns:

  • (Boolean)


317
318
319
# File 'lib/tecsgen/core/types.rb', line 317

def has_pointer?
  @type.has_pointer?
end

#has_sized_pointer?Boolean

size_is, count_is, string 指定されたポインタを持つか

size_is, count_is, string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれをを要素に持つ配列

Returns:

  • (Boolean)


323
324
325
# File 'lib/tecsgen/core/types.rb', line 323

def has_sized_pointer?
  @type.has_sized_pointer?
end

#has_unsized_string?Boolean

長さ指定のない string を持つ

なさ指定のない string 指定されたポインタ型、またはそれをメンバに持つ構造体、またはそれを要素に持つ配列

Returns:

  • (Boolean)


329
330
331
# File 'lib/tecsgen/core/types.rb', line 329

def has_unsized_string?
  @type.has_unsized_string?
end

#is_nullable?Boolean

Returns:

  • (Boolean)


282
283
284
# File 'lib/tecsgen/core/types.rb', line 282

def is_nullable?
  return @type.is_nullable?
end

#set_qualifier(qualifier) ⇒ Object

qualifier(const, volatile) の設定



287
288
289
290
291
# File 'lib/tecsgen/core/types.rb', line 287

def set_qualifier(qualifier)
  clone_type
  @type.set_qualifier(qualifier)
  super
end

#set_scs(size, count, string, max = nil, b_nullable = false) ⇒ Object



293
294
295
296
# File 'lib/tecsgen/core/types.rb', line 293

def set_scs(size, count, string, max = nil, b_nullable = false)
  clone_type
  @type.set_scs(size, count, string, max, b_nullable)
end

#show_tree(indent) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
# File 'lib/tecsgen/core/types.rb', line 333

def show_tree(indent)
  indent.times { print "  " }
  if @typedef.nil?
    puts "DefinedType: #{@type_name} is missing, const=#{@b_const} volatile=#{@b_volatile} #{locale_str}"
  else
    puts "DefinedType: #{@type_name}, const=#{@b_const} volatile=#{@b_volatile}"
  end
  super(indent + 1)
  @typedef.show_tree(indent + 1)
  @type.show_tree(indent + 1)
end