本文整理汇总了C++中SgVariableDeclaration::set_endOfConstruct方法的典型用法代码示例。如果您正苦于以下问题:C++ SgVariableDeclaration::set_endOfConstruct方法的具体用法?C++ SgVariableDeclaration::set_endOfConstruct怎么用?C++ SgVariableDeclaration::set_endOfConstruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgVariableDeclaration
的用法示例。
在下文中一共展示了SgVariableDeclaration::set_endOfConstruct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: thisname
//.........这里部分代码省略.........
assert (isSgFunctionDefinition(my_fundef));
if (isSgFunctionDefinition(my_fundef) == fundef)
{
std::cout << "Inline failed: trying to inline a procedure into itself" << std::endl;
return false;
}
}
SgVariableDeclaration* thisdecl = 0;
SgName thisname("this__");
thisname << ++gensym_counter;
SgInitializedName* thisinitname = 0;
if (isSgMemberFunctionSymbol(funsym) && !fundecl->get_declarationModifier().get_storageModifier().isStatic())
{
assert (thisptr != NULL);
SgType* thisptrtype = thisptr->get_type();
const SgSpecialFunctionModifier& specialMod =
funsym->get_declaration()->get_specialFunctionModifier();
if (specialMod.isConstructor()) {
SgFunctionType* ft = funsym->get_declaration()->get_type();
ROSE_ASSERT (ft);
SgMemberFunctionType* mft = isSgMemberFunctionType(ft);
ROSE_ASSERT (mft);
SgType* ct = mft->get_class_type();
thisptrtype = new SgPointerType(ct);
}
SgConstVolatileModifier& thiscv = fundecl->get_declarationModifier().get_typeModifier().get_constVolatileModifier();
// if (thiscv.isConst() || thiscv.isVolatile()) { FIXME
thisptrtype = new SgModifierType(thisptrtype);
isSgModifierType(thisptrtype)->get_typeModifier().get_constVolatileModifier() = thiscv;
// }
// cout << thisptrtype->unparseToString() << " --- " << thiscv.isConst() << " " << thiscv.isVolatile() << endl;
SgAssignInitializer* assignInitializer = new SgAssignInitializer(SgNULL_FILE, thisptr);
assignInitializer->set_endOfConstruct(SgNULL_FILE);
#if 1
printf ("before new SgVariableDeclaration(): assignInitializer = %p assignInitializer->isTransformation() = %s \n",assignInitializer,assignInitializer->isTransformation() ? "true" : "false");
#endif
thisdecl = new SgVariableDeclaration(SgNULL_FILE, thisname, thisptrtype, assignInitializer);
#if 1
printf ("(after new SgVariableDeclaration(): assignInitializer = %p assignInitializer->isTransformation() = %s \n",assignInitializer,assignInitializer->isTransformation() ? "true" : "false");
#endif
thisdecl->set_endOfConstruct(SgNULL_FILE);
thisdecl->get_definition()->set_endOfConstruct(SgNULL_FILE);
thisdecl->set_definingDeclaration(thisdecl);
thisinitname = (thisdecl->get_variables()).back();
//thisinitname = lastElementOfContainer(thisdecl->get_variables());
// thisinitname->set_endOfConstruct(SgNULL_FILE);
assignInitializer->set_parent(thisinitname);
markAsTransformation(assignInitializer);
// printf ("Built new SgVariableDeclaration #1 = %p \n",thisdecl);
// DQ (6/23/2006): New test
ROSE_ASSERT(assignInitializer->get_parent() != NULL);
}
// Get the list of actual argument expressions from the function call, which we'll later use to initialize new local
// variables in the inlined code. We need to detach the actual arguments from the AST here since we'll be reattaching
// them below (otherwise we would violate the invariant that the AST is a tree).
SgFunctionDefinition* targetFunction = PRE::getFunctionDefinition(funcall);
SgExpressionPtrList funargs = funcall->get_args()->get_expressions();
funcall->get_args()->get_expressions().clear();
BOOST_FOREACH (SgExpression *actual, funargs)
actual->set_parent(NULL);
示例4: if
//.........这里部分代码省略.........
assert (isSgFunctionDefinition(my_fundef));
if (isSgFunctionDefinition(my_fundef) == fundef)
{
std::cout << "Inline failed: trying to inline a procedure into itself" << std::endl;
return false;
}
}
SgVariableDeclaration* thisdecl = 0;
SgName thisname("this__");
thisname << ++gensym_counter;
SgInitializedName* thisinitname = 0;
if (isSgMemberFunctionSymbol(funsym) && !fundecl->get_declarationModifier().get_storageModifier().isStatic())
{
assert (thisptr != NULL);
SgType* thisptrtype = thisptr->get_type();
const SgSpecialFunctionModifier& specialMod =
funsym->get_declaration()->get_specialFunctionModifier();
if (specialMod.isConstructor()) {
SgFunctionType* ft = funsym->get_declaration()->get_type();
ROSE_ASSERT (ft);
SgMemberFunctionType* mft = isSgMemberFunctionType(ft);
ROSE_ASSERT (mft);
SgType* ct = mft->get_class_type();
thisptrtype = new SgPointerType(ct);
}
SgConstVolatileModifier& thiscv = fundecl->get_declarationModifier().get_typeModifier().get_constVolatileModifier();
// if (thiscv.isConst() || thiscv.isVolatile()) { FIXME
thisptrtype = new SgModifierType(thisptrtype);
isSgModifierType(thisptrtype)->get_typeModifier().get_constVolatileModifier() = thiscv;
// }
// cout << thisptrtype->unparseToString() << " --- " << thiscv.isConst() << " " << thiscv.isVolatile() << endl;
SgAssignInitializer* assignInitializer = new SgAssignInitializer(SgNULL_FILE, thisptr);
assignInitializer->set_endOfConstruct(SgNULL_FILE);
// thisdecl = new SgVariableDeclaration(SgNULL_FILE, thisname, thisptrtype, new SgAssignInitializer(SgNULL_FILE, thisptr));
thisdecl = new SgVariableDeclaration(SgNULL_FILE, thisname, thisptrtype, assignInitializer);
thisdecl->set_endOfConstruct(SgNULL_FILE);
thisdecl->get_definition()->set_endOfConstruct(SgNULL_FILE);
thisdecl->set_definingDeclaration(thisdecl);
thisinitname = (thisdecl->get_variables()).back();
//thisinitname = lastElementOfContainer(thisdecl->get_variables());
// thisinitname->set_endOfConstruct(SgNULL_FILE);
assignInitializer->set_parent(thisinitname);
// printf ("Built new SgVariableDeclaration #1 = %p \n",thisdecl);
// DQ (6/23/2006): New test
ROSE_ASSERT(assignInitializer->get_parent() != NULL);
}
std::cout << "Trying to inline function " << fundecl->get_name().str() << std::endl;
SgBasicBlock* funbody_raw = fundef->get_body();
SgInitializedNamePtrList& params = fundecl->get_args();
SgInitializedNamePtrList::iterator i;
SgExpressionPtrList& funargs = funcall->get_args()->get_expressions();
SgExpressionPtrList::iterator j;
//int ctr; // unused variable, Liao
std::vector<SgInitializedName*> inits;
SgTreeCopy tc;
SgFunctionDefinition* function_copy = isSgFunctionDefinition(fundef->copy(tc));
ROSE_ASSERT (function_copy);
SgBasicBlock* funbody_copy = function_copy->get_body();
SgFunctionDefinition* targetFunction = PRE::getFunctionDefinition(funcall);