chore(library/compiler): simplify procedure class
Remark: `procedure` will be deleted soon.
This commit is contained in:
parent
dc5dbb3b81
commit
2eea3d4c4b
6 changed files with 9 additions and 11 deletions
|
|
@ -25,7 +25,7 @@ class extract_values_fn : public compiler_step_visitor {
|
|||
if (it != m_cache.end())
|
||||
return it->second;
|
||||
name aux = mk_compiler_unused_name(env(), m_prefix, "_val", m_idx);
|
||||
m_new_procs.push_back(procedure(aux, m_pos, e));
|
||||
m_new_procs.push_back(procedure(aux, e));
|
||||
expr r = mk_constant(aux);
|
||||
m_cache.insert(mk_pair(e, r));
|
||||
return r;
|
||||
|
|
@ -54,7 +54,6 @@ public:
|
|||
|
||||
void operator()(procedure p) {
|
||||
m_root = p.m_code;
|
||||
m_pos = p.m_pos;
|
||||
p.m_code = visit(p.m_code);
|
||||
m_new_procs.push_back(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class lambda_lifting_fn : public compiler_step_visitor {
|
|||
buffer<expr> locals;
|
||||
new_e = abstract_locals(new_e, locals);
|
||||
name aux_name = mk_compiler_unused_name(env(), m_prefix, "_lambda", m_idx);
|
||||
m_new_procs.emplace_back(aux_name, get_pos_info(e), new_e);
|
||||
m_new_procs.emplace_back(aux_name, new_e);
|
||||
return mk_rev_app(mk_constant(aux_name), locals);
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ public:
|
|||
for (auto p : procs) {
|
||||
expr val = p.m_code;
|
||||
expr new_val = is_lambda(val) ? visit_lambda_core(val) : visit(val);
|
||||
m_new_procs.emplace_back(p.m_name, p.m_pos, new_val);
|
||||
m_new_procs.emplace_back(p.m_name, new_val);
|
||||
}
|
||||
procs.clear();
|
||||
procs.append(m_new_procs);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class preprocess_fn {
|
|||
}
|
||||
if (ctx.is_prop(type) || is_sort(type)) {
|
||||
expr r = locals.mk_lambda(mk_enf_neutral());
|
||||
procs.emplace_back(d.get_name(), optional<pos_info>(), r);
|
||||
procs.emplace_back(d.get_name(), r);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -138,7 +138,7 @@ public:
|
|||
m_env = module::add(m_env, simp_decl, false);
|
||||
v = erase_irrelevant(m_env, v);
|
||||
lean_trace(name({"compiler", "erase_irrelevant"}), tout() << "\n" << v << "\n";);
|
||||
procs.emplace_back(n, optional<pos_info>(), v);
|
||||
procs.emplace_back(n, v);
|
||||
|
||||
lambda_lifting(m_env, m_cache, n, procs);
|
||||
lean_trace(name({"compiler", "lambda_lifting"}), tout() << "\n"; display(procs););
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
struct procedure {
|
||||
name m_name;
|
||||
optional<pos_info> m_pos;
|
||||
expr m_code;
|
||||
procedure(name const & n, optional<pos_info> const & pos, expr const & code):
|
||||
m_name(n), m_pos(pos), m_code(code) {}
|
||||
procedure(name const & n, expr const & code):
|
||||
m_name(n), m_code(code) {}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ static environment vm_compile(environment const & env, buffer<procedure> const &
|
|||
optimize(new_env, code);
|
||||
lean_trace(name({"compiler", "optimize_bytecode"}), tout() << " " << p.m_name << " " << arity << "\n";
|
||||
display_vm_code(tout().get_stream(), code.size(), code.data()););
|
||||
new_env = update_vm_code(new_env, p.m_name, code.size(), code.data(), args_info, p.m_pos);
|
||||
new_env = update_vm_code(new_env, p.m_name, code.size(), code.data(), args_info);
|
||||
}
|
||||
return new_env;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -929,7 +929,7 @@ unsigned get_num_nested_lambdas(expr const & e);
|
|||
/** \brief Add bytcode for the function named \c fn in \c env.
|
||||
\remark The index for \c fn must have been reserved using reserve_vm_index. */
|
||||
environment update_vm_code(environment const & env, name const & fn, unsigned code_sz, vm_instr const * code,
|
||||
list<vm_local_info> const & args_info, optional<pos_info> const & pos);
|
||||
list<vm_local_info> const & args_info, optional<pos_info> const & pos = optional<pos_info>());
|
||||
|
||||
/** \brief Combines reserve_vm_index and update_vm_code */
|
||||
environment add_vm_code(environment const & env, name const & fn, expr const & e, unsigned code_sz, vm_instr const * code,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue