aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
authorEduardo Julian2017-04-03 18:18:34 -0400
committerEduardo Julian2017-04-03 18:18:34 -0400
commit82c955d5777ecb87b53bafcc658683d5a76e9a3c (patch)
tree5e9c638d7c9e3e04c0db94012184f606f7f71573 /luxc/src
parent65b39c7d66244d275ad75c734bc42b0588379bfb (diff)
- Implemented Int encoding/decoding in the standard library.
- Moved some type-constructors for building functor types into the lux/control/functor module. - Renamed Ord to Order. - Renamed Env to Reader.
Diffstat (limited to 'luxc/src')
-rw-r--r--luxc/src/lux/analyser/proc/common.clj3
-rw-r--r--luxc/src/lux/compiler/js/proc/common.clj5
-rw-r--r--luxc/src/lux/compiler/js/rt.clj65
-rw-r--r--luxc/src/lux/compiler/jvm/proc/common.clj3
4 files changed, 0 insertions, 76 deletions
diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj
index 2bd6ba648..842efc9c5 100644
--- a/luxc/src/lux/analyser/proc/common.clj
+++ b/luxc/src/lux/analyser/proc/common.clj
@@ -254,7 +254,6 @@
(return (&/|list (&&/|meta exo-type _cursor
(&&/$proc (&/T <decode-op>) (&/|list =x) (&/|list)))))))))
- ^:private analyse-int-encode ["int" "encode"] ^:private analyse-int-decode ["int" "decode"] &type/Int
^:private analyse-deg-encode ["deg" "encode"] ^:private analyse-deg-decode ["deg" "decode"] &type/Deg
^:private analyse-real-encode ["real" "encode"] ^:private analyse-real-decode ["real" "decode"] &type/Real
)
@@ -558,8 +557,6 @@
"%" (analyse-int-rem analyse exo-type ?values)
"=" (analyse-int-eq analyse exo-type ?values)
"<" (analyse-int-lt analyse exo-type ?values)
- "encode" (analyse-int-encode analyse exo-type ?values)
- "decode" (analyse-int-decode analyse exo-type ?values)
"min-value" (analyse-int-min-value analyse exo-type ?values)
"max-value" (analyse-int-max-value analyse exo-type ?values)
"to-nat" (analyse-int-to-nat analyse exo-type ?values)
diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj
index 130dbb298..4fdff5f21 100644
--- a/luxc/src/lux/compiler/js/proc/common.clj
+++ b/luxc/src/lux/compiler/js/proc/common.clj
@@ -148,10 +148,7 @@
(return (str "LuxRT$" <method> "(" =x ")"))
))
- ^:private compile-int-encode "encodeI64"
^:private compile-deg-encode "encodeD64"
-
- ^:private compile-int-decode "decodeI64"
^:private compile-deg-decode "decodeD64"
^:private compile-real-decode "decodeReal"
@@ -514,8 +511,6 @@
"%" (compile-int-rem compile ?values special-args)
"=" (compile-int-eq compile ?values special-args)
"<" (compile-int-lt compile ?values special-args)
- "encode" (compile-int-encode compile ?values special-args)
- "decode" (compile-int-decode compile ?values special-args)
"max-value" (compile-int-max-value compile ?values special-args)
"min-value" (compile-int-min-value compile ?values special-args)
"to-nat" (compile-int-to-nat compile ?values special-args)
diff --git a/luxc/src/lux/compiler/js/rt.clj b/luxc/src/lux/compiler/js/rt.clj
index 085cf5fe4..f17998871 100644
--- a/luxc/src/lux/compiler/js/rt.clj
+++ b/luxc/src/lux/compiler/js/rt.clj
@@ -283,71 +283,6 @@
"if(!ln && rn) { return false; }"
"return (LuxRT$subI64(l,r).H < 0);"
"})")
- "encodeI64" (str "(function LuxRT$encodeI64(input) {"
- ;; If input = 0
- (str "if((input.H === 0) && (input.L === 0)) {"
- "return '0';"
- "}")
- ;; If input < 0
- (str "if(input.H < 0) {"
- (str "if(LuxRT$eqI64(input,LuxRT$MIN_VALUE_I64)) {"
- "var radix = LuxRT$makeI64(0,10);"
- "var div = LuxRT$divI64(input,radix);"
- "var rem = LuxRT$subI64(LuxRT$mulI64(div,radix),input);"
- "return LuxRT$encodeI64(div).concat(rem.L+'');"
- "}")
- (str "else {"
- "return '-'.concat(LuxRT$encodeI64(LuxRT$negateI64(input)));"
- "}")
- "}")
- ;; If input > 0
- (str "var chunker = LuxRT$makeI64(0,1000000);"
- "var rem = input;"
- "var result = '';"
- "while(true) {"
- (str "var remDiv = LuxRT$divI64(rem,chunker);"
- "var chunk = LuxRT$subI64(rem,LuxRT$mulI64(remDiv,chunker));"
- "var digits = (chunk.L >>> 0)+'';"
- "rem = remDiv;"
- (str "if((rem.H === 0) && (rem.L === 0)) {"
- "return digits.concat(result);"
- "}"
- "else {"
- (str "while(digits.length < 6) {"
- "digits = '0' + digits;"
- "}")
- "result = '' + digits + result;"
- "}"))
- "}")
- "})")
- "decodeI64" (str "(function LuxRT$decodeI64(input) {"
- "input = LuxRT$clean_separators(input);"
- (str "if(/^-?\\d+$/.exec(input)) {"
- (str "var isNegative = (input.charAt(0) == '-');"
- "var sign = isNegative ? -1 : 1;"
- "input = isNegative ? input.substring(1) : input;"
-
- "var chunkPower = LuxRT$fromNumberI64(Math.pow(10, 8));"
- "var result = LuxRT$ZERO;"
- (str "for (var i = 0; i < input.length; i += 8) {"
- "var size = Math.min(8, input.length - i);"
- "var value = parseInt(input.substring(i, i + size), 10);"
- (str "if (size < 8) {"
- "var power = LuxRT$fromNumberI64(Math.pow(10, size));"
- "result = LuxRT$addI64(LuxRT$mulI64(result,power),LuxRT$fromNumberI64(value));"
- "}"
- "else {"
- "result = LuxRT$addI64(LuxRT$mulI64(result,chunkPower),LuxRT$fromNumberI64(value));"
- "}")
- "}")
- "result = LuxRT$mulI64(result,LuxRT$fromNumberI64(sign));"
- (str "return " (make-some "result") ";")
- )
- "}"
- "else {"
- (str "return " const-none ";")
- "}")
- "})")
})
(def ^:private n64-methods
diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj
index 5e1fe8a1a..311cbed87 100644
--- a/luxc/src/lux/compiler/jvm/proc/common.clj
+++ b/luxc/src/lux/compiler/jvm/proc/common.clj
@@ -421,7 +421,6 @@
(.visitMethodInsn Opcodes/INVOKESTATIC <class> "toString" <signature>))]]
(return nil)))
- ^:private compile-int-encode "java/lang/Long" "(J)Ljava/lang/String;" &&/unwrap-long
^:private compile-real-encode "java/lang/Double" "(D)Ljava/lang/String;" &&/unwrap-double
)
@@ -982,8 +981,6 @@
"min-value" (compile-int-min-value compile ?values special-args)
"to-nat" (compile-int-to-nat compile ?values special-args)
"to-real" (compile-int-to-real compile ?values special-args)
- "encode" (compile-int-encode compile ?values special-args)
- "decode" (compile-int-decode compile ?values special-args)
)
"real"