当前位置: 首页>>代码示例>>C++>>正文


C++ SgType::variantT方法代码示例

本文整理汇总了C++中SgType::variantT方法的典型用法代码示例。如果您正苦于以下问题:C++ SgType::variantT方法的具体用法?C++ SgType::variantT怎么用?C++ SgType::variantT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SgType的用法示例。


在下文中一共展示了SgType::variantT方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qualifiedName

void CompassAnalyses::AllowedFunctions::Traversal::
uniqueNameGenerator( 
  std::stringstream &ss, 
  const SgFunctionDeclaration *fdecl,
  std::string &qname )
{
  std::string qualifiedName( fdecl->get_qualified_name().str() );
  qname.assign(qualifiedName);

  SgFunctionType *fType = isSgFunctionType( fdecl->get_type() );
  ROSE_ASSERT(fType != NULL);

  SgType *fReturnType = fType->get_return_type();

  ROSE_ASSERT(fReturnType != NULL);

  std::string fReturnTypeName(
    typeVariantT(fReturnType, fReturnType->variantT()) );

  ss << fReturnTypeName << "," << qualifiedName << ",";

  const SgInitializedNamePtrList & arguments = fdecl->get_args();

  for( SgInitializedNamePtrList::const_iterator itr = arguments.begin();
       itr != arguments.end(); itr++ )
  {
    SgType *type = (*itr)->get_type();

    ss << this->typeVariantT(type, type->variantT()) << ",";
  } //for itr

  return;
}
开发者ID:8l,项目名称:rose,代码行数:33,代码来源:allowedFunctions.C

示例2: typeVectorFromType

       vector<SgType*> typeVectorFromType(SgType* sageType){
           vector<SgType*> typeVector;
			
           ROSE_ASSERT (sageType != NULL);
           SgType* baseType = sageType; 
           SgType* previousBaseType = NULL;
           
           while(previousBaseType != baseType) 
               {
                   previousBaseType = baseType; 
            
                   switch(baseType->variantT()){
                       case V_SgReferenceType:
                       case V_SgPointerType:
                           typeVector.push_back(baseType);
                       case V_SgTypedefType:
                           break;
                       default:
                           typeVector.push_back(baseType);
                           break;
                   }
                   baseType = findBaseType(baseType);
                   ROSE_ASSERT(baseType != NULL);

               }; 
		   
           return typeVector;

       };
开发者ID:8l,项目名称:rose,代码行数:29,代码来源:helpFunctions.C

示例3: typeFromTypedef

       string typeInterpreter::typeFromTypedef(SgTypedefDeclaration* typedefDeclaration){
                  ROSE_ASSERT( typedefDeclaration != NULL );
                  vector<SgType*> typeVector = typeVectorFromTypedef(typedefDeclaration); 

		  SgType* sageType;
		  string typeParsed = "";
		  for(unsigned int i = 0; i < typeVector.size(); i++){
		        sageType = typeVector[i];

		    	switch(sageType->variantT())
			{
				case V_SgReferenceType: 
					{
					break;
	                                }
	                        case V_SgPointerType:
	                                {
					typeParsed = typeParsed + "*";	
	                                break;
	                                }
				
				default:
					{
					typeParsed = typeParsed + TransformationSupport::getTypeName(sageType);
					break;
					}
			};	
		  }
		  return typeParsed;
       };
开发者ID:8l,项目名称:rose,代码行数:30,代码来源:helpFunctions.C

示例4: isSgVariableDeclaration

void
Unparse_Jovial::unparseVarDecl(SgStatement* stmt, SgInitializedName* initializedName, SgUnparse_Info& info)
   {
     SgName name         = initializedName->get_name();
     SgType* type        = initializedName->get_type();
     SgInitializer* init = initializedName->get_initializer();
     ROSE_ASSERT(type);

     SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(stmt);
     ROSE_ASSERT(variableDeclaration != NULL);

#if 0
     if (variableDeclaration->get_declarationModifier().get_typeModifier().isStatic() == true)
        {
           curprint("STATIC ");
        }
#endif

     switch (type->variantT())
        {
          case V_SgArrayType:
             curprint("TABLE ");
             curprint(name.str());
             break;
          default:
             curprint("ITEM ");
             curprint(name.str());
             curprint(" ");
        }

     unparseType(type, info);

     if (init != NULL)
        {
           curprint(" = ");
           SgInitializer* initializer = isSgInitializer(init);
           ROSE_ASSERT(initializer != NULL);
           // TODO
           // unparseExpression(initializer, info);
        }

     curprint(" ;\n");
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:43,代码来源:unparseJovial_statements.C

示例5: if


//.........这里部分代码省略.........

#if 0
    SgTypePtrList & argumentTypeList = functionType->get_arguments();
    ROSE_ASSERT (argumentTypeList.size() >= 0);
    SgTypePtrList::iterator argumentIterator = argumentTypeList.begin();

    for (argumentIterator = argumentTypeList.begin(); argumentIterator != argumentTypeList.end(); argumentIterator++)
    {
        // showSgType(os,(*argumentIterator), label, depth+1);

        string argumentTypeName = TransformationSupport::getTypeName(*argumentIterator);
        printf ("-----> argument #%d  argumentTypeName = %s \n",argumentCounter++,argumentTypeName.c_str());
    }
#endif

    //Determine the SIDL parameter passing mechanism (in,out,inout)
    SgInitializedNamePtrList & argumentList = functionDeclarationStatement->get_args();
    string parameterTypesAndNames;
    SgInitializedNamePtrList::iterator i;

    unsigned int argumentCounter = 0;
    for (i = argumentList.begin(); i != argumentList.end(); i++)
    {
        SgType* type = (*i)->get_type();
        ROSE_ASSERT (type != NULL);

        string typeName = TransformationSupport::getTypeName(type);
        ROSE_ASSERT (typeName.c_str() != NULL);

        string sidlParameterPassingMechanim = "in";

        //it seems like the has_ellipses value is wrong, so we'll set it
        functionType->set_has_ellipses(false);
        if(type->variantT() == V_SgTypeEllipse)
        {
            sidlParameterPassingMechanim = "inout";
            functionType->set_has_ellipses(true);
        }
        //else if (type->variantT() == V_SgTypeVoid)
        /*else if (rose::stringDuplicate(type->sage_class_name()) == "SgTypeVoid")
        {
        	printf("found a void\n");
        	//void type is only viable for a pointer.  foo(void) will just become foo()
        	if(isSgPointerType(type) != NULL)
        	{
        		printf("found a void pointer\n");
        		sidlParameterPassingMechanim ="inout opaque";
        	}
        }*/
        else if (isSgReferenceType(type) != NULL)
        {
            sidlParameterPassingMechanim = "inout";
        }
        else if (isSgPointerType(type) != NULL)
        {
            sidlParameterPassingMechanim = "inout";
        }
        else if (isSgArrayType(type) != NULL)
        {
            SgArrayType array = isSgArrayType(type);
            sidlParameterPassingMechanim = "inout Array<";
            SgType* baseType = array.get_base_type();
            sidlParameterPassingMechanim += TransformationSupport::getTypeName(baseType);
            sidlParameterPassingMechanim += ",1>";
            //FIXME: I don't see a way to determine the dimention of the array
        }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:67,代码来源:sidlFunction.C

示例6: switch

std::string CompassAnalyses::AllowedFunctions::Traversal::
typeVariantT( SgType *type, int vT )
{
  switch( vT )
  {
    case V_SgArrayType:
    {
      SgType *baseType = isSgArrayType(type)->get_base_type();
      ROSE_ASSERT(baseType != NULL);

      return this->typeVariantT( baseType, baseType->variantT() ) + "[]";
    } break;
    case V_SgMemberFunctionType:          //fall
    case V_SgPartialFunctionType:         //fall
    case V_SgPartialFunctionModifierType: //fall thru
    case V_SgFunctionType:
    {
      SgFunctionType *fType = isSgFunctionType(type);
      ROSE_ASSERT(fType != NULL);

      return fType->get_mangled_type().getString();
    } break;
    case V_SgModifierType:
    {
      SgType *baseType = isSgModifierType(type)->get_base_type();
      ROSE_ASSERT(baseType != NULL);

      return this->typeVariantT(baseType,baseType->variantT());
    } break;
    case V_SgClassType:    //fall
    case V_SgEnumType:     //fall
    case V_SgTypedefType:  //fall thru
    case V_SgNamedType:
    {
      SgNamedType *nType = isSgNamedType(type);
      ROSE_ASSERT(nType != NULL);

      return nType->get_name().getString();
    } break;
    case V_SgPointerMemberType:   //fall thru
    case V_SgPointerType:
    {
      SgType *baseType = isSgPointerType(type)->get_base_type();
      ROSE_ASSERT(baseType != NULL);

      return "*" + this->typeVariantT(baseType,baseType->variantT());
    } break;
    case V_SgQualifiedNameType:
    {
      SgType *baseType = isSgQualifiedNameType(type)->get_base_type();
      ROSE_ASSERT(baseType != NULL);

      return this->typeVariantT(baseType,baseType->variantT());
    } break;
    case V_SgReferenceType:
    {
      SgType *baseType = isSgReferenceType(type)->get_base_type();
      ROSE_ASSERT(baseType != NULL);

      return "&" + this->typeVariantT(baseType,baseType->variantT());
    } break;
    case V_SgTemplateType:
    {
      return "template<T>";
//      return isSgTemplateType(type)->get_mangled().getString();
    } break;
    case V_SgTypeBool: return "bool";
    case V_SgTypeChar: return "char";
    case V_SgTypeComplex: return "complex";
    case V_SgTypeDefault: return "default";
    case V_SgTypeDouble: return "double";
    case V_SgTypeEllipse: return "...";
    case V_SgTypeFloat: return "float";
    case V_SgTypeGlobalVoid: return "global void";
    case V_SgTypeImaginary: return "imaginary";
    case V_SgTypeInt: return "int";
    case V_SgTypeLong: return "long";
    case V_SgTypeLongDouble: return "long double";
    case V_SgTypeLongLong: return "long long";
    case V_SgTypeShort: return "short";
    case V_SgTypeSignedChar: return "signed char";
    case V_SgTypeSignedInt: return "signed int";
    case V_SgTypeSignedLong: return "signed long";
    case V_SgTypeSignedShort: return "signed short";
    case V_SgTypeString: return "string";
    case V_SgTypeUnknown: return isSgTypeUnknown(type)->get_mangled().getString();
    case V_SgTypeUnsignedChar: return "unsigned char";
    case V_SgTypeUnsignedInt: return "unsigned int";
    case V_SgTypeUnsignedLong: return "unsigned long";
    case V_SgTypeUnsignedLongLong: return "unsigned long long";
    case V_SgTypeUnsignedShort: return "unsigned short";
    case V_SgTypeVoid: return "void";
    case V_SgTypeWchar: return "wchar";
    default: break;
  } //switch( vT )

  std::cerr << "Got Unknown Variant: " << vT << std::endl;

  return "unknown";
}
开发者ID:8l,项目名称:rose,代码行数:100,代码来源:allowedFunctions.C

示例7: main

int main( int argc, char * argv[] )
{
// Option to linearize the array.
  Rose_STL_Container<std::string> localCopy_argv = CommandlineProcessing::generateArgListFromArgcArgv(argc, argv);
  int newArgc;
  char** newArgv = NULL;
  vector<string> argList = localCopy_argv;
  if (CommandlineProcessing::isOption(argList,"-f2c:","linearize",true) == true)
  {
    isLinearlizeArray = true;
  }
  CommandlineProcessing::generateArgcArgvFromList(argList,newArgc, newArgv);
// Build the AST used by ROSE
  SgProject* project = frontend(newArgc,newArgv);
  AstTests::runAllTests(project);   

  if (SgProject::get_verbose() > 2)
    generateAstGraph(project,8000,"_orig");
  
  // Traversal with Memory Pool to search for variableDeclaration
  variableDeclTraversal translateVariableDeclaration;
  traverseMemoryPoolVisitorPattern(translateVariableDeclaration);
  for(vector<SgVariableDeclaration*>::iterator dec=variableDeclList.begin(); dec!=variableDeclList.end(); ++dec)
  {
    /*
       For the Fortran AST, a single variableDeclaration can be shared by multiple variables.
       This violated the normalization rules for C unparser.  Therefore, we have to transform it.
    */
    SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(*dec);
    ROSE_ASSERT(variableDeclaration);
    if((variableDeclaration->get_variables()).size() != 1)
    {
      updateVariableDeclarationList(variableDeclaration);
      statementList.push_back(variableDeclaration);
      removeList.push_back(variableDeclaration);
    }
  }

  // reset the vector that collects all variable declaration. We need to walk through memory pool again to find types
  
  variableDeclList.clear();
  traverseMemoryPoolVisitorPattern(translateVariableDeclaration);
  for(vector<SgVariableDeclaration*>::iterator dec=variableDeclList.begin(); dec!=variableDeclList.end(); ++dec)
  {
    SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(*dec);
    ROSE_ASSERT(variableDeclaration);
    SgInitializedNamePtrList initializedNameList = variableDeclaration->get_variables();
    for(SgInitializedNamePtrList::iterator i=initializedNameList.begin(); i!=initializedNameList.end();++i)
    {
      SgInitializedName* initiallizedName = isSgInitializedName(*i);
      SgType* baseType = initiallizedName->get_type();
      if(baseType->variantT() == V_SgArrayType)
      {
        SgArrayType* arrayBase = isSgArrayType(baseType);
        // At this moment, we are still working on the Fortran-stype AST.  Therefore, there is no nested types for multi-dim array.
        if(arrayBase->findBaseType()->variantT() == V_SgTypeString)
        {
          arrayBase->reset_base_type(translateType(arrayBase->findBaseType()));
          arrayBase->set_rank(arrayBase->get_rank()+1);
        }
      }
      else
      {
        initiallizedName->set_type(translateType(baseType));
      }
    }
  }

  // replace the AttributeSpecificationStatement 
  Rose_STL_Container<SgNode*> AttributeSpecificationStatement = NodeQuery::querySubTree (project,V_SgAttributeSpecificationStatement);
  for (Rose_STL_Container<SgNode*>::iterator i = AttributeSpecificationStatement.begin(); i != AttributeSpecificationStatement.end(); i++)
  {
    SgAttributeSpecificationStatement* attributeSpecificationStatement = isSgAttributeSpecificationStatement(*i);
    ROSE_ASSERT(attributeSpecificationStatement);
    translateAttributeSpecificationStatement(attributeSpecificationStatement);
    statementList.push_back(attributeSpecificationStatement);
    removeList.push_back(attributeSpecificationStatement);
  }

  // replace the parameter reference
  parameterTraversal translateParameterRef;
  traverseMemoryPoolVisitorPattern(translateParameterRef);
  for(vector<SgVarRefExp*>::iterator i=parameterRefList.begin(); i!=parameterRefList.end(); ++i)
  {
    SgVarRefExp* parameterRef = isSgVarRefExp(*i);
    if(parameterSymbolList.find(parameterRef->get_symbol()) != parameterSymbolList.end())
    {
      SgExpression* newExpr = isSgExpression(deepCopy(parameterSymbolList.find(parameterRef->get_symbol())->second));
      ROSE_ASSERT(newExpr);
      newExpr->set_parent(parameterRef->get_parent());
      replaceExpression(parameterRef,
                        newExpr,
                        false);
    }
  }

  /*
     Parameters will be replaced by #define, all the declarations should be removed
  */
  for(map<SgVariableSymbol*,SgExpression*>::iterator i=parameterSymbolList.begin();i!=parameterSymbolList.end();++i)
//.........这里部分代码省略.........
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:101,代码来源:main.C

示例8: isSgType

// 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;
//.........这里部分代码省略.........
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:101,代码来源:nameQuery.C

示例9: backend

int
main( int argc, char* argv[] )
   {
  // Initialize and check compatibility. See rose::initialize
     ROSE_INITIALIZE;

     SgProject* project = frontend(argc,argv);
     AstTests::runAllTests(project);

#if 0
  // Output the graph so that we can see the whole AST graph, for debugging.
     generateAstGraph(project, 4000);
#endif
#if 1
     printf ("Generate the dot output of the SAGE III AST \n");
     generateDOT ( *project );
     printf ("DONE: Generate the dot output of the SAGE III AST \n");
#endif

  // There are lots of way to write this, this is one simple approach; get all the function calls.
     std::vector<SgNode*> functionCalls = NodeQuery::querySubTree (project,V_SgFunctionCallExp);

  // Find the SgFunctionSymbol for snprintf so that we can reset references to "sprintf" to "snprintf" instead.
  // SgGlobal* globalScope = (*project)[0]->get_globalScope();
     SgSourceFile* sourceFile = isSgSourceFile(project->get_fileList()[0]);
     ROSE_ASSERT(sourceFile != NULL);
     SgGlobal* globalScope = sourceFile->get_globalScope();
     SgFunctionSymbol* snprintf_functionSymbol = globalScope->lookup_function_symbol("snprintf");
     ROSE_ASSERT(snprintf_functionSymbol != NULL);

  // Iterate over the function calls to find the calls to "sprintf"
     for (unsigned long i = 0; i < functionCalls.size(); i++)
        {
          SgFunctionCallExp* functionCallExp = isSgFunctionCallExp(functionCalls[i]);
          ROSE_ASSERT(functionCallExp != NULL);

          SgFunctionRefExp* functionRefExp = isSgFunctionRefExp(functionCallExp->get_function());
          if (functionRefExp != NULL)
             {
               SgFunctionSymbol* functionSymbol = functionRefExp->get_symbol();
               if (functionSymbol != NULL)
                  {
                    SgName functionName = functionSymbol->get_name();
                 // printf ("Function being called: %s \n",functionName.str());
                    if (functionName == "sprintf")
                       {
                      // Now we have something to do!
                         functionRefExp->set_symbol(snprintf_functionSymbol);

                      // Now add the "n" argument
                         SgExprListExp* functionArguments = functionCallExp->get_args();
                         SgExpressionPtrList & functionArgumentList = functionArguments->get_expressions();

                      // "sprintf" shuld have exactly 2 arguments (I guess the "..." don't count)
                         printf ("functionArgumentList.size() = %zu \n",functionArgumentList.size());
                      // ROSE_ASSERT(functionArgumentList.size() == 2);
                         SgExpressionPtrList::iterator i = functionArgumentList.begin();

                      // printf ("(*i) = %p = %s = %s \n",*i,(*i)->class_name().c_str(),SageInterface::get_name(*i).c_str());
                         SgVarRefExp* variableRefExp = isSgVarRefExp(*i);
                         ROSE_ASSERT(variableRefExp != NULL);

                      // printf ("variableRefExp->get_type() = %p = %s = %s \n",variableRefExp->get_type(),variableRefExp->get_type()->class_name().c_str(),SageInterface::get_name(variableRefExp->get_type()).c_str());

                         SgType* bufferType = variableRefExp->get_type();
                         SgExpression* bufferLengthExpression = NULL;
                         switch(bufferType->variantT())
                            {
                              case V_SgArrayType:
                                 {
                                   SgArrayType* arrayType = isSgArrayType(bufferType);
                                   bufferLengthExpression = arrayType->get_index();
                                   break;
                                 }

                              case V_SgPointerType:
                                 {
                                // SgPointerType* pointerType = isSgPointerType(bufferType);
                                   SgInitializedName* variableDeclaration = variableRefExp->get_symbol()->get_declaration();
                                   ROSE_ASSERT(variableDeclaration != NULL);
                                   SgExpression* initializer = variableDeclaration->get_initializer();
                                   if (initializer != NULL)
                                      {
                                        SgAssignInitializer* assignmentInitializer = isSgAssignInitializer(initializer);
                                        ROSE_ASSERT(assignmentInitializer != NULL);

                                     // This is the rhs of the initialization of the pointer (likely a malloc through a cast).
                                     // This assumes: buffer = (char*) malloc(bufferLengthExpression);
                                        SgExpression* initializationExpression = assignmentInitializer->get_operand();
                                        ROSE_ASSERT(initializationExpression != NULL);
                                        SgCastExp* castExp = isSgCastExp(initializationExpression);
                                        ROSE_ASSERT(castExp != NULL);
                                        SgFunctionCallExp* functionCall = isSgFunctionCallExp(castExp->get_operand());
                                        ROSE_ASSERT(functionCall != NULL);
                                        SgExprListExp* functionArguments = isSgExprListExp(functionCall->get_args());
                                        bufferLengthExpression = functionArguments->get_expressions()[0];
                                        ROSE_ASSERT(bufferLengthExpression != NULL);
                                      }
                                     else
                                      {
//.........这里部分代码省略.........
开发者ID:billhoffman,项目名称:rose-develop,代码行数:101,代码来源:sprintf_to_snprintf.C


注:本文中的SgType::variantT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。