2014-08-15 00:44:07 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2014-08-15 01:19:17 +00:00
|
|
|
#include <string>
|
2014-08-15 00:44:07 +00:00
|
|
|
#include "library/declaration_index.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2014-08-23 19:39:59 +00:00
|
|
|
void declaration_index::add_decl(std::string const fname, pos_info const & p, name const & n, name const & k, expr const & t) {
|
|
|
|
m_entries.emplace_back(entry_kind::Declaration, fname, p, n, k, t);
|
2014-08-15 00:44:07 +00:00
|
|
|
}
|
|
|
|
void declaration_index::add_ref(std::string const fname, pos_info const & p, name const & n) {
|
2014-08-23 19:39:59 +00:00
|
|
|
m_entries.emplace_back(entry_kind::Reference, fname, p, n, name(), expr());
|
2014-08-15 00:44:07 +00:00
|
|
|
}
|
2014-08-23 19:39:59 +00:00
|
|
|
void declaration_index::save(io_state_stream const & out) const {
|
|
|
|
entry_kind k; std::string fname; pos_info p; name n, dk; expr t;
|
2014-08-15 00:44:07 +00:00
|
|
|
for (auto const & e : m_entries) {
|
2014-08-23 19:39:59 +00:00
|
|
|
std::tie(k, fname, p, n, dk, t) = e;
|
2014-08-15 00:44:07 +00:00
|
|
|
out << (k == entry_kind::Declaration ? "d" : "r") << "|" << fname << "|" << p.first
|
2014-08-23 19:39:59 +00:00
|
|
|
<< "|" << p.second << "|" << n;
|
|
|
|
if (k == entry_kind::Declaration) {
|
|
|
|
out << "|" << dk << "|";
|
|
|
|
options const & opts = out.get_options();
|
|
|
|
out.get_stream() << mk_pair(flatten(out.get_formatter()(t)), opts);
|
|
|
|
}
|
|
|
|
out << endl;
|
2014-08-15 00:44:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|