2013-10-03 22:02:07 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2013-10-14 15:16:23 +00:00
|
|
|
#include "util/pdeque.h"
|
|
|
|
#include "kernel/formatter.h"
|
2013-10-03 22:02:07 +00:00
|
|
|
#include "library/elaborator/elaborator.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
class elaborator::imp {
|
2013-10-14 15:16:23 +00:00
|
|
|
typedef pdeque<unification_constraint> cnstr_queue;
|
|
|
|
|
|
|
|
struct state {
|
|
|
|
unsigned m_id;
|
|
|
|
metavar_env m_menv;
|
|
|
|
cnstr_queue m_queue;
|
|
|
|
};
|
|
|
|
|
2013-10-03 22:02:07 +00:00
|
|
|
environment const & m_env;
|
|
|
|
std::shared_ptr<synthesizer> m_synthesizer;
|
|
|
|
std::shared_ptr<elaborator_plugin> m_plugin;
|
|
|
|
bool m_interrupted;
|
|
|
|
public:
|
2013-10-14 15:16:23 +00:00
|
|
|
imp(environment const & env, metavar_env const &, unsigned num_cnstrs, unification_constraint const * cnstrs,
|
2013-10-03 22:02:07 +00:00
|
|
|
std::shared_ptr<synthesizer> const & s, std::shared_ptr<elaborator_plugin> const & p):
|
|
|
|
m_env(env),
|
|
|
|
m_synthesizer(s),
|
|
|
|
m_plugin(p) {
|
|
|
|
m_interrupted = false;
|
2013-10-14 15:16:23 +00:00
|
|
|
|
|
|
|
formatter fmt = mk_simple_formatter();
|
|
|
|
for (unsigned i = 0; i < num_cnstrs; i++) {
|
2013-10-14 21:37:35 +00:00
|
|
|
std::cout << cnstrs[i].pp(fmt, options(), nullptr, true) << "\n";
|
2013-10-14 15:16:23 +00:00
|
|
|
}
|
2013-10-03 22:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
substitution next() {
|
|
|
|
// TODO(Leo)
|
|
|
|
return substitution();
|
|
|
|
}
|
|
|
|
|
|
|
|
void interrupt() {
|
|
|
|
m_interrupted = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
elaborator::elaborator(environment const & env,
|
|
|
|
metavar_env const & menv,
|
|
|
|
unsigned num_cnstrs,
|
|
|
|
unification_constraint const * cnstrs,
|
|
|
|
std::shared_ptr<synthesizer> const & s,
|
|
|
|
std::shared_ptr<elaborator_plugin> const & p):
|
|
|
|
m_ptr(new imp(env, menv, num_cnstrs, cnstrs, s, p)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
elaborator::elaborator(environment const & env,
|
|
|
|
metavar_env const & menv,
|
|
|
|
context const & ctx, expr const & lhs, expr const & rhs):
|
|
|
|
elaborator(env, menv, { mk_eq_constraint(ctx, lhs, rhs, trace()) }) {
|
|
|
|
}
|
|
|
|
|
|
|
|
elaborator::~elaborator() {
|
|
|
|
}
|
|
|
|
|
|
|
|
substitution elaborator::next() {
|
|
|
|
return m_ptr->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
void elaborator::interrupt() {
|
|
|
|
m_ptr->interrupt();
|
|
|
|
}
|
|
|
|
}
|