Class: IDL::AST::Component

Inherits:
ComponentBase show all
Defined in:
lib/ridl/node.rb,
lib/ridl/node.rb

Overview

Connector

Constant Summary collapse

NAMETYPE =
:class
DEFINABLE =
[IDL::AST::Attribute, IDL::AST::Port]

Instance Attribute Summary

Attributes inherited from ComponentBase

#base, #idltype, #interfaces

Attributes inherited from Leaf

#annotations, #enclosure, #intern, #lm_name, #name, #prefix, #scopes

Instance Method Summary collapse

Methods inherited from ComponentBase

#add_interfaces, #ancestors, #has_base?, #has_support?, #redefine, #supports?

Methods inherited from Derivable

#has_ancestor?, #search_self, #search_self_before_derived

Methods inherited from Node

#define, #introduce, #is_definable?, #match_members, #redefine, #replace_prefix, #resolve, #select_members, #undo_introduction, #walk_members

Methods inherited from Leaf

#_set_prefix, #has_annotations?, #is_local?, #is_template?, #lm_name_for_scope, #parsed_name_scope, #replace_prefix, #repo_scopes, #repository_id, #resolve, #scoped_lm_name, #scoped_name, #set_repo_id, #set_repo_version, #typename, #unescaped_name

Constructor Details

#initialize(_name, _enclosure, params) ⇒ Component

Returns a new instance of Component.



1474
1475
1476
1477
1478
# File 'lib/ridl/node.rb', line 1474

def initialize(_name, _enclosure, params)
  @idltype = IDL::Type::Component.new(self)
  super(_name, _enclosure, params)
  @defined = !params[:forward]
end

Instance Method Details

#attributes(include_bases = false, traversed = nil) ⇒ Object



1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
# File 'lib/ridl/node.rb', line 1529

def attributes(include_bases=false,traversed=nil)
  atts = @children.inject([]) do |lst, c|
    if IDL::AST::Port === c
      lst.concat(c.attributes)
    else
      lst << c
    end
    lst
  end
  atts.concat(base_attributes(traversed || [])) if include_bases
  atts
end

#instantiate(_context, _enclosure) ⇒ Object



1489
1490
1491
1492
# File 'lib/ridl/node.rb', line 1489

def instantiate(_context, _enclosure)
  # instantiate concrete component def and validate
  super(_context, _enclosure, { :forward => self.is_forward? })
end

#is_defined?Boolean

Returns:

  • (Boolean)


1494
# File 'lib/ridl/node.rb', line 1494

def is_defined?; @defined; end

#is_forward?Boolean

Returns:

  • (Boolean)


1495
# File 'lib/ridl/node.rb', line 1495

def is_forward?; not @defined; end

#marshal_dumpObject



1480
1481
1482
# File 'lib/ridl/node.rb', line 1480

def marshal_dump
  super() << @defined
end

#marshal_load(vars) ⇒ Object



1484
1485
1486
1487
# File 'lib/ridl/node.rb', line 1484

def marshal_load(vars)
  @defined = vars.pop
  super(vars)
end

#operations(include_bases = false, traversed = nil) ⇒ Object



1525
1526
1527
# File 'lib/ridl/node.rb', line 1525

def operations(include_bases=false,traversed=nil)
  include_bases ? base_operations(traversed || []) : []
end

#ports(include_bases = false, traversed = nil) ⇒ Object



1516
1517
1518
1519
1520
1521
1522
1523
# File 'lib/ridl/node.rb', line 1516

def ports(include_bases=false,traversed=nil)
  ports = @children.inject([]) do |lst, c|
    lst.concat(c.ports) if IDL::AST::Port === c
    lst
  end
  ports.concat(base_ports(traversed || [])) if include_bases
  ports
end

#set_base(parent) ⇒ Object



1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
# File 'lib/ridl/node.rb', line 1497

def set_base(parent)
  unless parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(IDL::AST::TemplateParam)
    if not (parent.is_a?(IDL::Type::ScopedName) && parent.is_node?(self.class))
      raise RuntimeError,
            "invalid inheritance identifier for #{typename} #{scoped_lm_name}: #{parent.typename}"
    end
    @resolved_base = parent.resolved_type.node
    if not @resolved_base.is_defined?
      raise RuntimeError,
            "#{typename} #{scoped_lm_name} cannot inherit from forward declared #{parent.node.typename} #{parent.node.scoped_lm_name}"
    end
    if @resolved_base.has_base?(self)
      raise RuntimeError,
            "circular inheritance detected for #{typename} #{scoped_lm_name}: #{parent.node.scoped_lm_name} is descendant"
    end
  end
  @base = parent.node
end