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


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

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


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

示例1: handleProgmemArrayIndexRef

void BasicProgmemTransform::handleProgmemArrayIndexRef(SgPntrArrRefExp *ref) {
	SgType *type = ref->get_type();
	if(isSgTypeChar(type)) {
		//character array
		SageInterface::addTextForUnparser(ref, "(char)pgm_read_byte(&(", AstUnparseAttribute::e_before);
		SageInterface::addTextForUnparser(ref, "))", AstUnparseAttribute::e_after);
	} else if(SageInterface::isPointerType(type) && isSgTypeChar(type->findBaseType())) {
		SageInterface::addTextForUnparser(ref, "(char *)pgm_read_word(&(", AstUnparseAttribute::e_before);
		SageInterface::addTextForUnparser(ref, "))", AstUnparseAttribute::e_after);
	}
}
开发者ID:naomilwx,项目名称:fyp-arduino-code-transformer,代码行数:11,代码来源:basicProgmemTransform.cpp

示例2: isSgSourceFile

	/* 
         * The function:
	 *      buildTypedefTranslationTable()
	 * takes as a parameter a SgProject*. It will return a map<SgTypedefDeclaration*, SgType*>
	 * where the idea is that all SgTypedefDeclaration* are unique, and therefore it is 
	 * possible to create a map with it's corresponding type for easy access.  
	 */
        map< SgTypedefDeclaration*, SgType*> 
	typeInterpreter::buildTypedefTranslationTable(SgProject* project){
		ROSE_ASSERT (project != NULL);
		const SgFilePtrList& sageFilePtrList = project->get_fileList ();

		//Iterate over all global scopes in the all the files the project spans.
		for (unsigned int i = 0; i < sageFilePtrList.size (); i += 1)
		  {
		    const SgSourceFile *sageFile = isSgSourceFile (sageFilePtrList[i]);
		    ROSE_ASSERT (sageFile != NULL);
		    SgGlobal *sageGlobal = sageFile->get_globalScope();
		    ROSE_ASSERT (sageGlobal != NULL);

		    SgTypedefDeclaration* typedefDeclaration;
		    
		    //Find all TypedefdefDeclarations in current global scope.
		    Rose_STL_Container< SgNode * > typedefDeclarationList =
		      NodeQuery::querySubTree (sageGlobal,
                                               NodeQuery::TypedefDeclarations);

                    // DQ (9/26/2007): Moved from std::list to std::vector uniformly within ROSE.
                    printf ("Commented out unique() member function since it is not in std::vector class \n");
                    // typedefDeclarationList.unique();

		   //Iterate over all SgTypedefDeclarations in current global scope,
		   //and find corresponding SgType*.
		   for (Rose_STL_Container< SgNode * >::iterator typedefDeclarationElm =
			 typedefDeclarationList.begin ();
			 typedefDeclarationElm != typedefDeclarationList.end ();
			 ++typedefDeclarationElm)
                      {
			typedefDeclaration =
			  isSgTypedefDeclaration (*typedefDeclarationElm);
			ROSE_ASSERT (typedefDeclaration != NULL);
			//We only register a typedef once
			ROSE_ASSERT (typedefTranslationTable.find (typedefDeclaration) == typedefTranslationTable.end ());
		       
			SgType* typedefBaseType = typedefDeclaration->get_base_type();
			ROSE_ASSERT(typedefBaseType != NULL );
			SgType* baseType  = typedefBaseType->findBaseType(); 
		       
			
			//If the SgTypedefDeclarations has a base type which is of SgTypedefType, find a
			//SgType* which is not of type SgTypedefType. That is the corresponging SgType*.	
			while(isSgTypedefType(baseType) != NULL) 
				baseType = isSgTypedefType(baseType)->get_base_type();
	/*		cout << "The name of the typedef is:" << typedefDeclaration->get_name().str() ;
			string baseName = TransformationSupport::getTypeName(baseType);

			cout << "  The correpsonding basetype is:" << baseName << endl;

			if(isSgClassType(baseType) == NULL)
				cout << "It is NOT a CLASS TYPE." << endl;
	*/		
			ROSE_ASSERT( baseType != NULL );
			typedefTranslationTable[typedefDeclaration] = baseType;

		      }
		  }

	return typedefTranslationTable;


	} /* End method: buildTypedefTranslationTable */	
开发者ID:8l,项目名称:rose,代码行数:71,代码来源:helpFunctions.C

示例3: instr


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

          SgClassDefinition* altDecl_definition = SB::buildClassDefinition(altDecl);

          SgDeclarationStatementPtrList originalMembers = originalDecl->get_definition()->get_members();
          for(SgDeclarationStatementPtrList::iterator it = originalMembers.begin(); it != originalMembers.end(); it++)
          {
            SgDeclarationStatement* member = *it;
            SgDeclarationStatement* membercpy = isSgDeclarationStatement(SI::copyStatement(member));
            altDecl_definition->append_member(membercpy);
          }


          SgClassDeclaration* altDecl_nondef = new SgClassDeclaration(new Sg_File_Info(SI::getEnclosingFileNode(global)->getFileName()),altDecl_name,originalDecl->get_class_type());

          altDecl_nondef->set_scope(global);
          altDecl->set_scope(global);

          altDecl->set_firstNondefiningDeclaration(altDecl_nondef);
          altDecl_nondef->set_firstNondefiningDeclaration(altDecl_nondef);
          altDecl->set_definingDeclaration(altDecl);
          altDecl_nondef->set_definingDeclaration(altDecl);


          SgClassType* altDecl_ct = SgClassType::createType(altDecl_nondef);
          altDecl->set_type(altDecl_ct);
          altDecl_nondef->set_type(altDecl_ct);

          altDecl->set_isUnNamed(false);
          altDecl_nondef->set_isUnNamed(false);

          altDecl_nondef->set_forward(true);

          SgSymbol* sym = new SgClassSymbol(altDecl_nondef);
          global->insert_symbol(altDecl_name, sym);

          altDecl->set_linkage("C");
          altDecl_nondef->set_linkage("C");

          ROSE_ASSERT(sym && sym->get_symbol_basis() == altDecl_nondef);
          ROSE_ASSERT(altDecl->get_definingDeclaration() == altDecl);
          ROSE_ASSERT(altDecl->get_firstNondefiningDeclaration() == altDecl_nondef);
          ROSE_ASSERT(altDecl->search_for_symbol_from_symbol_table() == sym);
          ROSE_ASSERT(altDecl->get_definition() == altDecl_definition);
          ROSE_ASSERT(altDecl->get_scope() == global && altDecl->get_scope() == altDecl_nondef->get_scope());
          ROSE_ASSERT(altDecl_ct->get_declaration() == altDecl_nondef);

          //For some reason, this is not working...

          //global->append_statement(altDecl);
          //global->prepend_statement(altDecl_nondef);

          //SI::setOneSourcePositionForTransformation(altDecl);
          //SI::setOneSourcePositionForTransformation(altDecl_nondef);
        }

        SgType* baseType;
        if(isSgPointerType(ptr))
          baseType = ptr->dereference();
        else
          baseType = ptr->findBaseType();

        baseType = baseType->stripTypedefsAndModifiers();
        if(baseType == NULL || baseType == ptr)
        {
          //In this case, there is no base type.
          rhs = SB::buildFunctionCallExp(SgName("ti_init"),SgTypeVoid::createType(),SB::buildExprListExp(
                                           SB::buildStringVal(ptr->unparseToString()),
                                           ((altDecl == NULL && !isSgTypeVoid(ptr)) ? (SgExpression*) SB::buildSizeOfOp(types[index]) : (SgExpression*) SB::buildIntVal(-1)),
                                           SB::buildIntVal(getClassification(ptr))
                                         ),init_definition);
        }
        else
        {
          //The type has a base type.
          std::string baseStructNameStr = prefix + Util::getNameForType(baseType).getString();
          rhs = SB::buildFunctionCallExp(SgName("ti_init"),ti_type,SB::buildExprListExp(
                                           SB::buildStringVal(ptr->unparseToString()),
                                           ((altDecl == NULL && !isSgTypeVoid(ptr)) ? (SgExpression*) SB::buildSizeOfOp(types[index]) : (SgExpression*) SB::buildIntVal(-1)),
                                           SB::buildIntVal(getClassification(ptr))
                                         ),init_definition);

          SgExprStatement* set_BT = SB::buildFunctionCallStmt(SgName("setBaseType"),ti_type,SB::buildExprListExp(
                                      SB::buildVarRefExp(structNameStr),
                                      SB::buildVarRefExp(baseStructNameStr)),
                                    init_definition);
          init_definition->append_statement(set_BT);
        }
        lhs = SB::buildVarRefExp(structNameStr);


        SgExprStatement* assignstmt = SB::buildAssignStatement(lhs,rhs);
        init_definition->prepend_statement(assignstmt);
        std::remove(lst.begin(),lst.end(),structNameStr);

      }



    }
  }
开发者ID:matzke1,项目名称:rose-develop,代码行数:101,代码来源:typechecking.C


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