@@ -10,7 +10,7 @@ import Data.Either (partitionEithers)
10import qualified Text.Pandoc as Pan
10import qualified Text.Pandoc as Pan
12import Unique
12import Unique
13−import Generate.Cases (caseToMatch, deprime, matchSubst, Match(..), Clause(..))
13+import Generate.Cases
14import SourceSyntax.Everything
14import SourceSyntax.Everything
15import SourceSyntax.Location
15import SourceSyntax.Location
16import qualified Transform.SortDefinitions as SD
16import qualified Transform.SortDefinitions as SD
@@ -75,7 +75,7 @@ jsModule modul =
75 jsExports = setup ("elm" : names modul) ++
75 jsExports = setup ("elm" : names modul) ++
76 ret (assign' ("elm." ++ modName) (brackets exs))
76 ret (assign' ("elm." ++ modName) (brackets exs))
78− exs = indent . commaSep . concatMap (pair . deprime) $ "_op" : exports modul
78+ exs = indent . commaSep . concatMap pair $ "_op" : exports modul
79 pair x | isOp x = []
79 pair x | isOp x = []
80 | otherwise = ["\n" ++ x ++ " : " ++ x]
80 | otherwise = ["\n" ++ x ++ " : " ++ x]
@@ -120,14 +120,13 @@ instance ToJS (Def t v) where
120 -- TODO: Make this handle patterns besides plain variables
120 -- TODO: Make this handle patterns besides plain variables
121 toJS (Def (PVar x) e)
121 toJS (Def (PVar x) e)
122 | isOp x = globalAssign ("_op['" ++ x ++ "']") `liftM` toJS' e
122 | isOp x = globalAssign ("_op['" ++ x ++ "']") `liftM` toJS' e
123− | otherwise = assign (deprime x) `liftM` toJS' e
123+ | otherwise = assign x `liftM` toJS' e
125 toJS (Def pattern e@(L s _)) =
125 toJS (Def pattern e@(L s _)) =
126 do n <- guid
126 do n <- guid
127 let x = "_" ++ show n
127 let x = "_" ++ show n
128 var = L s . Var
128 var = L s . Var
129− toDef y' = let y = deprime y' in
130− Def (PVar y) (L s $ Case (var x) [(pattern, var y)])
129+ toDef y = Def (PVar y) (L s $ Case (var x) [(pattern, var y)])
131 stmt <- assign x `liftM` toJS' e
130 stmt <- assign x `liftM` toJS' e
132 vars <- toJS . map toDef . Set.toList $ SD.boundVars pattern
131 vars <- toJS . map toDef . Set.toList $ SD.boundVars pattern
133 return (stmt ++ vars)
132 return (stmt ++ vars)
@@ -145,18 +144,18 @@ toJS' (L span expr) =
145 Case e cases -> caseToJS span e cases
144 Case e cases -> caseToJS span e cases
146 _ -> toJS expr
145 _ -> toJS expr
148−remove x e = "_N.remove('" ++ deprime x ++ "', " ++ e ++ ")"
147+remove x e = "_N.remove('" ++ x ++ "', " ++ e ++ ")"
149−addField x v e = "_N.insert('" ++ deprime x ++ "', " ++ v ++ ", " ++ e ++ ")"
148+addField x v e = "_N.insert('" ++ x ++ "', " ++ v ++ ", " ++ e ++ ")"
150setField fs e = "_N.replace(" ++ jsList (map f fs) ++ ", " ++ e ++ ")"
149setField fs e = "_N.replace(" ++ jsList (map f fs) ++ ", " ++ e ++ ")"
151− where f (x,v) = "['" ++ deprime x ++ "'," ++ v ++ "]"
150+ where f (x,v) = "['" ++ x ++ "'," ++ v ++ "]"
152−access x e = e ++ "." ++ deprime x
151+access x e = e ++ "." ++ x
153makeRecord kvs = record `liftM` collect kvs
152makeRecord kvs = record `liftM` collect kvs
155 combine r (k,v) = Map.insertWith (++) k v r
154 combine r (k,v) = Map.insertWith (++) k v r
156 collect = liftM (List.foldl' combine Map.empty) . mapM prep
155 collect = liftM (List.foldl' combine Map.empty) . mapM prep
157 prep (k, e) =
156 prep (k, e) =
158 do v <- toJS' e
157 do v <- toJS' e
159− return (deprime k, [v])
158+ return (k, [v])
160 fields fs =
159 fields fs =
161 brackets ("\n "++List.intercalate ",\n " (map (\(k,v) -> k++":"++v) fs))
160 brackets ("\n "++List.intercalate ",\n " (map (\(k,v) -> k++":"++v) fs))
162 hidden = fields . map (second jsList) .
161 hidden = fields . map (second jsList) .
@@ -177,7 +176,7 @@ instance ToJS Literal where
177instance ToJS (Expr t v) where
176instance ToJS (Expr t v) where
178 toJS expr =
177 toJS expr =
179 case expr of
178 case expr of
180− Var x -> return (deprime x)
179+ Var x -> return x
181 Literal lit -> toJS lit
180 Literal lit -> toJS lit
182 Range lo hi -> jsRange `liftM` toJS' lo `ap` toJS' hi
181 Range lo hi -> jsRange `liftM` toJS' lo `ap` toJS' hi
183 Access e x -> access x `liftM` toJS' e
182 Access e x -> access x `liftM` toJS' e
@@ -200,7 +199,7 @@ instance ToJS (Expr t v) where
201 depattern (pattern,n) (args, body) =
200 depattern (pattern,n) (args, body) =
202 case pattern of
201 case pattern of
203− PVar x -> (deprime x : args, body)
202+ PVar x -> (x : args, body)
204 _ -> let arg = "arg" ++ show n
203 _ -> let arg = "arg" ++ show n
205 in (arg:args, L s (Case (L s (Var arg)) [(pattern, body)]))
204 in (arg:args, L s (Case (L s (Var arg)) [(pattern, body)]))
@@ -268,7 +267,7 @@ caseToJS span e ps = do
268 (tempVar,match) <- caseToMatch ps
267 (tempVar,match) <- caseToMatch ps
269 e' <- toJS' e
268 e' <- toJS' e
270 let (match',stmt) = case e of
269 let (match',stmt) = case e of
271− L _ (Var x) -> (matchSubst [(tempVar,deprime x)] match, "")
270+ L _ (Var x) -> (matchSubst [(tempVar,x)] match, "")
272 _ -> (match, assign tempVar e')
271 _ -> (match, assign tempVar e')
273 matches <- matchToJS span match'
272 matches <- matchToJS span match'
274 return $ jsFunc "" (stmt ++ matches) ++ "()"
273 return $ jsFunc "" (stmt ++ matches) ++ "()"