@@ -59,7 +59,7 @@ data JS = JSRaw String
5959 | JSApp JS [JS]
6060 | JSNew String [JS]
6161 | JSError String
62− | JSOp String JS JS
62+ | JSBinOp String JS JS
6363 | JSProj JS String
6464 | JSVar LVar
6565 | JSNull
@@ -122,7 +122,7 @@ compileJS (JSNew name args) =
122122compileJS (JSError exc) =
123123 "throw new Error(\"" ++ exc ++ "\")"
124124
125−compileJS (JSOp op lhs rhs) =
125+compileJS (JSBinOp op lhs rhs) =
126126 compileJS lhs ++ " " ++ op ++ " " ++ compileJS rhs
127127
128128compileJS (JSProj obj field)
@@ -212,15 +212,15 @@ jsMeth obj meth =
212212
213213
214214jsInstanceOf :: JS -> JS -> JS
215−jsInstanceOf = JSOp "instanceof"
215+jsInstanceOf = JSBinOp "instanceof"
216216
217217
218218jsEq :: JS -> JS -> JS
219−jsEq = JSOp "=="
219+jsEq = JSBinOp "=="
220220
221221
222222jsAnd :: JS -> JS -> JS
223−jsAnd = JSOp "&&"
223+jsAnd = JSBinOp "&&"
224224
225225
226226jsType :: JS
@@ -277,7 +277,7 @@ foldJS tr add acc js =
277277 add (tr js) $ add (fold lhs) (foldl' add acc $ map fold rhs)
278278 | JSNew _ args <- js =
279279 add (tr js) $ foldl' add acc $ map fold args
280− | JSOp _ lhs rhs <- js =
280+ | JSBinOp _ lhs rhs <- js =
281281 add (tr js) $ add (fold lhs) (fold rhs)
282282 | JSProj obj _ <- js =
283283 add (tr js) (fold obj)
@@ -310,7 +310,7 @@ transformJS tr js =
310310 | JSReturn ret <- js = JSReturn $ tr ret
311311 | JSApp lhs rhs <- js = JSApp (tr lhs) $ map tr rhs
312312 | 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)
314314 | JSProj obj field <- js = JSProj (tr obj) field
315315 | JSArray vals <- js = JSArray $ map tr vals
316316 | JSAssign lhs rhs <- js = JSAssign (tr lhs) (tr rhs)
@@ -465,9 +465,9 @@ inlineJS (JSApp (JSFunction [arg] (JSReturn ret)) [val])
465465 ) field
466466 ) (inlineJS $ jsSubst (JSIdent arg) opt idx)
467467
468− | JSOp op lhs rhs <- ret
468+ | JSBinOp op lhs rhs <- ret
469469 , opt <- inlineJS val =
470− inlineJS $ JSOp op (inlineJS $ jsSubst (JSIdent arg) opt lhs) $
470+ inlineJS $ JSBinOp op (inlineJS $ jsSubst (JSIdent arg) opt lhs) $
471471 (inlineJS $ jsSubst (JSIdent arg) opt rhs)
472472
473473 | JSApp (JSIdent fun) args <- ret
@@ -706,9 +706,9 @@ reduceConstant
706706 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
707707 JSReturn (JSApp (JSIdent "__IDR__mEVAL0") [val])
708708 )])
709− | JSNum num <- val = val
710− | JSOp op lhs rhs <- val =
711− JSParens $ JSOp op (reduceConstant lhs) (reduceConstant rhs)
709+ | JSNum num <- val = val
710+ | JSBinOp op lhs rhs <- val =
711+ JSParens $ JSBinOp op (reduceConstant lhs) (reduceConstant rhs)
712712
713713 | JSApp (JSProj lhs op) [rhs] <- val
714714 , op `elem` [ "subtract"
@@ -770,7 +770,7 @@ removeInstanceChecks (JSCond conds) =
770770 ) conds
771771 where
772772 removeHelper (
773− JSOp "&&" (JSOp "instanceof" _ (JSIdent "__IDRRT__Con")) check
773+ JSBinOp "&&" (JSBinOp "instanceof" _ (JSIdent "__IDRRT__Con")) check
774774 ) = removeHelper check
775775 removeHelper js = js
776776
@@ -1337,7 +1337,7 @@ translateExpression (SOp op vars)
13371337
13381338 where
13391339 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)
13411341
13421342
13431343 invokeMeth :: LVar -> String -> [LVar] -> JS