aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/library/lux/meta.lux58
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux68
2 files changed, 96 insertions, 30 deletions
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index 4a8658eb1..a32be80ad 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -1,30 +1,30 @@
(.using
- [library
- [lux {"-" type macro try}
- [abstract
- [functor {"+" Functor}]
- [apply {"+" Apply}]
- ["[0]" monad {"+" Monad do}]]
- [control
- ["[0]" maybe]
- ["[0]" try {"+" Try}]]
- [data
- ["[0]" product]
- ["[0]" text ("[1]#[0]" monoid order)]
- [collection
- ["[0]" list ("[1]#[0]" monoid monad)]
- [dictionary
- ["[0]" plist]]]]
- [macro
- ["[0]" code]]
- [math
- [number
- ["n" nat]
- ["i" int]]]
- [meta
- ["[0]" symbol ("[1]#[0]" codec equivalence)]]]]
- [/
- ["[0]" location]])
+ [library
+ [lux {"-" type macro try}
+ [abstract
+ [functor {"+" Functor}]
+ [apply {"+" Apply}]
+ ["[0]" monad {"+" Monad do}]]
+ [control
+ ["[0]" maybe]
+ ["[0]" try {"+" Try}]]
+ [data
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" monoid order)]
+ [collection
+ ["[0]" list ("[1]#[0]" monoid monad)]
+ [dictionary
+ ["[0]" plist]]]]
+ [macro
+ ["[0]" code]]
+ [math
+ [number
+ ["n" nat]
+ ["i" int]]]
+ [meta
+ ["[0]" symbol ("[1]#[0]" codec equivalence)]]]]
+ [/
+ ["[0]" location]])
... (type: (Meta a)
... (-> Lux (Try [Lux a])))
@@ -664,3 +664,9 @@
{try.#Failure error}
{try.#Success [lux {try.#Failure error}]})))
+
+(def: .public target
+ (Meta Text)
+ (function (_ lux)
+ {try.#Success [lux
+ (value@ [.#info .#target] lux)]}))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
index a0ed6f3e6..12a13781c 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
@@ -1,6 +1,7 @@
(.using
[library
[lux "*"
+ ["@" target]
["[0]" meta]
[abstract
["[0]" monad {"+" do}]]
@@ -11,17 +12,20 @@
["<>" parser
["<[0]>" code {"+" Parser}]]]
[data
+ ["[0]" binary]
["[0]" product]
["[0]" text
["%" format {"+" format}]]
[collection
- ["[0]" dictionary]]]
+ ["[0]" dictionary]
+ ["[0]" array]
+ ["[0]" list ("[1]#[0]" functor)]]]
[macro
["[0]" code]]
[math
[number
["n" nat]]]
- ["[0]" type {"+" :sharing}
+ ["[0]" type {"+" :sharing} ("[1]#[0]" equivalence)
["[0]" check]]]]
["[0]" /// {"+" Extender}
["[1][0]" bundle]
@@ -351,6 +355,50 @@
(define_alias alias def_name)))]
(in /////directive.no_requirements)))]))
+... TODO: Stop requiring these types and the "swapped" function below to make types line-up.
+(template [<name> <anonymous>]
+ [(def: <name>
+ Type
+ (with_expansions [<original> binary.Binary]
+ (let [_ <original>]
+ {.#Named (symbol <original>)
+ <anonymous>})))]
+
+ [Binary|Python (Primitive "bytearray")]
+ [Binary|DEFAULT (type (array.Array (I64 Any)))]
+ )
+
+(def: (swapped original replacement)
+ (-> Type Type Type Type)
+ (function (again type)
+ (if (type#= original type)
+ replacement
+ (case type
+ {.#Primitive name parameters}
+ {.#Primitive name (list#each again parameters)}
+
+ (^template [<tag>]
+ [{<tag> left right}
+ {<tag> (again left) (again right)}])
+ ([.#Sum]
+ [.#Product]
+ [.#Function]
+ [.#Apply])
+
+ (^or {.#Parameter _}
+ {.#Var _}
+ {.#Ex _})
+ type
+
+ (^template [<tag>]
+ [{<tag> closure body}
+ {<tag> closure (again body)}])
+ ([.#UnivQ]
+ [.#ExQ])
+
+ {.#Named name anonymous}
+ {.#Named name (again anonymous)}))))
+
(template [<description> <mame> <def_type> <type> <scope> <definer>]
[(def: (<mame> [anchorT expressionT directiveT] extender)
(All (_ anchor expression directive)
@@ -360,9 +408,21 @@
(case inputsC+
(^ (list nameC valueC))
(do phase.monad
- [[_ _ name] (evaluate! archive Text nameC)
+ [target_platform (/////directive.lifted_analysis
+ (///.lifted meta.target))
+ [_ _ name] (evaluate! archive Text nameC)
[_ handlerV] (<definer> archive (:as Text name)
- (type <def_type>)
+ (let [raw_type (type <def_type>)]
+ (case target_platform
+ (^or (^ (static @.jvm))
+ (^ (static @.js)))
+ raw_type
+
+ (^ (static @.python))
+ (swapped binary.Binary Binary|Python raw_type)
+
+ _
+ (swapped binary.Binary Binary|DEFAULT raw_type)))
valueC)
_ (<| <scope>
(///.install extender (:as Text name))