aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
authorEduardo Julian2022-11-19 21:23:04 -0400
committerEduardo Julian2022-11-19 21:23:04 -0400
commitd4c72c03c1a47fe388ec36e973db17cb95dfdcfb (patch)
treeaef020e7b5f351cc0fd20e0656edc6a9f853bc62 /stdlib/source/library
parent6aa4fac0c97264a2b1186063c062ae0873582f54 (diff)
Got the tests to compile again for Python.
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux.lux11
-rw-r--r--stdlib/source/library/lux/ffi/export.py.lux37
-rw-r--r--stdlib/source/library/lux/meta.lux77
-rw-r--r--stdlib/source/library/lux/meta/extension.lux97
-rw-r--r--stdlib/source/library/lux/test/coverage.lux5
5 files changed, 124 insertions, 103 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 710521e74..54daff3b3 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -5661,16 +5661,7 @@
imports)
=module (` (.module# (, =imports)))]
g!_ (..generated_symbol "")]
- (in {#Item =module
- (for "Python"
- ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter.
- ... Without it, I get this strange error
- ... {library/lux/tool/compiler/language/lux/generation.no_buffer_for_saving_code}
- ... Artifact ID: 0
- ... Which only ever happens for the Python compiler.
- (list#partial (` (.def# (, g!_) [] #0))
- =refers)
- =refers)})))))
+ (in {#Item =module =refers})))))
(type .public Immediate_UnQuote
(Primitive "#Macro/Immediate_UnQuote"))
diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux
index 6e69e2a51..d46e632aa 100644
--- a/stdlib/source/library/lux/ffi/export.py.lux
+++ b/stdlib/source/library/lux/ffi/export.py.lux
@@ -11,11 +11,8 @@
[collection
["[0]" list (.use "[1]#[0]" monad mix)]
["[0]" set]]]
- [math
- ["[0]" random]]
["[0]" meta (.only)
[extension (.only declaration)]
- ["[0]" static]
["[0]" code (.only)
["<[1]>" \\parser]]
[macro
@@ -47,19 +44,19 @@
<code>.any)))
meta.lifted))
-(with_expansions [<extension> (static.random (|>> %.nat (%.format "python export ") code.text)
- random.nat)]
- (declaration (<extension> self phase archive [name <code>.text
- term <code>.any])
+(def .public export_one
+ (declaration (_ phase archive [name <code>.text
+ term <code>.any])
(do [! phase.monad]
[next declaration.analysis
[_ term] (<| declaration.lifted_analysis
type.inferring
(next archive term))
+ lux (declaration.lifted_analysis meta.compiler_state)
next declaration.synthesis
term (declaration.lifted_synthesis
- (next archive term))
+ (next lux archive term))
dependencies (declaration.lifted_translation
(dependency.dependencies archive term))
@@ -67,7 +64,7 @@
next declaration.translation
[interim_artifacts term] (declaration.lifted_translation
(translation.with_interim_artifacts archive
- (next archive term)))
+ (next lux archive term)))
_ (declaration.lifted_translation
(do !
@@ -76,15 +73,15 @@
_ (translation.execute! code)
_ (translation.save! @self {.#None} code)]
(translation.log! (%.format "Export " (%.text name)))))]
- (in declaration.no_requirements)))
+ (in declaration.no_requirements))))
- (def .public export
- (syntax (_ [exports (<>.many <code>.any)])
- (let [! meta.monad]
- (|> exports
- (monad.each ! expansion.complete)
- (at ! each (|>> list#conjoint
- (monad.each ! ..definition)))
- (at ! conjoint)
- (at ! each (list#each (function (_ [name term])
- (` (<extension> (, (code.text name)) (, term)))))))))))
+(def .public export
+ (syntax (_ [exports (<>.many <code>.any)])
+ (let [! meta.monad]
+ (|> exports
+ (monad.each ! expansion.complete)
+ (at ! each (|>> list#conjoint
+ (monad.each ! ..definition)))
+ (at ! conjoint)
+ (at ! each (list#each (function (_ [name term])
+ (` (..export_one (, (code.text name)) (, term))))))))))
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index 21a2db376..57476530a 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -499,35 +499,54 @@
(-> Text (Meta (List [Text [Bit Definition]])))
(do [! ..monad]
[it (..globals module)
- .let [it (list.all (function (_ [name [exported? global]])
- (when global
- {.#Alias de_aliased}
- {.#Some [name exported? {.#Left de_aliased}]}
-
- {.#Definition definition}
- {.#Some [name exported? {.#Right definition}]}
-
- {.#Default _}
- {.#None}))
- it)]]
- (monad.each ! (function (again [name [exported? it]])
- (when it
- {.#Left de_aliased}
- (do !
- [[_ definition] (..definition de_aliased)]
- (when definition
- {.#Alias de_aliased}
- (again [name [exported? {.#Left de_aliased}]])
-
- {.#Definition definition}
- (in [name [exported? definition]])
-
- {.#Default _}
- (undefined)))
-
- {.#Right definition}
- (in [name [exported? definition]])))
- it)))
+ .let [input (is (List [Text Bit (Either Symbol Definition)])
+ (list.all (function (_ [name [exported? global]])
+ (when global
+ {.#Alias de_aliased}
+ {.#Some [name exported? {.#Left de_aliased}]}
+
+ {.#Definition definition}
+ {.#Some [name exported? {.#Right definition}]}
+
+ {.#Default _}
+ {.#None}))
+ it))]]
+ (function (_ lux)
+ (loop (next [input input
+ output (is (List [Text [Bit Definition]])
+ (list))])
+ (when input
+ (list)
+ {try.#Success [lux output]}
+
+ (list.partial [name exported? it] input)
+ (let [real_definition (is (Try Definition)
+ (loop (again [it it])
+ (when it
+ {.#Left de_aliased}
+ (when (..definition de_aliased lux)
+ {try.#Success [_ [_ definition]]}
+ (when definition
+ {.#Alias de_aliased}
+ (again {.#Left de_aliased})
+
+ {.#Definition definition}
+ {try.#Success definition}
+
+ {.#Default _}
+ {try.#Failure "Cannot de-alias a default global."})
+
+ {try.#Failure error}
+ {try.#Failure error})
+
+ {.#Right definition}
+ {try.#Success definition})))]
+ (when real_definition
+ {try.#Success it}
+ (next input (list.partial [name [exported? it]] output))
+
+ {try.#Failure error}
+ {try.#Failure error})))))))
(def .public (exports module_name)
(-> Text (Meta (List [Text Definition])))
diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux
index 4169598cd..9d43881f1 100644
--- a/stdlib/source/library/lux/meta/extension.lux
+++ b/stdlib/source/library/lux/meta/extension.lux
@@ -1,45 +1,58 @@
-(.require
- [library
- [lux (.except)
- [abstract
- ["[0]" monad]]
- [control
- ["<>" parser (.use "[1]#[0]" monad)]]
- [data
- ["[0]" product]
- [collection
- ["[0]" list (.use "[1]#[0]" functor)]]]
- [meta
- ["@" target (.only)
- [jvm
- ["_" bytecode (.only Bytecode)]]]
- ["[0]" code (.only)
- ["<c>" \\parser (.only Parser)]]
- [macro (.only with_symbols)
- [syntax (.only syntax)]
- ["[0]" template]]
- [compiler
- ["[0]" phase]
- [language
- [lux
- ["[0]" analysis (.only)
- ["<a>" \\parser]]
- ["[0]" synthesis (.only)
- ["<s>" \\parser]]
- ["[0]" translation]
- ["[0]" declaration]
- [phase
- [translation
- ["[0]" jvm
- ["[1]" runtime]]
- ["[0]" js
- ["[1]" runtime]]
- ["[0]" lua
- ["[1]" runtime]]
- ["[0]" python
- ["[1]" runtime]]
- ["[0]" ruby
- ["[1]" runtime]]]]]]]]]])
+(.`` (.`` (.require
+ [library
+ [lux (.except)
+ [abstract
+ ["[0]" monad]]
+ [control
+ ["<>" parser (.use "[1]#[0]" monad)]]
+ [data
+ ["[0]" product]
+ [collection
+ ["[0]" list (.use "[1]#[0]" functor)]]]
+ [meta
+ ["@" target (.only)
+ (.,, (.for "JVM"
+ [jvm
+ ["_" bytecode (.only Bytecode)]]
+
+ ... else
+ [/]))]
+ ["[0]" code (.only)
+ ["<c>" \\parser (.only Parser)]]
+ [macro (.only with_symbols)
+ [syntax (.only syntax)]
+ ["[0]" template]]
+ [compiler
+ ["[0]" phase]
+ [language
+ [lux
+ ["[0]" analysis (.only)
+ ["<a>" \\parser]]
+ ["[0]" synthesis (.only)
+ ["<s>" \\parser]]
+ ["[0]" translation]
+ ["[0]" declaration]
+ [phase
+ [translation
+ (.,, (.for "JVM"
+ ["[0]" jvm
+ ["[1]" runtime]]
+
+ "JavaScript"
+ ["[0]" js
+ ["[1]" runtime]]
+
+ "Lua"
+ ["[0]" lua
+ ["[1]" runtime]]
+
+ "Python"
+ ["[0]" python
+ ["[1]" runtime]]
+
+ "Ruby"
+ ["[0]" ruby
+ ["[1]" runtime]]))]]]]]]]])))
(with_template [<any> <end> <and> <result> <name> <extension_type> <handler_type>]
[(def .public <name>
diff --git a/stdlib/source/library/lux/test/coverage.lux b/stdlib/source/library/lux/test/coverage.lux
index 86b1314cc..e717d27ed 100644
--- a/stdlib/source/library/lux/test/coverage.lux
+++ b/stdlib/source/library/lux/test/coverage.lux
@@ -42,5 +42,6 @@
(-> Text Text Coverage)
(|> encoding
(text.all_split_by ..separator)
- (list#each (|>> [module]))
- (set.of_list symbol.hash)))
+ (list#mix (function (_ short it)
+ (set.has [module short] it))
+ (set.empty symbol.hash))))