本文整理汇总了C++中ExpressionPtr::isReferencedValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::isReferencedValid方法的具体用法?C++ ExpressionPtr::isReferencedValid怎么用?C++ ExpressionPtr::isReferencedValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::isReferencedValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAccess
/*
The classical use/def isnt quite enough here. There are two unusual
issues:
- the ref/non-ref issue.
An assignment to a var which is referenced doesnt end its
lifetime. In fact it could just be a "use" of the var. But it
also counts as a def.
- the destructor issue.
variables which might need to be destroyed later are technically
alive, but dont interfere with any other variables in the same state.
They /do/ interfere with any truly "live" variables, however.
These are "dying".
So we end up defining, use, kill, def and dying.
use : a read of the variable, an ordinary assignment if it could
be referenced
kill : an unset, a ref assignment, or, for non referenced vars, any assignment
def : ref or normal assignment
dying : a variable whose destructor is (partially/locally) anticipated.
*/
void LiveDict::updateAccess(ExpressionPtr e) {
int cls = e->getExprClass();
if (cls & Expression::Store) {
/*
Handled when we see the lhs
*/
return;
}
int eid = e->getCanonID();
int context = e->getContext();
bool unset = false;
bool store = false;
if (context & Expression::LValue && context & Expression::UnsetContext) {
unset = true;
} else if (context & Expression::AssignmentLHS) {
store = true;
}
if (e->is(Expression::KindOfSimpleVariable)) {
SimpleVariablePtr sv(static_pointer_cast<SimpleVariable>(e));
bool use = false, kill = false, def = false;
Symbol *sym = sv->getSymbol();
bool isReferenced =
e->isReferencedValid() ?
e->isReferenced() :
sym && sym->isReferenced();
bool isNeeded =
e->isNeededValid() ?
e->isNeeded() :
sym && sym->isNeeded();
if (unset) {
kill = true;
} else if (store) {
if (context & Expression::RefAssignmentLHS ||
(!m_am.hasWildRefs() && !isReferenced)) {
kill = true;
}
def = true;
} else if ((context & Expression::Declaration) == Expression::Declaration) {
// a global declaration
def = kill = true;
} else if (context & (Expression::LValue|
Expression::RefValue|
Expression::DeepReference|
Expression::UnsetContext|
Expression::OprLValue)) {
use = def = true;
} else {
use = true;
}
if (kill && (!sym || isNeeded || isReferenced) &&
!BitOps::get_bit(eid, m_altered) &&
!BitOps::get_bit(eid, m_available)) {
BitOps::set_bit(eid, m_dying, true);
}
if (use &&
!BitOps::get_bit(eid, m_altered) &&
!BitOps::get_bit(eid, m_available)) {
BitOps::set_bit(eid, m_anticipated, true);
e->setAnticipated();
}
if (kill) {
BitOps::set_bit(eid, m_altered, true);
BitOps::set_bit(eid, m_available, def);
} else if (def) {
BitOps::set_bit(eid, m_available, true);
}
if (!m_am.couldBeAliased(sv)) {
return;
}
} else if (!e->is(Expression::KindOfDynamicVariable) &&
(unset || (context & Expression::RefAssignmentLHS))) {
// An unset, or a reference assignment to anything other
// than a simple or dynamic variable can never affect a simple
//.........这里部分代码省略.........
示例2: updateAccess
//.........这里部分代码省略.........
isRhsNeeded = Expression::CheckNeededRHS(rhs);
}
}
break;
default:
break;
}
}
bool isLhsSimpleVar = false;
bool isLhsDynamic = false;
bool isRefd = false;
if (lhs) {
isLhsSimpleVar = lhs->is(Expression::KindOfSimpleVariable);
// TODO: can a variable only be simple or dynamic?
// If so, this is un-necessary
isLhsDynamic = lhs->is(Expression::KindOfDynamicVariable);
if (isLhsSimpleVar) {
// clean up the LHS AST
lhs->clearAvailable();
lhs->clearNeeded();
lhs->clearNeededValid();
if (BitOps::get_bit(lhs->getCanonID(), m_obj)) {
lhs->setNeeded();
lhs->setNeededValid();
} else if (!BitOps::get_bit(lhs->getCanonID(), m_noobj)) {
lhs->setAvailable();
}
}
if (lhs->isReferencedValid() && lhs->isReferenced() && isRhsNeeded) {
// could we possibly have modified another referenced variable?
isRefd = true;
}
if (isLhsSimpleVar && isRhsNeeded) {
// we see this case:
// $x = new ...
// so we mark $x as being needed
BitOps::set_bit(lhs->getCanonID(), m_obj, true);
BitOps::set_bit(lhs->getCanonID(), m_noobj, false);
} else if (isLhsSimpleVar && canKill && !isRhsNeeded) {
// we saw an assignment that was of the form
// $x = <primitive>
// we can now set $x to be not an object
BitOps::set_bit(lhs->getCanonID(), m_obj, false);
BitOps::set_bit(lhs->getCanonID(), m_noobj, true);
}
}
if (isLhsDynamic && isRhsNeeded) {
// in this case, we must set EVERY variable to contain an object
BitOps::set(size(), m_obj, -1 /* true for each bit */);
BitOps::set(size(), m_noobj, 0 /* false for each bit */);
// we're done, since it can be no worse (no more conservative) than this
return;
}
// do we see a load which could cause the value of this expr to be changed?
// for example:
// function foo(&$x) { $x = 10; }
// $x = 30;