本文整理汇总了C++中ConstructPtr::getNthKid方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstructPtr::getNthKid方法的具体用法?C++ ConstructPtr::getNthKid怎么用?C++ ConstructPtr::getNthKid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstructPtr
的用法示例。
在下文中一共展示了ConstructPtr::getNthKid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeProgram
void AnalysisResult::analyzeProgram(ConstructPtr c) const {
if (!c) return;
for (auto i = 0, n = c->getKidCount(); i < n; ++i) {
analyzeProgram(c->getNthKid(i));
}
c->analyzeProgram(AnalysisResultConstRawPtr{this});
}
示例2: informClosuresAboutScopeClone
void ClassScope::informClosuresAboutScopeClone(
ConstructPtr root,
FunctionScopePtr outerScope,
AnalysisResultPtr ar) {
if (!root) {
return;
}
for (int i = 0; i < root->getKidCount(); i++) {
ConstructPtr cons = root->getNthKid(i);
ClosureExpressionPtr closure =
dynamic_pointer_cast<ClosureExpression>(cons);
if (!closure) {
informClosuresAboutScopeClone(cons, outerScope, ar);
continue;
}
FunctionStatementPtr func = closure->getClosureFunction();
HPHP::FunctionScopePtr funcScope = func->getFunctionScope();
assert(funcScope->isClosure());
funcScope->addClonedTraitOuterScope(outerScope);
// Don't need to recurse
}
}
示例3: walk_ast
void walk_ast(ConstructPtr node) {
if (!node) return;
if (dynamic_pointer_cast<MethodStatement>(node)) {
// Don't descend into nested non-closure functions, or functions
// in the psuedo-main.
return;
}
if (auto ce = dynamic_pointer_cast<ClosureExpression>(node)) {
visit_closure(ce);
return;
}
for (int i = 0; i < node->getKidCount(); ++i) {
walk_ast(node->getNthKid(i));
}
}
示例4: hasStaticLocalsImpl
bool ClosureExpression::hasStaticLocalsImpl(ConstructPtr root) {
if (!root) {
return false;
}
if (root->getFunctionScope() != m_func->getFunctionScope()) {
// new scope, new statics
return false;
}
for (int i = 0; i < root->getKidCount(); i++) {
ConstructPtr cons = root->getNthKid(i);
if (StatementPtr s = dynamic_pointer_cast<Statement>(cons)) {
if (s->is(Statement::KindOfStaticStatement)) {
return true;
}
}
if (hasStaticLocalsImpl(cons)) {
return true;
}
}
return false;
}
示例5: walk_ast
// Returns: whether or not $this is implicitly used in this part of the AST,
// e.g. via a call using parent::.
bool walk_ast(ConstructPtr node) {
if (!node) return false;
if (dynamic_pointer_cast<MethodStatement>(node)) {
// Don't descend into nested non-closure functions, or functions
// in the pseudo-main.
return false;
}
if (auto ce = dynamic_pointer_cast<ClosureExpression>(node)) {
return visit_closure(ce);
}
auto ret = false;
if (auto fc = dynamic_pointer_cast<FunctionCall>(node)) {
if (fc->isParent()) ret = true;
}
for (int i = 0; i < node->getKidCount(); ++i) {
if (walk_ast(node->getNthKid(i))) ret = true;
}
return ret;
}
示例6: collectAliasInfoRecur
void AliasManager::collectAliasInfoRecur(ConstructPtr cs) {
if (!cs) {
return;
}
if (StatementPtr s = dpc(Statement, cs)) {
switch (s->getKindOf()) {
case Statement::KindOfFunctionStatement:
case Statement::KindOfMethodStatement:
case Statement::KindOfClassStatement:
case Statement::KindOfInterfaceStatement:
return;
default:
break;
}
}
int nkid = cs->getKidCount();
for (int i = 0; i < nkid; i++) {
ConstructPtr kid = cs->getNthKid(i);
if (kid) {
collectAliasInfoRecur(kid);
}
}
if (ExpressionPtr e = dpc(Expression, cs)) {
int context = e->getContext();
switch (e->getKindOf()) {
case Expression::KindOfAssignmentExpression:
{
AssignmentExpressionPtr ae = spc(AssignmentExpression, e);
ExpressionPtr var = ae->getVariable();
ExpressionPtr val = ae->getValue();
if (var->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, var)->getName();
AliasInfo &ai = m_aliasInfo[name];
if (val->getContext() & Expression::RefValue) {
ai.setIsRefTo();
m_variables->addUsed(name);
} else {
Expression::checkUsed(m_arp, var, val);
}
}
}
break;
case Expression::KindOfListAssignment:
{
ListAssignmentPtr la = spc(ListAssignment, e);
ExpressionListPtr vars = la->getVariables();
for (int i = vars->getCount(); i--; ) {
ExpressionPtr v = (*vars)[i];
if (v && v->is(Expression::KindOfSimpleVariable)) {
SimpleVariablePtr sv = spc(SimpleVariable, v);
m_variables->addUsed(sv->getName());
}
}
}
break;
case Expression::KindOfSimpleVariable:
{
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
AliasInfo &ai = m_aliasInfo[name];
ai.addRefLevel(0);
}
if (!(context & (Expression::AssignmentLHS |
Expression::UnsetContext))) {
m_variables->addUsed(name);
}
}
break;
case Expression::KindOfDynamicVariable:
if (context & Expression::RefValue) {
m_wildRefs = true;
}
break;
case Expression::KindOfArrayElementExpression:
{
int n = 1;
while (n < 10 &&
e->is(Expression::KindOfArrayElementExpression)) {
e = spc(ArrayElementExpression, e)->getVariable();
}
if (e->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
AliasInfo &ai = m_aliasInfo[name];
ai.addRefLevel(n);
}
m_variables->addUsed(name); // need this for UnsetContext
}
}
break;
case Expression::KindOfObjectPropertyExpression:
{
e = spc(ObjectPropertyExpression, e)->getObject();
if (e->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
//.........这里部分代码省略.........