on master help sign in
Provide fewer JS features with Gen/JS/Builder
90fc530Evan Czaplicki
compiler/src/Generate/JavaScript.hs+24−35
@@ -225,7 +225,7 @@ addKernel (State revKernels revBuilders seen) kernel =
225
225
226var :: Opt.Global -> Expr.Code -> JS.Stmt
226var :: Opt.Global -> Expr.Code -> JS.Stmt
227var (Opt.Global home name) code =
227var (Opt.Global home name) code =
228− JS.Var [ (JsName.fromGlobal home name, Just (Expr.codeToExpr code)) ]
228+ JS.Var (JsName.fromGlobal home name) (Expr.codeToExpr code)
229
229
230
230
231isDebugger :: Opt.Global -> Bool
231isDebugger :: Opt.Global -> Bool
@@ -265,10 +265,10 @@ generateCycleFunc :: Mode.Mode -> ModuleName.Canonical -> Opt.Def -> JS.Stmt
265generateCycleFunc mode home def =
265generateCycleFunc mode home def =
266 case def of
266 case def of
267 Opt.Def name expr ->
267 Opt.Def name expr ->
268− JS.Var [ (JsName.fromGlobal home name, Just (Expr.codeToExpr (Expr.generate mode expr))) ]
268+ JS.Var (JsName.fromGlobal home name) (Expr.codeToExpr (Expr.generate mode expr))
269
269
270 Opt.TailDef name args expr ->
270 Opt.TailDef name args expr ->
271− JS.Var [ (JsName.fromGlobal home name, Just (Expr.codeToExpr (Expr.generateTailDef mode name args expr))) ]
271+ JS.Var (JsName.fromGlobal home name) (Expr.codeToExpr (Expr.generateTailDef mode name args expr))
272
272
273
273
274generateSafeCycle :: Mode.Mode -> ModuleName.Canonical -> (Name.Name, Opt.Expr) -> JS.Stmt
274generateSafeCycle :: Mode.Mode -> ModuleName.Canonical -> (Name.Name, Opt.Expr) -> JS.Stmt
@@ -284,7 +284,7 @@ generateRealCycle home (name, _) =
284 realName = JsName.fromGlobal home name
284 realName = JsName.fromGlobal home name
285 in
285 in
286 JS.Block
286 JS.Block
287− [ JS.Var [ ( realName, Just (JS.Call (JS.Ref safeName) []) ) ]
287+ [ JS.Var realName (JS.Call (JS.Ref safeName) [])
288 , JS.ExprStmt $ JS.Assign (JS.LRef safeName) $
288 , JS.ExprStmt $ JS.Assign (JS.LRef safeName) $
289 JS.Function Nothing [] [ JS.Return (Just (JS.Ref realName)) ]
289 JS.Function Nothing [] [ JS.Return (Just (JS.Ref realName)) ]
290 ]
290 ]
@@ -354,16 +354,13 @@ addChunk mode chunk builder =
354
354
355generateEnum :: Mode.Mode -> Opt.Global -> Index.ZeroBased -> JS.Stmt
355generateEnum :: Mode.Mode -> Opt.Global -> Index.ZeroBased -> JS.Stmt
356generateEnum mode global@(Opt.Global home name) index =
356generateEnum mode global@(Opt.Global home name) index =
357− let
357+ JS.Var (JsName.fromGlobal home name) $
358− definition =
359− case mode of
358+ case mode of
360− Mode.Dev _ ->
359+ Mode.Dev _ ->
361− Expr.codeToExpr (Expr.generateCtor mode global index 0)
360+ Expr.codeToExpr (Expr.generateCtor mode global index 0)
362
361
363− Mode.Prod _ ->
362+ Mode.Prod _ ->
364− JS.Int (Index.toMachine index)
363+ JS.Int (Index.toMachine index)
365− in
366− JS.Var [ (JsName.fromGlobal home name, Just definition) ]
367
364
368
365
369
366
@@ -372,16 +369,13 @@ generateEnum mode global@(Opt.Global home name) index =
372
369
373generateBox :: Mode.Mode -> Opt.Global -> JS.Stmt
370generateBox :: Mode.Mode -> Opt.Global -> JS.Stmt
374generateBox mode global@(Opt.Global home name) =
371generateBox mode global@(Opt.Global home name) =
375− let
372+ JS.Var (JsName.fromGlobal home name) $
376− definition =
377− case mode of
373+ case mode of
378− Mode.Dev _ ->
374+ Mode.Dev _ ->
379− Expr.codeToExpr (Expr.generateCtor mode global Index.first 1)
375+ Expr.codeToExpr (Expr.generateCtor mode global Index.first 1)
380
376
381− Mode.Prod _ ->
377+ Mode.Prod _ ->
382− JS.Ref (JsName.fromGlobal ModuleName.basics Name.identity)
378+ JS.Ref (JsName.fromGlobal ModuleName.basics Name.identity)
383− in
384− JS.Var [ (JsName.fromGlobal home name, Just definition) ]
385
379
386
380
387{-# NOINLINE identity #-}
381{-# NOINLINE identity #-}
@@ -396,14 +390,11 @@ identity =
396
390
397generatePort :: Mode.Mode -> Opt.Global -> Name.Name -> Opt.Expr -> JS.Stmt
391generatePort :: Mode.Mode -> Opt.Global -> Name.Name -> Opt.Expr -> JS.Stmt
398generatePort mode (Opt.Global home name) makePort converter =
392generatePort mode (Opt.Global home name) makePort converter =
399− let
393+ JS.Var (JsName.fromGlobal home name) $
400− definition =
401− JS.Call (JS.Ref (JsName.fromKernel Name.platform makePort))
394+ JS.Call (JS.Ref (JsName.fromKernel Name.platform makePort))
402− [ JS.String (Name.toBuilder name)
395+ [ JS.String (Name.toBuilder name)
403− , Expr.codeToExpr (Expr.generate mode converter)
396+ , Expr.codeToExpr (Expr.generate mode converter)
404− ]
397+ ]
405− in
406− JS.Var [ (JsName.fromGlobal home name, Just definition) ]
407
398
408
399
409
400
@@ -431,11 +422,9 @@ generateManager mode graph (Opt.Global home@(ModuleName.Canonical _ moduleName)
431
422
432generateLeaf :: ModuleName.Canonical -> Name.Name -> JS.Stmt
423generateLeaf :: ModuleName.Canonical -> Name.Name -> JS.Stmt
433generateLeaf home@(ModuleName.Canonical _ moduleName) name =
424generateLeaf home@(ModuleName.Canonical _ moduleName) name =
434− let
425+ JS.Var (JsName.fromGlobal home name) $
435− definition =
436− JS.Call leaf [ JS.String (Name.toBuilder moduleName) ]
426+ JS.Call leaf [ JS.String (Name.toBuilder moduleName) ]
437− in
427+
438− JS.Var [ (JsName.fromGlobal home name, Just definition) ]
439
428
440
429
441{-# NOINLINE leaf #-}
430{-# NOINLINE leaf #-}
compiler/src/Generate/JavaScript/Builder.hs+61−74
@@ -37,13 +37,13 @@ data Expr
37 | Array [Expr]
37 | Array [Expr]
38 | Object [(Name, Expr)]
38 | Object [(Name, Expr)]
39 | Ref Name
39 | Ref Name
40− | Access Expr Name -- ^ @foo.bar@, spec 11.2.1
40+ | Access Expr Name -- foo.bar
41− | Index Expr Expr -- ^ @foo[bar]@, spec 11.2.1
41+ | Index Expr Expr -- foo[bar]
42 | Prefix PrefixOp Expr
42 | Prefix PrefixOp Expr
43 | Infix InfixOp Expr Expr
43 | Infix InfixOp Expr Expr
44 | If Expr Expr Expr
44 | If Expr Expr Expr
45 | Assign LValue Expr
45 | Assign LValue Expr
46− | Call Expr [Expr] -- ^ @f(x,y,z)@, spec 11.2.3
46+ | Call Expr [Expr]
47 | Function (Maybe Name) [Name] [Stmt]
47 | Function (Maybe Name) [Name] [Stmt]
48
48
49
49
@@ -58,20 +58,21 @@ data LValue
58
58
59
59
60data Stmt
60data Stmt
61− = Block [Stmt] -- {stmts}
61+ = Block [Stmt]
62− | EmptyStmt -- ;
62+ | EmptyStmt
63− | ExprStmt Expr -- expr;
63+ | ExprStmt Expr
64− | IfStmt Expr Stmt Stmt -- if (e) stmt1 else stmt2
64+ | IfStmt Expr Stmt Stmt
65− | Switch Expr [Case] -- switch (e) clauses
65+ | Switch Expr [Case]
66− | While Expr Stmt -- while (e) do stmt
66+ | While Expr Stmt
67− | Break (Maybe Name) -- break lab;
67+ | Break (Maybe Name)
68− | Continue (Maybe Name) -- continue lab;
68+ | Continue (Maybe Name)
69− | Labelled Name Stmt -- lab: stmt
69+ | Labelled Name Stmt
70− | Try Stmt Name Stmt -- try stmt catch (x) stmt
70+ | Try Stmt Name Stmt
71− | Throw Expr -- throw expr;
71+ | Throw Expr
72− | Return (Maybe Expr) -- return expr;
72+ | Return (Maybe Expr)
73+ | Var Name Expr
73− | Var [(Name, Maybe Expr)] -- var x, y=42;
74+ | Vars [(Name, Expr)]
74− | FunctionStmt Name [Name] [Stmt] -- function f(x, y, z) {...}
75+ | FunctionStmt Name [Name] [Stmt]
75
76
76
77
77data Case
78data Case
@@ -84,37 +85,31 @@ data Case
84
85
85
86
86data InfixOp
87data InfixOp
87− = OpLT -- <
88+ = OpAdd -- +
88− | OpLEq -- <=
89+ | OpSub -- -
89− | OpGT -- >
90− | OpGEq -- >=
91− | OpIn -- in
92− | OpInstanceof -- instanceof
93− | OpEq -- ==
94− | OpNEq -- !=
95− | OpStrictEq -- ===
96− | OpStrictNEq -- !==
97− | OpLAnd -- &&
98− | OpLOr -- ||
99 | OpMul -- *
90 | OpMul -- *
100 | OpDiv -- /
91 | OpDiv -- /
101 | OpMod -- %
92 | OpMod -- %
102− | OpSub -- -
93+ | OpEq -- ===
94+ | OpNe -- !==
95+ | OpLt -- <
96+ | OpLe -- <=
97+ | OpGt -- >
98+ | OpGe -- >=
99+ | OpAnd -- &&
100+ | OpOr -- ||
101+ | OpBitwiseAnd -- &
102+ | OpBitwiseXor -- ^
103+ | OpBitwiseOr -- |
103− | OpLShift -- <<
104+ | OpLShift -- <<
104− | OpSpRShift -- >>
105+ | OpSpRShift -- >>
105− | OpZfRShift -- >>>
106+ | OpZfRShift -- >>>
106− | OpBAnd -- &
107− | OpBXor -- ^
108− | OpBOr -- |
109− | OpAdd -- +
110
107
111
108
112data PrefixOp
109data PrefixOp
113− = PrefixLNot -- !
110+ = PrefixNot -- !
114− | PrefixBNot -- ~
111+ | PrefixNegate -- -
115− | PrefixPlus -- +
112+ | PrefixComplement -- ~
116− | PrefixMinus -- -
117− | PrefixTypeof -- typeof
118
113
119
114
120
115
@@ -230,10 +225,13 @@ fromStmt indent statement =
230 Return (Just expr) ->
225 Return (Just expr) ->
231 indent <> "return " <> snd (fromExpr indent Whatever expr) <> ";\n"
226 indent <> "return " <> snd (fromExpr indent Whatever expr) <> ";\n"
232
227
233− Var [] ->
228+ Var name expr ->
229+ indent <> "var " <> Name.toBuilder name <> " = " <> snd (fromExpr indent Whatever expr) <> ";\n"
230+
231+ Vars [] ->
234 mempty
232 mempty
235
233
236− Var vars ->
234+ Vars vars ->
237 indent <> "var " <> commaNewlineSep indent (map (varToBuilder indent) vars) <> ";\n"
235 indent <> "var " <> commaNewlineSep indent (map (varToBuilder indent) vars) <> ";\n"
238
236
239 FunctionStmt name args stmts ->
237 FunctionStmt name args stmts ->
@@ -264,14 +262,9 @@ fromClause indent clause =
264-- VAR DECLS
262-- VAR DECLS
265
263
266
264
267−varToBuilder :: Builder -> (Name, Maybe Expr) -> Builder
265+varToBuilder :: Builder -> (Name, Expr) -> Builder
268−varToBuilder indent (name, maybeExpr) =
266+varToBuilder indent (name, expr) =
269− case maybeExpr of
270− Nothing ->
271− Name.toBuilder name
272−
273− Just expr ->
274− Name.toBuilder name <> " = " <> snd (fromExpr indent Whatever expr)
267+ Name.toBuilder name <> " = " <> snd (fromExpr indent Whatever expr)
275
268
276
269
277
270
@@ -505,36 +498,30 @@ makeBracketed indent expr bracketedExpr =
505fromPrefix :: PrefixOp -> Builder
498fromPrefix :: PrefixOp -> Builder
506fromPrefix op =
499fromPrefix op =
507 case op of
500 case op of
508− PrefixLNot -> "!"
501+ PrefixNot -> "!"
509− PrefixBNot -> "~"
502+ PrefixNegate -> "-"
510− PrefixPlus -> "+"
503+ PrefixComplement -> "~"
511− PrefixMinus -> "-"
512− PrefixTypeof -> "typeof "
513
504
514
505
515fromInfix :: InfixOp -> Builder
506fromInfix :: InfixOp -> Builder
516fromInfix op =
507fromInfix op =
517 case op of
508 case op of
518− OpLT -> " < "
509+ OpAdd -> " + "
519− OpLEq -> " <= "
510+ OpSub -> " - "
520− OpGT -> " > "
521− OpGEq -> " >= "
522− OpIn -> " in "
523− OpInstanceof -> " instanceof "
524− OpEq -> " == "
525− OpNEq -> " != "
526− OpStrictEq -> " === "
527− OpStrictNEq -> " !== "
528− OpLAnd -> " && "
529− OpLOr -> " || "
530 OpMul -> " * "
511 OpMul -> " * "
531 OpDiv -> " / "
512 OpDiv -> " / "
532 OpMod -> " % "
513 OpMod -> " % "
533− OpSub -> " - "
514+ OpEq -> " === "
515+ OpNe -> " !== "
516+ OpLt -> " < "
517+ OpLe -> " <= "
518+ OpGt -> " > "
519+ OpGe -> " >= "
520+ OpAnd -> " && "
521+ OpOr -> " || "
522+ OpBitwiseAnd -> " & "
523+ OpBitwiseXor -> " ^ "
524+ OpBitwiseOr -> " | "
534 OpLShift -> " << "
525 OpLShift -> " << "
535 OpSpRShift -> " >> "
526 OpSpRShift -> " >> "
536 OpZfRShift -> " >>> "
527 OpZfRShift -> " >>> "
537− OpBAnd -> " & "
538− OpBXor -> " ^ "
539− OpBOr -> " | "
540− OpAdd -> " + "
compiler/src/Generate/JavaScript/Expression.hs+37−38
@@ -128,8 +128,7 @@ generate mode expression =
128
128
129 Opt.Destruct (Opt.Destructor name path) body ->
129 Opt.Destruct (Opt.Destructor name path) body ->
130 let
130 let
131− pathExpr = generatePath mode path
132− pathDef = JS.Var [ (JsName.fromLocal name, Just pathExpr) ]
131+ pathDef = JS.Var (JsName.fromLocal name) (generatePath mode path)
133 in
132 in
134 JsBlock $ pathDef : codeToStmtList (generate mode body)
133 JsBlock $ pathDef : codeToStmtList (generate mode body)
135
134
@@ -482,17 +481,17 @@ generateBitwiseCall home name args =
482 case args of
481 case args of
483 [arg] ->
482 [arg] ->
484 case name of
483 case name of
485− "complement" -> JS.Prefix JS.PrefixBNot arg
484+ "complement" -> JS.Prefix JS.PrefixComplement arg
486 _ -> generateGlobalCall home name args
485 _ -> generateGlobalCall home name args
487
486
488 [left,right] ->
487 [left,right] ->
489 case name of
488 case name of
490− "and" -> JS.Infix JS.OpBAnd left right
489+ "and" -> JS.Infix JS.OpBitwiseAnd left right
491− "or" -> JS.Infix JS.OpBOr left right
490+ "or" -> JS.Infix JS.OpBitwiseOr left right
492− "xor" -> JS.Infix JS.OpBXor left right
491+ "xor" -> JS.Infix JS.OpBitwiseXor left right
493− "shiftLeftBy" -> JS.Infix JS.OpLShift right left
492+ "shiftLeftBy" -> JS.Infix JS.OpLShift right left
494− "shiftRightBy" -> JS.Infix JS.OpSpRShift right left
493+ "shiftRightBy" -> JS.Infix JS.OpSpRShift right left
495− "shiftRightZfBy" -> JS.Infix JS.OpZfRShift right left
494+ "shiftRightZfBy" -> JS.Infix JS.OpZfRShift right left
496 _ -> generateGlobalCall home name args
495 _ -> generateGlobalCall home name args
497
496
498 _ ->
497 _ ->
@@ -505,10 +504,10 @@ generateBasicsCall mode home name args =
505 [elmArg] ->
504 [elmArg] ->
506 let arg = generateJsExpr mode elmArg in
505 let arg = generateJsExpr mode elmArg in
507 case name of
506 case name of
508− "not" -> JS.Prefix JS.PrefixLNot arg
507+ "not" -> JS.Prefix JS.PrefixNot arg
509− "negate" -> JS.Prefix JS.PrefixMinus arg
508+ "negate" -> JS.Prefix JS.PrefixNegate arg
510 "toFloat" -> arg
509 "toFloat" -> arg
511− "truncate" -> JS.Infix JS.OpBOr arg (JS.Int 0)
510+ "truncate" -> JS.Infix JS.OpBitwiseOr arg (JS.Int 0)
512 _ -> generateGlobalCall home name [arg]
511 _ -> generateGlobalCall home name [arg]
513
512
514 [elmLeft, elmRight] ->
513 [elmLeft, elmRight] ->
@@ -528,16 +527,16 @@ generateBasicsCall mode home name args =
528 "sub" -> JS.Infix JS.OpSub left right
527 "sub" -> JS.Infix JS.OpSub left right
529 "mul" -> JS.Infix JS.OpMul left right
528 "mul" -> JS.Infix JS.OpMul left right
530 "fdiv" -> JS.Infix JS.OpDiv left right
529 "fdiv" -> JS.Infix JS.OpDiv left right
531− "idiv" -> JS.Infix JS.OpBOr (JS.Infix JS.OpDiv left right) (JS.Int 0)
530+ "idiv" -> JS.Infix JS.OpBitwiseOr (JS.Infix JS.OpDiv left right) (JS.Int 0)
532 "eq" -> equal left right
531 "eq" -> equal left right
533 "neq" -> notEqual left right
532 "neq" -> notEqual left right
534− "lt" -> cmp JS.OpLT JS.OpLT 0 left right
533+ "lt" -> cmp JS.OpLt JS.OpLt 0 left right
535− "gt" -> cmp JS.OpGT JS.OpGT 0 left right
534+ "gt" -> cmp JS.OpGt JS.OpGt 0 left right
536− "le" -> cmp JS.OpLEq JS.OpLT 1 left right
535+ "le" -> cmp JS.OpLe JS.OpLt 1 left right
537− "ge" -> cmp JS.OpGEq JS.OpGT (-1) left right
536+ "ge" -> cmp JS.OpGe JS.OpGt (-1) left right
538− "or" -> JS.Infix JS.OpLOr left right
537+ "or" -> JS.Infix JS.OpOr left right
539− "and" -> JS.Infix JS.OpLAnd left right
538+ "and" -> JS.Infix JS.OpAnd left right
540− "xor" -> JS.Infix JS.OpStrictNEq left right
539+ "xor" -> JS.Infix JS.OpNe left right
541 "remainderBy" -> JS.Infix JS.OpMod right left
540 "remainderBy" -> JS.Infix JS.OpMod right left
542 _ -> generateGlobalCall home name [left, right]
541 _ -> generateGlobalCall home name [left, right]
543
542
@@ -558,7 +557,7 @@ notEqual left right =
558 if isLiteral left || isLiteral right then
557 if isLiteral left || isLiteral right then
559 strictNEq left right
558 strictNEq left right
560 else
559 else
561− JS.Prefix JS.PrefixLNot $
560+ JS.Prefix JS.PrefixNot $
562 JS.Call (JS.Ref (JsName.fromKernel Name.utils "eq")) [left, right]
561 JS.Call (JS.Ref (JsName.fromKernel Name.utils "eq")) [left, right]
563
562
564
563
@@ -647,42 +646,42 @@ strictEq :: JS.Expr -> JS.Expr -> JS.Expr
647strictEq left right =
646strictEq left right =
648 case left of
647 case left of
649 JS.Int 0 ->
648 JS.Int 0 ->
650− JS.Prefix JS.PrefixLNot right
649+ JS.Prefix JS.PrefixNot right
651
650
652 JS.Bool bool ->
651 JS.Bool bool ->
653− if bool then right else JS.Prefix JS.PrefixLNot right
652+ if bool then right else JS.Prefix JS.PrefixNot right
654
653
655 _ ->
654 _ ->
656 case right of
655 case right of
657 JS.Int 0 ->
656 JS.Int 0 ->
658− JS.Prefix JS.PrefixLNot left
657+ JS.Prefix JS.PrefixNot left
659
658
660 JS.Bool bool ->
659 JS.Bool bool ->
661− if bool then left else JS.Prefix JS.PrefixLNot left
660+ if bool then left else JS.Prefix JS.PrefixNot left
662
661
663 _ ->
662 _ ->
664− JS.Infix JS.OpStrictEq left right
663+ JS.Infix JS.OpEq left right
665
664
666
665
667strictNEq :: JS.Expr -> JS.Expr -> JS.Expr
666strictNEq :: JS.Expr -> JS.Expr -> JS.Expr
668strictNEq left right =
667strictNEq left right =
669 case left of
668 case left of
670 JS.Int 0 ->
669 JS.Int 0 ->
671− JS.Prefix JS.PrefixLNot (JS.Prefix JS.PrefixLNot right)
670+ JS.Prefix JS.PrefixNot (JS.Prefix JS.PrefixNot right)
672
671
673 JS.Bool bool ->
672 JS.Bool bool ->
674− if bool then JS.Prefix JS.PrefixLNot right else right
673+ if bool then JS.Prefix JS.PrefixNot right else right
675
674
676 _ ->
675 _ ->
677 case right of
676 case right of
678 JS.Int 0 ->
677 JS.Int 0 ->
679− JS.Prefix JS.PrefixLNot (JS.Prefix JS.PrefixLNot left)
678+ JS.Prefix JS.PrefixNot (JS.Prefix JS.PrefixNot left)
680
679
681 JS.Bool bool ->
680 JS.Bool bool ->
682− if bool then JS.Prefix JS.PrefixLNot left else left
681+ if bool then JS.Prefix JS.PrefixNot left else left
683
682
684 _ ->
683 _ ->
685− JS.Infix JS.OpStrictNEq left right
684+ JS.Infix JS.OpNe left right
686
685
687
686
688
687
@@ -695,13 +694,13 @@ generateTailCall :: Mode.Mode -> Name.Name -> [(Name.Name, Opt.Expr)] -> [JS.Stm
695generateTailCall mode name args =
694generateTailCall mode name args =
696 let
695 let
697 toTempVars (argName, arg) =
696 toTempVars (argName, arg) =
698− ( JsName.makeTemp argName, Just (generateJsExpr mode arg) )
697+ ( JsName.makeTemp argName, generateJsExpr mode arg )
699
698
700 toRealVars (argName, _) =
699 toRealVars (argName, _) =
701 JS.ExprStmt $
700 JS.ExprStmt $
702 JS.Assign (JS.LRef (JsName.fromLocal argName)) (JS.Ref (JsName.makeTemp argName))
701 JS.Assign (JS.LRef (JsName.fromLocal argName)) (JS.Ref (JsName.makeTemp argName))
703 in
702 in
704− JS.Var (map toTempVars args)
703+ JS.Vars (map toTempVars args)
705 : map toRealVars args
704 : map toRealVars args
706 ++ [ JS.Continue (Just (JsName.fromLocal name)) ]
705 ++ [ JS.Continue (Just (JsName.fromLocal name)) ]
707
706
@@ -714,10 +713,10 @@ generateDef :: Mode.Mode -> Opt.Def -> JS.Stmt
714generateDef mode def =
713generateDef mode def =
715 case def of
714 case def of
716 Opt.Def name body ->
715 Opt.Def name body ->
717− JS.Var [ (JsName.fromLocal name, Just (generateJsExpr mode body)) ]
716+ JS.Var (JsName.fromLocal name) (generateJsExpr mode body)
718
717
719 Opt.TailDef name argNames body ->
718 Opt.TailDef name argNames body ->
720− JS.Var [ (JsName.fromLocal name, Just (codeToExpr (generateTailDef mode name argNames body))) ]
719+ JS.Var (JsName.fromLocal name) (codeToExpr (generateTailDef mode name argNames body))
721
720
722
721
723generateTailDef :: Mode.Mode -> Name.Name -> [Name.Name] -> Opt.Expr -> Code
722generateTailDef :: Mode.Mode -> Name.Name -> [Name.Name] -> Opt.Expr -> Code
@@ -850,7 +849,7 @@ generateDecider mode label root decisionTree =
850
849
851 Opt.Chain testChain success failure ->
850 Opt.Chain testChain success failure ->
852 [ JS.IfStmt
851 [ JS.IfStmt
853− (List.foldl1' (JS.Infix JS.OpLAnd) (map (generateIfTest mode root) testChain))
852+ (List.foldl1' (JS.Infix JS.OpAnd) (map (generateIfTest mode root) testChain))
854 (JS.Block $ generateDecider mode label root success)
853 (JS.Block $ generateDecider mode label root success)
855 (JS.Block $ generateDecider mode label root failure)
854 (JS.Block $ generateDecider mode label root failure)
856 ]
855 ]
@@ -892,7 +891,7 @@ generateIfTest mode root (path, test) =
892 value
891 value
893
892
894 DT.IsBool False ->
893 DT.IsBool False ->
895− JS.Prefix JS.PrefixLNot value
894+ JS.Prefix JS.PrefixNot value
896
895
897 DT.IsInt int ->
896 DT.IsInt int ->
898 strictEq value (JS.Int int)
897 strictEq value (JS.Int int)
@@ -910,7 +909,7 @@ generateIfTest mode root (path, test) =
910 JS.Access value (JsName.fromLocal "b")
909 JS.Access value (JsName.fromLocal "b")
911
910
912 DT.IsNil ->
911 DT.IsNil ->
913− JS.Prefix JS.PrefixLNot $
912+ JS.Prefix JS.PrefixNot $
914 JS.Access value (JsName.fromLocal "b")
913 JS.Access value (JsName.fromLocal "b")
915
914
916 DT.IsTuple ->
915 DT.IsTuple ->