aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2017-03-05 14:54:20 -0400
committerEduardo Julian2017-03-05 14:54:20 -0400
commit2bd7d936e0ca47e445c7d946aa1ae8287a62f049 (patch)
tree646b39ab0104e705217ab0919d3b7492004fedc9
parent27648dd619f1764ba58ca244e9fd0b017665058d (diff)
- Added temporary implementations for Nat division and remainder.
- Fixed a bug in the RT function for counting bits.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/compiler/js/rt.clj41
1 files changed, 40 insertions, 1 deletions
diff --git a/luxc/src/lux/compiler/js/rt.clj b/luxc/src/lux/compiler/js/rt.clj
index b1c1aeb1b..0c34453f7 100644
--- a/luxc/src/lux/compiler/js/rt.clj
+++ b/luxc/src/lux/compiler/js/rt.clj
@@ -965,6 +965,45 @@
"return '+'.concat(LuxRT.encodeI64(input));"
"}")
"})")
+ "divN64" (str "(function divN64(l,r) {"
+ (str "if(LuxRT.ltI64(r,LuxRT.ZERO)) {"
+ (str "if(LuxRT.ltN64(l,r)) {"
+ "return LuxRT.ZERO;"
+ "}"
+ "else {"
+ "return LuxRT.ONE;"
+ "}")
+ "}"
+ "else if(LuxRT.ltI64(LuxRT.ZERO,l)) {"
+ "return LuxRT.divI64(l,r);"
+ "}"
+ "else {"
+ (str "if(LuxRT.eqI64(LuxRT.ZERO,r)) {"
+ "throw new Error('Cannot divide by zero!');"
+ "}"
+ "else {"
+ (str "if(LuxRT.ltI64(l,r)) {"
+ "return LuxRT.ZERO;"
+ "}"
+ "else {"
+ "throw new Error('AWAITING BIG-INT DIVISION IMPLEMENTATION!!!');"
+ "}")
+ "}")
+ "}")
+ "})")
+ "remN64" (str "(function remN64(l,r) {"
+ (str "if(LuxRT.ltI64(l,LuxRT.ZERO) || LuxRT.ltI64(r,LuxRT.ZERO)) {"
+ (str "if(LuxRT.ltN64(l,r)) {"
+ "return l;"
+ "}"
+ "else {"
+ "throw new Error('AWAITING BIG-INT REMAINDER IMPLEMENTATION!!!');"
+ "}")
+ "}"
+ "else {"
+ "return LuxRT.remI64(l,r);"
+ "}")
+ "})")
"ltN64" (str "(function ltN64(l,r) {"
"var li = LuxRT.addI64(l,LuxRT.MIN_VALUE_I64);"
"var ri = LuxRT.addI64(r,LuxRT.MIN_VALUE_I64);"
@@ -1123,7 +1162,7 @@
"countI64" (str "(function countI64(input) {"
"var hs = (input.H).toString(2);"
"var ls = (input.L).toString(2);"
- "var num1s = hs.concat(ls).replace('0','').length;"
+ "var num1s = hs.concat(ls).replace(/0/g,'').length;"
"return LuxRT.fromNumberI64(num1s);"
"})")
"shlI64" (str "(function shlI64(input,shift) {"