aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2022-11-18 20:56:49 -0400
committerEduardo Julian2022-11-18 20:56:49 -0400
commit6aa4fac0c97264a2b1186063c062ae0873582f54 (patch)
treeb34540d9688ccef495a2c29eec3c7ff30d5e7f16 /stdlib
parent4ea7563c46a07dbe1cb84547a60e9398144917ae (diff)
Updated the Python compiler to work with the new format for extensions.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/library/lux/data/text.lux6
-rw-r--r--stdlib/source/library/lux/data/text/encoding/utf8.lux4
-rw-r--r--stdlib/source/library/lux/debug.lux12
-rw-r--r--stdlib/source/library/lux/ffi.lux82
-rw-r--r--stdlib/source/library/lux/math/number/frac.lux4
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux12
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux166
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux3
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux233
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux117
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux75
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux2
-rw-r--r--stdlib/source/library/lux/world/time/instant.lux4
-rw-r--r--stdlib/source/test/lux/meta/target/python.lux2
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux8
-rw-r--r--stdlib/source/unsafe/lux/data/collection/array.lux12
19 files changed, 394 insertions, 354 deletions
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux
index 6efb9eb0d..cc8bf71b8 100644
--- a/stdlib/source/library/lux/data/text.lux
+++ b/stdlib/source/library/lux/data/text.lux
@@ -241,7 +241,7 @@
("js object do" "replaceAll" template [pattern replacement])))
@.python
(as Text
- ("python object do" "replace" template [pattern replacement]))
+ (.python_object_do# "replace" template [pattern replacement]))
... TODO @.lua
@.ruby
(as Text
@@ -368,7 +368,7 @@
("js object do" "toLowerCase" value []))
@.python
(as Text
- ("python object do" "lower" value []))
+ (.python_object_do# "lower" value []))
@.lua
(as Text
("lua apply" ("lua constant" "string.lower") [value]))
@@ -391,7 +391,7 @@
("js object do" "toUpperCase" value []))
@.python
(as Text
- ("python object do" "upper" value []))
+ (.python_object_do# "upper" value []))
@.lua
(as Text
("lua apply" ("lua constant" "string.upper") [value]))
diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux
index d90d52a2a..cc5dcacd3 100644
--- a/stdlib/source/library/lux/data/text/encoding/utf8.lux
+++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux
@@ -90,7 +90,7 @@
)
@.python
- (as Binary ("python apply" (as_expected ("python constant" "bytearray")) [value "utf-8"]))
+ (as Binary (.python_apply# (as_expected (.python_constant# "bytearray")) [value "utf-8"]))
@.lua
("lua utf8 encode" value)
@@ -133,7 +133,7 @@
{try.#Success}))
@.python
- (try (as Text ("python object do" "decode" (as_expected value) ["utf-8"])))
+ (try (as Text (.python_object_do# "decode" (as_expected value) ["utf-8"])))
@.lua
{try.#Success ("lua utf8 decode" value)}
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 39c2aecd1..d132e6256 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -235,14 +235,14 @@
(^.or "<type 'tuple'>" "<class 'tuple'>")
(let [variant (as (array.Array Any) value)]
(when (array.size variant)
- 3 (let [variant_tag ("python array read" 0 variant)
- variant_flag ("python array read" 1 variant)
- variant_value ("python array read" 2 variant)]
- (if (or ("python object none?" variant_tag)
- ("python object none?" variant_value))
+ 3 (let [variant_tag (.python_array_read# 0 variant)
+ variant_flag (.python_array_read# 1 variant)
+ variant_value (.python_array_read# 2 variant)]
+ (if (or (.python_object_none?# variant_tag)
+ (.python_object_none?# variant_value))
(..str value)
(|> (%.format (|> variant_tag (as .Nat) %.nat)
- " " (|> variant_flag "python object none?" not %.bit)
+ " " (|> variant_flag .python_object_none?# not %.bit)
" " (inspection variant_value))
(text.enclosed ["{" "}"]))))
_ (..str value)))
diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux
index 575809639..e4d0878a5 100644
--- a/stdlib/source/library/lux/ffi.lux
+++ b/stdlib/source/library/lux/ffi.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Symbol Alias Global global function type_of undefined)
+ [lux (.except Symbol Alias Global Declaration global function type_of undefined)
[abstract
["[0]" monad (.only do)]]
[control
@@ -21,7 +21,7 @@
[syntax (.only syntax)]
["[0]" template]]
[type
- ["[0]" primitive (.except def)]]
+ ["[0]" primitive (.except #name def)]]
["@" target (.only)
["[0]" js]]]]])
@@ -81,9 +81,9 @@
{try.#Success [state (extension_analysis name (list))]})
(translation <undefined>
- [name phase archive state]
- (list)
- {try.#Success [state js.undefined]})
+ [name phase archive state]
+ (list)
+ {try.#Success [state js.undefined]})
(def .public undefined
(template (undefined)
@@ -98,11 +98,11 @@
(in [state (extension_analysis name (list it))])))
(translation <undefined?>
- [name phase archive state]
- (list it)
- (do try.monad
- [[state it] (phase archive it state)]
- (in [state (js.= js.undefined it)])))
+ [name phase archive state]
+ (list it)
+ (do try.monad
+ [[state it] (phase archive it state)]
+ (in [state (js.= js.undefined it)])))
(def .public undefined?
(template (undefined? <it>)
@@ -138,22 +138,22 @@
(.undefined)))
(translation <object>
- [name phase archive state]
- (list.partial head_key head_value tail)
- (do [! try.monad]
- [[state output] (monad.mix !
- (.function (_ [key value] [state output])
- (when key
- (text_synthesis key)
- (do try.monad
- [[state value] (phase archive value state)]
- (in [state (list.partial [key value] output)]))
-
- _
- (.undefined)))
- [state (list)]
- (pairs (list.partial head_key head_value tail)))]
- (in [state (js.object (list.reversed output))])))
+ [name phase archive state]
+ (list.partial head_key head_value tail)
+ (do [! try.monad]
+ [[state output] (monad.mix !
+ (.function (_ [key value] [state output])
+ (when key
+ (text_synthesis key)
+ (do try.monad
+ [[state value] (phase archive value state)]
+ (in [state (list.partial [key value] output)]))
+
+ _
+ (.undefined)))
+ [state (list)]
+ (pairs (list.partial head_key head_value tail)))]
+ (in [state (js.object (list.reversed output))])))
(def .public object
(syntax (_ [it (<>.some <code>.any)])
@@ -170,12 +170,12 @@
(in [state (extension_analysis name (list (text_analysis field) value object))])))
(translation <set>
- [name phase archive state]
- (list (text_synthesis field) value object)
- (do try.monad
- [[state value] (phase archive value state)
- [state object] (phase archive object state)]
- (in [state (js.set (js.the field object) value)])))
+ [name phase archive state]
+ (list (text_synthesis field) value object)
+ (do try.monad
+ [[state value] (phase archive value state)
+ [state object] (phase archive object state)]
+ (in [state (js.set (js.the field object) value)])))
(def .public set
(syntax (_ [field <code>.any
@@ -187,34 +187,34 @@
(these))
(with_expansions [<constant> (for @.js "js constant"
- @.python "python constant"
+ @.python .python_constant#
@.lua "lua constant"
@.ruby "ruby constant")
<apply> (for @.js "js apply"
- @.python "python apply"
+ @.python .python_apply#
@.lua "lua apply"
@.ruby "ruby apply")
<new> (for @.js "js object new"
- @.python "python apply"
+ @.python .python_apply#
(these))
<do> (for @.js "js object do"
- @.python "python object do"
+ @.python .python_object_do#
@.lua "lua object do"
@.ruby "ruby object do")
<get> (for @.js "js object get"
- @.python "python object get"
+ @.python .python_object_get#
@.lua "lua object get"
@.ruby "ruby object get"
(these))
<set> (for @.lua "lua object set"
@.ruby "ruby object set"
(these))
- <import> (for @.python "python import"
+ <import> (for @.python .python_import#
@.lua "lua import"
@.ruby "ruby import"
(these))
<function> (for @.js "js function"
- @.python "python function"
+ @.python .python_function#
@.lua "lua function"
(these))]
(primitive.def .public (Object brand) Any)
@@ -462,8 +462,8 @@
(,, (for @.js [null "js object null"
null? "js object null?"]
- @.python [none "python object none"
- none? "python object none?"]
+ @.python [none .python_object_none#
+ none? .python_object_none?#]
@.lua [nil "lua object nil"
nil? "lua object nil?"]
@.ruby [nil "ruby object nil"
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index 13c54f28b..916fa95f7 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -142,7 +142,7 @@
[(def .public <name>
(-> Frac Frac)
(|>> []
- ("python object do" <method> ("python import" "math"))
+ (.python_object_do# <method> (.python_import# "math"))
(as Frac)))]
[cos "cos"]
@@ -164,7 +164,7 @@
(def .public (pow param subject)
(-> Frac Frac Frac)
- (as Frac ("python object do" "pow" ("python import" "math") [subject param])))
+ (as Frac (.python_object_do# "pow" (.python_import# "math") [subject param])))
(def .public (root_3 it)
(-> Frac Frac)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
index adfdc2e52..d79128c56 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
@@ -53,6 +53,12 @@
{try.#Failure error}
(phase.failure error))))
+(def .public translation
+ (-> Text
+ Symbol)
+ (|>> (text.suffix "|translation")
+ [.prelude]))
+
(def .public (install name anonymous)
(-> Text (-> Text Handler)
(-> Bundle Bundle))
@@ -78,7 +84,7 @@
(analyse archive argC)))
(list.zipped_2 inputsT+ args))
@ meta.location]
- (in [@ {analysis.#Extension [.prelude (format extension_name "|translation")] argsA}]))
+ (in [@ {analysis.#Extension (..translation extension_name) argsA}]))
(analysis.except ..incorrect_arity [num_expected num_actual]))))))
(def .public (nullary valueT)
@@ -153,7 +159,7 @@
(list (analysis.tuple @ (list#each (|>> (analysis.nat @)) cases))
branch))))
(list.partial input else)
- {analysis.#Extension [.prelude (format extension_name "|translation")]}
+ {analysis.#Extension (..translation extension_name)}
[@]))))])))
... .is?# represents reference/pointer equality.
@@ -180,7 +186,7 @@
(analyse archive)
(typeA.expecting (type_literal (-> .Any :var:)))
(at ! each (|>> list
- {analysis.#Extension [.prelude (format extension_name "|translation")]}
+ {analysis.#Extension (..translation extension_name)}
[@]))))))]))
(def lux::in_module
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
index 823ffe79a..eb457c03a 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux
@@ -11,17 +11,16 @@
["[0]" array]
["[0]" dictionary]
["[0]" list]]]
- [meta
+ ["[0]" meta (.only)
["@" target (.only)
["_" python]]
["[0]" code
["<[1]>" \\parser (.only Parser)]]
["[0]" type (.only)
["[0]" check]]]]]
- [//
+ ["[0]" //
["/" lux (.only custom)]
- [//
- ["[0]" bundle]
+ ["/[1]" // (.only)
[///
["[0]" analysis (.only Analysis Operation Phase Handler Bundle)
["[1]/[0]" type]]
@@ -29,7 +28,7 @@
["[0]" phase]]]]])
(def array::new
- Handler
+ (-> Text Handler)
(custom
[<code>.any
(function (_ extension phase archive lengthC)
@@ -40,11 +39,13 @@
(do phase.monad
[lengthA (analysis/type.expecting Nat
(phase archive lengthC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list lengthA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list lengthA)}]))))]))
(def array::length
- Handler
+ (-> Text Handler)
(custom
[<code>.any
(function (_ extension phase archive arrayC)
@@ -55,11 +56,13 @@
(do phase.monad
[arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference Nat)]
- (in {analysis.#Extension extension (list arrayA)}))))]))
+ _ (analysis/type.inference Nat)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list arrayA)}]))))]))
(def array::read
- Handler
+ (-> Text Handler)
(custom
[(<>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
@@ -72,11 +75,13 @@
(phase archive indexC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference :read:)]
- (in {analysis.#Extension extension (list indexA arrayA)}))))]))
+ _ (analysis/type.inference :read:)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA arrayA)}]))))]))
(def array::write
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any <code>.any)
(function (_ extension phase archive [indexC valueC arrayC])
@@ -91,11 +96,13 @@
(phase archive valueC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list indexA valueA arrayA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA valueA arrayA)}]))))]))
(def array::delete
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any)
(function (_ extension phase archive [indexC arrayC])
@@ -108,19 +115,19 @@
(phase archive indexC))
arrayA (analysis/type.expecting (type_literal (array.Array' :read: :write:))
(phase archive arrayC))
- _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))]
- (in {analysis.#Extension extension (list indexA arrayA)}))))]))
+ _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list indexA arrayA)}]))))]))
-(def bundle::array
- Bundle
- (<| (bundle.prefix "array")
- (|> bundle.empty
- (bundle.install "new" array::new)
- (bundle.install "length" array::length)
- (bundle.install "read" array::read)
- (bundle.install "write" array::write)
- (bundle.install "delete" array::delete)
- )))
+(def with_array_extensions
+ (-> Bundle Bundle)
+ (|>> (/.install "python_array_new#" array::new)
+ (/.install "python_array_length#" array::length)
+ (/.install "python_array_read#" array::read)
+ (/.install "python_array_write#" array::write)
+ (/.install "python_array_delete#" array::delete)
+ ))
(def None
(for @.python ffi.None
@@ -139,19 +146,21 @@
Any))
(def object::get
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.text <code>.any)
(function (_ extension phase archive [fieldC objectC])
(do phase.monad
[objectA (analysis/type.expecting ..Object
(phase archive objectC))
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list (analysis.text fieldC)
- objectA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ fieldC)
+ objectA)}])))]))
(def object::do
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any)))
(function (_ extension phase archive [methodC objectC inputsC])
@@ -159,41 +168,45 @@
[objectA (analysis/type.expecting ..Object
(phase archive objectC))
inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC)
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list.partial (analysis.text methodC)
- objectA
- inputsA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list.partial (analysis.text @ methodC)
+ objectA
+ inputsA)}])))]))
-(def bundle::object
- Bundle
- (<| (bundle.prefix "object")
- (|> bundle.empty
- (bundle.install "get" object::get)
- (bundle.install "do" object::do)
- (bundle.install "none" (/.nullary ..None))
- (bundle.install "none?" (/.unary Any Bit))
- )))
+(def with_object_extensions
+ (-> Bundle Bundle)
+ (|>> (/.install "python_object_get#" object::get)
+ (/.install "python_object_do#" object::do)
+ (/.install "python_object_none#" (/.nullary ..None))
+ (/.install "python_object_none?#" (/.unary Any Bit))
+ ))
(def python::constant
- Handler
+ (-> Text Handler)
(custom
[<code>.text
(function (_ extension phase archive name)
(do phase.monad
- [_ (analysis/type.inference Any)]
- (in {analysis.#Extension extension (list (analysis.text name))})))]))
+ [_ (analysis/type.inference Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ name))}])))]))
(def python::import
- Handler
+ (-> Text Handler)
(custom
[<code>.text
(function (_ extension phase archive name)
(do phase.monad
- [_ (analysis/type.inference ..Object)]
- (in {analysis.#Extension extension (list (analysis.text name))})))]))
+ [_ (analysis/type.inference ..Object)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.text @ name))}])))]))
(def python::apply
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any (<code>.tuple (<>.some <code>.any)))
(function (_ extension phase archive [abstractionC inputsC])
@@ -201,11 +214,13 @@
[abstractionA (analysis/type.expecting ..Function
(phase archive abstractionC))
inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC)
- _ (analysis/type.inference Any)]
- (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))]))
+ _ (analysis/type.inference Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list.partial abstractionA inputsA)}])))]))
(def python::function
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.nat <code>.any)
(function (_ extension phase archive [arity abstractionC])
@@ -213,12 +228,14 @@
[.let [inputT (type.tuple (list.repeated arity Any))]
abstractionA (analysis/type.expecting (-> inputT Any)
(phase archive abstractionC))
- _ (analysis/type.inference ..Function)]
- (in {analysis.#Extension extension (list (analysis.nat arity)
- abstractionA)})))]))
+ _ (analysis/type.inference ..Function)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list (analysis.nat @ arity)
+ abstractionA)}])))]))
(def python::exec
- Handler
+ (-> Text Handler)
(custom
[(all <>.and <code>.any <code>.any)
(function (_ extension phase archive [codeC globalsC])
@@ -227,19 +244,20 @@
(phase archive codeC))
globalsA (analysis/type.expecting ..Dict
(phase archive globalsC))
- _ (analysis/type.inference .Any)]
- (in {analysis.#Extension extension (list codeA globalsA)})))]))
+ _ (analysis/type.inference .Any)
+ @ meta.location]
+ (in [@ {analysis.#Extension (/.translation extension)
+ (list codeA globalsA)}])))]))
(def .public bundle
Bundle
- (<| (bundle.prefix "python")
- (|> bundle.empty
- (dictionary.composite bundle::array)
- (dictionary.composite bundle::object)
-
- (bundle.install "constant" python::constant)
- (bundle.install "import" python::import)
- (bundle.install "apply" python::apply)
- (bundle.install "function" python::function)
- (bundle.install "exec" python::exec)
- )))
+ (|> ///.empty
+ with_array_extensions
+ with_object_extensions
+
+ (/.install "python_constant#" python::constant)
+ (/.install "python_import#" python::import)
+ (/.install "python_apply#" python::apply)
+ (/.install "python_function#" python::function)
+ (/.install "python_exec#" python::exec)
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
index 034560910..b7ddc07e9 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux
@@ -465,4 +465,5 @@
with_text_extensions
with_i64_extensions
with_int_extensions
- with_frac_extensions))
+ with_frac_extensions
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
index ff724bd07..edabbd255 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux
@@ -21,43 +21,44 @@
[macro
["^" pattern]]
[target
- ["_" python (.only Expression Statement)]]]]]
- ["[0]" ////
- ["/" bundle]
- ["/[1]" //
- ["[0]" extension]
- [translation
- ["[0]" reference]
- [extension (.only Nullary Unary Binary Trinary
- nullary unary binary trinary)]
- ["//" python
- ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)]
- ["[1][0]" primitive]
- ["[1][0]" structure]
- ["[1][0]" reference]
- ["[1][0]" function]
- ["[1][0]" when]
- ["[1][0]" loop]]]
- [//
- [analysis (.only)]
- ["[0]" translation]
- ["[0]" synthesis (.only %synthesis)
- ["<[1]>" \\parser (.only Parser)]]
- [///
- ["[1]" phase (.use "[1]#[0]" monad)]]]]])
+ ["_" python (.only Expression Statement)]]
+ [compiler
+ [meta
+ [archive (.only Archive)]]]]]]
+ [/////
+ ["[0]" extension]
+ [translation
+ ["[0]" reference]
+ [extension (.only Nullary Unary Binary Trinary Variadic
+ nullary unary binary trinary variadic)]
+ ["//" python
+ ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)]
+ ["[1][0]" primitive]
+ ["[1][0]" structure]
+ ["[1][0]" reference]
+ ["[1][0]" function]
+ ["[1][0]" when]
+ ["[1][0]" loop]]]
+ [//
+ [analysis (.only)]
+ ["[0]" translation]
+ ["[0]" synthesis (.only %synthesis)
+ ["<[1]>" \\parser (.only Parser)]]
+ [///
+ ["[0]" phase (.use "[1]#[0]" monad)]]]])
(def .public (statement expression archive synthesis)
Phase!
(when synthesis
... TODO: Get rid of this ASAP
- {synthesis.#Extension [.prelude "when_char#|translation"] parameters}
- (do /////.monad
+ [@ {synthesis.#Extension [.prelude "when_char#|translation"] parameters}]
+ (do phase.monad
[body (expression archive synthesis)]
(in (as (Statement Any) body)))
(^.with_template [<tag>]
- [(<tag> value)
- (/////#each _.return (expression archive synthesis))])
+ [(<tag> @ value)
+ (phase#each _.return (expression archive synthesis))])
([synthesis.bit]
[synthesis.i64]
[synthesis.f64]
@@ -68,16 +69,16 @@
[synthesis.function/apply])
(^.with_template [<tag>]
- [{<tag> value}
- (/////#each _.return (expression archive synthesis))])
+ [[@ {<tag> value}]
+ (phase#each _.return (expression archive synthesis))])
([synthesis.#Reference]
[synthesis.#Extension])
- (synthesis.branch/when when)
+ (synthesis.branch/when @ when)
(//when.when! false statement expression archive when)
(^.with_template [<tag> <translator>]
- [(<tag> value)
+ [(<tag> @ value)
(<translator> statement expression archive value)])
([synthesis.branch/exec //when.exec!]
[synthesis.branch/let //when.let!]
@@ -85,10 +86,23 @@
[synthesis.loop/scope //loop.scope!]
[synthesis.loop/again //loop.again!])
- (synthesis.function/abstraction abstraction)
- (/////#each _.return (//function.function statement expression archive abstraction))
+ (synthesis.function/abstraction @ abstraction)
+ (phase#each _.return (//function.function statement expression archive abstraction))
))
+(def .public (custom [parser handler])
+ (All (_ s)
+ (-> [(Parser s)
+ (-> Phase Archive s (Operation (Expression Any)))]
+ Handler))
+ (function (_ phase archive input)
+ (when (<synthesis>.result parser input)
+ {try.#Success input'}
+ (handler phase archive input')
+
+ {try.#Failure error}
+ (phase.failure error))))
+
... TODO: Get rid of this ASAP
(def lux::syntax_char_case!
(..custom [(all <>.and
@@ -97,8 +111,8 @@
(<>.some (<synthesis>.tuple (all <>.and
(<synthesis>.tuple (<>.many <synthesis>.i64))
<synthesis>.any))))
- (function (_ extension_name phase archive [input else conditionals])
- (do [! /////.monad]
+ (function (_ phase archive [input else conditionals])
+ (do [! phase.monad]
[inputG (phase archive input)
else! (..statement phase archive else)
@input (at ! each _.var (translation.symbol "input"))
@@ -144,55 +158,55 @@
else!
conditionals!))))))]))
-(def lux_procs
- Bundle
- (|> /.empty
- (/.install "syntax char case!" lux::syntax_char_case!)
- (/.install "is" (binary (product.uncurried _.is)))
- (/.install "try" (unary //runtime.lux::try))))
+(def with_basic_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "when_char#|translation" lux::syntax_char_case!)
+ (dictionary.has "is?#|translation" (binary (product.uncurried _.is)))
+ (dictionary.has "try#|translation" (unary //runtime.lux::try))))
(def (capped operation parameter subject)
(-> (-> (Expression Any) (Expression Any) (Expression Any))
(-> (Expression Any) (Expression Any) (Expression Any)))
(//runtime.i64::64 (operation parameter subject)))
-(def i64_procs
- Bundle
- (<| (/.prefix "i64")
- (|> /.empty
- (/.install "and" (binary (product.uncurried //runtime.i64::and)))
- (/.install "or" (binary (product.uncurried //runtime.i64::or)))
- (/.install "xor" (binary (product.uncurried //runtime.i64::xor)))
- (/.install "left-shift" (binary (product.uncurried //runtime.i64::left_shifted)))
- (/.install "right-shift" (binary (product.uncurried //runtime.i64::right_shifted)))
-
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "+" (binary (product.uncurried (..capped _.+))))
- (/.install "-" (binary (product.uncurried (..capped _.-))))
- (/.install "*" (binary (product.uncurried (..capped _.*))))
- (/.install "/" (binary (product.uncurried //runtime.i64#/)))
- (/.install "%" (binary (product.uncurried //runtime.i64::remainder)))
- (/.install "f64" (unary _.float/1))
- (/.install "char" (unary //runtime.i64::char))
- )))
-
-(def f64_procs
- Bundle
- (<| (/.prefix "f64")
- (|> /.empty
- (/.install "+" (binary (product.uncurried _.+)))
- (/.install "-" (binary (product.uncurried _.-)))
- (/.install "*" (binary (product.uncurried _.*)))
- (/.install "/" (binary (product.uncurried //runtime.f64::/)))
- (/.install "%" (binary (function (_ [parameter subject])
- (|> (_.__import__/1 (_.unicode "math"))
- (_.do "fmod" (list subject parameter))))))
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "i64" (unary _.int/1))
- (/.install "encode" (unary _.repr/1))
- (/.install "decode" (unary //runtime.f64::decode)))))
+(def with_i64_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "i64_and#|translation" (binary (product.uncurried //runtime.i64::and)))
+ (dictionary.has "i64_or#|translation" (binary (product.uncurried //runtime.i64::or)))
+ (dictionary.has "i64_xor#|translation" (binary (product.uncurried //runtime.i64::xor)))
+ (dictionary.has "i64_left#|translation" (binary (product.uncurried //runtime.i64::left_shifted)))
+ (dictionary.has "i64_right#|translation" (binary (product.uncurried //runtime.i64::right_shifted)))
+
+ (dictionary.has "i64_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "i64_+#|translation" (binary (product.uncurried (..capped _.+))))
+ (dictionary.has "i64_-#|translation" (binary (product.uncurried (..capped _.-))))
+ ))
+
+(def with_int_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "int_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "int_*#|translation" (binary (product.uncurried (..capped _.*))))
+ (dictionary.has "int_/#|translation" (binary (product.uncurried //runtime.i64#/)))
+ (dictionary.has "int_%#|translation" (binary (product.uncurried //runtime.i64::remainder)))
+
+ (dictionary.has "int_f64#|translation" (unary _.float/1))
+ (dictionary.has "int_char#|translation" (unary //runtime.i64::char))
+ ))
+
+(def with_frac_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "f64_+#|translation" (binary (product.uncurried _.+)))
+ (dictionary.has "f64_-#|translation" (binary (product.uncurried _.-)))
+ (dictionary.has "f64_*#|translation" (binary (product.uncurried _.*)))
+ (dictionary.has "f64_/#|translation" (binary (product.uncurried //runtime.f64::/)))
+ (dictionary.has "f64_%#|translation" (binary (function (_ [parameter subject])
+ (|> (_.__import__/1 (_.unicode "math"))
+ (_.do "fmod" (list subject parameter))))))
+ (dictionary.has "f64_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "f64_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "f64_int#|translation" (unary _.int/1))
+ (dictionary.has "f64_encoded#|translation" (unary _.repr/1))
+ (dictionary.has "f64_decoded#|translation" (unary //runtime.f64::decode))))
(def (text::clip [paramO extraO subjectO])
(Trinary (Expression Any))
@@ -202,32 +216,41 @@
(Trinary (Expression Any))
(//runtime.text::index startO partO textO))
-(def text_procs
- Bundle
- (<| (/.prefix "text")
- (|> /.empty
- (/.install "=" (binary (product.uncurried _.=)))
- (/.install "<" (binary (product.uncurried _.<)))
- (/.install "concat" (binary (product.uncurried (function.flipped _.+))))
- (/.install "index" (trinary ..text::index))
- (/.install "size" (unary _.len/1))
- (/.install "char" (binary (product.uncurried //runtime.text::char)))
- (/.install "clip" (trinary ..text::clip))
- )))
-
-(def io_procs
- Bundle
- (<| (/.prefix "io")
- (|> /.empty
- (/.install "log" (unary //runtime.io::log!))
- (/.install "error" (unary //runtime.io::throw!)))))
+(def (text::composite parts)
+ (Variadic (Expression Any))
+ (when parts
+ (list)
+ (_.string "")
+
+ (list single)
+ single
+
+ _
+ (_.do "join" (list (_.list parts)) (_.string ""))))
+
+(def with_text_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "text_=#|translation" (binary (product.uncurried _.=)))
+ (dictionary.has "text_<#|translation" (binary (product.uncurried _.<)))
+ (dictionary.has "text_composite#|translation" (variadic ..text::composite))
+ (dictionary.has "text_index#|translation" (trinary ..text::index))
+ (dictionary.has "text_size#|translation" (unary _.len/1))
+ (dictionary.has "text_char#|translation" (binary (product.uncurried //runtime.text::char)))
+ (dictionary.has "text_clip#|translation" (trinary ..text::clip))
+ ))
+
+(def with_io_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "log!#|translation" (unary //runtime.io::log!))
+ (dictionary.has "error#|translation" (unary //runtime.io::throw!))))
(def .public bundle
Bundle
- (<| (/.prefix "lux")
- (|> lux_procs
- (dictionary.composite i64_procs)
- (dictionary.composite f64_procs)
- (dictionary.composite text_procs)
- (dictionary.composite io_procs)
- )))
+ (|> extension.empty
+ with_basic_extensions
+ with_i64_extensions
+ with_int_extensions
+ with_frac_extensions
+ with_text_extensions
+ with_io_extensions
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
index d9af74b71..adb650f17 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux
@@ -15,24 +15,22 @@
[meta
[target
["_" python (.only Expression SVar)]]]]]
- ["[0]" //
- ["[1][0]" common (.only custom)]
- ["//[1]" ///
- ["/" bundle]
- ["/[1]" //
- ["[0]" extension]
- [translation
- [extension (.only Nullary Unary Binary Trinary
- nullary unary binary trinary)]
- ["//" python
- ["[1][0]" runtime (.only Operation Phase Handler Bundle
- with_vars)]]]
- ["/[1]" //
- ["[0]" translation]
- [synthesis
- ["<s>" \\parser (.only Parser)]]
- ["//[1]" ///
- ["[1][0]" phase]]]]]])
+ [//
+ [common (.only custom)]
+ [////
+ ["[0]" extension]
+ [translation
+ [extension (.only Nullary Unary Binary Trinary
+ nullary unary binary trinary)]
+ ["//" python
+ ["[1][0]" runtime (.only Operation Phase Handler Bundle
+ with_vars)]]]
+ [//
+ ["[0]" translation]
+ [synthesis
+ ["<s>" \\parser (.only Parser)]]
+ [///
+ ["[0]" phase]]]]])
(def (array::new size)
(Unary (Expression Any))
@@ -56,23 +54,21 @@
(Binary (Expression Any))
(//runtime.array::write indexG _.none arrayG))
-(def array
- Bundle
- (<| (/.prefix "array")
- (|> /.empty
- (/.install "new" (unary array::new))
- (/.install "length" (unary array::length))
- (/.install "read" (binary array::read))
- (/.install "write" (trinary array::write))
- (/.install "delete" (binary array::delete))
- )))
+(def with_array_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "python_array_new#|translation" (unary array::new))
+ (dictionary.has "python_array_length#|translation" (unary array::length))
+ (dictionary.has "python_array_read#|translation" (binary array::read))
+ (dictionary.has "python_array_write#|translation" (trinary array::write))
+ (dictionary.has "python_array_delete#|translation" (binary array::delete))
+ ))
(def object::get
Handler
(custom
[(all <>.and <s>.text <s>.any)
- (function (_ extension phase archive [fieldS objectS])
- (do ////////phase.monad
+ (function (_ phase archive [fieldS objectS])
+ (do phase.monad
[objectG (phase archive objectS)]
(in (_.the fieldS objectG))))]))
@@ -80,8 +76,8 @@
Handler
(custom
[(all <>.and <s>.text <s>.any (<>.some <s>.any))
- (function (_ extension phase archive [methodS objectS inputsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [methodS objectS inputsS])
+ (do [! phase.monad]
[objectG (phase archive objectS)
inputsG (monad.each ! (phase archive) inputsS)]
(in (_.do methodS inputsG objectG))))]))
@@ -93,37 +89,35 @@
[object::none object::none? _.none]
)
-(def object
- Bundle
- (<| (/.prefix "object")
- (|> /.empty
- (/.install "get" object::get)
- (/.install "do" object::do)
- (/.install "none" (nullary object::none))
- (/.install "none?" (unary object::none?))
- )))
+(def with_object_extensions
+ (-> Bundle Bundle)
+ (|>> (dictionary.has "python_object_get#|translation" object::get)
+ (dictionary.has "python_object_do#|translation" object::do)
+ (dictionary.has "python_object_none#|translation" (nullary object::none))
+ (dictionary.has "python_object_none?#|translation" (unary object::none?))
+ ))
(def python::constant
(custom
[<s>.text
- (function (_ extension phase archive name)
- (do ////////phase.monad
+ (function (_ phase archive name)
+ (do phase.monad
[]
(in (_.var name))))]))
(def python::import
(custom
[<s>.text
- (function (_ extension phase archive module)
- (do ////////phase.monad
+ (function (_ phase archive module)
+ (do phase.monad
[]
(in (_.apply (list (_.string module)) (_.var "__import__")))))]))
(def python::apply
(custom
[(all <>.and <s>.any (<>.some <s>.any))
- (function (_ extension phase archive [abstractionS inputsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [abstractionS inputsS])
+ (do [! phase.monad]
[abstractionG (phase archive abstractionS)
inputsG (monad.each ! (phase archive) inputsS)]
(in (_.apply inputsG abstractionG))))]))
@@ -131,8 +125,8 @@
(def python::function
(custom
[(all <>.and <s>.i64 <s>.any)
- (function (_ extension phase archive [arity abstractionS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [arity abstractionS])
+ (do [! phase.monad]
[abstractionG (phase archive abstractionS)
.let [variable (is (-> Text (Operation SVar))
(|>> translation.symbol
@@ -148,22 +142,21 @@
(def python::exec
(custom
[(all <>.and <s>.any <s>.any)
- (function (_ extension phase archive [codeS globalsS])
- (do [! ////////phase.monad]
+ (function (_ phase archive [codeS globalsS])
+ (do [! phase.monad]
[codeG (phase archive codeS)
globalsG (phase archive globalsS)]
(in (//runtime.lux::exec codeG globalsG))))]))
(def .public bundle
Bundle
- (<| (/.prefix "python")
- (|> /.empty
- (dictionary.composite ..array)
- (dictionary.composite ..object)
-
- (/.install "constant" python::constant)
- (/.install "import" python::import)
- (/.install "apply" python::apply)
- (/.install "function" python::function)
- (/.install "exec" python::exec)
- )))
+ (|> extension.empty
+ with_array_extensions
+ with_object_extensions
+
+ (dictionary.has "python_constant#|translation" python::constant)
+ (dictionary.has "python_import#|translation" python::import)
+ (dictionary.has "python_apply#|translation" python::apply)
+ (dictionary.has "python_function#|translation" python::function)
+ (dictionary.has "python_exec#|translation" python::exec)
+ ))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
index 4555c1b6a..bc59b8d93 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
@@ -35,46 +35,45 @@
(exception.def .public cannot_recur_as_an_expression)
-(def .public (expression archive synthesis)
- Phase
- (when synthesis
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (//////phase#in (<translator> value))])
- ([////synthesis.bit /primitive.bit]
- [////synthesis.i64 /primitive.i64]
- [////synthesis.f64 /primitive.f64]
- [////synthesis.text /primitive.text])
+(def .public (expression extender lux)
+ (-> ///extension.Extender Lux Phase)
+ (function (expression archive synthesis)
+ (when synthesis
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (//////phase#in (<translator> value))])
+ ([////synthesis.bit /primitive.bit]
+ [////synthesis.i64 /primitive.i64]
+ [////synthesis.f64 /primitive.f64]
+ [////synthesis.text /primitive.text])
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (<translator> expression archive value)])
- ([////synthesis.variant /structure.variant]
- [////synthesis.tuple /structure.tuple]
-
- [////synthesis.branch/exec /when.exec]
- [////synthesis.branch/let /when.let]
- [////synthesis.branch/if /when.if]
- [////synthesis.branch/get /when.get]
-
- [////synthesis.function/apply /function.apply])
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (<translator> expression archive value)])
+ ([////synthesis.variant /structure.variant]
+ [////synthesis.tuple /structure.tuple]
+
+ [////synthesis.branch/exec /when.exec]
+ [////synthesis.branch/let /when.let]
+ [////synthesis.branch/if /when.if]
+ [////synthesis.branch/get /when.get]
+
+ [////synthesis.function/apply /function.apply])
- (^.with_template [<tag> <translator>]
- [(<tag> value)
- (<translator> ///extension/common.statement expression archive value)])
- ([////synthesis.branch/when /when.when]
- [////synthesis.loop/scope /loop.scope]
- [////synthesis.function/abstraction /function.function])
+ (^.with_template [<tag> <translator>]
+ [(<tag> @ value)
+ (<translator> ///extension/common.statement expression archive value)])
+ ([////synthesis.branch/when /when.when]
+ [////synthesis.loop/scope /loop.scope]
+ [////synthesis.function/abstraction /function.function])
- (////synthesis.loop/again updates)
- (//////phase.except ..cannot_recur_as_an_expression [])
+ (////synthesis.loop/again @ updates)
+ (//////phase.except ..cannot_recur_as_an_expression [])
- {////synthesis.#Reference value}
- (//reference.reference /reference.system archive value)
+ [@ {////synthesis.#Reference value}]
+ (//reference.reference /reference.system archive value)
- {////synthesis.#Extension extension}
- (///extension.apply archive expression extension)))
-
-(def .public translate
- Phase
- ..expression)
+ [@ {////synthesis.#Extension [name parameters]}]
+ (///extension.application extender lux expression archive .Translation false name parameters
+ (|>>)
+ (function (_ _) {.#None})))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
index 5ee68797a..f176eb403 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except function)
+ [lux (.except Analysis Synthesis function)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
index 3d4943710..1d4a4a01b 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Scope)
+ [lux (.except Scope Synthesis)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
index 723796d21..cdca9d0b1 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Variant Tuple)
+ [lux (.except Variant Tuple Synthesis)
[abstract
["[0]" monad (.only do)]]
[meta
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
index 4a92d11ef..9dadc3fab 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except when exec let if symbol)
+ [lux (.except Synthesis when exec let if symbol)
[abstract
["[0]" monad (.only do)]]
[data
diff --git a/stdlib/source/library/lux/world/time/instant.lux b/stdlib/source/library/lux/world/time/instant.lux
index 233c8d511..db49c57c6 100644
--- a/stdlib/source/library/lux/world/time/instant.lux
+++ b/stdlib/source/library/lux/world/time/instant.lux
@@ -167,8 +167,8 @@
(|> ("js object do" "getTime" date [])
(as Frac)
.f64_int#))
- @.python (let [time ("python import" "time")]
- (|> ("python object do" "time" time [])
+ @.python (let [time (.python_import# "time")]
+ (|> (.python_object_do# "time" time [])
(as Frac)
(f.* +1,000.0)
.f64_int#))
diff --git a/stdlib/source/test/lux/meta/target/python.lux b/stdlib/source/test/lux/meta/target/python.lux
index 7b0b0d77a..13510a10b 100644
--- a/stdlib/source/test/lux/meta/target/python.lux
+++ b/stdlib/source/test/lux/meta/target/python.lux
@@ -440,7 +440,7 @@
random.nat)
environment (..dict [])]
(exec
- ("python exec" (/.code (it (/.var $output))) (as_expected environment))
+ (.python_exec# (/.code (it (/.var $output))) (as_expected environment))
(Dict::get $output environment))))
(def test|access
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index 1e79c9480..83a6df975 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -80,7 +80,7 @@
(,, (.static @.python))
(.|> <size>
[]
- ("python apply" (.as ffi.Function ("python constant" "bytearray")))
+ (.python_apply# (.as ffi.Function (.python_constant# "bytearray")))
(.as ..Binary))
(,, (.static @.scheme))
@@ -107,7 +107,7 @@
(,, (.static @.python))
(.|> <it>
(.as (array.Array (.I64 .Any)))
- "python array length")
+ .python_array_length#)
(,, (.static @.scheme))
(..bytevector-length [<it>])
@@ -145,7 +145,7 @@
(,, (.static @.python))
(.|> <it>
(.as (array.Array .I64))
- ("python array read" <index>))
+ (.python_array_read# <index>))
(,, (.static @.scheme))
(..bytevector-u8-ref [<it> <index>])
@@ -228,7 +228,7 @@
(.|> <it>
(.is ..Binary)
(.as (array.Array (.I64 .Any)))
- ("python array write" <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any))))
+ (.python_array_write# <index> (.|> <value> (.i64_and# <byte>) (.is (.I64 .Any))))
(.as ..Binary))
(,, (.static @.scheme))
diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux
index c8c98508c..8c1d0ce47 100644
--- a/stdlib/source/unsafe/lux/data/collection/array.lux
+++ b/stdlib/source/unsafe/lux/data/collection/array.lux
@@ -46,7 +46,7 @@
(.is (..Array <item_type>)))
(,, (.static @.js)) ("js array new" size)
- (,, (.static @.python)) ("python array new" size)
+ (,, (.static @.python)) (.python_array_new# size)
(,, (.static @.lua)) ("lua array new" size)
(,, (.static @.ruby)) ("ruby array new" size)
(,, (.static @.php)) ("php array new" size)
@@ -69,7 +69,7 @@
(.as .Nat))
(,, (.static @.js)) ("js array length" array)
- (,, (.static @.python)) ("python array length" array)
+ (,, (.static @.python)) (.python_array_length# array)
(,, (.static @.lua)) ("lua array length" array)
(,, (.static @.ruby)) ("ruby array length" array)
(,, (.static @.php)) ("php array length" array)
@@ -96,7 +96,7 @@
.jvm_object_null?#)
(,, (.static @.js)) (,, (lacks?' "js array read" "js object undefined?" index array))
- (,, (.static @.python)) (,, (lacks?' "python array read" "python object none?" index array))
+ (,, (.static @.python)) (,, (lacks?' .python_array_read# .python_object_none?# index array))
(,, (.static @.lua)) (,, (lacks?' "lua array read" "lua object nil?" index array))
(,, (.static @.ruby)) (,, (lacks?' "ruby array read" "ruby object nil?" index array))
(,, (.static @.php)) (,, (lacks?' "php array read" "php object null?" index array))
@@ -121,7 +121,7 @@
(.jvm_array_read_object# (,, (jvm_int index)) array)
(,, (.static @.js)) ("js array read" index array)
- (,, (.static @.python)) ("python array read" index array)
+ (,, (.static @.python)) (.python_array_read# index array)
(,, (.static @.lua)) ("lua array read" index array)
(,, (.static @.ruby)) ("ruby array read" index array)
(,, (.static @.php)) ("php array read" index array)
@@ -142,7 +142,7 @@
.as_expected)
(,, (.static @.js)) ("js array write" index (.as_expected value) array)
- (,, (.static @.python)) ("python array write" index (.as_expected value) array)
+ (,, (.static @.python)) (.python_array_write# index (.as_expected value) array)
(,, (.static @.lua)) ("lua array write" index (.as_expected value) array)
(,, (.static @.ruby)) ("ruby array write" index (.as_expected value) array)
(,, (.static @.php)) ("php array write" index (.as_expected value) array)
@@ -163,7 +163,7 @@
(..has! index (.as_expected (is <item_type> (.jvm_object_null#))) array)
(,, (.static @.js)) ("js array delete" index array)
- (,, (.static @.python)) ("python array delete" index array)
+ (,, (.static @.python)) (.python_array_delete# index array)
(,, (.static @.lua)) ("lua array delete" index array)
(,, (.static @.ruby)) ("ruby array delete" index array)
(,, (.static @.php)) ("php array delete" index array)