00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00041
00042 #include <assert.h>
00043 #include <stdint.h>
00044 #include <stdlib.h>
00045 #include <dirent.h>
00046 #include <fstream>
00047 #include <iostream>
00048 #include <string>
00049 #include <sstream>
00050
00051 #include <libsherpa/UExcept.hxx>
00052
00053 #include "UocInfo.hxx"
00054 #include "AST.hxx"
00055 #include "Type.hxx"
00056 #include "TypeInfer.hxx"
00057 #include "TypeScheme.hxx"
00058 #include "Typeclass.hxx"
00059 #include "inter-pass.hxx"
00060
00061 using namespace std;
00062 using namespace boost;
00063 using namespace sherpa;
00064
00067 bool
00068 TCConstraints::contains(shared_ptr<Typeclass> tc)
00069 {
00070 for (iterator itr = begin(); itr != end(); ++itr)
00071 if ((*itr)->strictlyEquals(tc, false, true))
00072 return true;
00073
00074 return false;
00075 }
00076
00086
00087 void
00088 TCConstraints::addPred(shared_ptr<Typeclass> tc)
00089 {
00090 for (iterator itr = begin(); itr != end(); ++itr) {
00091 if ((*itr)->strictlyEquals(tc, false, true)) {
00092
00093
00094
00095 if (tc->flags & TY_CT_SUBSUMED)
00096 (*itr)->flags |= TY_CT_SUBSUMED;
00097 return;
00098 }
00099 }
00100
00101 pred.insert(tc);
00102 }
00103
00106 void
00107 TCConstraints::clearPred(shared_ptr<Constraint> ct)
00108 {
00109 ct = ct->getType();
00110 for (iterator itr = begin(); itr != end(); ++itr) {
00111 shared_ptr<Constraint> pr = (*itr)->getType();
00112 if (pr == ct) {
00113 pred.erase(itr);
00114 return;
00115 }
00116 }
00117 }
00118
00121 void
00122 TCConstraints::normalize()
00123 {
00124 TypeSet allPreds = pred;
00125 pred.clear();
00126
00127 for (iterator itr = allPreds.begin(); itr != allPreds.end(); ++itr)
00128 addPred((*itr));
00129 }
00130