@@ -128,8 +128,7 @@ generate mode expression =
129 Opt.Destruct (Opt.Destructor name path) body ->
129 Opt.Destruct (Opt.Destructor name path) body ->
131− pathExpr = generatePath mode path
132− pathDef = JS.Var [ (JsName.fromLocal name, Just pathExpr) ]
131+ pathDef = JS.Var (JsName.fromLocal name) (generatePath mode path)
134 JsBlock $ pathDef : codeToStmtList (generate mode body)
133 JsBlock $ pathDef : codeToStmtList (generate mode body)
@@ -482,17 +481,17 @@ generateBitwiseCall home name args =
482 case args of
481 case args of
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
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
@@ -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]
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]
@@ -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
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]
@@ -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
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
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
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
664− JS.Infix JS.OpStrictEq left right
663+ JS.Infix JS.OpEq left right
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)
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
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)
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
685− JS.Infix JS.OpStrictNEq left right
684+ JS.Infix JS.OpNe left right
@@ -695,13 +694,13 @@ generateTailCall :: Mode.Mode -> Name.Name -> [(Name.Name, Opt.Expr)] -> [JS.Stm
695generateTailCall mode name args =
694generateTailCall mode name args =
697 toTempVars (argName, arg) =
696 toTempVars (argName, arg) =
698− ( JsName.makeTemp argName, Just (generateJsExpr mode arg) )
697+ ( JsName.makeTemp argName, generateJsExpr mode arg )
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))
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)) ]
@@ -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)
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))
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 =
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)
@@ -892,7 +891,7 @@ generateIfTest mode root (path, test) =
894 DT.IsBool False ->
893 DT.IsBool False ->
895− JS.Prefix JS.PrefixLNot value
894+ JS.Prefix JS.PrefixNot value
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")
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")
916 DT.IsTuple ->
915 DT.IsTuple ->