From 1797521191746640e761cc1b4973d46b8c403dee Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 28 Jan 2021 20:14:11 -0400 Subject: Implemented arithmetic right-shift in terms of logic right-shift. --- lux-bootstrapper/src/lux/analyser/proc/common.clj | 60 +++++++++++----------- .../src/lux/compiler/jvm/proc/common.clj | 32 ++++++------ 2 files changed, 44 insertions(+), 48 deletions(-) (limited to 'lux-bootstrapper/src') diff --git a/lux-bootstrapper/src/lux/analyser/proc/common.clj b/lux-bootstrapper/src/lux/analyser/proc/common.clj index 1226e47f2..3f89b0ee4 100644 --- a/lux-bootstrapper/src/lux/analyser/proc/common.clj +++ b/lux-bootstrapper/src/lux/analyser/proc/common.clj @@ -139,12 +139,11 @@ (return (&/|list (&&/|meta exo-type _location (&&/$proc (&/T ["i64" ]) (&/|list =input =shift) (&/|list)))))))) - analyse-i64-left-shift "left-shift" - analyse-i64-arithmetic-right-shift "arithmetic-right-shift" - analyse-i64-logical-right-shift "logical-right-shift" + analyse-i64-left-shift "left-shift" + analyse-i64-right-shift "right-shift" ) -(do-template [ ] +(do-template [ ] (let [inputT outputT ] (defn- [analyse exo-type ?values] @@ -156,22 +155,22 @@ (return (&/|list (&&/|meta exo-type _location (&&/$proc (&/T ) (&/|list subjectA parameterA) (&/|list)))))))) - analyse-i64-eq ["i64" "="] (&/$Apply &type/Any &type/I64) &type/Bit - analyse-i64-add ["i64" "+"] (&/$Apply &type/Any &type/I64) &type/I64 - analyse-i64-sub ["i64" "-"] (&/$Apply &type/Any &type/I64) &type/I64 + ["i64" "="] analyse-i64-eq (&/$Apply &type/Any &type/I64) &type/Bit + ["i64" "+"] analyse-i64-add (&/$Apply &type/Any &type/I64) &type/I64 + ["i64" "-"] analyse-i64-sub (&/$Apply &type/Any &type/I64) &type/I64 - analyse-int-mul ["i64" "*"] &type/Int &type/Int - analyse-int-div ["i64" "/"] &type/Int &type/Int - analyse-int-rem ["i64" "%"] &type/Int &type/Int - analyse-int-lt ["i64" "<"] &type/Int &type/Bit + ["i64" "*"] analyse-int-mul &type/Int &type/Int + ["i64" "/"] analyse-int-div &type/Int &type/Int + ["i64" "%"] analyse-int-rem &type/Int &type/Int + ["i64" "<"] analyse-int-lt &type/Int &type/Bit - analyse-frac-add ["f64" "+"] &type/Frac &type/Frac - analyse-frac-sub ["f64" "-"] &type/Frac &type/Frac - analyse-frac-mul ["f64" "*"] &type/Frac &type/Frac - analyse-frac-div ["f64" "/"] &type/Frac &type/Frac - analyse-frac-rem ["f64" "%"] &type/Frac &type/Frac - analyse-frac-eq ["f64" "="] &type/Frac &type/Bit - analyse-frac-lt ["f64" "<"] &type/Frac &type/Bit + ["f64" "+"] analyse-frac-add &type/Frac &type/Frac + ["f64" "-"] analyse-frac-sub &type/Frac &type/Frac + ["f64" "*"] analyse-frac-mul &type/Frac &type/Frac + ["f64" "/"] analyse-frac-div &type/Frac &type/Frac + ["f64" "%"] analyse-frac-rem &type/Frac &type/Frac + ["f64" "="] analyse-frac-eq &type/Frac &type/Bit + ["f64" "<"] analyse-frac-lt &type/Frac &type/Bit ) (do-template [ ] @@ -249,20 +248,19 @@ "lux io error" (analyse-io-error analyse exo-type ?values) "lux io current-time" (analyse-io-current-time analyse exo-type ?values) - "lux text =" (analyse-text-eq analyse exo-type ?values) - "lux text <" (analyse-text-lt analyse exo-type ?values) - "lux text concat" (analyse-text-concat analyse exo-type ?values) - "lux text clip" (analyse-text-clip analyse exo-type ?values) - "lux text index" (analyse-text-index analyse exo-type ?values) - "lux text size" (analyse-text-size analyse exo-type ?values) - "lux text char" (analyse-text-char analyse exo-type ?values) + "lux text =" (analyse-text-eq analyse exo-type ?values) + "lux text <" (analyse-text-lt analyse exo-type ?values) + "lux text concat" (analyse-text-concat analyse exo-type ?values) + "lux text clip" (analyse-text-clip analyse exo-type ?values) + "lux text index" (analyse-text-index analyse exo-type ?values) + "lux text size" (analyse-text-size analyse exo-type ?values) + "lux text char" (analyse-text-char analyse exo-type ?values) - "lux i64 and" (analyse-i64-and analyse exo-type ?values) - "lux i64 or" (analyse-i64-or analyse exo-type ?values) - "lux i64 xor" (analyse-i64-xor analyse exo-type ?values) - "lux i64 left-shift" (analyse-i64-left-shift analyse exo-type ?values) - "lux i64 arithmetic-right-shift" (analyse-i64-arithmetic-right-shift analyse exo-type ?values) - "lux i64 logical-right-shift" (analyse-i64-logical-right-shift analyse exo-type ?values) + "lux i64 and" (analyse-i64-and analyse exo-type ?values) + "lux i64 or" (analyse-i64-or analyse exo-type ?values) + "lux i64 xor" (analyse-i64-xor analyse exo-type ?values) + "lux i64 left-shift" (analyse-i64-left-shift analyse exo-type ?values) + "lux i64 right-shift" (analyse-i64-right-shift analyse exo-type ?values) "lux i64 +" (analyse-i64-add analyse exo-type ?values) "lux i64 -" (analyse-i64-sub analyse exo-type ?values) "lux i64 =" (analyse-i64-eq analyse exo-type ?values) diff --git a/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj index f16d89e2a..ad01dfb31 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj @@ -56,8 +56,7 @@ (return nil))) Opcodes/LSHL ^:private compile-i64-left-shift - Opcodes/LSHR ^:private compile-i64-arithmetic-right-shift - Opcodes/LUSHR ^:private compile-i64-logical-right-shift + Opcodes/LUSHR ^:private compile-i64-right-shift ) (defn ^:private compile-lux-is [compile ?values special-args] @@ -420,21 +419,20 @@ "i64" (case proc - "and" (compile-i64-and compile ?values special-args) - "or" (compile-i64-or compile ?values special-args) - "xor" (compile-i64-xor compile ?values special-args) - "left-shift" (compile-i64-left-shift compile ?values special-args) - "arithmetic-right-shift" (compile-i64-arithmetic-right-shift compile ?values special-args) - "logical-right-shift" (compile-i64-logical-right-shift compile ?values special-args) - "=" (compile-i64-eq compile ?values special-args) - "+" (compile-i64-add compile ?values special-args) - "-" (compile-i64-sub compile ?values special-args) - "*" (compile-int-mul compile ?values special-args) - "/" (compile-int-div compile ?values special-args) - "%" (compile-int-rem compile ?values special-args) - "<" (compile-int-lt compile ?values special-args) - "f64" (compile-int-frac compile ?values special-args) - "char" (compile-int-char compile ?values special-args) + "and" (compile-i64-and compile ?values special-args) + "or" (compile-i64-or compile ?values special-args) + "xor" (compile-i64-xor compile ?values special-args) + "left-shift" (compile-i64-left-shift compile ?values special-args) + "right-shift" (compile-i64-right-shift compile ?values special-args) + "=" (compile-i64-eq compile ?values special-args) + "+" (compile-i64-add compile ?values special-args) + "-" (compile-i64-sub compile ?values special-args) + "*" (compile-int-mul compile ?values special-args) + "/" (compile-int-div compile ?values special-args) + "%" (compile-int-rem compile ?values special-args) + "<" (compile-int-lt compile ?values special-args) + "f64" (compile-int-frac compile ?values special-args) + "char" (compile-int-char compile ?values special-args) ) "f64" -- cgit v1.2.3