@@ -48,14 +48,17 @@ trait OrderingOps extends Base with Variables with OverloadHack {
4848
4949
5050trait OrderingOpsExp extends OrderingOps with VariablesExp {
51-
52- case class OrderingLT [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [Boolean ]
53- case class OrderingLTEQ [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [Boolean ]
54- case class OrderingGT [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [Boolean ]
55- case class OrderingGTEQ [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [Boolean ]
56- case class OrderingEquiv [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [Boolean ]
57- case class OrderingMax [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [T ]
58- case class OrderingMin [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends Def [T ]
51+ abstract class DefMN [T : Ordering : Manifest ,A ]extends Def [A ] {
52+ def mev = manifest[T ]
53+ def aev = implicitly[Ordering [T ]]
54+ }
55+ case class OrderingLT [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,Boolean ]
56+ case class OrderingLTEQ [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,Boolean ]
57+ case class OrderingGT [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,Boolean ]
58+ case class OrderingGTEQ [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,Boolean ]
59+ case class OrderingEquiv [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,Boolean ]
60+ case class OrderingMax [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,T ]
61+ case class OrderingMin [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])extends DefMN [T ,T ]
5962
6063def ordering_lt [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])(implicit pos :SourceContext ): Rep [Boolean ]= OrderingLT (lhs,rhs)
6164def ordering_lteq [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])(implicit pos :SourceContext ): Rep [Boolean ]= OrderingLTEQ (lhs,rhs)
@@ -66,16 +69,14 @@ trait OrderingOpsExp extends OrderingOps with VariablesExp {
6669def ordering_min [T : Ordering : Manifest ](lhs :Exp [T ],rhs :Exp [T ])(implicit pos :SourceContext ): Rep [T ]= OrderingMin (lhs,rhs)
6770
6871override def mirror [A : Manifest ](e :Def [A ],f :Transformer )(implicit pos :SourceContext ): Exp [A ]= {
69- implicit val z1 : Ordering [Any ]= null // hack!! need to store it in Def instances??
70- implicit val z2 : Ordering [A ]= null // hack!! need to store it in Def instances??
7172 (ematch {
72- case OrderingLT (a,b)=> ordering_lt(f(a),f(b))
73- case OrderingLTEQ (a,b)=> ordering_lteq(f(a),f(b))
74- case OrderingGT (a,b)=> ordering_gt(f(a),f(b))
75- case OrderingGTEQ (a,b)=> ordering_gteq(f(a),f(b))
76- case OrderingEquiv (a,b)=> ordering_equiv(f(a),f(b))
77- case OrderingMax (a,b)=> ordering_max(f(a),f(b))
78- case OrderingMin (a,b)=> ordering_min(f(a),f(b))
73+ case e @ OrderingLT (a,b)=> ordering_lt(f(a),f(b))(e.aev,e.mev,pos )
74+ case e @ OrderingLTEQ (a,b)=> ordering_lteq(f(a),f(b))(e.aev,e.mev,pos )
75+ case e @ OrderingGT (a,b)=> ordering_gt(f(a),f(b))(e.aev,e.mev,pos )
76+ case e @ OrderingGTEQ (a,b)=> ordering_gteq(f(a),f(b))(e.aev,e.mev,pos )
77+ case e @ OrderingEquiv (a,b)=> ordering_equiv(f(a),f(b))(e.aev,e.mev,pos )
78+ case e @ OrderingMax (a,b)=> ordering_max(f(a),f(b))(e.aev. asInstanceOf [ Ordering [ A ]],mtype(e.mev),pos )
79+ case e @ OrderingMin (a,b)=> ordering_min(f(a),f(b))(e.aev. asInstanceOf [ Ordering [ A ]],mtype(e.mev),pos )
7980case _=> super .mirror(e, f)
8081 }).asInstanceOf [Exp [A ]]
8182 }