Exemple #1
0
void NameCompiler::visitTemplateArgument(TemplateArgumentAST *node)
{
  if (node->type_id && node->type_id->type_specifier)
    {
      TypeCompiler type_cc(_M_binder);
      type_cc.run(node->type_id->type_specifier);

      DeclaratorCompiler decl_cc(_M_binder);
      decl_cc.run(node->type_id->declarator);

      if (type_cc.isConstant())
        _M_name.last() += "const ";

      QStringList q = type_cc.qualifiedName ();

      if (q.count () == 1)
        {
#if defined (RXX_RESOLVE_TYPEDEF) // ### it'll break :(
          TypeInfo tp;
          tp.setQualifiedName (q);
          tp = TypeInfo::resolveType (tp, _M_binder->currentScope ()->toItem ());
          q = tp.qualifiedName ();
#endif

          if (CodeModelItem item = _M_binder->model ()->findItem (q, _M_binder->currentScope ()->toItem ()))
            {
              if (item->name () == q.last ())
                q = item->qualifiedName ();
            }
        }

      _M_name.last() += q.join("::");

      if (decl_cc.isReference())
        _M_name.last() += "&";
      if (decl_cc.indirection())
        _M_name.last() += QString(decl_cc.indirection(), '*');

      _M_name.last() += QLatin1String(",");
    }
}
TypeInfo TypeInfo::resolveType(TypeInfo const &__type, CodeModelItem __scope) {
    CodeModel *__model = __scope->model();
    Q_ASSERT(__model != 0);

    CodeModelItem __item = __model->findItem(__type.qualifiedName(), __scope);

    // Copy the type and replace with the proper qualified name. This
    // only makes sence to do if we're actually getting a resolved
    // type with a namespace. We only get this if the returned type
    // has more than 2 entries in the qualified name... This test
    // could be improved by returning if the type was found or not.
    TypeInfo otherType(__type);
    if (__item && __item->qualifiedName().size() > 1) {
        otherType.setQualifiedName(__item->qualifiedName());
    }

    if (TypeAliasModelItem __alias = model_dynamic_cast<TypeAliasModelItem> (__item))
        return resolveType(TypeInfo::combine(__alias->type(), otherType), __scope);

    return otherType;
}