From 60daee098f92a44c3b404a9f5801f2e8126ad650 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 5 Apr 2022 18:32:42 -0400 Subject: No longer depending on the ASM library for JVM bytecode generation. --- .../library/lux/control/concurrency/atom.lux | 16 +++++---- .../library/lux/tool/compiler/default/platform.lux | 22 +++++------- .../lux/phase/extension/analysis/python.lux | 40 ++++++++++++++-------- stdlib/source/library/lux/world/file.lux | 2 +- 4 files changed, 44 insertions(+), 36 deletions(-) (limited to 'stdlib/source/library') diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 08533b6a5..39207767c 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -44,7 +44,7 @@ (with_expansions [ (as_expected (java/util/concurrent/atomic/AtomicReference::new value))] (for @.old @.jvm - (array.has! 0 value (array.empty 1)))))) + (array.has! 0 (variance.write value) (array.empty 1)))))) (def: .public (read! atom) (All (_ r w) (-> (Atom' r w) (IO r))) @@ -63,12 +63,14 @@ (representation atom))) @.jvm (ffi.of_boolean (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (representation atom))) - (let [old (array.item 0 (representation atom))] - (if (same? old current) - (exec - (array.has! 0 new (representation atom)) - true) - false))))) + (if (|> (representation atom) + (array.item 0) + variance.read + (same? current)) + (exec + (array.has! 0 (variance.write new) (representation atom)) + true) + false)))) ) (def: .public (update! f atom) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index 1facd15f6..9201b9cc2 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -115,10 +115,8 @@ (let [system (the #&file_system platform) write_artifact! (is (-> [artifact.ID (Maybe Text) Binary] (Action Any)) (function (_ [artifact_id custom content]) - (with_expansions [ (cache/artifact.cache! system context @module artifact_id content)] - (for @.old (as (Async (Try Any)) - ) - ))))] + (is (Async (Try Any)) + (cache/artifact.cache! system context @module artifact_id content))))] (do [! ..monad] [_ (is (Async (Try Any)) (cache/module.enable! async.monad system context @module)) @@ -135,15 +133,13 @@ (is (Action (List Any))))) document (# async.monad in (document.marked? key (the [archive.#module module.#document] entry)))] - (with_expansions [ (|> [(|> entry - (the archive.#module) - (has module.#document document)) - (the archive.#registry entry)] - (_.result (..writer format)) - (cache/module.cache! system context @module))] - (for @.old (as (Async (Try Any)) - ) - ))))) + (is (Async (Try Any)) + (|> [(|> entry + (the archive.#module) + (has module.#document document)) + (the archive.#registry entry)] + (_.result (..writer format)) + (cache/module.cache! system context @module)))))) ... TODO: Inline ASAP (def: initialize_buffer! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index f07d818d5..fa87792da 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -9,7 +9,7 @@ ["<[0]>" code {"+" Parser}]]] [data [collection - ["[0]" array {"+" Array}] + ["[0]" array] ["[0]" dictionary] ["[0]" list]]] ["[0]" type @@ -32,11 +32,13 @@ [.any (function (_ extension phase archive lengthC) (<| analysis/type.with_var - (function (_ [@var :var:])) + (function (_ [@read :read:])) + analysis/type.with_var + (function (_ [@write :write:])) (do phase.monad [lengthA (analysis/type.expecting Nat (phase archive lengthC)) - _ (analysis/type.inference (type (Array :var:)))] + _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) (def: array::length @@ -45,9 +47,11 @@ [.any (function (_ extension phase archive arrayC) (<| analysis/type.with_var - (function (_ [@var :var:])) + (function (_ [@read :read:])) + analysis/type.with_var + (function (_ [@write :write:])) (do phase.monad - [arrayA (analysis/type.expecting (type (Array :var:)) + [arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) (phase archive arrayC)) _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) @@ -58,13 +62,15 @@ [(<>.and .any .any) (function (_ extension phase archive [indexC arrayC]) (<| analysis/type.with_var - (function (_ [@var :var:])) + (function (_ [@read :read:])) + analysis/type.with_var + (function (_ [@write :write:])) (do phase.monad [indexA (analysis/type.expecting Nat (phase archive indexC)) - arrayA (analysis/type.expecting (type (Array :var:)) + arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) (phase archive arrayC)) - _ (analysis/type.inference :var:)] + _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) (def: array::write @@ -73,15 +79,17 @@ [($_ <>.and .any .any .any) (function (_ extension phase archive [indexC valueC arrayC]) (<| analysis/type.with_var - (function (_ [@var :var:])) + (function (_ [@read :read:])) + analysis/type.with_var + (function (_ [@write :write:])) (do phase.monad [indexA (analysis/type.expecting Nat (phase archive indexC)) - valueA (analysis/type.expecting :var: + valueA (analysis/type.expecting :write: (phase archive valueC)) - arrayA (analysis/type.expecting (type (Array :var:)) + arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) (phase archive arrayC)) - _ (analysis/type.inference (type (Array :var:)))] + _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) (def: array::delete @@ -90,13 +98,15 @@ [($_ <>.and .any .any) (function (_ extension phase archive [indexC arrayC]) (<| analysis/type.with_var - (function (_ [@var :var:])) + (function (_ [@read :read:])) + analysis/type.with_var + (function (_ [@write :write:])) (do phase.monad [indexA (analysis/type.expecting Nat (phase archive indexC)) - arrayA (analysis/type.expecting (type (Array :var:)) + arrayA (analysis/type.expecting (type (array.Array' :read: :write:)) (phase archive arrayC)) - _ (analysis/type.inference (type (Array :var:)))] + _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) (def: bundle::array diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index c0c76d6de..d04f8c052 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -1,6 +1,6 @@ (.`` (.`` (.using [library - [lux "*" + [lux {"-" open} ["@" target] [abstract ["[0]" monad {"+" Monad do}]] -- cgit v1.2.3