本文整理汇总了C++中UnaryOpExpressionPtr::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ UnaryOpExpressionPtr::getLocation方法的具体用法?C++ UnaryOpExpressionPtr::getLocation怎么用?C++ UnaryOpExpressionPtr::getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnaryOpExpressionPtr
的用法示例。
在下文中一共展示了UnaryOpExpressionPtr::getLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool Option::Load(map<string, int> &option, ExpressionPtr value) {
ExpressionListPtr elements;
if (!GetArrayElements(value, elements)) return false;
for (int i = 0; i < elements->getCount(); i++) {
ExpressionPtr e = (*elements)[i];
ArrayPairExpressionPtr pair = dynamic_pointer_cast<ArrayPairExpression>(e);
bool negative = false;
ScalarExpressionPtr n, v;
if (pair) n = dynamic_pointer_cast<ScalarExpression>(pair->getName());
if (pair) {
if (pair->getValue()->is(Expression::KindOfUnaryOpExpression)) {
UnaryOpExpressionPtr una =
dynamic_pointer_cast<UnaryOpExpression>(pair->getValue());
if (una->getOp() != '+' && una->getOp() != '-') {
Logger::Error("Line %d: invalid integer: %s",
una->getLocation()->line1, una->getText().c_str());
return false;
}
v = dynamic_pointer_cast<ScalarExpression>(una->getExpression());
if (una->getOp() == '-') {
negative = true;
}
} else {
v = dynamic_pointer_cast<ScalarExpression>(pair->getValue());
}
}
if (!pair || !n || !v || !n->isLiteralString() || !v->isLiteralInteger()) {
Logger::Error("Line %d: invalid element: %s", e->getLocation()->line1,
e->getText().c_str());
return false;
}
if (negative) {
option[n->getLiteralString()] = - v->getLiteralInteger();
} else {
option[n->getLiteralString()] = v->getLiteralInteger();
}
}
return true;
}
示例2: canonicalizeNode
ExpressionPtr AliasManager::canonicalizeNode(ExpressionPtr e) {
e->setCanonPtr(ExpressionPtr());
e->setCanonID(0);
switch (e->getKindOf()) {
case Expression::KindOfObjectMethodExpression:
case Expression::KindOfDynamicFunctionCall:
case Expression::KindOfSimpleFunctionCall:
case Expression::KindOfNewObjectExpression:
add(m_bucketMap[0], e);
break;
case Expression::KindOfListAssignment:
add(m_bucketMap[0], e);
break;
case Expression::KindOfAssignmentExpression: {
AssignmentExpressionPtr ae = spc(AssignmentExpression,e);
if (e->getContext() & Expression::DeadStore) {
Construct::recomputeEffects();
return ae->getValue();
}
ExpressionPtr rep;
int interf = findInterf(ae->getVariable(), false, rep);
if (interf == SameAccess) {
switch (rep->getKindOf()) {
default:
break;
case Expression::KindOfAssignmentExpression:
{
AssignmentExpressionPtr a = spc(AssignmentExpression, rep);
ExpressionPtr value = a->getValue();
if (a->getValue()->getContext() & Expression::RefValue) {
break;
}
}
case Expression::KindOfUnaryOpExpression:
case Expression::KindOfBinaryOpExpression:
rep->setContext(Expression::DeadStore);
break;
}
}
add(m_bucketMap[0], e);
break;
}
case Expression::KindOfConstantExpression:
case Expression::KindOfSimpleVariable:
case Expression::KindOfDynamicVariable:
case Expression::KindOfArrayElementExpression:
case Expression::KindOfObjectPropertyExpression:
case Expression::KindOfStaticMemberExpression:
if (!(e->getContext() & (Expression::AssignmentLHS|
Expression::DeepAssignmentLHS|
Expression::OprLValue))) {
if (!(e->getContext() & (Expression::LValue|
Expression::RefValue|
Expression::RefParameter|
Expression::UnsetContext))) {
ExpressionPtr rep;
int interf = findInterf(e, true, rep);
if (interf == SameAccess) {
if (rep->getKindOf() == e->getKindOf()) {
e->setCanonID(rep->getCanonID());
e->setCanonPtr(rep);
return ExpressionPtr();
}
if (rep->getKindOf() == Expression::KindOfAssignmentExpression) {
ExpressionPtr rhs = spc(AssignmentExpression,rep)->getValue();
if (rhs->is(Expression::KindOfScalarExpression)) {
rhs = rhs->clone();
getCanonical(rhs);
return rhs;
}
e->setCanonPtr(rhs);
}
}
}
add(m_bucketMap[0], e);
} else {
getCanonical(e);
}
break;
case Expression::KindOfBinaryOpExpression: {
BinaryOpExpressionPtr bop = spc(BinaryOpExpression, e);
int rop = getOpForAssignmentOp(bop->getOp());
if (rop) {
ExpressionPtr lhs = bop->getExp1();
ExpressionPtr rep;
if (bop->getContext() & Expression::DeadStore) {
Construct::recomputeEffects();
ExpressionPtr rhs = bop->getExp2()->clone();
lhs = lhs->clone();
lhs->clearContext(Expression::LValue);
lhs->clearContext(Expression::NoLValueWrapper);
lhs->clearContext(Expression::OprLValue);
rep = ExpressionPtr
(new BinaryOpExpression(e->getLocation(),
//.........这里部分代码省略.........