comparison src/reduce.sml @ 443:bd9ee9aeca2f

Especialize
author Adam Chlipala <adamc@hcoop.net>
date Thu, 30 Oct 2008 16:58:54 -0400
parents e0e9e9eca1cb
children dfc8c991abd0
comparison
equal deleted inserted replaced
442:9095a95a1bf9 443:bd9ee9aeca2f
35 structure U = CoreUtil 35 structure U = CoreUtil
36 36
37 val liftConInCon = E.liftConInCon 37 val liftConInCon = E.liftConInCon
38 val subConInCon = E.subConInCon 38 val subConInCon = E.subConInCon
39 val liftConInExp = E.liftConInExp 39 val liftConInExp = E.liftConInExp
40 40 val liftExpInExp = E.liftExpInExp
41 val liftExpInExp = 41 val subExpInExp = E.subExpInExp
42 U.Exp.mapB {kind = fn k => k,
43 con = fn _ => fn c => c,
44 exp = fn bound => fn e =>
45 case e of
46 ERel xn =>
47 if xn < bound then
48 e
49 else
50 ERel (xn + 1)
51 | _ => e,
52 bind = fn (bound, U.Exp.RelE _) => bound + 1
53 | (bound, _) => bound}
54
55 val subExpInExp =
56 U.Exp.mapB {kind = fn k => k,
57 con = fn _ => fn c => c,
58 exp = fn (xn, rep) => fn e =>
59 case e of
60 ERel xn' =>
61 (case Int.compare (xn', xn) of
62 EQUAL => #1 rep
63 | GREATER=> ERel (xn' - 1)
64 | LESS => e)
65 | _ => e,
66 bind = fn ((xn, rep), U.Exp.RelE _) => (xn+1, liftExpInExp 0 rep)
67 | ((xn, rep), U.Exp.RelC _) => (xn, liftConInExp 0 rep)
68 | (ctx, _) => ctx}
69
70 val liftConInExp = E.liftConInExp 42 val liftConInExp = E.liftConInExp
71 val subConInExp = E.subConInExp 43 val subConInExp = E.subConInExp
72 44
73 fun bindC (env, b) = 45 fun bindC (env, b) =
74 case b of 46 case b of