@@ -56,6 +56,8 @@ data JSNum = JSInt Int
57data JSWord = JSWord8 Word8
57data JSWord = JSWord8 Word8
58 | JSWord16 Word16
58 | JSWord16 Word16
59 deriving Eq
61 deriving Eq
@@ -267,6 +269,9 @@ compileJS (JSWhile cond body) =
267compileJS (JSWord word)
269compileJS (JSWord word)
268 | JSWord8 b <- word = show b
270 | JSWord8 b <- word = show b
269 | JSWord16 b <- word = show b
271 | JSWord16 b <- word = show b
272+ | JSWord32 b <- word = show b
273+ | JSWord64 b <- word = idrRTNamespace ++ "bigInt(\"" ++ show b ++ "\")"
271jsTailcall :: JS -> JS
276jsTailcall :: JS -> JS
272jsTailcall call =
277jsTailcall call =
@@ -1452,6 +1457,7 @@ codegenJS_all target definitions includes filename outputType = do
1453 match :: JS -> Bool
1458 match :: JS -> Bool
1454 match (JSIdent "__IDRRT__bigInt") = True
1459 match (JSIdent "__IDRRT__bigInt") = True
1460+ match (JSWord (JSWord64 _)) = True
1455 match (JSNum (JSInteger _)) = True
1461 match (JSNum (JSInteger _)) = True
1456 match js = False
1462 match js = False
@@ -1646,6 +1652,8 @@ translateConstant Forgot = JSType JSForgotTy
1646translateConstant (BI i) = jsBigInt $ JSString (show i)
1652translateConstant (BI i) = jsBigInt $ JSString (show i)
1647translateConstant (B8 b) = JSWord (JSWord8 b)
1653translateConstant (B8 b) = JSWord (JSWord8 b)
1648translateConstant (B16 b) = JSWord (JSWord16 b)
1654translateConstant (B16 b) = JSWord (JSWord16 b)
1655+translateConstant (B32 b) = JSWord (JSWord32 b)
1656+translateConstant (B64 b) = JSWord (JSWord64 b)
1649translateConstant c =
1657translateConstant c =
1650 jsError $ "Unimplemented Constant: " ++ show c
1658 jsError $ "Unimplemented Constant: " ++ show c
@@ -1827,6 +1835,16 @@ translateExpression (SOp op vars)
1827 | (LLSHR (ITFixed IT8)) <- op
1835 | (LLSHR (ITFixed IT8)) <- op
1828 , (lhs:rhs:_) <- vars = translateBinaryOp ">>" lhs rhs
1836 , (lhs:rhs:_) <- vars = translateBinaryOp ">>" lhs rhs
1838+ | (LLSHR (ITFixed IT16)) <- op
1839+ , (lhs:rhs:_) <- vars = translateBinaryOp ">>" lhs rhs
1841+ | (LLSHR (ITFixed IT32)) <- op
1842+ , (lhs:rhs:_) <- vars = translateBinaryOp ">>" lhs rhs
1844+ | (LLSHR (ITFixed IT64)) <- op
1845+ , (lhs:rhs:_) <- vars =
1846+ jsMeth (jsMeth (JSVar lhs) "shiftRight" [JSVar rhs]) "intValue" []
1830 | (LZExt _ ITBig) <- op = jsBigInt $ jsCall "String" [JSVar (last vars)]
1848 | (LZExt _ ITBig) <- op = jsBigInt $ jsCall "String" [JSVar (last vars)]
1831 | (LPlus (ATInt ITBig)) <- op
1849 | (LPlus (ATInt ITBig)) <- op
1832 , (lhs:rhs:_) <- vars = invokeMeth lhs "add" [rhs]
1850 , (lhs:rhs:_) <- vars = invokeMeth lhs "add" [rhs]
@@ -1878,6 +1896,18 @@ translateExpression (SOp op vars)
1899+ | (LTrunc (ITFixed IT16) (ITFixed IT8)) <- op
1900+ , (arg:_) <- vars =
1901+ JSBinOp "&" (JSVar arg) (JSNum (JSInt 0xFF))
1903+ | (LTrunc (ITFixed IT32) (ITFixed IT16)) <- op
1904+ , (arg:_) <- vars =
1905+ JSBinOp "&" (JSVar arg) (JSNum (JSInt 0xFFFF))
1907+ | (LTrunc (ITFixed IT64) (ITFixed IT32)) <- op
1908+ , (arg:_) <- vars =
1909+ jsMeth (JSVar arg) "and" [jsBigInt (JSString $ show 0xFFFFFFFF)]
1881 | (LPlus _) <- op
1911 | (LPlus _) <- op
1882 , (lhs:rhs:_) <- vars = translateBinaryOp "+" lhs rhs
1912 , (lhs:rhs:_) <- vars = translateBinaryOp "+" lhs rhs
1883 | (LMinus _) <- op
1913 | (LMinus _) <- op