1 #include <AD/pretty/postream.h>
5 ///////////////////////////////////////////////////////////////////////////////
7 // Constructors and destructors for phase3
9 ///////////////////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////////////////
15 // Methods to invoke phase3
17 ///////////////////////////////////////////////////////////////////////////////
18 Exp Phase3::phase3(Exp e)
19 { message("Disjunction removal phase", e); (*this)(e); return e; }
21 ///////////////////////////////////////////////////////////////////////////////
23 // Transformations to change disjunctions into unions
25 ///////////////////////////////////////////////////////////////////////////////
29 // Flatten set comprehensions
31 GENERATOR(x,A,GENERATOR(y,B,C)): GENERATOR(append(x,y),append(A,B),C)
35 // Flatten disjunctions
36 | Or(a,OP("or",b)): OP("or",#[a ... b])
38 // The following rules transform disjunction into unions
39 | GENERATOR(x,A,GUARD(OP("or", es),e)):
44 match while (disjuncts) of
48 Qs = #[ GENERATOR(x,A,GUARD(h,e)) ... Qs];
49 exps = #[ ID(Q) ... exps ];
53 rewrite(make_let(xs,Qs,OP("union",exps)));
57 | LET(x,LET(y,b,a),e): LET(y,b,LET(x,a,e))