From fb72b937aba7886ce204379e97aa06c327a4029f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 6 May 2018 23:27:12 -0400 Subject: - Implemented Nat functionality in pure Lux. --- .../lang/translation/jvm/procedure/common.jvm.lux | 44 +++------------------- 1 file changed, 5 insertions(+), 39 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux index 3a5cc9b70..05a38eb2f 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux @@ -267,18 +267,11 @@ (def: deg-method $.Method nat-method) -(def: compare-nat-method - $.Method - ($t.method (list $t.long $t.long) (#.Some $t.int) (list))) - (do-template [ ] [(def: ( _) Nullary (|>> ($i.wrap )))] - [nat//min ($i.long 0) #$.Long] - [nat//max ($i.long -1) #$.Long] - [int//min ($i.long Long::MIN_VALUE) #$.Long] [int//max ($i.long Long::MAX_VALUE) #$.Long] @@ -307,12 +300,6 @@ [int//div #$.Long $i.LDIV] [int//rem #$.Long $i.LREM] - [nat//add #$.Long $i.LADD] - [nat//sub #$.Long $i.LSUB] - [nat//mul #$.Long $i.LMUL] - [nat//div #$.Long ($i.INVOKESTATIC hostL.runtime-class "div_nat" nat-method false)] - [nat//rem #$.Long ($i.INVOKESTATIC hostL.runtime-class "rem_nat" nat-method false)] - [frac//add #$.Double $i.DADD] [frac//sub #$.Double $i.DSUB] [frac//mul #$.Double $i.DMUL] @@ -340,10 +327,9 @@ [ 0] [ -1])] - [nat//eq nat//lt ($i.unwrap #$.Long) ($i.INVOKESTATIC hostL.runtime-class "compare_nat" compare-nat-method false)] [int//eq int//lt ($i.unwrap #$.Long) $i.LCMP] [frac//eq frac//lt ($i.unwrap #$.Double) $i.DCMPG] - [deg//eq deg//lt ($i.unwrap #$.Long) ($i.INVOKESTATIC hostL.runtime-class "compare_nat" compare-nat-method false)] + [deg//eq deg//lt ($i.unwrap #$.Long) $i.LCMP] ) (do-template [ ] @@ -351,12 +337,9 @@ Unary (|>> inputI ))] - [nat//to-int id id] - [nat//char ($i.unwrap #$.Long) - ((|>> $i.L2I $i.I2C ($i.INVOKESTATIC "java.lang.Character" "toString" ($t.method (list $t.char) (#.Some $String) (list)) false)))] - - [int//to-nat id id] [int//to-frac ($i.unwrap #$.Long) (<| ($i.wrap #$.Double) $i.L2D)] + [int//char ($i.unwrap #$.Long) + ((|>> $i.L2I $i.I2C ($i.INVOKESTATIC "java.lang.Character" "toString" ($t.method (list $t.char) (#.Some $String) (list)) false)))] [frac//to-int ($i.unwrap #$.Double) (<| ($i.wrap #$.Long) $i.D2L)] [frac//to-deg ($i.unwrap #$.Double) @@ -623,22 +606,6 @@ (install "arithmetic-right-shift" (binary bit//arithmetic-right-shift)) ))) -(def: nat-procs - Bundle - (<| (prefix "nat") - (|> (dict.new text.Hash) - (install "+" (binary nat//add)) - (install "-" (binary nat//sub)) - (install "*" (binary nat//mul)) - (install "/" (binary nat//div)) - (install "%" (binary nat//rem)) - (install "=" (binary nat//eq)) - (install "<" (binary nat//lt)) - (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") @@ -652,8 +619,8 @@ (install "<" (binary int//lt)) (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 @@ -782,7 +749,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) -- cgit v1.2.3