class IDL::AST::Module
Forward declarations
Constants
- DEFINABLE
Attributes
anchor[R]
next[R]
template[R]
template_params[R]
Public Class Methods
new(_name, _enclosure, params)
click to toggle source
Calls superclass method
IDL::AST::Node::new
# File lib/ridl/node.rb, line 394 def initialize(_name, _enclosure, params) super(_name, _enclosure) @anchor = params[:anchor] @prefix = params[:prefix] || @prefix @template = params[:template] @template_params = (params[:template_params] || []).dup @next = nil end
Public Instance Methods
annotations()
click to toggle source
# File lib/ridl/node.rb, line 425 def annotations (has_anchor? ? self.anchor : self).get_annotations end
has_anchor?()
click to toggle source
# File lib/ridl/node.rb, line 403 def has_anchor? !@anchor.nil? end
instantiate(instantiation_context, _enclosure)
click to toggle source
Calls superclass method
IDL::AST::Leaf#instantiate
# File lib/ridl/node.rb, line 439 def instantiate(instantiation_context, _enclosure) super(instantiation_context, _enclosure, {}) end
is_templated?()
click to toggle source
# File lib/ridl/node.rb, line 407 def is_templated? @template ? true : false end
marshal_dump()
click to toggle source
Calls superclass method
IDL::AST::Node#marshal_dump
# File lib/ridl/node.rb, line 429 def marshal_dump super() << @anchor << @next end
marshal_load(vars)
click to toggle source
Calls superclass method
IDL::AST::Node#marshal_load
# File lib/ridl/node.rb, line 433 def marshal_load(vars) @next = vars.pop @anchor = vars.pop super(vars) end
redefine(node, params)
click to toggle source
# File lib/ridl/node.rb, line 443 def redefine(node, params) case node when IDL::AST::Include if node.enclosure == self return node else _inc = IDL::AST::Include.new(node.name, self, params) _inc.annotations.concat(params[:annotations]) @children << _inc return _inc end when IDL::AST::Module # Module reopening _anchor = node.has_anchor? ? node.anchor : node _anchor.annotations.concat(params.delete(:annotations)) _last = _anchor.find_last _params = params.merge({ anchor: _anchor, prefix: node.prefix }) _next = IDL::AST::Module.new(node.name, self, _params) _last.set_next(_next) @children << _next return _next when IDL::AST::Interface node.annotations.concat(params[:annotations]) # in case of a forward declaration in the same module ignore it since a previous declaration already exists if params[:forward] return node if node.enclosure == self # forward declaration in different scope (other module section in same file or other file) elsif node.is_defined? # multiple full declarations are illegal raise "#{node.typename} \"#{node.name}\" is already defined." end if (node.is_abstract? != params[:abstract]) || (node.is_local? != params[:local]) || (node.is_pseudo? != params[:pseudo]) raise "\"attributes are not the same: \"#{node.name}\"." end _intf = IDL::AST::Interface.new(node.name, self, params) _intf.annotations.concat(node.annotations) _intf.prefix = node.prefix _intf.instance_variable_set(:@repo_ver, node.instance_variable_get(:@repo_ver)) _intf.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id)) @children << _intf # in case of a full declaration undo the preceding forward introduction and # replace by full node # (no need to introduce forward declaration since there is a preceding introduction) unless params[:forward] # replace forward node registration node.enclosure.undo_introduction(node) introduce(_intf) end return _intf when IDL::AST::Valuetype node.annotations.concat(params[:annotations]) return node if params[:forward] if node.is_defined? raise "#{node.typename} \"#{node.name}\" is already defined." end if (node.is_abstract? != params[:abstract]) raise "\"attributes are not the same: \"#{node.name}\"." end _new_node = node.class.new(node.name, self, params) _new_node.annotations.concat(node.annotations) _new_node.prefix = node.prefix _new_node.instance_variable_set(:@repo_ver, node.instance_variable_get(:@repo_ver)) _new_node.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id)) @children << _new_node # replace forward node registration node.enclosure.undo_introduction(node) introduce(_new_node) return _new_node when IDL::AST::Struct, IDL::AST::Union node.annotations.concat(params[:annotations]) return node if params[:forward] if node.is_defined? raise "#{node.typename} \"#{node.name}\" is already defined." end _new_node = node.class.new(node.name, self, params) _new_node.annotations.concat(node.annotations) _new_node.prefix = node.prefix _new_node.instance_variable_set(:@repo_ver, node.instance_variable_get(:@repo_ver)) _new_node.instance_variable_set(:@repo_id, node.instance_variable_get(:@repo_id)) node.switchtype = params[:switchtype] if node.is_a?(IDL::AST::Union) @children << _new_node # replace forward node registration node.enclosure.undo_introduction(node) introduce(_new_node) return _new_node end raise "#{node.name} is already introduced as #{node.typename} #{node.scoped_name}." end
replace_prefix(pfx)
click to toggle source
# File lib/ridl/node.rb, line 551 def replace_prefix(pfx) self.prefix = pfx # handles validation if @anchor.nil? self.replace_prefix_i(pfx) else @anchor.replace_prefix_i(pfx) end end
template_param(param)
click to toggle source
# File lib/ridl/node.rb, line 411 def template_param(param) return nil unless @template param = param.to_s if ::Symbol === param if ::String === param @template.params.each_with_index do |tp, ix| return @template_params[ix] if tp.name == param end nil else @template_params[param] rescue nil end end
undo_introduction(node)
click to toggle source
# File lib/ridl/node.rb, line 543 def undo_introduction(node) _mod = (@anchor || self) while _mod _mod._undo_link_introduction(node) _mod = _mod.next end end
Protected Instance Methods
_undo_link_introduction(node)
click to toggle source
# File lib/ridl/node.rb, line 620 def _undo_link_introduction(node) @introduced.delete(node.intern) end
copy_from(_template, instantiation_context)
click to toggle source
Calls superclass method
IDL::AST::Node#copy_from
# File lib/ridl/node.rb, line 574 def copy_from(_template, instantiation_context) super if _template.has_anchor? # module anchor is first to be copied/instantiated and # should be registered in instantiation_context cp = IDL::AST::TemplateParam.concrete_param(instantiation_context, _template.anchor) # concrete param must be a IDL::Type::NodeType and it's node a Module (should never fail) raise "Invalid concrete anchor found" unless cp.is_a?(IDL::Type::NodeType) && cp.node.is_a?(IDL::AST::Module) @anchor = cp.node # link our self into module chain @anchor.find_last.set_next(self) end @next = nil # to be sure self end
find_last()
click to toggle source
# File lib/ridl/node.rb, line 628 def find_last if @next.nil? self else @next.find_last end end
get_annotations()
click to toggle source
# File lib/ridl/node.rb, line 570 def get_annotations @annotations end
replace_prefix_i(pfx)
click to toggle source
# File lib/ridl/node.rb, line 591 def replace_prefix_i(pfx) walk_members { |m| m.replace_prefix(pfx) } # propagate along chain using fast method @next.replace_prefix_i(pfx) unless @next.nil? end
search_links(_name)
click to toggle source
# File lib/ridl/node.rb, line 607 def search_links(_name) _key = _name.downcase.intern node = @introduced[_key] if not node.nil? and node.name != _name raise "\"#{_name}\" clashed with \"#{node.name}\"." end if node.nil? && @next node = @next.search_links(_name) end node end
search_self(_name)
click to toggle source
# File lib/ridl/node.rb, line 603 def search_self(_name) (@anchor || self).search_links(_name) end
set_next(mod)
click to toggle source
# File lib/ridl/node.rb, line 624 def set_next(mod) @next = mod end
set_prefix(pfx)
click to toggle source
# File lib/ridl/node.rb, line 562 def set_prefix(pfx) if @anchor.nil? self.set_prefix_i(pfx) else @anchor.set_prefix_i(pfx) end end
set_prefix_i(pfx)
click to toggle source
# File lib/ridl/node.rb, line 597 def set_prefix_i(pfx) @prefix = pfx # propagate along chain self.next.set_prefix_i(pfx) unless self.next.nil? end