本文整理汇总了C++中StatementPtr::getKidCount方法的典型用法代码示例。如果您正苦于以下问题:C++ StatementPtr::getKidCount方法的具体用法?C++ StatementPtr::getKidCount怎么用?C++ StatementPtr::getKidCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementPtr
的用法示例。
在下文中一共展示了StatementPtr::getKidCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build
void Dictionary::build(StatementPtr stmt) {
for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
if (ConstructPtr kid = stmt->getNthKid(i)) {
if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
if (FunctionWalker::SkipRecurse(s)) continue;
build(s);
} else {
ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
build(e);
}
}
}
}
示例2: cloneStmtsForInline
static int cloneStmtsForInline(InlineCloneInfo &info, StatementPtr s,
const std::string &prefix,
AnalysisResultConstPtr ar,
FunctionScopePtr scope) {
switch (s->getKindOf()) {
case Statement::KindOfStatementList:
{
for (int i = 0, n = s->getKidCount(); i < n; ++i) {
if (int ret = cloneStmtsForInline(info, s->getNthStmt(i),
prefix, ar, scope)) {
return ret;
}
}
return 0;
}
case Statement::KindOfExpStatement:
info.elist->addElement(cloneForInline(
info, dynamic_pointer_cast<ExpStatement>(s)->
getExpression(), prefix, ar, scope));
return 0;
case Statement::KindOfReturnStatement:
{
ExpressionPtr exp =
dynamic_pointer_cast<ReturnStatement>(s)->getRetExp();
if (exp) {
exp = cloneForInline(info, exp, prefix, ar, scope);
if (exp->hasContext(Expression::RefValue)) {
exp->clearContext(Expression::RefValue);
if (exp->isRefable()) exp->setContext(Expression::LValue);
}
info.elist->addElement(exp);
return 1;
}
return -1;
}
default:
not_reached();
}
return 1;
}
示例3: build
void Dictionary::build(StatementPtr stmt) {
for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
if (ConstructPtr kid = stmt->getNthKid(i)) {
if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
switch (s->getKindOf()) {
case Statement::KindOfFunctionStatement:
case Statement::KindOfMethodStatement:
case Statement::KindOfClassStatement:
case Statement::KindOfInterfaceStatement:
continue;
default:
break;
}
build(s);
} else {
ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
build(e);
}
}
}
}
示例4: canonicalizeRecur
int AliasManager::canonicalizeRecur(StatementPtr s) {
if (!s) return FallThrough;
Statement::KindOf stype = s->getKindOf();
int ret = FallThrough;
int start = 0;
switch (stype) {
case Statement::KindOfFunctionStatement:
case Statement::KindOfMethodStatement:
case Statement::KindOfClassStatement:
case Statement::KindOfInterfaceStatement:
// Dont handle nested functions
// they will be dealt with by another
// top level call to optimize
return ret;
case Statement::KindOfStaticStatement:
clear();
ret = Converge;
break;
case Statement::KindOfClassVariable:
clear();
ret = Branch;
case Statement::KindOfClassConstant:
case Statement::KindOfGlobalStatement:
case Statement::KindOfEchoStatement:
case Statement::KindOfUnsetStatement:
case Statement::KindOfExpStatement:
case Statement::KindOfStatementList:
case Statement::KindOfBlockStatement:
case Statement::KindOfTryStatement:
// No special action, just execute
// and fall through
break;
case Statement::KindOfIfStatement:
{
StatementPtr iflist = spc(Statement, s->getNthKid(0));
if (iflist) {
for (int i = 0, n = iflist->getKidCount(); i < n; i++) {
StatementPtr ifstmt = spc(Statement, iflist->getNthKid(i));
ExpressionPtr cond = spc(Expression, ifstmt->getNthKid(0));
canonicalizeKid(ifstmt, cond, 0);
if (!i) beginScope();
beginScope();
canonicalizeRecur(spc(Statement, ifstmt->getNthKid(1)));
endScope();
if (i+1 < n) resetScope();
}
endScope();
}
ret = Converge;
return FallThrough;
}
break;
case Statement::KindOfIfBranchStatement:
assert(0);
break;
case Statement::KindOfForStatement:
canonicalizeKid(s, spc(Expression,s->getNthKid(0)), 0);
clear();
canonicalizeKid(s, spc(Expression,s->getNthKid(1)), 1);
canonicalizeRecur(spc(Statement, s->getNthKid(2)));
clear();
canonicalizeKid(s, spc(Expression,s->getNthKid(3)), 3);
return Converge;
case Statement::KindOfWhileStatement:
case Statement::KindOfDoStatement:
case Statement::KindOfForEachStatement:
clear();
ret = Converge;
break;
case Statement::KindOfSwitchStatement:
canonicalizeKid(s, spc(Expression,s->getNthKid(0)), 0);
clear();
start = 1;
ret = Converge;
break;
case Statement::KindOfCaseStatement:
clear();
break;
case Statement::KindOfBreakStatement:
case Statement::KindOfContinueStatement:
case Statement::KindOfReturnStatement:
ret = Branch;
break;
case Statement::KindOfCatchStatement:
clear();
ret = Converge;
break;
case Statement::KindOfThrowStatement:
ret = Branch;
//.........这里部分代码省略.........