2 #ifndef HOBBES_LANG_TYPEMAP_HPP_INCLUDED 3 #define HOBBES_LANG_TYPEMAP_HPP_INCLUDED 20 typedef std::map<MonoTypePtr, V, MonoTypeLT>
type;
33 this->d.insert(mts.begin(), mts.end(), v);
37 return this->d.lookup(mts.begin(), mts.end());
41 return this->d.values();
47 return hasMatch(u, this->d.rootPoint(), mts, 0);
53 findMatches(u, this->d.rootPoint(), mts, 0,
out);
59 findBidiMatches(u, this->d.rootPoint(), mts, 0,
out);
63 void find(
const MaybePathPoints& path, std::vector<V>*
out)
const {
64 findMatches(this->d.rootPoint(), path, 0,
out);
75 if (i == mts.size()) {
81 return hasMatch(u, this->d.
moveTo(mty, p), mts, i + 1);
86 for (
typename tmdata::KeyPointSeq::const_iterator kp = kps.begin(); kp != kps.end(); ++kp) {
89 mgu(mty, kp->first, &pu);
90 if (hasMatch(pu, kp->second, mts, i + 1))
return true;
91 }
catch (std::exception& ex) {
102 if (i == mts.size()) {
103 if (
const V* v = this->d.
valueAt(p)) {
110 findMatches(u, this->d.
moveTo(mty, p), mts, i + 1,
out);
115 for (
typename tmdata::KeyPointSeq::const_iterator kp = kps.begin(); kp != kps.end(); ++kp) {
118 mgu(mty, kp->first, &pu);
119 findMatches(pu, kp->second, mts, i + 1, out);
120 }
catch (std::exception& ex) {
130 if (i == mts.size()) {
131 if (
const V* v = this->d.
valueAt(p)) {
140 for (
typename tmdata::KeyPointSeq::const_iterator kp = kps.begin(); kp != kps.end(); ++kp) {
144 findBidiMatches(pu, kp->second, mts, i + 1, out);
145 }
catch (std::exception& ex) {
154 if (i == path.size()) {
155 if (
const V* v = this->d.
valueAt(p)) {
160 if (
const MonoTypePtr* mt = get<MonoTypePtr>(path[i])) {
161 findMatches(this->d.
moveTo(*mt, p), path, i + 1,
out);
166 for (
auto kp : kps) {
167 findMatches(kp.second, path, i + 1, out);
tmdata d
Definition: typemap.H:68
bool hasMatch(const TEnvPtr &tenv, const MonoTypes &mts) const
Definition: typemap.H:45
V * valueAt(point_t base) const
Definition: trie.H:143
MonoTypePtr substitute(const MonoTypePtr &)
Definition: typeinf.C:341
void findBidiMatches(MonoTypeUnifier &u, typename tmdata::point_t p, const MonoTypes &mts, size_t i, std::vector< V > *out) const
Definition: typemap.H:127
std::map< MonoTypePtr, V, MonoTypeLT > type
Definition: typemap.H:20
void insert(const MonoTypes &mts, const V &v)
Definition: typemap.H:32
void keyPointsAt(KeyPointSeq *kps, point_t base) const
Definition: trie.H:135
MonoType::ptr MonoTypePtr
Definition: type.H:71
void * point_t
Definition: trie.H:109
void findMatches(MonoTypeUnifier &u, typename tmdata::point_t p, const MonoTypes &mts, size_t i, std::vector< V > *out) const
Definition: typemap.H:99
V * lookup(const MonoTypes &mts) const
Definition: typemap.H:36
void bidimatches(const TEnvPtr &tenv, const MonoTypes &mts, std::vector< V > *out) const
Definition: typemap.H:57
std::vector< V > values() const
Definition: typemap.H:40
void find(const MaybePathPoints &path, std::vector< V > *out) const
Definition: typemap.H:63
std::vector< MaybePathPoint > MaybePathPoints
Definition: typemap.H:26
void matches(const TEnvPtr &tenv, const MonoTypes &mts, std::vector< V > *out) const
Definition: typemap.H:51
variant< unit, MonoTypePtr > MaybePathPoint
Definition: typemap.H:25
std::shared_ptr< TEnv > TEnvPtr
Definition: type.H:80
bool hasMatch(MonoTypeUnifier &u, typename tmdata::point_t p, const MonoTypes &mts, size_t i) const
Definition: typemap.H:70
void findMatches(typename tmdata::point_t p, const MaybePathPoints &path, size_t i, std::vector< V > *out) const
Definition: typemap.H:151
point_t moveTo(const K &k, point_t base) const
Definition: trie.H:112
#define out
Definition: netio.H:19
Definition: variant.H:103
bool hasFreeVariables(const QualTypePtr &)
Definition: type.C:1858
bool operator()(const MonoTypePtr &, const MonoTypePtr &) const
Definition: typemap.C:187
std::vector< MonoTypePtr > MonoTypes
Definition: type.H:72
std::vector< KeyPoint > KeyPointSeq
Definition: trie.H:134
prefix_tree< MonoTypePtr, V, MTyMap > tmdata
Definition: typemap.H:67
void mgu(const ExprPtr &, const ExprPtr &, MonoTypeUnifier *)
Definition: typeinf.C:959