aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/ruby
diff options
context:
space:
mode:
authorEduardo Julian2018-05-07 01:37:38 -0400
committerEduardo Julian2018-05-07 01:37:38 -0400
commitfebfa99c2823219c2e76d2c73b1fd8db8f6c9918 (patch)
treef521419a80b04f465c6c9c5020c2063e2e555895 /new-luxc/source/luxc/lang/translation/ruby
parent3e2fddc6bfdda56dbe6947c476f85760b0811654 (diff)
- Implemented Deg functionality in pure Lux.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux56
-rw-r--r--new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux58
2 files changed, 3 insertions, 111 deletions
diff --git a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
index e38dfff28..729acd978 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/procedure/common.jvm.lux
@@ -236,9 +236,6 @@
[frac//smallest Double::MIN_VALUE ruby.float]
[frac//min (f/* -1.0 Double::MAX_VALUE) ruby.float]
[frac//max Double::MAX_VALUE ruby.float]
-
- [deg//min 0 ruby.int]
- [deg//max -1 ruby.int]
)
(do-template [<name> <expression>]
@@ -278,14 +275,6 @@
[int//div ruby./]
[int//rem ruby.%]
-
- [deg//add ruby.+]
- [deg//sub ruby.-]
- [deg//mul runtimeT.deg//*]
- [deg//div runtimeT.deg///]
- [deg//rem ruby.-]
- [deg//scale ruby.*]
- [deg//reciprocal ruby./]
)
(do-template [<name> <op>]
@@ -312,8 +301,7 @@
[int//= ruby.=]
[int//< ruby.<]
- [deg//= ruby.=]
- [deg//< ruby.<])
+ )
(def: frac//encode
Unary
@@ -331,25 +319,6 @@
(ruby.return! (runtimeT.some "temp"))
(ruby.return! runtimeT.none)))))))
-(do-template [<name> <divisor>]
- [(def: (<name> inputO)
- Unary
- (ruby./ <divisor> inputO))]
-
- [int//to-frac (ruby.float 1.0)]
- [deg//to-frac (ruby.send "to_f" (list)
- (ruby.bit-shl (ruby.int 32) (ruby.int 1)))]
- )
-
-(do-template [<name> <transform>]
- [(def: <name>
- Unary
- <transform>)]
-
- [frac//to-int (ruby.send "floor" (list))]
- [frac//to-deg runtimeT.deg//from-frac]
- )
-
(def: int-procs
Bundle
(<| (prefix "int")
@@ -363,26 +332,9 @@
(install "<" (binary int//<))
(install "min" (nullary int//min))
(install "max" (nullary int//max))
- (install "to-frac" (unary int//to-frac))
+ (install "to-frac" (unary (ruby./ (ruby.float 1.0))))
(install "char" (unary (ruby.send "chr" (list)))))))
-(def: deg-procs
- Bundle
- (<| (prefix "deg")
- (|> (dict.new text.Hash<Text>)
- (install "+" (binary deg//add))
- (install "-" (binary deg//sub))
- (install "*" (binary deg//mul))
- (install "/" (binary deg//div))
- (install "%" (binary deg//rem))
- (install "=" (binary deg//=))
- (install "<" (binary deg//<))
- (install "scale" (binary deg//scale))
- (install "reciprocal" (binary deg//reciprocal))
- (install "min" (nullary deg//min))
- (install "max" (nullary deg//max))
- (install "to-frac" (unary deg//to-frac)))))
-
(def: frac-procs
Bundle
(<| (prefix "frac")
@@ -400,8 +352,7 @@
(install "not-a-number" (nullary frac//not-a-number))
(install "positive-infinity" (nullary frac//positive-infinity))
(install "negative-infinity" (nullary frac//negative-infinity))
- (install "to-deg" (unary frac//to-deg))
- (install "to-int" (unary frac//to-int))
+ (install "to-int" (unary (ruby.send "floor" (list))))
(install "encode" (unary frac//encode))
(install "decode" (unary frac//decode)))))
@@ -608,7 +559,6 @@
(|> lux-procs
(dict.merge bit-procs)
(dict.merge int-procs)
- (dict.merge deg-procs)
(dict.merge frac-procs)
(dict.merge text-procs)
(dict.merge array-procs)
diff --git a/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
index 7f66b0cd5..ac8f7b11a 100644
--- a/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/ruby/runtime.jvm.lux
@@ -178,63 +178,6 @@
(format @@bit//count
@@bit//logical-right-shift))
-(def: high (-> Expression Expression) (bit//logical-right-shift (ruby.int 32)))
-(def: low (-> Expression Expression) (ruby.bit-and "0xFFFFFFFF"))
-
-(runtime: (deg//* param subject)
- (ruby.block! (list (ruby.set! (list "sL") (low subject))
- (ruby.set! (list "sH") (high subject))
- (ruby.set! (list "pL") (low param))
- (ruby.set! (list "pH") (high param))
- (ruby.set! (list "bottom") (bit//logical-right-shift (ruby.int 32)
- (ruby.* "pL" "sL")))
- (ruby.set! (list "middle") (ruby.+ (ruby.* "pL" "sH")
- (ruby.* "pH" "sL")))
- (ruby.set! (list "top") (ruby.* "pH" "sH"))
- (ruby.return! (|> "bottom"
- (ruby.+ "middle")
- high
- (ruby.+ "top"))))))
-
-(runtime: (deg//leading-zeroes input)
- (ruby.block! (list (ruby.set! (list "zeroes") (ruby.int 64))
- (ruby.while! (ruby.not (ruby.= (ruby.int 0) input))
- (ruby.block! (list (ruby.set! (list "zeroes") (ruby.- (ruby.int 1) "zeroes"))
- (ruby.set! (list input) (bit//logical-right-shift (ruby.int 1) input)))))
- (ruby.return! "zeroes"))))
-
-(runtime: (deg/// param subject)
- (ruby.if! (ruby.= param subject)
- (ruby.return! (ruby.int -1))
- (ruby.block! (list (ruby.set! (list "min_shift")
- (ruby.send "min" (list)
- (ruby.array (list (deg//leading-zeroes param)
- (deg//leading-zeroes subject)))))
- (ruby.return! (|> (ruby.bit-shl "min_shift" subject)
- (ruby./ (|> param (ruby.bit-shl "min_shift") low))
- (ruby.bit-shl (ruby.int 32))))))))
-
-(runtime: (deg//from-frac input)
- (let [->int (ruby.send "floor" (list))]
- (ruby.block! (list (ruby.set! (list "two32") (ruby.pow (ruby.float 32.0) (ruby.float 2.0)))
- (ruby.set! (list "shifted") (|> input
- (ruby.% (ruby.float 1.0))
- (ruby.* "two32")))
- (ruby.set! (list "low") (|> "shifted"
- (ruby.% (ruby.float 1.0))
- (ruby.* "two32")
- ->int))
- (ruby.set! (list "high") (|> "shifted" ->int))
- (ruby.return! (ruby.+ (ruby.bit-shl (ruby.int 32) "high")
- "low"))))))
-
-(def: runtime//deg
- Runtime
- (format @@deg//*
- @@deg//leading-zeroes
- @@deg///
- @@deg//from-frac))
-
(runtime: (text//index subject param start)
(ruby.block! (list (ruby.set! (list "idx") (ruby.send "index" (list param start) subject))
(ruby.if! (ruby.= ruby.nil "idx")
@@ -332,7 +275,6 @@
(format runtime//lux "\n"
runtime//adt "\n"
runtime//bit "\n"
- runtime//deg "\n"
runtime//text "\n"
runtime//array "\n"
runtime//atom "\n"