本文整理汇总了C++中IdSet::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ IdSet::erase方法的具体用法?C++ IdSet::erase怎么用?C++ IdSet::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdSet
的用法示例。
在下文中一共展示了IdSet::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: static_analysis
/** Statically analyse the given ast.
*
* \param ast_ The AST.
* \param in_object Whether or not ast_ is within the lexical scope of an object AST.
* \param vars The variables defined within lexical scope of ast_.
* \returns The free variables in ast_.
*/
static IdSet static_analysis(AST *ast_, bool in_object, const IdSet &vars)
{
IdSet r;
if (auto *ast = dynamic_cast<const Apply*>(ast_)) {
append(r, static_analysis(ast->target, in_object, vars));
for (AST *arg : ast->arguments)
append(r, static_analysis(arg, in_object, vars));
} else if (auto *ast = dynamic_cast<const Array*>(ast_)) {
for (AST *el : ast->elements)
append(r, static_analysis(el, in_object, vars));
} else if (auto *ast = dynamic_cast<const Binary*>(ast_)) {
append(r, static_analysis(ast->left, in_object, vars));
append(r, static_analysis(ast->right, in_object, vars));
} else if (dynamic_cast<const BuiltinFunction*>(ast_)) {
// Nothing to do.
} else if (auto *ast = dynamic_cast<const Conditional*>(ast_)) {
append(r, static_analysis(ast->cond, in_object, vars));
append(r, static_analysis(ast->branchTrue, in_object, vars));
append(r, static_analysis(ast->branchFalse, in_object, vars));
} else if (auto *ast = dynamic_cast<const Error*>(ast_)) {
return static_analysis(ast->expr, in_object, vars);
} else if (auto *ast = dynamic_cast<const Function*>(ast_)) {
auto new_vars = vars;
IdSet params;
for (auto *p : ast->parameters) {
if (params.find(p) != params.end()) {
throw StaticError(ast_->location, "Duplicate function parameter: " + p->name);
}
params.insert(p);
new_vars.insert(p);
}
auto fv = static_analysis(ast->body, in_object, new_vars);
for (auto *p : ast->parameters)
fv.erase(p);
append(r, fv);
} else if (dynamic_cast<const Import*>(ast_)) {
// Nothing to do.
} else if (dynamic_cast<const Importstr*>(ast_)) {
// Nothing to do.
} else if (auto *ast = dynamic_cast<const Index*>(ast_)) {
append(r, static_analysis(ast->target, in_object, vars));
append(r, static_analysis(ast->index, in_object, vars));
} else if (auto *ast = dynamic_cast<const Local*>(ast_)) {
IdSet ast_vars;
for (const auto &bind: ast->binds) {
ast_vars.insert(bind.first);
}
auto new_vars = vars;
append(new_vars, ast_vars);
IdSet fvs;
for (const auto &bind: ast->binds)
append(fvs, static_analysis(bind.second, in_object, new_vars));
append(fvs, static_analysis(ast->body, in_object, new_vars));
for (const auto &bind: ast->binds)
fvs.erase(bind.first);
append(r, fvs);
} else if (dynamic_cast<const LiteralBoolean*>(ast_)) {
// Nothing to do.
} else if (dynamic_cast<const LiteralNumber*>(ast_)) {
// Nothing to do.
} else if (dynamic_cast<const LiteralString*>(ast_)) {
// Nothing to do.
} else if (dynamic_cast<const LiteralNull*>(ast_)) {
// Nothing to do.
} else if (auto *ast = dynamic_cast<Object*>(ast_)) {
for (auto field : ast->fields) {
append(r, static_analysis(field.name, in_object, vars));
append(r, static_analysis(field.body, true, vars));
}
} else if (auto *ast = dynamic_cast<ObjectComposition*>(ast_)) {
auto new_vars = vars;
new_vars.insert(ast->id);
append(r, static_analysis(ast->field, false, new_vars));
//.........这里部分代码省略.........