本文整理汇总了C++中StatementPtr::getScope方法的典型用法代码示例。如果您正苦于以下问题:C++ StatementPtr::getScope方法的具体用法?C++ StatementPtr::getScope怎么用?C++ StatementPtr::getScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementPtr
的用法示例。
在下文中一共展示了StatementPtr::getScope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void execute() {
std::sort(m_rootEntries.begin(), m_rootEntries.end(), reCmp);
for (int i = 0; i < m_size; i++) {
RootEntry &re = m_rootEntries[i];
if (!re.second) break;
const AstWalkerState &s = re.first[re.first.size() - 1];
StatementPtr sp(dynamic_pointer_cast<Statement>(s.cp));
assert(sp);
StatementListPtr sl;
int ix;
if (sp->is(Statement::KindOfStatementList)) {
sl = static_pointer_cast<StatementList>(sp);
ix = (s.index - 1) / 2;
} else {
assert(sp->is(Statement::KindOfBlockStatement));
sl = static_pointer_cast<BlockStatement>(sp)->getStmts();
if (!sl) continue;
ix = 0;
}
ExpressionPtr e = m_dict.get(re.second);
assert(e && e->is(Expression::KindOfSimpleVariable));
SimpleVariablePtr sv(static_pointer_cast<SimpleVariable>(e));
Symbol *sym = sv->getSymbol();
bool inGen = sv->getFunctionScope()->isGenerator();
if (!sym || sym->isGlobal() || sym->isStatic() || sym->isParameter() ||
sym->isClosureVar() || sv->isThis() || inGen) {
continue;
}
sym->setShrinkWrapped();
e = e->clone();
e->clearContext();
e->recomputeEffects();
e->setContext(Expression::Declaration);
StatementPtr sub = (*sl)[ix];
e->setLocation(sub->getLocation());
e->setBlockScope(sub->getScope());
ExpStatementPtr exp(
new ExpStatement(sub->getScope(), sub->getLocation(), e));
sl->insertElement(exp, ix);
}
}