本文整理汇总了C++中SgVarRefExp::set_symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SgVarRefExp::set_symbol方法的具体用法?C++ SgVarRefExp::set_symbol怎么用?C++ SgVarRefExp::set_symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgVarRefExp
的用法示例。
在下文中一共展示了SgVarRefExp::set_symbol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isPotentiallyModifiedDuringLifeOf
// Within sc, is the variable toCheck modified between the declaration of
// lifetime and its last use? This is used to determine whether, whenever
// toCheck and lifetime are equal, one can be used as a substitute for the
// other.
bool isPotentiallyModifiedDuringLifeOf(SgBasicBlock* sc,
SgInitializedName* toCheck,
SgInitializedName* lifetime) {
SgStatementPtrList& stmts = sc->get_statements();
bool inLiveRange = false;
for (SgStatementPtrList::reverse_iterator i = stmts.rbegin();
i != stmts.rend(); ++i) {
if (containsVariableReference(*i, lifetime))
inLiveRange = true;
SgVariableSymbol* toCheckSym = new SgVariableSymbol(toCheck);
SgVarRefExp* toCheckVr = new SgVarRefExp(SgNULL_FILE, toCheckSym);
bool result = false;
if (inLiveRange && isPotentiallyModified(toCheckVr, *i)) {
result = true;
}
delete toCheckSym;
toCheckSym = NULL;
toCheckVr->set_symbol(NULL);
delete toCheckVr;
toCheckVr = NULL;
if (result) return true;
if (isSgVariableDeclaration(*i) &&
isDeclarationOf(isSgVariableDeclaration(*i), lifetime))
return false; // This must be last
}
return false;
}
示例2: visit
virtual void visit(SgNode* n) {
SgVarRefExp* vr = isSgVarRefExp(n);
if (!vr) return;
SgInitializedName* in = vr->get_symbol()->get_declaration();
paramMapType::const_iterator iter = paramMap.find(in);
if (iter == paramMap.end()) return; // This is not a parameter use
vr->set_symbol(iter->second);
}
示例3: doSubexpressionExpansionSmart
// Same as doSubexpressionExpansion, but requires exactly one use of
// initname, and this use must be in a simple context
void doSubexpressionExpansionSmart(SgInitializedName* initname) {
SgNode* root = initname->get_parent()->get_parent();
assert (root);
int count = countVariableReferences(root, initname);
// cout << "Initname " << initname->get_name().str() << " was used " << count << " time(s)" << endl;
if (count != 1) return;
bool doExpansion = true;
SgVariableSymbol* initnameSym = new SgVariableSymbol(initname);
SgVarRefExp* initnameVr = new SgVarRefExp(SgNULL_FILE, initnameSym);
if (isPotentiallyModified(initnameVr, root)) {
doExpansion = false;
}
delete initnameSym;
initnameSym = NULL;
initnameVr->set_symbol(NULL);
delete initnameVr;
initnameVr = NULL;
if (doExpansion) {
doSubexpressionExpansion(initname, true);
}
}
示例4: isSgStatement
ClastToSage::ClastToSage(SgScopeStatement* scopScope,
clast_stmt* root,
scoplib_scop_p scoplibScop,
PolyRoseOptions& options)
{
//SgScopeStatement* scope = isSgScopeStatement((SgNode*) scoplibScop->usr);
_polyoptions = options;
SgScopeStatement* scope = scopScope;
ROSE_ASSERT(scope);
m_scopRoot = NULL;
/// OLD:
m_scope = scope;
m_scoplib_scop = scoplibScop;
m_verbose = _polyoptions.isVerbose();
// 0- Retrive meta information stored as an annotation of the
// SageAST root.
SgStatement* scopRoot = isSgStatement((SgNode*)(scoplibScop->usr));
ScopRootAnnotation* annot =
(ScopRootAnnotation*)(scopRoot->getAttribute("ScopRoot"));
ROSE_ASSERT(annot);
_fakeSymbolMap = annot->fakeSymbolMap;
// 1- Collect all iterators in the clast. They are of the from 'cXX'
// where XX is an integer.
_scoplibIterators = collectAllIterators(root);
// 2- Map clast iterator to new variables that does not conflict
// with existing names, and register the symbols in the symbol
// table.
_sageIterators = createNewIterators(_scoplibIterators, scope);
// 3- Create the basic block containing the transformed scop.
SgBasicBlock* bb = buildBasicBlock(root);
// 4- Update the variable scope with the new bb, and insert the
// declaration statement in the AST.
std::map<const char*, SgVariableDeclaration*>::iterator iter;
Rose_STL_Container<SgNode*> varRefs =
NodeQuery::querySubTree(bb,V_SgVarRefExp);
for(iter = _sageIterators.begin(); iter != _sageIterators.end(); ++iter)
{
// Deal with the symbol tables.
SgInitializedNamePtrList& l = iter->second->get_variables();
for (SgInitializedNamePtrList::iterator i = l.begin(); i != l.end(); i++)
{
(*i)->set_scope(bb);
SgVariableSymbol* sym = new SgVariableSymbol(*i);
bb->insert_symbol((*i)->get_name(), sym);
// Ugly hack: replace the old symbol with the new entry in
// the symbol table.
for (Rose_STL_Container<SgNode *>::iterator j = varRefs.begin();
j != varRefs.end(); j++)
{
SgVarRefExp *vRef = isSgVarRefExp((*j));
if (vRef->get_symbol()->get_name() == (*i)->get_name())
vRef->set_symbol(sym);
}
}
// Insert the declaration statement in the BB.
bb->prepend_statement(iter->second);
}
// Post-process for pragma insertion.
if (options.getGeneratePragmas())
insertPragmas(bb);
m_scopRoot = bb;
}