void UnparseFortran_type::unparsePointerType(SgType* type, SgUnparse_Info& info, bool printAttrs) { #if 0 // printf ("Inside of UnparserFort::unparsePointerType \n"); // cur << "\n/* Inside of UnparserFort::unparsePointerType */\n"; curprint ("\n! Inside of UnparserFort::unparsePointerType \n"); #endif // DQ (1/16/2011): Note that pointers in fortran are not expressed the same as in C/C++, are are // only a part of the type which is managed more directly using attributes in the variable declaration. // Not clear that we want to do anything here in the unparser... SgPointerType* pointer_type = isSgPointerType(type); ROSE_ASSERT(pointer_type != NULL); #if 0 /* special cases: ptr to array, int (*p) [10] */ /* ptr to function, int (*p)(int) */ /* ptr to ptr to .. int (**p) (int) */ if (isSgReferenceType(pointer_type->get_base_type()) || isSgPointerType(pointer_type->get_base_type()) || isSgArrayType(pointer_type->get_base_type()) || isSgFunctionType(pointer_type->get_base_type()) || isSgMemberFunctionType(pointer_type->get_base_type()) || isSgModifierType(pointer_type->get_base_type()) ) { info.set_isPointerToSomething(); } // If not isTypeFirstPart nor isTypeSecondPart this unparse call // is not controlled from the statement level but from the type level if (info.isTypeFirstPart() == true) { unparseType(pointer_type->get_base_type(), info); // DQ (9/21/2004): Moved this conditional into this branch (to fix test2004_93.C) // DQ (9/21/2004): I think we can assert this, and if so we can simplify the logic below ROSE_ASSERT(info.isTypeSecondPart() == false); curprint("*"); } else { if (info.isTypeSecondPart() == true) { unparseType(pointer_type->get_base_type(), info); } else { SgUnparse_Info ninfo(info); ninfo.set_isTypeFirstPart(); unparseType(pointer_type, ninfo); ninfo.set_isTypeSecondPart(); unparseType(pointer_type, ninfo); } } #else if (info.supressStrippedTypeName() == false) { // DQ (1/16/2011): We only want to output the name of the stripped type once! SgType* stripType = pointer_type->stripType(); unparseType(stripType, info); info.set_supressStrippedTypeName(); } curprint(type->get_isCoArray()? ", COPOINTER": ", POINTER"); // DQ (1/16/2011): Plus unparse the base type...(unless it will just output the stripped types name). if (pointer_type->get_base_type()->containsInternalTypes() == true) { unparseType(pointer_type->get_base_type(), info, printAttrs); } #endif #if 0 // printf ("Leaving of UnparserFort::unparsePointerType \n"); // cur << "\n/* Leaving of UnparserFort::unparsePointerType */\n"; curprint ("\n! Leaving UnparserFort::unparsePointerType \n"); #endif }
void Unparse_Java::unparseEnumType(SgEnumType* type, SgUnparse_Info& info) { SgEnumType* enum_type = isSgEnumType(type); ROSE_ASSERT(enum_type); if (info.isTypeSecondPart() == false) { SgEnumDeclaration *edecl = isSgEnumDeclaration(enum_type->get_declaration()); SgClassDefinition *cdefn = NULL; SgNamespaceDefinitionStatement* namespaceDefn = NULL; ROSE_ASSERT(edecl != NULL); // Build reference to any possible enclosing scope represented by a SgClassDefinition or SgNamespaceDefinition // to be used check if name qualification is required. unp->u_exprStmt->initializeDeclarationsFromParent ( edecl, cdefn, namespaceDefn ); if (info.isTypeFirstPart() == true && info.SkipEnumDefinition() == false) { unp->u_exprStmt->unparseAttachedPreprocessingInfo(edecl, info, PreprocessingInfo::before); } curprint ( "enum "); SgNamedType *ptype = NULL; if (cdefn != NULL) { ptype = isSgNamedType(cdefn->get_declaration()->get_type()); } if (SageInterface::is_C_language() == true || SageInterface::is_C99_language() == true) { curprint ( enum_type->get_name().getString() + " "); } else { // DQ (7/20/2011): Test compilation without the generateNameQualifier() functions. // The C++ support is more complex and can require qualified names! // SgName nameQualifier = unp->u_name->generateNameQualifier( edecl , info ); SgName nameQualifier; // printf ("nameQualifier (from unp->u_name->generateNameQualifier function) = %s \n",nameQualifier.str()); // curprint ( "\n/* nameQualifier (from unp->u_name->generateNameQualifier function) = " + nameQualifier + " */ \n "; curprint ( nameQualifier.str()); SgName nm = enum_type->get_name(); if (nm.getString() != "") { // printf ("Output qualifier of current types to the name = %s \n",nm.str()); curprint ( nm.getString() + " "); } } } if (info.isTypeFirstPart() == true) { // info.display("info before constructing ninfo"); SgUnparse_Info ninfo(info); // don't skip the semicolon in the output of the statement in the class definition ninfo.unset_SkipSemiColon(); ninfo.set_isUnsetAccess(); // printf ("info.SkipEnumDefinition() = %s \n",(info.SkipEnumDefinition() == true) ? "true" : "false"); if ( info.SkipEnumDefinition() == false) { SgUnparse_Info ninfo(info); ninfo.set_inEnumDecl(); SgInitializer *tmp_init = NULL; SgName tmp_name; SgEnumDeclaration *enum_stmt = isSgEnumDeclaration(enum_type->get_declaration()); ROSE_ASSERT(enum_stmt != NULL); // This permits support of the empty enum case! "enum x{};" curprint ( "{"); SgInitializedNamePtrList::iterator p = enum_stmt->get_enumerators().begin(); if (p != enum_stmt->get_enumerators().end()) { // curprint ( "{"; while (1) { unp->u_exprStmt->unparseAttachedPreprocessingInfo(*p, info, PreprocessingInfo::before); tmp_name=(*p)->get_name(); tmp_init=(*p)->get_initializer(); curprint ( tmp_name.str()); if(tmp_init) { curprint ( "="); unp->u_exprStmt->unparseExpression(tmp_init, ninfo); } p++; if (p != enum_stmt->get_enumerators().end()) { curprint ( ","); } else break; } // curprint ( "}"; } // Putting the "inside" info right here is just a wild guess as to where it might really belong. unp->u_exprStmt->unparseAttachedPreprocessingInfo(enum_stmt, info, PreprocessingInfo::inside); curprint ( "}"); unp->u_exprStmt->unparseAttachedPreprocessingInfo(enum_stmt, info, PreprocessingInfo::after); } } }