6 #include <union_find.h>
22 class ECR :
public UF_elem
28 {
return static_cast<ECR*
>(UF_elem::find_group()); }
36 UF_elem::union_with(that);
37 return static_cast<ECR*
>(UF_elem::find_group());
54 #define Variable std::string
95 for (std::list<Variable>::const_iterator yp = y.begin();
96 yp != y.end(); ++yp) {
98 if (t1 != t2)
cjoin(t1, t2);
133 std::list<ECR *>::const_iterator p1=l->
get_inParams().begin();
134 std::list<Variable>::const_iterator p2=inParams.begin();
136 assert(p2 != inParams.end());
139 assert(p2 == inParams.end());
141 p2=outParams.begin();
143 assert(p2 != outParams.end());
146 assert(p2 == outParams.end());
160 std::list<ECR *>::const_iterator p1=l->
get_inParams().begin();
161 std::list<Variable>::const_iterator p2=y.begin();
163 assert(p2 != y.end());
170 assert(p2 == y.end());
174 assert(p2 != x.end());
181 assert(p2 == x.end());
186 int find_LOC(std::ostream& out, std::map<ECR*, int>& locmap,
int& loc,
ECR* p)
189 std::map<ECR*, int>::const_iterator p1 = locmap.find(p);
190 if (p1 == locmap.end()) {
198 void outputLOC(std::ostream& out, std::map<ECR*, int>& locmap,
int& loc,
ECR* p) {
200 out <<
" LOC" <<
find_LOC(out,locmap,loc,p);
204 int cur =
find_LOC(out,locmap,loc,p);
206 else if (cur <= max) max = -1;
208 out <<
"=>" <<
"LOC" << cur <<
" ";
209 if (p ->get_pending().size() != 0) {
211 for (std::list<ECR*>::const_iterator pp=p->
get_pending().begin();
213 outputLOC(out,locmap, loc, (*pp)->get_ecr());
218 out <<
"(inparams: ";
219 for (std::list<ECR*>::const_iterator pp=t->
get_inParams().begin();
221 outputLOC(out,locmap,loc,(*pp)->get_ecr());
223 out <<
"->(outparams: ";
224 for (std::list<ECR*>::const_iterator pp=t->
get_outParams().begin();
226 outputLOC(out,locmap,loc,(*pp)->get_ecr());
233 std::map<ECR*, int> locmap;
235 for (std::map<Variable, ECR*>::iterator
236 itMap =
table.begin(); itMap !=
table.end(); itMap++) {
238 out << itMap->first ;
248 if (
table[x]->get_type() ==
table[y]->get_type())
254 for (std::list<ECR*>::const_iterator p =
ecrList.begin();
266 std::map<Variable, ECR*>::const_iterator p =
table.find(x);
268 if (p ==
table.end()) {
286 void set_lambda(
Lambda* l,
const std::list<Variable>& inParams,
const std::list<Variable>& outParams) {
287 for (std::list<Variable>::const_iterator p = inParams.begin();
288 p != inParams.end(); ++p) {
294 for (std::list<Variable>::const_iterator p2 = outParams.begin();
295 p2 != outParams.end(); ++p2) {
307 if (pending.size()) {
308 for (std::list<ECR*>::const_iterator p=pending.begin();
309 p != pending.end(); ++p)
325 std::list<ECR *>::const_iterator p1=l1->
get_inParams().begin();
326 std::list<ECR *>::const_iterator p2=l2->
get_inParams().begin();
341 assert(t1 != 0 && t2 != 0);
353 if (e1 == e2)
return;
376 assert(pending != pending1);
377 pending->insert(pending->end(), pending1->begin(), pending1->end());
380 assert(pending != pending2);
381 pending->insert(pending->end(), pending2->begin(), pending2->end());
384 assert(pending != pending2 && pending != pending1);
385 *pending = *pending1;
386 pending->insert(pending->end(), pending2->begin(), pending2->end());
390 if (pending1->size()) {
391 for (std::list<ECR*>::const_iterator p=pending1->begin();
392 p != pending1->end(); ++p)
401 if (pending2->size()) {
402 for (std::list<ECR*>::const_iterator p=pending2->begin();
403 p != pending2->end(); ++p)