diff options
author | Eduardo Julian | 2017-11-22 20:37:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-22 20:37:41 -0400 |
commit | 0e3830be97930a01c38d8bca09a1ac9d5bf55465 (patch) | |
tree | 3078996542de6d53baa43388d0bca96e2b517aa9 /luxc | |
parent | e37e3713e080606930a5f8442f03dabc4c26a7f9 (diff) |
- Fixed some bugs.
- Some refactoring.
- Added some alternative snippets of code that new-luxc can handle better.
Diffstat (limited to 'luxc')
-rw-r--r-- | luxc/src/lux/analyser/proc/common.clj | 24 | ||||
-rw-r--r-- | luxc/src/lux/compiler/jvm/proc/common.clj | 23 |
2 files changed, 9 insertions, 38 deletions
diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 1dce02b2c..7031a9135 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -289,7 +289,7 @@ ^:private analyse-nat-to-int &type/Nat &type/Int ["nat" "to-int"] ^:private analyse-int-to-nat &type/Int &type/Nat ["int" "to-nat"] - ^:private analyse-nat-to-char &type/Nat &type/Text ["nat" "to-char"] + ^:private analyse-nat-char &type/Nat &type/Text ["nat" "char"] ^:private analyse-int-to-frac &type/Int &type/Frac ["int" "to-frac"] ^:private analyse-frac-to-int &type/Frac &type/Int ["frac" "to-int"] @@ -365,18 +365,6 @@ (do-template [<name> <proc>] (defn <name> [analyse exo-type ?values] - (|do [:let [(&/$Nil) ?values] - _ (&type/check exo-type &type/Frac) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["math" <proc>]) (&/|list) (&/|list))))))) - - ^:private analyse-math-e "e" - ^:private analyse-math-pi "pi" - ) - -(do-template [<name> <proc>] - (defn <name> [analyse exo-type ?values] (|do [:let [(&/$Cons ?input (&/$Nil)) ?values] =input (&&/analyse-1 analyse &type/Frac ?input) _ (&type/check exo-type &type/Frac) @@ -426,7 +414,7 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["atom" "new"]) (&/|list =init) (&/|list))))))))) -(defn ^:private analyse-atom-get [analyse exo-type ?values] +(defn ^:private analyse-atom-read [analyse exo-type ?values] (&type/with-var (fn [$var] (|do [:let [(&/$Cons ?atom (&/$Nil)) ?values] @@ -434,7 +422,7 @@ _ (&type/check exo-type $var) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["atom" "get"]) (&/|list =atom) (&/|list))))))))) + (&&/$proc (&/T ["atom" "read"]) (&/|list =atom) (&/|list))))))))) (defn ^:private analyse-atom-compare-and-swap [analyse exo-type ?values] (&type/with-var @@ -519,7 +507,7 @@ "lux nat min" (analyse-nat-min analyse exo-type ?values) "lux nat max" (analyse-nat-max analyse exo-type ?values) "lux nat to-int" (analyse-nat-to-int analyse exo-type ?values) - "lux nat to-char" (analyse-nat-to-char analyse exo-type ?values) + "lux nat char" (analyse-nat-char analyse exo-type ?values) "lux int +" (analyse-int-add analyse exo-type ?values) "lux int -" (analyse-int-sub analyse exo-type ?values) @@ -564,8 +552,6 @@ "lux frac to-deg" (analyse-frac-to-deg analyse exo-type ?values) "lux frac to-int" (analyse-frac-to-int analyse exo-type ?values) - "lux math e" (analyse-math-e analyse exo-type ?values) - "lux math pi" (analyse-math-pi analyse exo-type ?values) "lux math cos" (analyse-math-cos analyse exo-type ?values) "lux math sin" (analyse-math-sin analyse exo-type ?values) "lux math tan" (analyse-math-tan analyse exo-type ?values) @@ -586,7 +572,7 @@ "lux math pow" (analyse-math-pow analyse exo-type ?values) "lux atom new" (analyse-atom-new analyse exo-type ?values) - "lux atom get" (analyse-atom-get analyse exo-type ?values) + "lux atom read" (analyse-atom-read analyse exo-type ?values) "lux atom compare-and-swap" (analyse-atom-compare-and-swap analyse exo-type ?values) "lux process concurrency-level" (analyse-process-concurrency-level analyse exo-type ?values) diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index 3c948e8bc..bead93256 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -415,7 +415,7 @@ ^:private compile-frac-to-deg "java.lang.Double" "frac-to-deg" "(D)J" &&/unwrap-double &&/wrap-long ) -(defn ^:private compile-nat-to-char [compile ?values special-args] +(defn ^:private compile-nat-char [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] ^MethodVisitor *writer* &/get-writer _ (compile ?x) @@ -667,19 +667,6 @@ &&/wrap-long)]] (return nil))) -(do-template [<name> <field>] - (defn <name> [compile ?values special-args] - (|do [:let [(&/$Nil) ?values] - ^MethodVisitor *writer* &/get-writer - :let [_ (doto *writer* - (.visitFieldInsn Opcodes/GETSTATIC "java/lang/Math" <field> "D") - &&/wrap-double)]] - (return nil))) - - ^:private compile-math-e "E" - ^:private compile-math-pi "PI" - ) - (do-template [<name> <method>] (defn <name> [compile ?values special-args] (|do [:let [(&/$Cons ?input (&/$Nil)) ?values] @@ -749,7 +736,7 @@ (.visitMethodInsn Opcodes/INVOKESPECIAL "java/util/concurrent/atomic/AtomicReference" "<init>" "(Ljava/lang/Object;)V"))]] (return nil))) -(defn ^:private compile-atom-get [compile ?values special-args] +(defn ^:private compile-atom-read [compile ?values special-args] (|do [:let [(&/$Cons ?atom (&/$Nil)) ?values] ^MethodVisitor *writer* &/get-writer _ (compile ?atom) @@ -865,7 +852,7 @@ "max" (compile-nat-max compile ?values special-args) "min" (compile-nat-min compile ?values special-args) "to-int" (compile-nat-to-int compile ?values special-args) - "to-char" (compile-nat-to-char compile ?values special-args) + "char" (compile-nat-char compile ?values special-args) ) "deg" @@ -922,8 +909,6 @@ "math" (case proc - "e" (compile-math-e compile ?values special-args) - "pi" (compile-math-pi compile ?values special-args) "cos" (compile-math-cos compile ?values special-args) "sin" (compile-math-sin compile ?values special-args) "tan" (compile-math-tan compile ?values special-args) @@ -947,7 +932,7 @@ "atom" (case proc "new" (compile-atom-new compile ?values special-args) - "get" (compile-atom-get compile ?values special-args) + "read" (compile-atom-read compile ?values special-args) "compare-and-swap" (compile-atom-compare-and-swap compile ?values special-args) ) |