本文整理汇总了C++中SgInitializedName::set_file_info方法的典型用法代码示例。如果您正苦于以下问题:C++ SgInitializedName::set_file_info方法的具体用法?C++ SgInitializedName::set_file_info怎么用?C++ SgInitializedName::set_file_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgInitializedName
的用法示例。
在下文中一共展示了SgInitializedName::set_file_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildClassDeclarationAndDefinition
SgVariableDeclaration*
buildStructVariable ( SgScopeStatement* scope,
vector<SgType*> memberTypes, vector<string> memberNames,
string structName = "", string varName = "", SgAggregateInitializer *initializer = NULL )
{
ROSE_ASSERT(memberTypes.size() == memberNames.size());
SgClassDeclaration* classDeclaration = buildClassDeclarationAndDefinition(structName,scope);
vector<SgType*>::iterator typeIterator = memberTypes.begin();
vector<string>::iterator memberNameIterator = memberNames.begin();
while (typeIterator != memberTypes.end())
{
// printf ("Adding data member type = %s variable name = %s \n",(*typeIterator)->unparseToString().c_str(),memberNameIterator->c_str());
SgVariableDeclaration* memberDeclaration = new SgVariableDeclaration(SOURCE_POSITION,*memberNameIterator,*typeIterator,NULL);
memberDeclaration->set_endOfConstruct(SOURCE_POSITION);
classDeclaration->get_definition()->append_member(memberDeclaration);
memberDeclaration->set_parent(classDeclaration->get_definition());
// Liao (2/13/2008) scope and symbols for member variables
SgInitializedName* initializedName = *(memberDeclaration->get_variables().begin());
initializedName->set_file_info(SOURCE_POSITION);
initializedName->set_scope(classDeclaration->get_definition());
// set nondefning declaration pointer
memberDeclaration->set_firstNondefiningDeclaration(memberDeclaration);
SgVariableSymbol* variableSymbol = new SgVariableSymbol(initializedName);
classDeclaration->get_definition()->insert_symbol(*memberNameIterator,variableSymbol);
typeIterator++;
memberNameIterator++;
}
SgClassType* classType = new SgClassType(classDeclaration->get_firstNondefiningDeclaration());
SgVariableDeclaration* variableDeclaration = new SgVariableDeclaration(SOURCE_POSITION,varName,classType,initializer);
variableDeclaration->set_endOfConstruct(SOURCE_POSITION);
//Liao (2/13/2008) scope and symbols for struct variable
SgInitializedName* initializedName = *(variableDeclaration->get_variables().begin());
initializedName->set_file_info(SOURCE_POSITION);
initializedName->set_scope(scope);
SgVariableSymbol* variableSymbol = new SgVariableSymbol(initializedName);
scope->insert_symbol(varName,variableSymbol);
//set nondefining declaration
variableDeclaration->set_firstNondefiningDeclaration(variableDeclaration);
// This is required, since it is not set in the SgVariableDeclaration constructor
initializer->set_parent(variableDeclaration);
variableDeclaration->set_variableDeclarationContainsBaseTypeDefiningDeclaration(true);
variableDeclaration->set_baseTypeDefiningDeclaration(classDeclaration->get_definingDeclaration());
classDeclaration->set_parent(variableDeclaration);
return variableDeclaration;
}
示例2: rand
DoxygenFile::DoxygenFile(SgProject *prj, string filename)
{
Sg_File_Info *info = new Sg_File_Info(filename, 0, 0);
SgInitializedName *iname = new SgInitializedName;
stringstream sname;
sname << "SAGE_Doxygen_Dummy_" << rand();
iname->set_name(sname.str());
iname->set_type(new SgTypeInt);
iname->set_file_info(info);
iname->get_storageModifier().setExtern();
SgVariableDeclaration *decl = new SgVariableDeclaration;
decl->get_variables().push_back(iname);
decl->set_startOfConstruct(info);
decl->set_endOfConstruct(info);
decl->get_declarationModifier().get_storageModifier().setExtern();
iname->set_parent(decl);
iname->set_prev_decl_item(iname);
// SgGlobal *glob = prj->get_file(0).get_globalScope();
SgSourceFile* sourceFile = isSgSourceFile(prj->get_fileList()[0]);
ROSE_ASSERT(sourceFile != NULL);
SgGlobal *glob = sourceFile->get_globalScope();
// glob->insertStatementInScope(decl, true);
glob->get_declarations().insert(glob->get_declarations().begin(),decl);
decl->set_parent(glob);
SgVariableSymbol* variableSymbol = new SgVariableSymbol(iname);
glob->insert_symbol(sname.str(),variableSymbol);
decl->set_parent(glob);
std::cout << "Before complete string." << std::endl;
//glob->append_declaration(decl);
iname->set_scope(glob);
decl->unparseToCompleteString();
std::cout << "After complete string." << std::endl;
commentParent = decl;
printf("commentParent = %p\n", commentParent);
}
示例3: isSgBasicBlock
void
SimpleInstrumentation::visit ( SgNode* astNode )
{
SgBasicBlock* block = isSgBasicBlock(astNode);
if (block != NULL)
{
// Mark this as a transformation (required)
Sg_File_Info* sourceLocation = Sg_File_Info::generateDefaultFileInfoForTransformationNode();
ROSE_ASSERT(sourceLocation != NULL);
SgType* type = new SgTypeInt();
ROSE_ASSERT(type != NULL);
SgName name = "newVariable";
SgVariableDeclaration* variableDeclaration = new SgVariableDeclaration(sourceLocation,name,type);
ROSE_ASSERT(variableDeclaration != NULL);
SgInitializedName* initializedName = *(variableDeclaration->get_variables().begin());
initializedName->set_file_info(Sg_File_Info::generateDefaultFileInfoForTransformationNode());
// DQ (6/18/2007): The unparser requires that the scope be set (for name qualification to work).
initializedName->set_scope(block);
// Liao (2/13/2008): AstTests requires this to be set
variableDeclaration->set_firstNondefiningDeclaration(variableDeclaration);
ROSE_ASSERT(block->get_statements().size() > 0);
block->get_statements().insert(block->get_statements().begin(),variableDeclaration);
variableDeclaration->set_parent(block);
// Add a symbol to the sybol table for the new variable
SgVariableSymbol* variableSymbol = new SgVariableSymbol(initializedName);
block->insert_symbol(name,variableSymbol);
}
}