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


C++ SgInitializedName::get_name方法代码示例

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


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

示例1: applyRegisterOpt

void CudaOptimizer::applyRegisterOpt(SgFunctionDeclaration* kernel,
				     std::set<SgInitializedName*> readOnlyVars,
				     const MintArrFreqPairList_t& candidateVarsShared,
				     const MintArrFreqPairList_t& candidateVarsReg,
				     const bool optUnrollZ) 
{
  //perform register optimizations, go through each element in the candidate list
  //the list is in decending order based on the number of references
  
  bool optShared = MintOptions::GetInstance()->isSharedOpt();

  MintArrFreqPairList_t::const_iterator it;   
  for(it = candidateVarsReg.begin(); it != candidateVarsReg.end(); it++)
    {
      MintArrFreqPair_t apair = (*it); 
      
      SgInitializedName* array = apair.first;
      ROSE_ASSERT(array);
      
      int freq = apair.second; 
      
      MintArrFreqPairList_t::const_iterator it2; 

      bool alsoShared = false;

      for(it2 = candidateVarsShared.begin(); it2 != candidateVarsShared.end(); it2++){
	  SgInitializedName* name = (*it2).first;

	  if(name == array){
	    alsoShared = true; break;
	  }
	}

      //if we slide the planes, we perform the register opt to that variable later
      //but if shared is ON, unroll is false, then we still perform register opt first
      //TODO: Check if that includes the shared memory opt only ? Yes, shared should be ON to skip this opt      
       if( optShared && alsoShared  && optUnrollZ ){
	continue;
      }

      //TODO: should I put a limit about how many variables should be put into the registers?
      if(freq > 0 ) //should I set it to 1?
	{
	  cout << "  INFO:Mint: Candidate variable for register opt ("<< array->get_name().str() << ")";
	  cout << " with # of refs : "<< freq<< endl ; 	      
	  cout << "  INFO:Mint: Applying register optimization to array ("<< array->get_name().str() << ")"<< endl;
	  OnChipMemoryOpt::registerOptimizer(readOnlyVars, kernel, array);
	}

      //We want to put that variable in register, if we apply shared memory optimization
      else if(alsoShared && optShared )
	{
	  cout << "  INFO:Mint: Candidate variable for register opt ("<< array->get_name().str() << ")";
	  cout << " with # of refs : "<< freq<< endl ; 	      
	  cout << "  INFO:Mint: Applying register optimization to array ("<< array->get_name().str() << ")"<< endl;
	  OnChipMemoryOpt::registerOptimizer(readOnlyVars, kernel, array, NULL, true);
	}

    }//end of for 
}
开发者ID:8l,项目名称:rose,代码行数:60,代码来源:CudaOptimizer.C

示例2: DCL02_C

/**
 * Use visually distinct identifiers 
 *
 * \note also checks DCL31-C
 */
bool DCL02_C( const SgNode *node ) {
	static std::map<const SgScopeStatement *, std::set<std::string> > scopeMap;
	static std::map<std::string, const SgInitializedName *> strVarMap;

	const SgScopeStatement *scope = isSgScopeStatement(node);
	if (!scope)
		return false;

	bool violation = false;

	if (isSgGlobal(scope)) {
		std::set<std::string> externNames;

		/** populate scopeMap */
		FOREACH_SUBNODE(scope, nodes, i, V_SgInitializedName) {
			SgInitializedName *var = isSgInitializedName(*i);
			assert(var);
			if (isCompilerGeneratedNode(var)
			|| !isSgDeclarationStatement(var->get_parent())
			|| findParentOfType(var, SgCtorInitializerList)
			|| findParentOfType(var, SgClassDeclaration) // Might be too strong
			|| var->get_name().getString().empty()
			|| (var->get_name().getString().substr(0,2) == "__"))
				continue;

			/** Ignore function prototypes */
			const SgFunctionDeclaration * fnDecl = findParentOfType(var, SgFunctionDeclaration);
			if (fnDecl && !fnDecl->get_definition())
				continue;

			if (isExternVar(var)) {
				if (externNames.find(var->get_name().getString()) != externNames.end())
					continue;

				externNames.insert(var->get_name().getString());
			}

			const SgScopeStatement *varScope = var->get_scope();
			std::string str (normalize_string(var->get_name().str(), isExternVar(var)));
			if (scopeMap[varScope].find(str) != scopeMap[varScope].end()) {
				DCL02_report_error(var);
				violation = true;
			} else {
				scopeMap[varScope].insert(str);
				strVarMap[str] = var;
			}
		}
		return false;
	}
开发者ID:8l,项目名称:rose,代码行数:54,代码来源:DCL.C

示例3: visit

void visitorTraversal::visit(SgNode* n)
   {
  // There are three types ir IR nodes that can be queried for scope:
  //   - SgStatement, and 
  //   - SgInitializedName
     SgStatement* statement = isSgStatement(n);
     if (statement != NULL)
        {
          SgScopeStatement* scope = statement->get_scope();
          ROSE_ASSERT(scope != NULL);
          printf ("SgStatement       = %12p = %30s has scope = %12p = %s (total number = %d) \n",
               statement,statement->class_name().c_str(),
               scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
        }

     SgInitializedName* initializedName = isSgInitializedName(n);
     if (initializedName != NULL)
        {
          SgScopeStatement* scope = initializedName->get_scope();
          ROSE_ASSERT(scope != NULL);
          printf ("SgInitializedName = %12p = %30s has scope = %12p = %s (total number = %d)\n",
               initializedName,initializedName->get_name().str(),
               scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
        }
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:25,代码来源:scopeInformation.C

示例4: isAPPArray

// Check if this is an A++ Array Reference
bool isAPPArray(SgNode *astNode) {

	SgVarRefExp* varRefExp = isSgVarRefExp(astNode);

	if (varRefExp == NULL)
		return false;

	SgVariableSymbol* variableSymbol = varRefExp->get_symbol();
	ROSE_ASSERT(variableSymbol != NULL);
	SgInitializedName* initializedName = variableSymbol->get_declaration();
	ROSE_ASSERT(initializedName != NULL);
	SgName variableName = initializedName->get_name();

	// Now compute the offset to the index objects (form a special query for this???)

	SgType* type = variableSymbol->get_type();
	ROSE_ASSERT(type != NULL);

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

	// Recognize only these types at present
	if (typeName == "intArray" || typeName == "floatArray" || typeName == "doubleArray") {
		return true;
	}

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

示例5: fixOpStructs

/*
 *  Fix OP function calls and inject debug names
 */
void OPSource::fixOpStructs(SgNode *n)
{
  SgInitializedName* initname = isSgInitializedName(n);
  if(initname)
  {
    string var_name = initname->get_name().getString();
    SgConstructorInitializer *initer = isSgConstructorInitializer(initname->get_initializer());
    if(initer)
    {
      string class_name = initer->get_class_decl()->get_name().getString();
      if(class_name.find("op_dat") != string::npos
          || class_name.find("op_dat_gbl") != string::npos
          || class_name.compare("_op_ptr") == 0 
          || class_name.compare("_op_set") == 0 
          || class_name.compare("_op_dat_const") == 0)
      {
        cout << "---Injecting Debug Name: " << var_name << "---" << endl;
        SgExprListExp* list = initer->get_args();
        SgExpressionPtrList &exprs = list->get_expressions();
        if( isSgStringVal(exprs.back()) == NULL )
        {
          list->append_expression(buildStringVal(var_name));
        }
      }
    }
  }
}
开发者ID:nao15irikiin,项目名称:Mesh-Partitioning,代码行数:30,代码来源:rose_op2source.cpp

示例6: isSgClassDefinition

NameQuerySynthesizedAttributeType
NameQuery::queryNameUnionFieldNames (SgNode * astNode)
{

  ROSE_ASSERT (astNode != 0);

  NameQuerySynthesizedAttributeType returnNameList;

// SgNode *sageReturnNode = NULL;

  SgClassDefinition *sageClassDefinition = isSgClassDefinition (astNode);

  if (sageClassDefinition != NULL)
    {
      ROSE_ASSERT (sageClassDefinition->get_declaration () != NULL);
      if (sageClassDefinition->get_declaration ()->get_class_type () ==
          SgClassDeclaration::e_struct)
        {
          SgDeclarationStatementPtrList declarationStatementPtrList =
            sageClassDefinition->get_members ();

        typedef SgDeclarationStatementPtrList::iterator LI;

        for (LI i = declarationStatementPtrList.begin ();
             i != declarationStatementPtrList.end (); ++i)
          {
            SgNode *listElement = *i;

            SgVariableDeclaration *sageVariableDeclaration =
              isSgVariableDeclaration (listElement);

            if (sageVariableDeclaration != NULL)
              {


                typedef SgInitializedNamePtrList::iterator INITLI;

                SgInitializedNamePtrList sageInitializedNameList = sageVariableDeclaration->get_variables ();

                for (INITLI i = sageInitializedNameList.begin ();
                     i != sageInitializedNameList.end (); ++i)
                  {
                    SgInitializedName* initializedListElement = *i;
                    ROSE_ASSERT (isSgInitializedName (initializedListElement) != NULL);

                    returnNameList.push_back (initializedListElement->get_name().str());

                  }             /* End iteration over declarationStatementPtrList */

              }                 /* End iteration over declarationStatementPtrList */
          }

        }
    }

  return returnNameList;

}                               /* End function queryUnionFieldNames() */
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:58,代码来源:nameQuery.C

示例7: convertVarDeclToProgmemDecl

void BasicProgmemTransform::convertVarDeclToProgmemDecl(SgVariableDeclaration *varDecl) {
	printf("converting %s\n", varDecl->unparseToString().c_str());
	std::string dec = "const char ";
	SgInitializedName *initName = varDecl->get_variables()[0];
	std::string literal = isSgAssignInitializer(initName->get_initializer())->get_operand()->unparseToString();
	dec += initName->get_name().getString() + "[] PROGMEM =" + literal + ";";
	insertPreprocessingInfo(dec);
	SageInterface::removeStatement(varDecl, true);
}
开发者ID:naomilwx,项目名称:fyp-arduino-code-transformer,代码行数:9,代码来源:basicProgmemTransform.cpp

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

示例9: isSgArrayType

/**
 * class: SgVarRefExp
 * term: var_ref_exp_annotation(tpe,name,static,scope)
 * arg tpe: type
 * arg name: name
 * arg static: wether the declaration was static
 * arg scope: scope name (either from a namespace, a class or "null")
 */
PrologCompTerm* 
RoseToTerm::getVarRefExpSpecific(SgVarRefExp* vr) {
  SgInitializedName* n = vr->get_symbol()->get_declaration();
  /* type: in general, this can be taken "as is" from the ROSE AST. However,
   * ROSE (up to 0.9.4a-8xxx at least) gets a detail wrong: a declaration
   * like "int arr[]" as a function parameter declares a *pointer*, not an
   * array. Thus we check whether the variable might be of this sort, and if
   * yes, we must make a pointer type for it. */
  PrologTerm* typeSpecific = NULL;
  SgInitializedName* vardecl = vr->get_symbol()->get_declaration();
  SgType* t = vr->get_type()->stripType(SgType::STRIP_MODIFIER_TYPE
                                      | SgType::STRIP_REFERENCE_TYPE
                                      | SgType::STRIP_TYPEDEF_TYPE);
  if (isSgFunctionParameterList(vardecl->get_parent()) && isSgArrayType(t)) {
    SgType* baseType = isSgArrayType(t)->get_base_type();
    PrologTerm* baseTypeSpecific = getTypeSpecific(baseType);
    typeSpecific = new PrologCompTerm("pointer_type", /*1,*/ baseTypeSpecific);
  } else {
    typeSpecific = getTypeSpecific(n->get_typeptr());
  }
  /* static? (relevant for unparsing if scope is a class)*/
  PrologTerm *isStatic;
  SgDeclarationStatement* vdec = n->get_declaration();
  if (vdec != NULL) {
    isStatic = 
      getEnum(vdec->get_declarationModifier().get_storageModifier().isStatic(),
	      re.static_flags);
  } else {
    isStatic = getEnum(0, re.static_flags);
  }
  PrologTerm* scope;
  if (vdec != NULL) {
    /* named scope or irrelevant?*/
    if (SgNamespaceDefinitionStatement* scn = 
	isSgNamespaceDefinitionStatement(vdec->get_parent())) {
      scope = getNamespaceScopeName(scn);
    } else if (SgClassDefinition* scn = 
	       isSgClassDefinition(vdec->get_parent())) {
      scope = getClassScopeName(scn);
    } else {
      scope = new PrologAtom("null");
    }
  } else {
    scope = new PrologAtom("null");
  }

  return new PrologCompTerm
    ("var_ref_exp_annotation", //5,
     typeSpecific,
     /* name*/ new PrologAtom(n->get_name().getString()),
     isStatic,
     scope,
     PPI(vr));
}
开发者ID:8l,项目名称:rose,代码行数:62,代码来源:RoseToTerm.C

示例10: isSgFunctionDeclaration

void
Traversal::processNode(SgNode* n, SynthesizedAttribute& synthesizedAttribute )
  {
    // Look for names of functions
    SgFunctionDeclaration* functionDeclaration = isSgFunctionDeclaration(n);
    if (functionDeclaration != NULL)
    {
        string name = functionDeclaration->get_name().str();

        #if DEBUG > 3
          SgFunctionDefinition* functionDefinition =
              functionDeclaration->get_definition();
          if (functionDefinition != NULL)
              printf ("SgFunctionDefinition: %s \n",name.c_str());
          else
              printf ("SgFunctionDeclaration: %s \n",name.c_str());
        #endif

        synthesizedAttribute.nameList.push_back(
            NameStructureType(name,n));
        // nameSet.insert(name);
    }

    SgInitializedName* initializedName = isSgInitializedName(n);
    if (initializedName != NULL)
    {
        string name = initializedName->get_name().str();

        #if DEBUG > 3
          printf ("SgInitializedName: %s \n",name.c_str());
        #endif

        synthesizedAttribute.nameList.push_back(
            NameStructureType(name,n));
        // nameSet.insert(name);
    }

    SgNamespaceDeclarationStatement* namespaceDeclaration = isSgNamespaceDeclarationStatement(n);
    if (namespaceDeclaration != NULL)
    {
        string name = namespaceDeclaration->get_name().str();

        #if DEBUG > 3
          printf ("SgNamespaceDeclaration: %s \n",name.c_str());
        #endif

        synthesizedAttribute.nameList.push_back(
            NameStructureType(name,n));
        // nameSet.insert(name);
    }
  }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:51,代码来源:variable_name_similarity.cpp

示例11: findCandidateVarForSharedMem

void CudaOptimizer::findCandidateVarForSharedMem(MintInitNameMapExpList_t arrRefList,
						 SgInitializedName* &candidateVar, 
						 SgInitializedName* prevCandidate, 
						 int &countMaxStencilRef,int &countNonStencilRef )
{
  countMaxStencilRef = 0;
  countNonStencilRef = 0;
  
  MintInitNameMapExpList_t::iterator it; 
  //find the candidate for shared memory 
  //go through all the array list to find the candidates

  //arrRefList contains the (array, expList)
  //ex: A -> A[i][j], A[i+1][j], A[i][j-1] ...

  for(it = arrRefList.begin(); it != arrRefList.end(); it++)
    {
      SgInitializedName* array = it->first;
      ROSE_ASSERT(array);
      
      std::vector<SgExpression*> expList = it->second;
      
      //TODO: we need a better mechanism to find the count of stencil references 
      //it is not enough to say that every non-[i][j] reference is stencil
      int countNonStencil = getNonStencilArrayRefCount(expList);
      int countStencilRef = expList.size() - countNonStencil;

      //need to check if candidate is the same as prevCandidate
      //because we may be looking for the second candidate 
      if(prevCandidate == NULL || prevCandidate->get_name().str() != array->get_name().str())
	{
	  //TODO: we need to make more roboust function for isStencilArray
	  if(MintArrayInterface::isStencilArray(expList))
	    {	
	      //these ones are canditates for shared memory
	      if(countMaxStencilRef < countStencilRef)
		{
		  candidateVar = array;
		  countMaxStencilRef = countStencilRef;
		  countNonStencilRef = countNonStencil ; //do we need this?
		}
	    }	
	}
    }

  if(candidateVar != NULL)
    cout << "  INFO:Mint: Candidate variable for shared memory opt: ("<< candidateVar->get_name().str() << ")"<< endl;
}
开发者ID:8l,项目名称:rose,代码行数:48,代码来源:CudaOptimizer.C

示例12: shiftVarDeclsToProgmem

void BasicProgmemTransform::shiftVarDeclsToProgmem() {
	std::string flashHelper = "#define FS(x)(__FlashStringHelper*)(x)";
	insertPreprocessingInfo(flashHelper);
	printf("shifting var decls...\n");
	for(auto& varDecl : varDeclsToShift) {
		convertVarDeclToProgmemDecl(varDecl);
	}
	printf("shifting additional progmem strings...\n");
	for(auto &item: additionalProgmemStrings) {
		SgInitializedName *initName = item.second->get_variables()[0];
		std::string dec = "const char " + initName->get_name().getString() + "[] PROGMEM = \"" + item.first + "\";";
		insertPreprocessingInfo(dec);
//		convertVarDeclToProgmemDecl(varDecl, false);
	}
	printf("ok here\n");
}
开发者ID:naomilwx,项目名称:fyp-arduino-code-transformer,代码行数:16,代码来源:basicProgmemTransform.cpp

示例13: isSgInitializedName

bool
TaintAnalysis::magic_tainted(SgNode *node, FiniteVarsExprsProductLattice *prodLat) {
    if (isSgInitializedName(node)) {
        SgInitializedName *iname = isSgInitializedName(node);
        std::string vname = iname->get_name().getString();
        TaintLattice *tlat = dynamic_cast<TaintLattice*>(prodLat->getVarLattice(varID(iname)));
        if (tlat && 0==vname.compare(0, 7, "TAINTED")) {
            bool modified = tlat->set_vertex(TaintLattice::VERTEX_TAINTED);
            if (debug) {
                *debug <<"TaintAnalysis::magic_tainted: lattice is magically " <<tlat->to_string()
                       <<(modified?" (modified)":" (not modified)") <<"\n";
            }
            return modified;
        }
    } else if (isSgVarRefExp(node)) {
        SgVarRefExp *vref = isSgVarRefExp(node);
        std::string vname = vref->get_symbol()->get_name().getString();
        TaintLattice *tlat = dynamic_cast<TaintLattice*>(prodLat->getVarLattice(varID(vref)));
        if (tlat && 0==vname.compare(0, 7, "TAINTED")) {
            bool modified = tlat->set_vertex(TaintLattice::VERTEX_TAINTED);
            if (debug) {
                *debug <<"TaintAnalysis::magic_tainted: lattice is magically " <<tlat->to_string()
                       <<(modified?" (modified)":" (not modified)") <<"\n";
            }
            return modified;
        }
    } else if (isSgVariableDeclaration(node)) {
        SgVariableDeclaration *vdecl = isSgVariableDeclaration(node);
        const SgInitializedNamePtrList &inames = vdecl->get_variables();
        for (size_t i=0; i<inames.size(); ++i) {
            std::string vname = inames[i]->get_name().getString();
            TaintLattice *tlat = dynamic_cast<TaintLattice*>(prodLat->getVarLattice(varID(inames[i])));
            if (tlat && 0==vname.compare(0, 7, "TAINTED")) {
                bool modified = tlat->set_vertex(TaintLattice::VERTEX_TAINTED);
                if (debug) {
                    *debug <<"TaintAnalysis::magic_tainted: lattice is magically " <<tlat->to_string()
                           <<(modified?" (modified)":" (not modified)") <<"\n";
                }
                return modified;
            }
        }
    }

    return false;
}
开发者ID:LindaLovelace,项目名称:rose,代码行数:45,代码来源:taintAnalysis.C

示例14: transformCharArrayInitialization

void BasicProgmemTransform::transformCharArrayInitialization(SgFunctionDeclaration *func) {
	/* *
	 * Translates statements of the form:
	 * char arr[n] = "some string"; to:
	 * char arr[n];
	 * strcpy_P(arr, <progmem placeholder>);
	 * */
	Rose_STL_Container<SgNode *> initNames = NodeQuery::querySubTree(func, V_SgInitializedName);
	for(auto &item: initNames) {
		SgInitializedName *initName = isSgInitializedName(item);
		if(initName->get_initializer() == NULL) {
			continue;
		}
		SgVariableDeclaration * varDecl = isSgVariableDeclaration(initName->get_declaration());
		if(varDecl == NULL) {
			continue;
		}
		SgAssignInitializer *assignInit = isSgAssignInitializer(initName->get_initializer());
		if(assignInit == NULL) {
			continue;
		}
		SgType *type = initName->get_type();
		SgType *eleType = SageInterface::getElementType(type);
		if(isSgArrayType(type) && eleType != NULL && isSgTypeChar(eleType)) {
			SgStringVal* strVal = isSgStringVal(assignInit->get_operand());
			std::string str = strVal->get_value();
			int arrSize = getDeclaredArraySize(isSgArrayType(type));
			if(arrSize == 0) {
				//char arr[] = "something";
				int size = str.length() + 1;
				SgArrayType *type = SageBuilder::buildArrayType(SageBuilder::buildCharType(), SageBuilder::buildIntVal(size));
				initName->set_type(type);
			}
			varDecl->reset_initializer(NULL);
			SgVariableDeclaration *placeholder = getVariableDeclPlaceholderForString(str);
			SgVarRefExp *ref = SageBuilder::buildVarRefExp(placeholder);
			std::stringstream instr;
			instr << "\n strcpy_P(" << initName->get_name().getString();
			instr <<  ", " << ref->get_symbol()->get_name().getString() << ");\n";
			SageInterface::attachComment(varDecl, instr.str(), PreprocessingInfo::after);
			printf("transformed %s\n", initName->unparseToString().c_str());
		}

	}
}
开发者ID:naomilwx,项目名称:fyp-arduino-code-transformer,代码行数:45,代码来源:basicProgmemTransform.cpp

示例15: sageArgument

NameQuerySynthesizedAttributeType
NameQuery::queryNameArgumentNames (SgNode * astNode)
{

  ROSE_ASSERT (astNode != 0);

  NameQuerySynthesizedAttributeType returnNameList;

  SgFunctionDeclaration *sageFunctionDeclaration =
    isSgFunctionDeclaration (astNode);

  if (sageFunctionDeclaration != NULL)
    {

      typedef SgInitializedNamePtrList::iterator argumentIterator;
      SgInitializedNamePtrList sageNameList = sageFunctionDeclaration->get_args ();
      int countArguments = 0;
      for (argumentIterator i = sageNameList.begin();
           i != sageNameList.end(); ++i)
        {
          SgInitializedName* elementNode = *i;
          ROSE_ASSERT (elementNode != NULL);

          string sageArgument(elementNode->get_name().str());

          returnNameList.push_back(sageArgument.c_str());

          countArguments += 1;
        }
#if DEBUG_NAMEQUERY
      printf ("\nHere is a function declaration :Line = %d Columns = %d \n",
              ROSE::getLineNumber (isSgLocatedNode (astNode)),
              ROSE::getColumnNumber (isSgLocatedNode (astNode)));
      cout << "The filename is:" << ROSE::
        getFileName (isSgLocatedNode (astNode)) << endl;
      cout << "The count of arguments is: " << countArguments << endl;
#endif
    }

  return returnNameList;
}                               /* End function queryNameArgumentNames() */
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:41,代码来源:nameQuery.C


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