/** * class: SgTypedefType * term: typedef_type(name, base) * arg name: name of the new type * arg base: basetype */ PrologCompTerm* RoseToTerm::getTypedefTypeSpecific(SgType* mtype) { /* make sure this is actually a SgTypedefType*/ SgTypedefType* tp = isSgTypedefType(mtype); ROSE_ASSERT(tp != NULL); /* create term and add name*/ return new PrologCompTerm ("typedef_type", //2, new PrologAtom(tp->get_name().getString()), (tp->get_base_type() != NULL /* add base type */ ? getTypeSpecific(tp->get_base_type()) : new PrologAtom("null"))); }
// DQ (8/27/2006): This functionality already exists elsewhere // It is a shame that it is recreated here as well !!! NameQuerySynthesizedAttributeType NameQuery::queryNameTypeName (SgNode * astNode) { ROSE_ASSERT (astNode != NULL); string typeName = ""; Rose_STL_Container< string > returnList; SgType *type = isSgType (astNode); // printf ("In TransformationSupport::getTypeName(): type->sage_class_name() = %s \n",type->sage_class_name()); if (type != NULL) switch (type->variantT ()) { case V_SgTypeComplex: typeName = "complex"; break; case V_SgTypeImaginary: typeName = "imaginary"; break; case V_SgTypeBool: typeName = "bool"; break; case V_SgEnumType: typeName = "enum"; break; case V_SgTypeChar: typeName = "char"; break; case V_SgTypeVoid: typeName = "void"; break; case V_SgTypeInt: typeName = "int"; break; case V_SgTypeDouble: typeName = "double"; break; case V_SgTypeFloat: typeName = "float"; break; case V_SgTypeLong: typeName = "long"; break; case V_SgTypeLongDouble: typeName = "long double"; break; case V_SgTypeEllipse: typeName = "ellipse"; break; case V_SgTypeGlobalVoid: typeName = "void"; break; case V_SgTypeLongLong: typeName = "long long"; break; case V_SgTypeShort: typeName = "short"; break; case V_SgTypeSignedChar: typeName = "signed char"; break; case V_SgTypeSignedInt: typeName = "signed int"; break; case V_SgTypeSignedLong: typeName = "signed long"; break; case V_SgTypeSignedShort: typeName = "signed short"; break; case V_SgTypeString: typeName = "string"; break; case V_SgTypeUnknown: typeName = "unknown"; break; case V_SgTypeUnsignedChar: typeName = "unsigned char"; break; case V_SgTypeUnsignedInt: typeName = "unsigned int"; break; case V_SgTypeUnsignedLong: typeName = "unsigned long"; break; case V_SgTypeUnsignedShort: typeName = "unsigned short"; break; case V_SgTypeUnsignedLongLong: typeName = "unsigned long long"; break; case V_SgReferenceType: { ROSE_ASSERT (isSgReferenceType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgReferenceType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgPointerType: { ROSE_ASSERT (isSgPointerType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgPointerType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgModifierType: { ROSE_ASSERT (isSgModifierType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgModifierType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgNamedType: { SgNamedType *sageNamedType = isSgNamedType (type); ROSE_ASSERT (sageNamedType != NULL); typeName = sageNamedType->get_name ().str (); break; } case V_SgClassType: { SgClassType *sageClassType = isSgClassType (type); ROSE_ASSERT (sageClassType != NULL); typeName = sageClassType->get_name ().str (); break; } case V_SgTypedefType: { SgTypedefType *sageTypedefType = isSgTypedefType (type); ROSE_ASSERT (sageTypedefType != NULL); typeName = sageTypedefType->get_name ().str (); break; } case V_SgPointerMemberType: { SgPointerMemberType *pointerMemberType = isSgPointerMemberType (type); ROSE_ASSERT (pointerMemberType != NULL); SgClassType *classType = isSgClassType(pointerMemberType->get_class_type()->stripTypedefsAndModifiers()); ROSE_ASSERT (classType != NULL); SgClassDeclaration *classDeclaration = isSgClassDeclaration(classType->get_declaration()); ROSE_ASSERT (classDeclaration != NULL); typeName = classDeclaration->get_name ().str (); break; } case V_SgArrayType: { ROSE_ASSERT (isSgArrayType (type)->get_base_type () != NULL); Rose_STL_Container< string > subTypeNames = queryNameTypeName (isSgArrayType (type)->get_base_type ()); typedef Rose_STL_Container< string >::iterator typeIterator; //This iterator will only contain one name for (typeIterator i = subTypeNames.begin (); i != subTypeNames.end (); ++i) { string e = *i; typeName = e; break; } break; } case V_SgFunctionType: { SgFunctionType *functionType = isSgFunctionType (type); ROSE_ASSERT (functionType != NULL); typeName = functionType->get_mangled_type ().str (); break; } case V_SgMemberFunctionType: { SgMemberFunctionType *memberFunctionType = isSgMemberFunctionType (type); ROSE_ASSERT (memberFunctionType != NULL); SgClassType *classType = isSgClassType(memberFunctionType->get_class_type()->stripTypedefsAndModifiers()); ROSE_ASSERT (classType != NULL); SgClassDeclaration *classDeclaration = isSgClassDeclaration(classType->get_declaration()); ROSE_ASSERT (classDeclaration != NULL); typeName = classDeclaration->get_name ().str (); break; } case V_SgTypeWchar: typeName = "wchar"; break; case V_SgTypeDefault: typeName = "default"; break; default: printf ("default reached in switch within TransformationSupport::getTypeName type->sage_class_name() = %s variant = %d \n", type->sage_class_name (), type->variant ()); ROSE_ABORT (); break; } // Fix for purify problem report // typeName = ROSE::stringDuplicate(typeName); if (typeName.size () > 0) returnList.push_back (typeName); //ROSE_ASSERT(typeName.c_str() != NULL); // return typeName; return returnList; //return ROSE::stringDuplicate(typeName.c_str()); }