comparison src/mono_env.sml @ 182:d11754ffe252

Compiled pattern matching to C
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 12:43:20 -0400
parents 3bbed533fbd2
children c0ea24dcb86f
comparison
equal deleted inserted replaced
181:31dfab1d4050 182:d11754ffe252
51 namedE = IM.empty 51 namedE = IM.empty
52 } 52 }
53 53
54 fun pushDatatype (env : env) x n xncs = 54 fun pushDatatype (env : env) x n xncs =
55 {datatypes = IM.insert (#datatypes env, n, (x, xncs)), 55 {datatypes = IM.insert (#datatypes env, n, (x, xncs)),
56 constructors = foldl (fn ((x, n, to), constructors) => 56 constructors = foldl (fn ((x, n', to), constructors) =>
57 IM.insert (constructors, n, (x, to, n))) 57 IM.insert (constructors, n', (x, to, n)))
58 (#constructors env) xncs, 58 (#constructors env) xncs,
59 59
60 relE = #relE env, 60 relE = #relE env,
61 namedE = #namedE env} 61 namedE = #namedE env}
62 62
105 end 105 end
106 | DVal (x, n, t, e, s) => pushENamed env x n t (SOME e) s 106 | DVal (x, n, t, e, s) => pushENamed env x n t (SOME e) s
107 | DValRec vis => foldl (fn ((x, n, t, e, s), env) => pushENamed env x n t NONE s) env vis 107 | DValRec vis => foldl (fn ((x, n, t, e, s), env) => pushENamed env x n t NONE s) env vis
108 | DExport _ => env 108 | DExport _ => env
109 109
110 val dummyt = (TFfi ("", ""), ErrorMsg.dummySpan)
111
112 fun patBinds env (p, loc) = 110 fun patBinds env (p, loc) =
113 case p of 111 case p of
114 PWild => env 112 PWild => env
115 | PVar x => pushERel env x dummyt 113 | PVar (x, t) => pushERel env x t
116 | PPrim _ => env 114 | PPrim _ => env
117 | PCon (_, NONE) => env 115 | PCon (_, NONE) => env
118 | PCon (_, SOME p) => patBinds env p 116 | PCon (_, SOME p) => patBinds env p
119 | PRecord xps => foldl (fn ((_, p), env) => patBinds env p) env xps 117 | PRecord xps => foldl (fn ((_, p, _), env) => patBinds env p) env xps
120 118
121 end 119 end