diff options
author | Eduardo Julian | 2017-12-31 20:43:51 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-12-31 20:43:51 -0400 |
commit | 64a2cf543232df320374d0676607e2855765b5ed (patch) | |
tree | 99153d19ccd1645be1d8a294253c6cad3f77059c /luxc/src/lux/compiler/jvm/proc/common.clj | |
parent | 8f071917892ac919b91da12c2bf02d5d9b79f81a (diff) |
- Added safe (single-threaded) mutation.
Diffstat (limited to 'luxc/src/lux/compiler/jvm/proc/common.clj')
-rw-r--r-- | luxc/src/lux/compiler/jvm/proc/common.clj | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index bead93256..b23a59ce1 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -759,6 +759,47 @@ &&/wrap-boolean)]] (return nil))) +(defn ^:private compile-box-new [compile ?values special-args] + (|do [:let [(&/$Cons initS (&/$Nil)) ?values] + ^MethodVisitor *writer* &/get-writer + :let [_ (doto *writer* + (.visitLdcInsn (int 1)) + (.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object"))] + :let [_ (doto *writer* + (.visitInsn Opcodes/DUP) + (.visitLdcInsn (int 0)))] + _ (compile initS) + :let [_ (doto *writer* + (.visitInsn Opcodes/AASTORE))]] + (return nil))) + +(defn ^:private compile-box-read [compile ?values special-args] + (|do [:let [(&/$Cons boxS (&/$Nil)) ?values + ;; (&/$Nil) special-args + ] + ^MethodVisitor *writer* &/get-writer + _ (compile boxS) + :let [_ (doto *writer* + (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") + (.visitLdcInsn (int 0)) + (.visitInsn Opcodes/AALOAD))]] + (return nil))) + +(defn ^:private compile-box-write [compile ?values special-args] + (|do [:let [(&/$Cons valueS (&/$Cons boxS (&/$Nil))) ?values + ;; (&/$Nil) special-args + ] + ^MethodVisitor *writer* &/get-writer + _ (compile boxS) + :let [_ (doto *writer* + (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") + (.visitLdcInsn (int 0)))] + _ (compile valueS) + :let [_ (doto *writer* + (.visitInsn Opcodes/AASTORE) + (.visitLdcInsn &/unit-tag))]] + (return nil))) + (defn ^:private compile-process-concurrency-level [compile ?values special-args] (|do [:let [(&/$Nil) ?values] ^MethodVisitor *writer* &/get-writer @@ -929,6 +970,13 @@ "pow" (compile-math-pow compile ?values special-args) ) + "box" + (case proc + "new" (compile-box-new compile ?values special-args) + "read" (compile-box-read compile ?values special-args) + "write" (compile-box-write compile ?values special-args) + ) + "atom" (case proc "new" (compile-atom-new compile ?values special-args) |