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