fix(kernel/declaration): allow introspection of declarations in GDB

If the declaration::cell struct is not defined in the same header file
as declaration, GDB will show the cells as <incomplete type>.
This commit is contained in:
Gabriel Ebner 2016-11-07 12:39:48 -05:00 committed by Leonardo de Moura
parent f52b178a29
commit 8eb4bbd0cb
2 changed files with 24 additions and 24 deletions

View file

@ -37,30 +37,6 @@ int compare(reducibility_hints const & h1, reducibility_hints const & h2) {
}
}
struct declaration::cell {
MK_LEAN_RC();
name m_name;
level_param_names m_params;
expr m_type;
bool m_theorem;
optional<expr> m_value; // if none, then declaration is actually a postulate
reducibility_hints m_hints;
/* Definitions are trusted by default, and nested macros are expanded when kernel is instantiated with
trust level 0. When this flag is false, then we do not expand nested macros. We say the
associated definitions are "untrusted". We use this feature to define tactical-definitions.
The kernel type checker ensures trusted definitions do not use untrusted ones. */
bool m_trusted;
void dealloc() { delete this; }
cell(name const & n, level_param_names const & params, expr const & t, bool is_axiom, bool trusted):
m_rc(1), m_name(n), m_params(params), m_type(t), m_theorem(is_axiom),
m_hints(reducibility_hints::mk_opaque()), m_trusted(trusted) {}
cell(name const & n, level_param_names const & params, expr const & t, bool is_thm, expr const & v,
reducibility_hints const & h, bool trusted):
m_rc(1), m_name(n), m_params(params), m_type(t), m_theorem(is_thm),
m_value(v), m_hints(h), m_trusted(trusted) {}
};
static declaration * g_dummy = nullptr;
declaration::declaration():declaration(*g_dummy) {}

View file

@ -118,6 +118,30 @@ public:
friend declaration mk_constant_assumption(name const & n, level_param_names const & params, expr const & t, bool trusted);
};
struct declaration::cell {
MK_LEAN_RC();
name m_name;
level_param_names m_params;
expr m_type;
bool m_theorem;
optional<expr> m_value; // if none, then declaration is actually a postulate
reducibility_hints m_hints;
/* Definitions are trusted by default, and nested macros are expanded when kernel is instantiated with
trust level 0. When this flag is false, then we do not expand nested macros. We say the
associated definitions are "untrusted". We use this feature to define tactical-definitions.
The kernel type checker ensures trusted definitions do not use untrusted ones. */
bool m_trusted;
void dealloc() { delete this; }
cell(name const & n, level_param_names const & params, expr const & t, bool is_axiom, bool trusted):
m_rc(1), m_name(n), m_params(params), m_type(t), m_theorem(is_axiom),
m_hints(reducibility_hints::mk_opaque()), m_trusted(trusted) {}
cell(name const & n, level_param_names const & params, expr const & t, bool is_thm, expr const & v,
reducibility_hints const & h, bool trusted):
m_rc(1), m_name(n), m_params(params), m_type(t), m_theorem(is_thm),
m_value(v), m_hints(h), m_trusted(trusted) {}
};
inline optional<declaration> none_declaration() { return optional<declaration>(); }
inline optional<declaration> some_declaration(declaration const & o) { return optional<declaration>(o); }
inline optional<declaration> some_declaration(declaration && o) { return optional<declaration>(std::forward<declaration>(o)); }