本文整理汇总了C++中name::get_prefix方法的典型用法代码示例。如果您正苦于以下问题:C++ name::get_prefix方法的具体用法?C++ name::get_prefix怎么用?C++ name::get_prefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类name
的用法示例。
在下文中一共展示了name::get_prefix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_namespace
environment add_namespace(environment const & env, name const & ns) {
scope_mng_ext ext = get_extension(env);
if (!ext.m_namespace_set.contains(ns)) {
ext.m_namespace_set.insert(ns);
environment r = update(env, ext);
r = module::add(r, *g_new_namespace_key, [=](environment const &, serializer & s) { s << ns; });
if (ns.is_atomic())
return r;
else
return add_namespace(r, ns.get_prefix());
} else {
return env;
}
}
示例2: add_alias
environment add_alias(parser & p, environment env, bool composite,
name const & full_id, levels const & ctx_levels, buffer<expr> const & ctx_params) {
name id;
if (composite)
id = name(name(full_id.get_prefix().get_string()), full_id.get_string());
else
id = name(full_id.get_string());
if (!empty(ctx_levels) || !ctx_params.empty()) {
expr r = mk_local_ref(full_id, ctx_levels, ctx_params);
env = p.add_local_ref(env, id, r);
}
if (full_id != id)
env = add_expr_alias_rec(env, id, full_id);
return env;
}
示例3: visit_cases_on
expr visit_cases_on(name const & fn, buffer<expr> & args) {
name const & I_name = fn.get_prefix();
if (is_inductive_predicate(env(), I_name))
throw exception(sstream() << "code generation failed, inductive predicate '" << I_name << "' is not supported");
bool is_builtin = is_vm_builtin_function(fn);
buffer<name> cnames;
get_intro_rule_names(env(), I_name, cnames);
lean_assert(args.size() >= cnames.size() + 1);
if (args.size() > cnames.size() + 1)
distribute_extra_args_over_minors(I_name, cnames, args);
lean_assert(args.size() == cnames.size() + 1);
/* Process major premise */
args[0] = visit(args[0]);
unsigned num_reachable = 0;
optional<expr> reachable_case;
/* Process minor premises */
for (unsigned i = 0; i < cnames.size(); i++) {
buffer<bool> rel_fields;
get_constructor_info(cnames[i], rel_fields);
auto p = visit_minor_premise(args[i+1], rel_fields);
expr new_minor = p.first;
if (i == 0 && has_trivial_structure(I_name, rel_fields)) {
/* Optimization for an inductive datatype that has a single constructor with only one relevant field */
return beta_reduce(mk_app(new_minor, args[0]));
}
args[i+1] = new_minor;
if (!p.second) {
num_reachable++;
reachable_case = p.first;
}
}
if (num_reachable == 0) {
return mk_unreachable_expr();
} else if (num_reachable == 1 && !is_builtin) {
/* Use _cases.1 */
return mk_app(mk_cases(1), args[0], *reachable_case);
} else if (is_builtin) {
return mk_app(mk_constant(fn), args);
} else {
return mk_app(mk_cases(cnames.size()), args);
}
}
示例4: is_explicit_placeholder
static bool is_explicit_placeholder(name const & n) {
return !n.is_atomic() && n.get_prefix() == *g_explicit_placeholder_name;
}
示例5: is_placeholder
static bool is_placeholder(name const & n) {
if (n.is_atomic())
return false;
name const & p = n.get_prefix();
return p == *g_implicit_placeholder_name || p == *g_strict_placeholder_name || p == *g_explicit_placeholder_name;
}