@@ -59,7 +59,7 @@ data JS = JSRaw String
59 | JSApp JS [JS]
59 | JSApp JS [JS]
60 | JSNew String [JS]
60 | JSNew String [JS]
61 | JSError String
61 | JSError String
62− | JSOp String JS JS
62+ | JSBinOp String JS JS
63 | JSProj JS String
63 | JSProj JS String
64 | JSVar LVar
64 | JSVar LVar
@@ -122,7 +122,7 @@ compileJS (JSNew name args) =
122compileJS (JSError exc) =
122compileJS (JSError exc) =
123 "throw new Error(\"" ++ exc ++ "\")"
123 "throw new Error(\"" ++ exc ++ "\")"
125−compileJS (JSOp op lhs rhs) =
125+compileJS (JSBinOp op lhs rhs) =
126 compileJS lhs ++ " " ++ op ++ " " ++ compileJS rhs
126 compileJS lhs ++ " " ++ op ++ " " ++ compileJS rhs
128compileJS (JSProj obj field)
128compileJS (JSProj obj field)
@@ -212,15 +212,15 @@ jsMeth obj meth =
214jsInstanceOf :: JS -> JS -> JS
214jsInstanceOf :: JS -> JS -> JS
215−jsInstanceOf = JSOp "instanceof"
215+jsInstanceOf = JSBinOp "instanceof"
218jsEq :: JS -> JS -> JS
218jsEq :: JS -> JS -> JS
219−jsEq = JSOp "=="
219+jsEq = JSBinOp "=="
222jsAnd :: JS -> JS -> JS
222jsAnd :: JS -> JS -> JS
223−jsAnd = JSOp "&&"
223+jsAnd = JSBinOp "&&"
226jsType :: JS
226jsType :: JS
@@ -277,7 +277,7 @@ foldJS tr add acc js =
277 add (tr js) $ add (fold lhs) (foldl' add acc $ map fold rhs)
277 add (tr js) $ add (fold lhs) (foldl' add acc $ map fold rhs)
278 | JSNew _ args <- js =
278 | JSNew _ args <- js =
279 add (tr js) $ foldl' add acc $ map fold args
279 add (tr js) $ foldl' add acc $ map fold args
280− | JSOp _ lhs rhs <- js =
280+ | JSBinOp _ lhs rhs <- js =
281 add (tr js) $ add (fold lhs) (fold rhs)
281 add (tr js) $ add (fold lhs) (fold rhs)
282 | JSProj obj _ <- js =
282 | JSProj obj _ <- js =
283 add (tr js) (fold obj)
283 add (tr js) (fold obj)
@@ -310,7 +310,7 @@ transformJS tr js =
310 | JSReturn ret <- js = JSReturn $ tr ret
310 | JSReturn ret <- js = JSReturn $ tr ret
311 | JSApp lhs rhs <- js = JSApp (tr lhs) $ map tr rhs
311 | JSApp lhs rhs <- js = JSApp (tr lhs) $ map tr rhs
312 | JSNew con args <- js = JSNew con $ map tr args
312 | JSNew con args <- js = JSNew con $ map tr args
313− | JSOp op lhs rhs <- js = JSOp op (tr lhs) (tr rhs)
313+ | JSBinOp op lhs rhs <- js = JSBinOp op (tr lhs) (tr rhs)
314 | JSProj obj field <- js = JSProj (tr obj) field
314 | JSProj obj field <- js = JSProj (tr obj) field
315 | JSArray vals <- js = JSArray $ map tr vals
315 | JSArray vals <- js = JSArray $ map tr vals
316 | JSAssign lhs rhs <- js = JSAssign (tr lhs) (tr rhs)
316 | JSAssign lhs rhs <- js = JSAssign (tr lhs) (tr rhs)
@@ -465,9 +465,9 @@ inlineJS (JSApp (JSFunction [arg] (JSReturn ret)) [val])
466 ) (inlineJS $ jsSubst (JSIdent arg) opt idx)
466 ) (inlineJS $ jsSubst (JSIdent arg) opt idx)
468− | JSOp op lhs rhs <- ret
468+ | JSBinOp op lhs rhs <- ret
469 , opt <- inlineJS val =
469 , opt <- inlineJS val =
470− inlineJS $ JSOp op (inlineJS $ jsSubst (JSIdent arg) opt lhs) $
470+ inlineJS $ JSBinOp op (inlineJS $ jsSubst (JSIdent arg) opt lhs) $
471 (inlineJS $ jsSubst (JSIdent arg) opt rhs)
471 (inlineJS $ jsSubst (JSIdent arg) opt rhs)
473 | JSApp (JSIdent fun) args <- ret
473 | JSApp (JSIdent fun) args <- ret
@@ -706,9 +706,9 @@ reduceConstant
706 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
706 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
707 JSReturn (JSApp (JSIdent "__IDR__mEVAL0") [val])
707 JSReturn (JSApp (JSIdent "__IDR__mEVAL0") [val])
709− | JSNum num <- val = val
709+ | JSNum num <- val = val
710− | JSOp op lhs rhs <- val =
710+ | JSBinOp op lhs rhs <- val =
711− JSParens $ JSOp op (reduceConstant lhs) (reduceConstant rhs)
711+ JSParens $ JSBinOp op (reduceConstant lhs) (reduceConstant rhs)
713 | JSApp (JSProj lhs op) [rhs] <- val
713 | JSApp (JSProj lhs op) [rhs] <- val
714 , op `elem` [ "subtract"
714 , op `elem` [ "subtract"
@@ -770,7 +770,7 @@ removeInstanceChecks (JSCond conds) =
772 removeHelper (
772 removeHelper (
773− JSOp "&&" (JSOp "instanceof" _ (JSIdent "__IDRRT__Con")) check
773+ JSBinOp "&&" (JSBinOp "instanceof" _ (JSIdent "__IDRRT__Con")) check
774 ) = removeHelper check
774 ) = removeHelper check
775 removeHelper js = js
775 removeHelper js = js
@@ -1337,7 +1337,7 @@ translateExpression (SOp op vars)
1339 translateBinaryOp :: String -> LVar -> LVar -> JS
1339 translateBinaryOp :: String -> LVar -> LVar -> JS
1340− translateBinaryOp f lhs rhs = JSOp f (JSVar lhs) (JSVar rhs)
1340+ translateBinaryOp f lhs rhs = JSBinOp f (JSVar lhs) (JSVar rhs)
1343 invokeMeth :: LVar -> String -> [LVar] -> JS
1343 invokeMeth :: LVar -> String -> [LVar] -> JS