本文整理汇总了C++中StatementPtr::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ StatementPtr::getLocation方法的具体用法?C++ StatementPtr::getLocation怎么用?C++ StatementPtr::getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementPtr
的用法示例。
在下文中一共展示了StatementPtr::getLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void DependencyGraph::add(KindOf kindOf, const std::string &program,
const std::string &parent, StatementPtr stmt) {
ASSERT(kindOf == KindOfProgramMaxInclude ||
kindOf == KindOfProgramMinInclude ||
kindOf == KindOfProgramUserFunction ||
kindOf == KindOfProgramUserClass);
add(kindOf, program, program, ConstructPtr(), parent, ConstructPtr());
if ((kindOf == KindOfProgramUserFunction ||
kindOf == KindOfProgramUserClass) && *stmt->getLocation()->file) {
add(KindOfProgramMinInclude, program, program, ConstructPtr(),
stmt->getLocation()->file, ConstructPtr());
}
}
示例2: 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);
}
}
示例3: getEffectiveImpl
ExpressionPtr StatementList::getEffectiveImpl(AnalysisResultPtr ar) const {
for (unsigned int i = 0; i < m_stmts.size(); i++) {
StatementPtr s = m_stmts[i];
if (s->is(KindOfReturnStatement)) {
ExpressionPtr e = static_pointer_cast<ReturnStatement>(s)->getRetExp();
if (!e) {
e = Expression::MakeConstant(ar, s->getLocation(), "null");
} else if (!e->isScalar()) {
break;
}
return e;
}
if (m_stmts[i]->hasImpl()) break;
}
return ExpressionPtr();
}
示例4: printAsBlock
void CodeGenerator::printAsBlock(StatementPtr s) {
if (s->is(Statement::KindOfBlockStatement)) {
s->outputCodeModel(*this);
} else {
printObjectHeader("BlockStatement", 2);
printPropertyHeader("statements");
if (s->is(Statement::KindOfStatementList)) {
auto sl = static_pointer_cast<StatementList>(s);
printStatementVector(sl);
} else {
printf("V:9:\"HH\\Vector\":1:{");
s->outputCodeModel(*this);
printf("}");
}
printPropertyHeader("sourceLocation");
printLocation(s->getLocation());
printObjectFooter();
}
}
示例5: printAsBlock
void CodeGenerator::printAsBlock(StatementPtr s, bool isEnclosed) {
if (s != nullptr && s->is(Statement::KindOfBlockStatement)) {
s->outputCodeModel(*this);
} else {
auto numProps = s == nullptr ? 0 : 2;
if (isEnclosed) numProps++;
printObjectHeader("BlockStatement", numProps);
if (s != nullptr) {
printPropertyHeader("statements");
printStatementVector(s);
printPropertyHeader("sourceLocation");
printLocation(s->getLocation());
}
if (isEnclosed) {
printPropertyHeader("isEnclosed");
printBool(true);
}
printObjectFooter();
}
}