TypeInfo CompilerUtils::typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder) {
    TypeCompiler type_cc(binder);
    DeclaratorCompiler decl_cc(binder);

    type_cc.run(type_specifier);
    decl_cc.run(declarator);

    TypeInfo typeInfo;
    typeInfo.setQualifiedName(type_cc.qualifiedName());
    typeInfo.setConstant(type_cc.isConstant());
    typeInfo.setVolatile(type_cc.isVolatile());
    typeInfo.setReference(decl_cc.isReference());
    typeInfo.setIndirections(decl_cc.indirection());
    typeInfo.setArrayElements(decl_cc.arrayElements());

    return typeInfo;
}
Exemple #2
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(",");
    }
}