aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/js')
-rw-r--r--new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux45
-rw-r--r--new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux94
2 files changed, 4 insertions, 135 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
index 14e37efb8..f9e00be2a 100644
--- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux
@@ -210,9 +210,6 @@
Nullary
(<encode> <const>))]
- [nat//min 0 runtimeT.int]
- [nat//max -1 runtimeT.int]
-
[int//min Long::MIN_VALUE runtimeT.int]
[int//max Long::MAX_VALUE runtimeT.int]
@@ -238,12 +235,6 @@
[int//div runtimeT.int///]
[int//rem runtimeT.int//%]
- [nat//add runtimeT.int//+]
- [nat//sub runtimeT.int//-]
- [nat//mul runtimeT.int//*]
- [nat//div runtimeT.nat///]
- [nat//rem runtimeT.nat//%]
-
[deg//add runtimeT.int//+]
[deg//sub runtimeT.int//-]
[deg//mul runtimeT.deg//*]
@@ -275,21 +266,10 @@
Binary
(format <cmp> "(" subjectJS "," paramJS ")"))]
- [nat//= runtimeT.int//=]
- [nat//< runtimeT.nat//<]
[int//= runtimeT.int//=]
[int//< runtimeT.int//<]
[deg//= runtimeT.int//=]
- [deg//< runtimeT.nat//<]
- )
-
-(do-template [<name>]
- [(def: (<name> inputJS)
- Unary
- inputJS)]
-
- [nat//to-int]
- [int//to-nat]
+ [deg//< runtimeT.int//<]
)
(def: (frac//encode inputJS)
@@ -314,7 +294,7 @@
[text//hash runtimeT.text//hash]
)
-(def: (nat//char inputJS)
+(def: (int//char inputJS)
Unary
(format "String.fromCharCode" "(" (int//to-frac inputJS) ")"))
@@ -479,22 +459,6 @@
(install "arithmetic-right-shift" (binary bit//arithmetic-right-shift))
)))
-(def: nat-procs
- Bundle
- (<| (prefix "nat")
- (|> (dict.new text.Hash<Text>)
- (install "+" (binary nat//add))
- (install "-" (binary nat//sub))
- (install "*" (binary nat//mul))
- (install "/" (binary nat//div))
- (install "%" (binary nat//rem))
- (install "=" (binary nat//=))
- (install "<" (binary nat//<))
- (install "min" (nullary nat//min))
- (install "max" (nullary nat//max))
- (install "to-int" (unary nat//to-int))
- (install "char" (unary nat//char)))))
-
(def: int-procs
Bundle
(<| (prefix "int")
@@ -508,8 +472,8 @@
(install "<" (binary int//<))
(install "min" (nullary int//min))
(install "max" (nullary int//max))
- (install "to-nat" (unary int//to-nat))
- (install "to-frac" (unary int//to-frac)))))
+ (install "to-frac" (unary int//to-frac))
+ (install "char" (unary int//char)))))
(def: deg-procs
Bundle
@@ -638,7 +602,6 @@
(<| (prefix "lux")
(|> lux-procs
(dict.merge bit-procs)
- (dict.merge nat-procs)
(dict.merge int-procs)
(dict.merge deg-procs)
(dict.merge frac-procs)
diff --git a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux
index afb3cd538..5fab92941 100644
--- a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux
@@ -584,99 +584,6 @@
__int///
__int//%))
-(runtime: nat//< "ltN64"
- (let [high (function (_ i64) (format "(" i64 "." //.int-high-field ")"))
- low (function (_ i64) (format "(" i64 "." //.int-low-field ")"))
- i32 (function (_ word) (format "(" word " >>> 0)"))]
- (js.function @ (list "subject" "parameter")
- (list (js.return! (js.or (js.> (i32 (high "subject"))
- (i32 (high "parameter")))
- (js.and (js.= (high "subject")
- (high "parameter"))
- (js.> (i32 (low "subject"))
- (i32 (low "parameter"))))))))))
-
-(def: (<N param subject)
- (-> Expression Expression Expression)
- (js.apply nat//< (list subject param)))
-
-(def: (<=N param subject)
- (-> Expression Expression Expression)
- (js.or (js.apply nat//< (list subject param))
- (js.apply int//= (list subject param))))
-
-(def: (>N param subject)
- (-> Expression Expression Expression)
- (js.apply nat//< (list param subject)))
-
-(def: (>=N param subject)
- (-> Expression Expression Expression)
- (js.or (js.apply nat//< (list param subject))
- (js.apply int//= (list subject param))))
-
-(runtime: nat/// "divN64"
- (let [negative? (function (_ value)
- (js.apply int//< (list value int//zero)))
- valid-division-check [(=I int//zero "parameter")
- (js.throw! (js.string "Cannot divide by zero!"))]
- short-circuit-check [(=I int//zero "subject")
- (js.return! int//zero)]]
- (js.function @ (list "subject" "parameter")
- (list (js.cond! (list valid-division-check
- short-circuit-check
-
- [(>N "subject" "parameter")
- (js.return! int//zero)]
-
- [(>N (js.apply bit//logical-right-shift
- (list "subject" (js.number 1.0)))
- "parameter")
- (js.return! int//one)])
- (js.block! (list (js.var! "result" (#.Some int//zero))
- (js.var! "remainder" (#.Some "subject"))
- (js.while! (>=N "parameter" "remainder")
- (let [rough-estimate (js.apply "Math.floor" (list (js./ (js.apply int//to-number (list "parameter"))
- (js.apply int//to-number (list "remainder")))))
- log2 (js./ "Math.LN2"
- (js.apply "Math.log" (list "approximate")))
- approx-result (js.apply int//from-number (list "approximate"))
- approx-remainder (js.apply int//* (list "approximate_result" "parameter"))]
- (list (js.var! "approximate" (#.Some (js.apply "Math.max" (list (js.number 1.0)
- rough-estimate))))
- (js.var! "log2" (#.Some (js.apply "Math.ceil" (list log2))))
- (js.var! "delta" (#.Some (js.? (js.<= (js.number 48.0) "log2")
- (js.number 1.0)
- (js.apply "Math.pow" (list (js.number 2.0)
- (js.- (js.number 48.0)
- "log2"))))))
- (js.var! "approximate_result" (#.Some approx-result))
- (js.var! "approximate_remainder" (#.Some approx-remainder))
- (js.while! (js.or (negative? "approximate_remainder")
- (>N "remainder"
- "approximate_remainder"))
- (list (js.set! "approximate" (js.- "delta" "approximate"))
- (js.set! "approximate_result" approx-result)
- (js.set! "approximate_remainder" approx-remainder)))
- (js.block! (list (js.set! "result" (js.apply int//+ (list "result"
- (js.? (=I int//zero "approximate_result")
- int//one
- "approximate_result"))))
- (js.set! "remainder" (js.apply int//- (list "remainder" "approximate_remainder"))))))))
- (js.return! "result")))
- )))))
-
-(runtime: nat//% "remN64"
- (js.function @ (list "subject" "parameter")
- (list (let [flat (js.apply int//* (list (js.apply nat/// (list "subject" "parameter"))
- "parameter"))]
- (js.return! (js.apply int//- (list "subject" flat)))))))
-
-(def: runtime//nat
- Runtime
- (format __nat//<
- __nat///
- __nat//%))
-
(runtime: deg//* "mulD64"
(format "(function " @ "(l,r) {"
"var lL = " int//from-number "(l.L);"
@@ -900,7 +807,6 @@
runtime//adt
runtime//bit
runtime//int
- runtime//nat
runtime//deg
runtime//text
runtime//array