本文整理汇总了C++中environment::find方法的典型用法代码示例。如果您正苦于以下问题:C++ environment::find方法的具体用法?C++ environment::find怎么用?C++ environment::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environment
的用法示例。
在下文中一共展示了environment::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
environment decl_attributes::apply(environment env, io_state const & ios, name const & d) const {
if (m_is_instance) {
if (m_priority) {
#if defined(__GNUC__) && !defined(__CLANG__)
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
env = add_instance(env, d, *m_priority, m_persistent);
} else {
env = add_instance(env, d, m_persistent);
}
}
if (m_is_trans_instance) {
if (m_priority) {
#if defined(__GNUC__) && !defined(__CLANG__)
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
env = add_trans_instance(env, d, *m_priority, m_persistent);
} else {
env = add_trans_instance(env, d, m_persistent);
}
}
if (m_is_coercion)
env = add_coercion(env, ios, d, m_persistent);
auto decl = env.find(d);
if (decl && decl->is_definition()) {
if (m_is_reducible)
env = set_reducible(env, d, reducible_status::Reducible, m_persistent);
if (m_is_irreducible)
env = set_reducible(env, d, reducible_status::Irreducible, m_persistent);
if (m_is_semireducible)
env = set_reducible(env, d, reducible_status::Semireducible, m_persistent);
if (m_is_quasireducible)
env = set_reducible(env, d, reducible_status::Quasireducible, m_persistent);
if (m_unfold_hint)
env = add_unfold_hint(env, d, m_unfold_hint, m_persistent);
if (m_unfold_full_hint)
env = add_unfold_full_hint(env, d, m_persistent);
}
if (m_constructor_hint)
env = add_constructor_hint(env, d, m_persistent);
if (m_symm)
env = add_symm(env, d, m_persistent);
if (m_refl)
env = add_refl(env, d, m_persistent);
if (m_trans)
env = add_trans(env, d, m_persistent);
if (m_subst)
env = add_subst(env, d, m_persistent);
if (m_recursor)
env = add_user_recursor(env, d, m_recursor_major_pos, m_persistent);
if (m_is_class)
env = add_class(env, d, m_persistent);
if (m_rewrite)
env = add_rewrite_rule(env, d, m_persistent);
if (m_has_multiple_instances)
env = mark_multiple_instances(env, d, m_persistent);
return env;
}
示例2: mk_fresh_name
name mk_fresh_name(environment const & env, name const & prefix, char const * suffix, unsigned & idx) {
while (true) {
name curr(prefix, suffix);
curr = curr.append_after(idx);
idx++;
if (!env.find(curr) && !is_vm_function(env, curr))
return curr;
}
}
示例3: mk_fresh_name
static name mk_fresh_name(environment const & env, buffer<name> const & names, name const & s) {
unsigned i = 1;
name c = s;
while (true) {
if (!env.find(c) &&
std::find(names.begin(), names.end(), c) == names.end())
return c;
c = s.append_after(i);
i++;
}
}
示例4: get_max_height
static unsigned get_max_height(environment const & env, expr const & v) {
unsigned h = 0;
for_each(v, [&](expr const & e, unsigned) {
if (is_constant(e)) {
auto d = env.find(const_name(e));
if (d && d->get_height() > h)
h = d->get_height();
}
return true;
});
return h;
}
示例5: mk_name_for
name mk_name_for(expr const & e) {
lean_assert(is_nested_declaration(e));
if (auto n = get_nested_declaration_name(e)) {
return *n;
} else {
name ns = get_namespace(m_env);
while (true) {
name aux = m_dname.append_after(m_idx);
m_idx++;
if (!m_env.find(ns + aux))
return aux;
}
}
}
示例6: check_dependencies
/** \brief Return true iff the type of all declarations in deps still have the same hashcode
stored in deps. */
bool definition_cache::check_dependencies(environment const & env, dependencies const & deps) {
bool ok = true;
deps.for_each([&](name const & n, unsigned h) {
if (ok) {
if (auto d = env.find(n)) {
if (h != hash_bi(d->get_type()))
ok = false;
} else {
ok = false;
}
}
});
return ok;
}
示例7: collect_dependencies
void definition_cache::collect_dependencies(environment const & env, expr const & e, dependencies & deps) {
for_each(e, [&](expr const & e, unsigned) {
if (!is_constant(e))
return true;
name const & n = const_name(e);
if (deps.contains(n))
return true;
auto d = env.find(n);
if (!d)
return true;
deps.insert(n, hash_bi(d->get_type()));
return true;
});
}
示例8: is_tactic_namespace_open
bool is_tactic_namespace_open(environment const & env) {
for (name const & a : get_expr_aliases(env, "apply")) {
if (a == get_tactic_apply_name()) {
// make sure the type is the expected one
if (auto d = env.find(a)) {
expr t = d->get_type();
if (is_pi(t)) {
expr b = binding_body(t);
if (!is_constant(b) || const_name(b) != get_tactic_name())
throw exception("tactic namespace declarations have been modified, "
"function 'tactic.apply' is expected to return a 'tactic'");
}
}
return true;
}
}
return false;
}
示例9: check_identifier
static void check_identifier(parser & p, environment const & env, name const & ns, name const & id) {
name full_id = ns + id;
if (!env.find(full_id))
throw parser_error(sstream() << "invalid 'using' command, unknown declaration '" << full_id << "'", p.pos());
}