on master help sign in
javascript: added JSPreOp and JSPostOp
commita80f29a18d2f81e58155dfa8aedc8530992b7922 authorraichoo <raichoo@googlemail.com> dateMon 3 Feb 2014, 04:36 (13 years ago) parent9f69c8d
1 file changed+8
src/IRTS/CodegenJavaScript.hs+8
src/IRTS/CodegenJavaScript.hs+8
@@ -60,6 +60,8 @@ data JS = JSRaw String
6060 | JSNew String [JS]
6161 | JSError String
6262 | JSBinOp String JS JS
63+ | JSPreOp String JS
64+ | JSPostOp String JS
6365 | JSProj JS String
6466 | JSVar LVar
6567 | JSNull
@@ -279,6 +281,10 @@ foldJS tr add acc js =
279281 add (tr js) $ foldl' add acc $ map fold args
280282 | JSBinOp _ lhs rhs <- js =
281283 add (tr js) $ add (fold lhs) (fold rhs)
284+ | JSPreOp _ val <- js =
285+ add (tr js) $ fold val
286+ | JSPostOp _ val <- js =
287+ add (tr js) $ fold val
282288 | JSProj obj _ <- js =
283289 add (tr js) (fold obj)
284290 | JSArray vals <- js =
@@ -311,6 +317,8 @@ transformJS tr js =
311317 | JSApp lhs rhs <- js = JSApp (tr lhs) $ map tr rhs
312318 | JSNew con args <- js = JSNew con $ map tr args
313319 | JSBinOp op lhs rhs <- js = JSBinOp op (tr lhs) (tr rhs)
320+ | JSPreOp op val <- js = JSPreOp op (tr val)
321+ | JSPostOp op val <- js = JSPostOp op (tr val)
314322 | JSProj obj field <- js = JSProj (tr obj) field
315323 | JSArray vals <- js = JSArray $ map tr vals
316324 | JSAssign lhs rhs <- js = JSAssign (tr lhs) (tr rhs)