diff options
author | Eduardo Julian | 2020-10-12 20:22:31 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-10-12 20:22:31 -0400 |
commit | 00d5ccbc043960037f644d4ff09b6a46fd0093d0 (patch) | |
tree | 9515edc59fb511fa30e68c832d669654853ff702 /stdlib/source/lux/tool | |
parent | 5b222d040ee361dd4022e88488a6bcef3ca40a71 (diff) |
Type-checking macros via the Macro' type from the standard library.
Diffstat (limited to 'stdlib/source/lux/tool')
-rw-r--r-- | stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 72096032a..59241f43d 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -192,16 +192,32 @@ (def: (caster input output) (-> Type Type Handler) - (function (_ extension-name analyse archive args) - (case args - (^ (list valueC)) - (do ////.monad + (..custom + [<c>.any + (function (_ extension-name phase archive valueC) + (do {@ ////.monad} [_ (typeA.infer output)] (typeA.with-type input - (analyse archive valueC))) - - _ - (////analysis.throw ///.incorrect-arity [extension-name 1 (list.size args)])))) + (phase archive valueC))))])) + +(def: lux::macro + Handler + (..custom + [<c>.any + (function (_ extension-name phase archive valueC) + (do {@ ////.monad} + [_ (typeA.infer .Macro) + input-type (loop [input-name (name-of .Macro')] + (do @ + [input-type (///.lift (meta.find-def (name-of .Macro')))] + (case input-type + (#.Definition [exported? def-type def-data def-value]) + (wrap (:coerce Type def-value)) + + (#.Alias real-name) + (recur real-name))))] + (typeA.with-type input-type + (phase archive valueC))))])) (def: (bundle::lux eval) (-> Eval Bundle) @@ -211,7 +227,7 @@ (///bundle.install "try" lux::try) (///bundle.install "check" (lux::check eval)) (///bundle.install "coerce" (lux::coerce eval)) - (///bundle.install "macro" (..caster .Macro' .Macro)) + (///bundle.install "macro" ..lux::macro) (///bundle.install "check type" (..caster .Type .Type)) (///bundle.install "in-module" lux::in-module))) |