class IDL::AST::TemplateParam

def self.concrete_param(instantiation_context, tpl_elem)

def self.concrete_param(instantiation_context, tpl_elem)
  # is this an element from the template's scope
  if tpl_elem.is_template?
    celem = if tpl_elem.is_a?(IDL::AST::TemplateParam) # an actual template parameter?
      tpl_elem.concrete # get the template parameter's concrete (instantiation argument) value
    else
      # referenced template elements should have been instantiated already and available through context
      ctxelem = instantiation_context[tpl_elem]
      # all items in the context are AST elements but for a concrete parameter value only constants and type
      # elements will be referenced; return accordingly
      ctxelem.is_a?(IDL::AST::Const) ? ctxelem.expression : ctxelem.idltype
    end
    raise "cannot resolve concrete node for template #{tpl_elem.typename} #{tpl_elem.scoped_lm_name}" unless celem
    celem
  else
    tpl_elem.idltype # just return the element's idltype if not from the template scope
  end
end

def concrete_matches?(idl_type)

def concrete_matches?(idl_type)
  if @concrete
    concrete_type = (@concrete.is_a?(IDL::Type) ? @concrete : @concrete.idltype).resolved_type
    return concrete_type.matches?(idl_type.resolved_type)
  end
  false
end

def initialize(_name, _enclosure, params)

def initialize(_name, _enclosure, params)
  super(_name, _enclosure)
  @idltype = params[:type]
  @concrete = nil
end

def is_template?

def is_template?
  true
end

def marshal_dump

def marshal_dump
  super() << @idltype
end

def marshal_load(vars)

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

def set_concrete_param(_param)

def set_concrete_param(_param)
  @concrete = _param
end