class IDL::Delegator

def parse_scopedname(global, namelist)

def parse_scopedname(global, namelist)
  node = root = if global then @root else @cur end
  first = nil
  namelist.each do |nm|
    n = node.resolve(nm)
    if n.nil?
      raise "cannot find type name '#{nm}' in scope '#{node.scoped_name}'"
    end
    node = n
    first = node if first.nil?
  end
  root.introduce(first)
  case node
  when IDL::AST::Module, IDL::AST::TemplateModule,
       IDL::AST::Interface, IDL::AST::Home, IDL::AST::Component,
       IDL::AST::Porttype, IDL::AST::Connector,
       IDL::AST::Struct, IDL::AST::Union, IDL::AST::Typedef,
       IDL::AST::Exception, IDL::AST::Enum, IDL::AST::BitMask,
       IDL::AST::Valuetype, IDL::AST::Valuebox, IDL::AST::BitSet
    Type::ScopedName.new(node)
  when IDL::AST::TemplateParam
    if node.idltype.is_a?(IDL::Type::Const)
      Expression::ScopedName.new(node)
    else
      Type::ScopedName.new(node)
    end
  when IDL::AST::Const
    Expression::ScopedName.new(node)
  when IDL::AST::Enumerator
    Expression::Enumerator.new(node)
  when IDL::AST::BitValue
    Expression::BitValue.new(node)
  when IDL::AST::BitField
    Expression::BitField.new(node)
  else
    raise "invalid reference to #{node.class.name}: #{node.scoped_name}"
  end
end