diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/macro.lux')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/macro.lux | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/macro.lux b/stdlib/source/lux/tool/compiler/phase/macro.lux index dbc201ca3..ddbde68ad 100644 --- a/stdlib/source/lux/tool/compiler/phase/macro.lux +++ b/stdlib/source/lux/tool/compiler/phase/macro.lux @@ -11,8 +11,7 @@ [collection [array (#+ Array)] ["." list ("#;." functor)]]] - ["." macro] - ["." host (#+ import:)]] + ["." macro]] ["." //]) (exception: #export (expansion-failed {macro Name} {inputs (List Code)} {error Text}) @@ -30,43 +29,9 @@ (list;map (|>> %code (format text.new-line text.tab))) (text.join-with ""))])) -(import: #long java/lang/reflect/Method - (invoke [java/lang/Object (Array java/lang/Object)] #try java/lang/Object)) - -(import: #long (java/lang/Class c) - (getMethod [java/lang/String (Array (java/lang/Class java/lang/Object))] #try java/lang/reflect/Method)) - -(import: #long java/lang/Object - (getClass [] (java/lang/Class java/lang/Object))) - -(def: _object-class - (java/lang/Class java/lang/Object) - (host.class-for java/lang/Object)) - -(def: _apply-args - (Array (java/lang/Class java/lang/Object)) - (|> (host.array (java/lang/Class java/lang/Object) 2) - (host.array-write 0 _object-class) - (host.array-write 1 _object-class))) - (type: #export Expander (-> Macro (List Code) Lux (Error (Error [Lux (List Code)])))) -(def: #export (jvm macro inputs lux) - Expander - (do error.monad - [apply-method (|> macro - (:coerce java/lang/Object) - (java/lang/Object::getClass) - (java/lang/Class::getMethod "apply" _apply-args))] - (:coerce (Error (Error [Lux (List Code)])) - (java/lang/reflect/Method::invoke - (:coerce java/lang/Object macro) - (|> (host.array java/lang/Object 2) - (host.array-write 0 (:coerce java/lang/Object inputs)) - (host.array-write 1 (:coerce java/lang/Object lux))) - apply-method)))) - (def: #export (expand expander name macro inputs) (-> Expander Name Macro (List Code) (Meta (List Code))) (function (_ state) |