feat(library/export): export the whole environment when using "--expor-all"
This commit is contained in:
parent
bed751a2d7
commit
9bf64c10fd
1 changed files with 39 additions and 25 deletions
|
@ -187,8 +187,6 @@ class exporter {
|
|||
for_each(e, [&](expr const & e, unsigned) {
|
||||
if (is_constant(e)) {
|
||||
name const & n = const_name(e);
|
||||
if (!inductive::is_intro_rule(m_env, n) &&
|
||||
!inductive::is_elim_rule(m_env, n))
|
||||
export_declaration(n);
|
||||
}
|
||||
return true;
|
||||
|
@ -196,6 +194,8 @@ class exporter {
|
|||
}
|
||||
|
||||
void export_definition(declaration const & d) {
|
||||
if (inductive::is_intro_rule(m_env, d.get_name()) || inductive::is_elim_rule(m_env, d.get_name()))
|
||||
return;
|
||||
if (already_exported(d.get_name()))
|
||||
return;
|
||||
mark(d.get_name());
|
||||
|
@ -284,6 +284,11 @@ class exporter {
|
|||
}
|
||||
|
||||
void export_declarations() {
|
||||
if (m_all) {
|
||||
m_env.for_each_declaration([&](declaration const & d) {
|
||||
export_declaration(d.get_name());
|
||||
});
|
||||
} else {
|
||||
buffer<name> ns;
|
||||
to_buffer(get_curr_module_decl_names(m_env), ns);
|
||||
std::reverse(ns.begin(), ns.end());
|
||||
|
@ -291,8 +296,10 @@ class exporter {
|
|||
export_declaration(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void export_direct_imports() {
|
||||
if (!m_all) {
|
||||
buffer<module_name> imports;
|
||||
to_buffer(get_curr_module_imports(m_env), imports);
|
||||
std::reverse(imports.begin(), imports.end());
|
||||
|
@ -305,8 +312,15 @@ class exporter {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void export_global_universes() {
|
||||
if (m_all) {
|
||||
m_env.for_each_universe([&](name const & u) {
|
||||
unsigned n = export_name(u);
|
||||
m_out << "#UNI " << n << "\n";
|
||||
});
|
||||
} else {
|
||||
buffer<name> ns;
|
||||
to_buffer(get_curr_module_univ_names(m_env), ns);
|
||||
std::reverse(ns.begin(), ns.end());
|
||||
|
@ -315,6 +329,7 @@ class exporter {
|
|||
m_out << "#UNI " << n << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
exporter(std::ostream & out, environment const & env, bool all):m_out(out), m_env(env), m_all(all) {}
|
||||
|
@ -322,7 +337,6 @@ public:
|
|||
void operator()() {
|
||||
m_name2idx.insert(mk_pair(name(), 0));
|
||||
m_level2idx.insert(mk_pair(level(), 0));
|
||||
if (!m_all)
|
||||
export_direct_imports();
|
||||
export_global_universes();
|
||||
export_declarations();
|
||||
|
|
Loading…
Reference in a new issue