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


C++ SgType类代码示例

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


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

示例1: visit

void
CompassAnalyses::SizeOfPointer::Traversal::
visit(SgNode* node)
   { 
     int starCount;
     SgSizeOfOp *szOf = isSgSizeOfOp(node);
     if(!szOf) return;
     Rose_STL_Container<SgNode*> pointers = NodeQuery::querySubTree(node,V_SgPointerType);
     Rose_STL_Container<SgNode*> deRefs = NodeQuery::querySubTree(node,V_SgPointerDerefExp);
     Rose_STL_Container<SgNode*> varRefs = NodeQuery::querySubTree(node,V_SgVarRefExp);
     for (Rose_STL_Container<SgNode *>::iterator i = varRefs.begin(); i != varRefs.end(); i++)
       {
         SgVarRefExp *vRef = isSgVarRefExp((*i));
         if (!vRef) return;
         SgType *t = vRef->get_type();
         std::string typeName = t->unparseToString();
         //std::cout << countStars(typeName) <<   std::endl;
         starCount = countStars(typeName);
         if (!starCount or
             (starCount == pointers.size() and 
              deRefs.size() == (starCount - 1)))
           {
             //std::cout << "IT'S OK!" << std::endl;
             return;
           }
         
         
       }
     output->addOutput(new CheckerOutput(node));
} //End of the visit function.
开发者ID:8l,项目名称:rose,代码行数:30,代码来源:sizeOfPointer.C

示例2: ROSE_ASSERT

       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

示例3: uniqueNameGenerator

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

示例4: 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

示例5: main

int main(int argc, char** argv) {

   SgProject* proj = frontend(argc, argv);

  // Set up the struct layout chain
  initUpcSizes(); 
  CustomizedPrimitiveTypeLayoutGenerator gen1_upc(NULL,&upc_sizes);
  NonpackedTypeLayoutGenerator gen_upc(&gen1_upc);

  // Process every type used in a variable or parameter declaration
  vector<SgNode*> initNames = NodeQuery::querySubTree(proj, V_SgInitializedName);
  for (size_t i = 0; i < initNames.size(); ++i) {
    SgInitializedName* in = isSgInitializedName(initNames[i]);
    SgType* t = in->get_type();
    if (isSgTypeEllipse(t)) continue;
    cout << in->get_name().getString() << " has type " << t->unparseToString() << ":\n";
    cout << "For a customized UPC platform:\n";
    cout << gen_upc.layoutType(t) << "\n";
    size_t size = gen_upc.layoutType(t).size;
    size_t element_size=size;
    if (isSgArrayType(t)) 
      element_size = gen_upc.layoutType(
                SageInterface::getArrayElementType(isSgArrayType(t))).size;

#if 0
    if (isSgArrayType(t))
    {
      cout<<"Found an array, output its element type info."<<endl;
      cout<< gen_upc.layoutType(SageInterface::getArrayElementType(isSgArrayType(t)))<<endl;
      // Array of shared UPC elements

    }
#endif    
    if (isUpcSharedType(t))
    { 
      size_t block_bytes = SageInterface::getUpcSharedBlockSize(t);
      if (!isSgArrayType(t) || block_bytes == 0)
        { block_bytes = size; }
      else
        {block_bytes = min (block_bytes*element_size, size);}
      size_t num_blocks = (size % block_bytes==0)?(size/block_bytes):size/block_bytes +1;
      int hasThreads=0;
      if (isSgArrayType(t))
        if (isUpcArrayWithThreads(isSgArrayType(t)))
          hasThreads =1;

      cout<<"Found a shared UPC type: block bytes="<<block_bytes
          <<" Number of block="<<num_blocks
          <<" Multiply by THREADS="<<hasThreads
          <<" Element size="<<element_size
          <<endl;
    } // UPC shared types

  } // end for
  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:56,代码来源:abiStuffTestUPC.C

示例6: if

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

示例7: visit

void
CompassAnalyses::UnaryMinus::Traversal::
visit(SgNode* node)
   { 
     if (SgMinusOp *minus = isSgMinusOp(node))
     {
       SgType *t = minus->get_operand()->get_type();
       if (t->isUnsignedType())
         output->addOutput(new CheckerOutput(minus));
     }
   } //End of the visit function.
开发者ID:8l,项目名称:rose,代码行数:11,代码来源:unaryMinus.C

示例8: isSgFunctionDeclaration

void PreAndPostOrderTraversal::preOrderVisit(SgNode* n) {

        SgFunctionDeclaration * dec = isSgFunctionDeclaration(n);
        if (dec != NULL) {
                cout << "Found function declaration " << dec->get_name().getString();
                Sg_File_Info * start = dec->get_startOfConstruct();
                Sg_File_Info * end = dec->get_endOfConstruct();
                if(start->isCompilerGenerated()) {
                        cout << ", which is compiler-generated" << endl;
                } else {
                        cout << " in file " << start->get_raw_filename() << ", " << start->get_file_id() << " from line " << 
                            start->get_line() << ", col " << start->get_col() << " to line " << 
                            end->get_line() << ", col " << end->get_col() << endl;
                }
                SgFunctionType * type = dec->get_type();
                SgType * retType = type->get_return_type();
        cout << "Return type: " << retType->unparseToString() << endl;
        SgFunctionParameterList * params = dec->get_parameterList();
        SgInitializedNamePtrList & ptrList = params->get_args();
        if(!ptrList.empty()) {
            cout << "Parameter types: ";
            for(SgInitializedNamePtrList::iterator j = ptrList.begin(); j != ptrList.end(); j++) {
                SgType * pType = (*j)->get_type();
                cout << pType->unparseToString() << " ";
            }
            cout << endl;
        }
        cout << "Linkage: " << dec->get_linkage() << endl;
               cout << endl;
        }


        SgFunctionDefinition * def = isSgFunctionDefinition(n);
        if (def != NULL) {
                cout << "Found function definition " << def->get_declaration()->get_name().getString();
                Sg_File_Info * start = def->get_startOfConstruct();
                Sg_File_Info * end = def->get_endOfConstruct();
                if(start->isCompilerGenerated()) {
                        cout << ", which is compiler-generated" << endl;
                } else {
                        cout << " in file " << start->get_raw_filename() << " from line " << start->get_line() << ", col " << start->get_col() << " to line " << end->get_line() << ", col " << end->get_col() << endl;
                SgBasicBlock * body = def->get_body();
        Sg_File_Info * bodyStart = body->get_startOfConstruct();
        Sg_File_Info * bodyEnd =   body->get_endOfConstruct();
        cout << "Function body from line " << bodyStart->get_line() << ", col " << bodyStart->get_col() << " to line " << bodyEnd->get_line() << ", col " << bodyEnd->get_col() << endl; 
 }
        cout << endl;
        }
}
开发者ID:nchaimov,项目名称:pdt_roseparse,代码行数:49,代码来源:functionLocator.C

示例9: 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

示例10: translateArrayDeclaration

void Fortran_to_C::translateArrayDeclaration(SgArrayType* originalArrayType)
{
  // Get dim_info
  SgExprListExp* dimInfo = originalArrayType->get_dim_info();
  // Get dim list
  SgExpressionPtrList dimExpressionPtrList = dimInfo->get_expressions();
  // Get array base_type
  SgType* baseType = originalArrayType->get_base_type();

  Rose_STL_Container<SgExpression*>::iterator j =  dimExpressionPtrList.begin();
  SgExpression* indexExpression = getFortranDimensionSize(*j);
  //std::cout << "array rank:" << originalArrayType->get_rank() << std::endl;
  if(originalArrayType->get_rank() == 1)
  {
    originalArrayType->set_base_type(baseType);
    originalArrayType->set_index(indexExpression);
    indexExpression->set_parent(originalArrayType);
    constantFolding(indexExpression);
  }
  else
  {
    SgArrayType* newType = buildArrayType(baseType,indexExpression);
    baseType->set_parent(newType);
    j = j + 1;
    for(; j< (dimExpressionPtrList.end()-1); ++j)
    {
      indexExpression = getFortranDimensionSize(*j);
      baseType = newType;
      newType = buildArrayType(baseType,indexExpression);
      baseType->set_parent(newType);
    }
    j = dimExpressionPtrList.end()-1;
    indexExpression = getFortranDimensionSize(*j);
    originalArrayType->set_base_type(newType);
    originalArrayType->set_index(indexExpression);
    indexExpression->set_parent(originalArrayType);
  }
}
开发者ID:8l,项目名称:rose,代码行数:38,代码来源:f2cArray.C

示例11: typeVariantT

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

示例12: writeSgBinaryOpZ3

std::string writeSgBinaryOpZ3(SgBinaryOp* op, SgExpression* lhs, SgExpression* rhs) {
	
	std::stringstream ss;
	std::string opStr;
	bool compAssign = false;
	if (isSgCompoundAssignOp(op)) {
		compAssign = true;
		opStr = getSgCompoundAssignOp(isSgCompoundAssignOp(op));
	
	}
	else {
		opStr = getSgBinaryOp(op);
	}
	ROSE_ASSERT(opStr != "unknown");
	std::string rhsstring;
	std::string lhsstring;
	lhsstring = getSgExpressionString(lhs);
	SgType* lhstyp;
	SgType* rhstyp;
	if (isSgArrayType(lhs->get_type())) {
	lhstyp = isSgArrayType(lhs->get_type())->get_base_type();	
	}
	else {
	lhstyp = lhs->get_type();
	}
	if (isSgArrayType(rhs->get_type())) {
	rhstyp = isSgArrayType(rhs->get_type())->get_base_type();
	}
	else {
	rhstyp = rhs->get_type();
	}
	if (isSgEnumType(lhs->get_type())) {
	}
	else {	
	ROSE_ASSERT(lhstyp == rhstyp);
	}	
	if (isSgValueExp(rhs)) {
		rhsstring = getSgValueExp(isSgValueExp(rhs));
	}
	else if (isSgUnaryOp(rhs)) {	
		rhsstring = getSgUnaryOp(isSgUnaryOp(rhs));
	}
		
	else {
		rhsstring = getSgExpressionString(rhs);
	}
	if (opStr == "/" && lhstyp->isIntegerType()) {
		opStr = "cdiv";
	} 
	if (opStr == "assign" || compAssign) {
		if (isSgVarRefExp(lhs)) {
		SgVarRefExp* lhsSgVarRefExp = isSgVarRefExp(lhs);
		int instances = SymbolToInstances[lhsSgVarRefExp->get_symbol()];
		std::stringstream instanceName;
		SymbolToInstances[lhsSgVarRefExp->get_symbol()] = instances + 1;
		std::string lhsname = SymbolToZ3[lhsSgVarRefExp->get_symbol()];
		instanceName << lhsname << "_" << (instances+1);
		SgType* varType = lhsSgVarRefExp->get_type();
		std::string typeZ3;
		if (varType->isFloatType()) {
			typeZ3 = "Real";
		}
		else if (varType->isIntegerType()) {
			typeZ3 = "Int";
		}
		else if (isSgEnumType(varType)) {
			typeZ3 = isSgEnumType(varType)->get_name().getString();
		}
		else {
			typeZ3 = "Unknown";
		}
		ss << "(declare-fun " << instanceName.str() << " () " << typeZ3 << ")\n";
		if (!compAssign) {  		
			ss << "(assert (= " << instanceName.str() << " " << rhsstring << "))";
		}
		else {
			std::stringstream oldInstanceName;
			oldInstanceName << lhsname << "_" << instances;
			ss << "(assert (= " << instanceName.str() << " (" << opStr << " " << oldInstanceName.str() << " " << rhsstring << ")))"; 
		}
		}
		
		else {
			ROSE_ASSERT(isSgPntrArrRefExp(lhs));
			std::string u_type;
			SgPntrArrRefExp* lhspntr = isSgPntrArrRefExp(lhs);
			SgVarRefExp* varlhspntr = isSgVarRefExp(lhspntr->get_lhs_operand());
			SgArrayType* arrTy = isSgArrayType(varlhspntr->get_type());
			if (arrTy->get_base_type()->isIntegerType()) {
				u_type = "Int";
			}
			else if (arrTy->get_base_type()->isFloatType()) {
				u_type = "Real";
			}
			else {
				std::cout << "unknown base type for array" << std::endl;
				ROSE_ASSERT(false);
			}
			std::stringstream oldInstanceName;
			SgVarRefExp* varexp = isSgVarRefExp((isSgPntrArrRefExp(lhs))->get_lhs_operand());
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:smtQueryLib.cpp

示例13: querySolverGrammarElementFromVariantVector

// DQ (4/7/2004): Added to support more general lookup of data in the AST (vector of variants)
void* querySolverGrammarElementFromVariantVector ( SgNode * astNode, VariantVector targetVariantVector,  NodeQuerySynthesizedAttributeType* returnNodeList )
   {
  // This function extracts type nodes that would not be traversed so that they can
  // accumulated to a list.  The specific nodes collected into the list is controlled
  // by targetVariantVector.

     ROSE_ASSERT (astNode != NULL);

#if 0
     printf ("Inside of void* querySolverGrammarElementFromVariantVector() astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif

     Rose_STL_Container<SgNode*> nodesToVisitTraverseOnlyOnce;

     pushNewNode (returnNodeList,targetVariantVector,astNode);

     vector<SgNode*>               succContainer      = astNode->get_traversalSuccessorContainer();
     vector<pair<SgNode*,string> > allNodesInSubtree  = astNode->returnDataMemberPointers();

#if 0
     printf ("succContainer.size()     = %zu \n",succContainer.size());
     printf ("allNodesInSubtree.size() = %zu \n",allNodesInSubtree.size());
#endif

     if ( succContainer.size() != allNodesInSubtree.size() )
        {
          for (vector<pair<SgNode*,string> >::iterator iItr = allNodesInSubtree.begin(); iItr!= allNodesInSubtree.end(); ++iItr )
             {
#if 0
               if ( iItr->first != NULL  )
                  {
                 // printf ("iItr->first = %p = %s \n",iItr->first,iItr->first->class_name().c_str());
                    printf ("iItr->first = %p \n",iItr->first);
                    printf ("iItr->first = %p = %s \n",iItr->first,iItr->first->class_name().c_str());
                  }
#endif
            // DQ (7/27/2014): Check if this is always non-NULL.
            // ROSE_ASSERT(iItr->first != NULL);
#if 0
               if (iItr->first != NULL)
                  {
                 // printf ("In querySolverGrammarElementFromVariantVector(): iItr->first->variantT() = %d class_name = %s \n",iItr->first->variantT(),iItr->first->class_name().c_str());
                    printf ("In querySolverGrammarElementFromVariantVector(): iItr->first             = %p \n",iItr->first);
                    printf ("In querySolverGrammarElementFromVariantVector(): iItr->first->class_name = %s \n",iItr->first->class_name().c_str());
                    printf ("In querySolverGrammarElementFromVariantVector(): iItr->first->variantT() = %d \n",(int)iItr->first->variantT());
                  }
                 else
                  {
                    printf ("In querySolverGrammarElementFromVariantVector(): iItr->first == NULL \n");
                  }
#endif
               SgType* type = isSgType(iItr->first);
               if ( type != NULL  )
                  {
                 // DQ (1/13/2011): If we have not already seen this entry then we have to chase down possible nested types.
                 // if (std::find(succContainer.begin(),succContainer.end(),iItr->first) == succContainer.end() )
                    if (std::find(succContainer.begin(),succContainer.end(),type) == succContainer.end() )
                       {
                      // DQ (1/30/2010): Push the current type onto the list first, then any internal types...
                         pushNewNode (returnNodeList,targetVariantVector,type);

                      // Are there any other places where nested types can be found...?
                      // if ( isSgPointerType(iItr->first) != NULL  || isSgArrayType(iItr->first) != NULL || isSgReferenceType(iItr->first) != NULL || isSgTypedefType(iItr->first) != NULL || isSgFunctionType(iItr->first) != NULL || isSgModifierType(iItr->first) != NULL)
                      // if (type->containsInternalTypes() == true)
                         if (type->containsInternalTypes() == true)
                            {
#if 0
                              printf ("If we have not already seen this entry then we have to chase down possible nested types. \n");
                           // ROSE_ASSERT(false);
#endif

                              Rose_STL_Container<SgType*> typeVector = type->getInternalTypes();
#if 0
                              printf ("----- typeVector.size() = %zu \n",typeVector.size());
#endif
                              Rose_STL_Container<SgType*>::iterator i = typeVector.begin();
                              while(i != typeVector.end())
                                 {
#if 0
                                   printf ("----- internal type = %s \n",(*i)->class_name().c_str());
#endif
                                // DQ (1/16/2011): This causes a test in tests/roseTests/programAnalysisTests/variableLivenessTests 
                                // to fail with error "Error :: Number of nodes = 37  should be : 36"

                                // Add this type to the return list of types.
                                   pushNewNode (returnNodeList,targetVariantVector,*i);

                                   i++;
                                 }
                            }

                      // DQ (1/30/2010): Move this code to the top of the basic block.
                      // pushNewNode (returnNodeList,targetVariantVector,iItr->first);
                      // pushNewNode (returnNodeList,targetVariantVector,type);
                       }
                  }
             }
        }

//.........这里部分代码省略.........
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:101,代码来源:queryVariant.C

示例14: ATgetAnnotation

SgType*
AtermSupport::getAtermTypeNodeAttribute (ATerm term, const std::string & annotationName )
   {
     SgType* returnNode = NULL;

     ATerm idannot = ATgetAnnotation(term, ATmake(annotationName.c_str()));
     if (idannot)
        {
#if 1
          printf ("In getAtermTypeNodeAttribute(): Found an annotation: annotationName = %s \n",annotationName.c_str());
#endif
          char* id = NULL;
       // Get the associated annotation string.
          if (ATmatch(idannot, "<str>", &id))
             {
#if 1
                printf ("In getAtermTypeNodeAttribute(): Found an string in the annotation: annotationName = %s id = %s \n",annotationName.c_str(),id);
#endif
               if (translationTypeMap.find(id) != translationTypeMap.end())
                  {
                    returnNode = translationTypeMap[id];
                    ROSE_ASSERT(returnNode != NULL);
#if 1
                    printf ("In getAtermTypeNodeAttribute translationTypeMap: id = %s returnNode = %p = %s \n",id,returnNode,returnNode->class_name().c_str());
#endif
                  }
                 else
                  {
#if 1
                    printf ("In getAtermTypeNodeAttribute(): Node not found in translationTypeMap: returing NULL pointer \n");
#endif
                  }
             }
            else
             {
            // Including types in the aterm annotations will put <term> entried in the associated term used for annotations.
            // so we need to handle ATmatch(idannot, "<term>", &term1)) as a pattern.
               ATerm term1;
               if (ATmatch(idannot, "<term>", &term1))
                  {
                    printf ("Found pattern used for nested types! \n");

                    string type_aterm_string = ATwriteToString(term1);
                    printf ("NOTE: type_aterm_string = %s \n",type_aterm_string.c_str());
                    printf ("DIAGNOSTIC: aterm_type_name = %s \n",aterm_type_name(term).c_str());

                    SgNode* n = generate_AST(term1);
                    ROSE_ASSERT(n != NULL);
                    returnNode = isSgType(n);
                    ROSE_ASSERT(returnNode != NULL);
                  }
                 else
                  {
                    printf ("Could not find nested type! \n");
                    ROSE_ASSERT(false);
                  }
#if 0
               printf ("Error: The nested aterm associated with the annotation must be available on the aterm: annotationName = %s \n",annotationName.c_str());
               ROSE_ASSERT(false);
#endif
             }
        }
       else
        {
          printf ("Error: The annotation not found on the aterm: annotationName = %s \n",annotationName.c_str());
          ROSE_ASSERT(false);
        }

#if 0
     printf ("In AtermSupport::getAtermTypeNodeAttribute(): not yet implemented \n");
     ROSE_ASSERT(false);
#endif

     return returnNode;
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:75,代码来源:atermSupport.C

示例15: calculateBytes

  //! Return an expression like 8*sizeof(int)+ 3*sizeof(float) + 5*sizeof(double) for a list of variables accessed (either read or write)
  // For array variable, we should only count a single element access, not the entire array size
  // Algorithm:  
  //   Iterate on each variable in the set
  //     group them into buckets based on types, using a map<SgType*, int> to store this
  //   Iterate the list of buckets to generate count*sizeof(type) + .. expression 
  SgExpression* calculateBytes (std::set<SgInitializedName*>& name_set, SgScopeStatement* scope, bool isRead)
  {
    SgExpression* result = NULL; 
    if (name_set.size()==0) return result;

   // the input is essentially the loop body, a scope statement
   ROSE_ASSERT (scope != NULL);
    // We need to record the associated loop info.
    SgStatement* loop= NULL;
    SgForStatement* forloop = isSgForStatement(scope->get_scope());
    SgFortranDo* doloop = isSgFortranDo(scope->get_scope());

    if (forloop)
      loop = forloop;
    else if (doloop)
      loop = doloop;
    else
    {
      cerr<<"Error in CountLoadStoreBytes (): input is not loop body type:"<< scope->class_name()<<endl;
      assert(false);
    }   

    std::map<SgType* , int> type_based_counters; 

   // get all processed variables by inner loops
    std::set<SgInitializedName*> processed_var_set; 
    getVariablesProcessedByInnerLoops (scope, isRead, processed_var_set);
    
    // fill in the type-based counters
    std::set<SgInitializedName*>::iterator set_iter; 
    for (set_iter = name_set.begin(); set_iter != name_set.end(); set_iter++)
    {
      SgInitializedName* init_name = *set_iter; 
      // skip visited variable when processing inner loops
      // some global variables may be visited by another function
      // But we should count it when processing the current function!
      //
      // We group all references to a same variable into one reference for now
      // if a variable is considered when processing inner loops, the variable
      // will be skipped when processing outer loops.
      if (isRead)
      {
         // if inner loops already processed it, skip it
        if (processed_var_set.find(init_name) != processed_var_set.end())
          continue; 
        else
          LoopLoadVariables[loop].insert(init_name); 
      }
      else
      {
        if (processed_var_set.find(init_name) != processed_var_set.end())
          continue; 
        else
          LoopStoreVariables[loop].insert(init_name); 
      }
      // It is tricky here, TODO consider pointer, typedefs, reference, modifier types
      SgType* stripped_type = (*set_iter)->get_type()->stripTypedefsAndModifiers();
      SgType* base_type = NULL; 
      if (isScalarType(stripped_type))
        base_type = stripped_type;
      else if (isSgArrayType(stripped_type))
      {  // we may have multi-dimensional arrays like int a[][][];
        base_type = stripped_type; 
        do {
         base_type = isSgArrayType(base_type)->get_base_type(); 
        } while (isSgArrayType (base_type));
      }
      else 
      {
        cerr<<"Error in calculateBytes(). Unhandled stripped type:"<<stripped_type->class_name()<<endl;
        assert (false);
      }

      type_based_counters[base_type] ++; 
    } // end for

    // use the type-based counters for byte calculation
    std::map<SgType* , int>::iterator citer; 
    //It is possible now to have zero after filtering out redundant variables
    //assert (type_based_counters.size()>0);
    for (citer = type_based_counters.begin(); citer !=type_based_counters.end(); citer ++)
    {
      SgType* t = (*citer).first;
      // at this point, we should not have array types any more
      ROSE_ASSERT (isSgArrayType (t) == false); 
      int count = (*citer).second; 
      assert (t != NULL);
      assert (count>0);
      SgExpression* sizeof_exp = NULL; 
      if (is_Fortran_language())
      {
#if 0  // this does not work. cannot find func symbol for sizeof()       
      // In Fortran sizeof() is a function call, not  SgSizeOfOp.
      // type name is a variable in the AST, 
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:ai_measurement.cpp


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