Class: IDL::Type::Array

Inherits:
IDL::Type show all
Defined in:
lib/ridl/type.rb

Constant Summary

Constants inherited from IDL::Type

Long, LongLong, Octet, Short, TinyShort, ULong, ULongLong, UShort, UTinyShort

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from IDL::Type

#is_node?, #resolved_node, #resolved_type, #typeerror

Constructor Details

#initialize(t, sizes) ⇒ Array

Returns a new instance of Array.



468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/ridl/type.rb', line 468

def initialize(t, sizes)
  raise "Anonymous type definitions are not allowed!" if t.is_anonymous?

  @basetype = t
  if sizes.nil?
    @sizes = []
    @typename = t.typename + "[]"
  else
    @sizes = sizes
    @typename = t.typename + sizes.collect { |s| "[#{IDL::Expression::ScopedName === s ? s.node.name : s.to_s}]" }.join
  end
end

Instance Attribute Details

#basetypeObject (readonly)

Returns the value of attribute basetype.



466
467
468
# File 'lib/ridl/type.rb', line 466

def basetype
  @basetype
end

#sizesObject (readonly)

Returns the value of attribute sizes.



466
467
468
# File 'lib/ridl/type.rb', line 466

def sizes
  @sizes
end

Instance Method Details

#instantiate(instantiation_context) ⇒ Object



509
510
511
# File 'lib/ridl/type.rb', line 509

def instantiate(instantiation_context)
  self.is_template? ? Type::Array.new(@basetype.instantiate(instantiation_context), @sizes.collect { |sz| sz.instantiate(instantiation_context).value }) : self
end

#is_anonymous?Boolean

Returns:



497
498
499
# File 'lib/ridl/type.rb', line 497

def is_anonymous?
  true
end

#is_complete?Boolean

Returns:



489
490
491
# File 'lib/ridl/type.rb', line 489

def is_complete?
  @basetype.resolved_type.is_complete?
end

#is_local?(recurstk = []) ⇒ Boolean

Returns:



493
494
495
# File 'lib/ridl/type.rb', line 493

def is_local?(recurstk = [])
  @basetype.resolved_type.is_local?(recurstk)
end

#is_template?Boolean

Returns:



501
502
503
# File 'lib/ridl/type.rb', line 501

def is_template?
  @sizes.any? { |sz| (sz.is_a?(IDL::Expression::ScopedName) && sz.node.is_a?(IDL::AST::TemplateParam)) } || @basetype.is_template?
end

#matches?(idltype) ⇒ Boolean

Returns:



505
506
507
# File 'lib/ridl/type.rb', line 505

def matches?(idltype)
  super && self.sizes == idltype.sizes && self.basetype.resolved_type.matches?(idltype.basetype.resolved_type)
end

#narrow(obj) ⇒ Object



485
486
487
# File 'lib/ridl/type.rb', line 485

def narrow(obj)
  typeerror(obj)
end

#typenameObject



481
482
483
# File 'lib/ridl/type.rb', line 481

def typename
  @typename
end