string
FixupTemplateArguments::generate_string_name (SgType* type, SgNode* nodeReferenceToType)
   {
  // DQ (2/11/2017): This function has been added to support debugging.  It is a current problem that
  // the substitution of private types in template arguments with type aliases not containing private 
  // types, is that the typename can be generated to be extremely large (e.g 803+ million characters long).

     SgUnparse_Info* unparseInfoPointer = new SgUnparse_Info();
     ROSE_ASSERT (unparseInfoPointer != NULL);
     unparseInfoPointer->set_outputCompilerGeneratedStatements();

  // Avoid unpasing the class definition when unparseing the type.
     unparseInfoPointer->set_SkipClassDefinition();

  // DQ (5/8/2013): Added specification to skip enum definitions also (see test2012_202.C).
     unparseInfoPointer->set_SkipEnumDefinition();

  // Associate the unparsing of this type with the statement or scope where it occures.
  // This is the key to use in the lookup of the qualified name. But this is the correct key....
  // unparseInfoPointer->set_reference_node_for_qualification(positionStatement);
  // unparseInfoPointer->set_reference_node_for_qualification(currentScope);
     unparseInfoPointer->set_reference_node_for_qualification(nodeReferenceToType);

  // DQ (5/7/2013): A problem with this is that it combines the first and second parts of the 
  // type into a single string (e.g. the array type will include two parts "base_type" <array name> "[index]".
  // When this is combined for types that have two parts (most types don't) the result is an error
  // when the type is unparsed.  It is not clear, but a solution might be for this to be built here
  // as just the 1st part, and let the second part be generated when the array type is unparsed.
  // BTW, the reason why it is computed here is that there may be many nested types that require 
  // name qualifications and so it is required that we save the whole string.  However, name 
  // qualification might only apply to the first part of types.  So we need to investigate this.
  // This is a problem demonstrated in test2013_156.C and test2013_158.C.

  // DQ (5/8/2013): Set the SgUnparse_Info so that only the first part will be unparsed.
     unparseInfoPointer->set_isTypeFirstPart();

  // DQ (8/19/2013): Added specification to skip class specifier (fixes problem with test2013_306.C).
     unparseInfoPointer->set_SkipClassSpecifier();

     string typeNameString = globalUnparseToString(type,unparseInfoPointer);

     return typeNameString;
   }
示例#2
0
string
Doxygen::getQualifiedPrototype(SgNode *node)
{
    SgClassDeclaration *cd = dynamic_cast<SgClassDeclaration *>(node);
    if (cd) return getProtoName(cd);
    SgUnparse_Info info;
    info.set_SkipSemiColon();
    info.set_SkipFunctionDefinition();
    info.set_forceQualifiedNames();
    info.set_skipCheckAccess();
    info.set_SkipClassSpecifier();
    info.set_SkipInitializer();
    info.set_current_scope(TransformationSupport::getGlobalScope(node));

    string proto = node->unparseToString(&info);
    while (proto[proto.size()-1] == '\n') { /* sometimes the prototype will be unparsed with a newline at the end */
        proto.resize(proto.size()-1);
    }
    return proto;
}
示例#3
0
string
Doxygen::getProtoName(SgDeclarationStatement *st)
{
    SgScopeStatement *scope;
    if (SgVariableDeclaration* varDeclSt = isSgVariableDeclaration(st))
    {
        // TODO: uncomment SgVariableDeclaration::get_scope removing need for this code
        scope = varDeclSt->get_variables().front()->get_scope();
    }
    else
    {
        scope = st->get_scope();
    }
    if (isSgGlobal(scope))
    {
        return getDeclStmtName(st);
    }
    else
    {
        SgUnparse_Info info;
        info.set_SkipSemiColon();
        info.set_SkipFunctionDefinition();
        info.set_forceQualifiedNames();
        info.set_skipCheckAccess();
        info.set_SkipInitializer();
        info.set_SkipClassSpecifier();
        //AS(091507) In the new version of ROSE global qualifiers are paret of the qualified name of
        //a scope statement. For the documentation work we do not want that and we therefore use string::substr()
        //to trim of  "::" from the front of the qualified name.

        if( scope->get_qualified_name().getString().length() > 2 )
        {
            return scope->get_qualified_name().getString().substr(2)+("::"+getDeclStmtName(st));
        } else {
            return getDeclStmtName(st);

        }

        //return scope->get_qualified_name().str()+("::"+getDeclStmtName(st));
    }
}