on master help sign in
Guard against issue #387
61ff490Evan Czaplicki
compiler/Generate/JavaScript.hs+15−15
@@ -50,7 +50,7 @@ varDecl x expr =
50 VarDecl () (var x) (Just expr)
50 VarDecl () (var x) (Just expr)
51
51
52include alias moduleName =
52include alias moduleName =
53− varDecl alias (obj (moduleName ++ ".make") <| ref "elm")
53+ varDecl alias (obj (moduleName ++ ".make") <| ref "_elm")
54
54
55internalImports name =
55internalImports name =
56 VarDeclStmt ()
56 VarDeclStmt ()
@@ -293,11 +293,11 @@ clause span variable (Case.Clause value vars mtch) =
293generate :: MetadataModule () () -> String
293generate :: MetadataModule () () -> String
294generate modul =
294generate modul =
295 show . prettyPrint $ setup (Just "Elm") (names modul ++ ["make"]) ++
295 show . prettyPrint $ setup (Just "Elm") (names modul ++ ["make"]) ++
296− [ assign ("Elm" : names modul ++ ["make"]) (function ["elm"] programStmts) ]
296+ [ assign ("Elm" : names modul ++ ["make"]) (function ["_elm"] programStmts) ]
297 where
297 where
298− thisModule = dotSep ("elm" : names modul ++ ["values"])
298+ thisModule = dotSep ("_elm" : names modul ++ ["values"])
299 programStmts =
299 programStmts =
300− concat [ setup (Just "elm") (names modul ++ ["values"])
300+ concat [ setup (Just "_elm") (names modul ++ ["values"])
301 , [ IfSingleStmt () thisModule (ReturnStmt () (Just thisModule)) ]
301 , [ IfSingleStmt () thisModule (ReturnStmt () (Just thisModule)) ]
302 , [ internalImports (List.intercalate "." (names modul)) ]
302 , [ internalImports (List.intercalate "." (names modul)) ]
303 , concatMap jsImport (imports modul)
303 , concatMap jsImport (imports modul)
@@ -309,7 +309,7 @@ generate modul =
309 , [ ReturnStmt () (Just thisModule) ]
309 , [ ReturnStmt () (Just thisModule) ]
310 ]
310 ]
311
311
312− jsExports = assign ("elm" : names modul ++ ["values"]) (ObjectLit () exs)
312+ jsExports = assign ("_elm" : names modul ++ ["values"]) (ObjectLit () exs)
313 where
313 where
314 exs = map entry . filter (not . isOp) $ "_op" : exports modul
314 exs = map entry . filter (not . isOp) $ "_op" : exports modul
315 entry x = (PropId () (var x), ref x)
315 entry x = (PropId () (var x), ref x)
@@ -323,7 +323,7 @@ generate modul =
323 jsImport (modul,_) = setup Nothing path ++ [ include ]
323 jsImport (modul,_) = setup Nothing path ++ [ include ]
324 where
324 where
325 path = split modul
325 path = split modul
326− include = assign path $ dotSep ("Elm" : path ++ ["make"]) <| ref "elm"
326+ include = assign path $ dotSep ("Elm" : path ++ ["make"]) <| ref "_elm"
327
327
328 setup namespace path = map create paths
328 setup namespace path = map create paths
329 where
329 where
@@ -332,15 +332,15 @@ generate modul =
332 Nothing -> tail . init $ List.inits path
332 Nothing -> tail . init $ List.inits path
333 Just nmspc -> drop 2 . init . List.inits $ nmspc : path
333 Just nmspc -> drop 2 . init . List.inits $ nmspc : path
334
334
335− addId js = InfixExpr () OpAdd (string (js++"_")) (obj "elm.id")
335+ addId js = InfixExpr () OpAdd (string (js++"_")) (obj "_elm.id")
336
336
337 importEvent (js,base,elm,_) =
337 importEvent (js,base,elm,_) =
338 [ VarDeclStmt () [ varDecl elm $ obj "Signal.constant" <| evalState (expression base) 0 ]
338 [ VarDeclStmt () [ varDecl elm $ obj "Signal.constant" <| evalState (expression base) 0 ]
339 , ExprStmt () $
339 , ExprStmt () $
340 obj "document.addEventListener" `call`
340 obj "document.addEventListener" `call`
341 [ addId js
341 [ addId js
342− , function ["e"]
342+ , function ["_e"]
343− [ ExprStmt () $ obj "elm.notify" `call` [dotSep [elm,"id"], obj "e.value"] ]
343+ [ ExprStmt () $ obj "_elm.notify" `call` [dotSep [elm,"id"], obj "_e.value"] ]
344 ]
344 ]
345 ]
345 ]
346
346
@@ -348,13 +348,13 @@ generate modul =
348 ExprStmt () $
348 ExprStmt () $
349 ref "A2" `call`
349 ref "A2" `call`
350 [ obj "Signal.lift"
350 [ obj "Signal.lift"
351− , function ["v"]
351+ , function ["_v"]
352− [ VarDeclStmt () [varDecl "e" $ obj "document.createEvent" <| string "Event"]
352+ [ VarDeclStmt () [varDecl "_e" $ obj "document.createEvent" <| string "Event"]
353 , ExprStmt () $
353 , ExprStmt () $
354− obj "e.initEvent" `call` [ addId js, BoolLit () True, BoolLit () True ]
354+ obj "_e.initEvent" `call` [ addId js, BoolLit () True, BoolLit () True ]
355− , ExprStmt () $ AssignExpr () OpAssign (LDot () (ref "e") "value") (ref "v")
355+ , ExprStmt () $ AssignExpr () OpAssign (LDot () (ref "_e") "value") (ref "_v")
356− , ExprStmt () $ obj "document.dispatchEvent" <| ref "e"
356+ , ExprStmt () $ obj "document.dispatchEvent" <| ref "_e"
357− , ReturnStmt () (Just $ ref "v")
357+ , ReturnStmt () (Just $ ref "_v")
358 ]
358 ]
359 , ref elm ]
359 , ref elm ]
360
360