(.module: [lux #* [control [monad (#+ do)] ["ex" exception (#+ exception:)]] [io] [concurrency [atom (#+ Atom atom)]] [data [error (#+ Error)] [text ("text/" Hash) format] [collection [dictionary (#+ Dictionary)]]] [macro] [host (#+ import:)] [world [blob (#+ Blob)]] [language [name] [reference (#+ Register)] ["." compiler]]] ## [luxc ## [lang ## [host ## ["." jvm ## [type]]]]] ) ## (def: #export (with-artifacts action) ## (All [a] (-> (Meta a) (Meta [Artifacts a]))) ## (function (_ compiler) ## (case (action (update@ #.host ## (|>> (:coerce Host) ## (set@ #artifacts (dictionary.new text.Hash)) ## (:coerce Nothing)) ## compiler)) ## (#error.Success [compiler' output]) ## (#error.Success [(update@ #.host ## (|>> (:coerce Host) ## (set@ #artifacts (|> (get@ #.host compiler) (:coerce Host) (get@ #artifacts))) ## (:coerce Nothing)) ## compiler') ## [(|> compiler' (get@ #.host) (:coerce Host) (get@ #artifacts)) ## output]]) ## (#error.Error error) ## (#error.Error error)))) ## (def: #export (load-definition compiler) ## (-> Lux (-> Ident Blob (Error Any))) ## (function (_ (^@ def-ident [def-module def-name]) def-bytecode) ## (let [normal-name (format (name.normalize def-name) (%n (text/hash def-name))) ## class-name (format (text.replace-all "/" "." def-module) "." normal-name)] ## (<| (macro.run compiler) ## (do macro.Monad ## [_ (..store-class class-name def-bytecode) ## class (..load-class class-name)] ## (case (do error.Monad ## [field (Class::getField [..value-field] class)] ## (Field::get [#.None] field)) ## (#error.Success (#.Some def-value)) ## (wrap def-value) ## (#error.Success #.None) ## (compiler.throw invalid-definition-value (%ident def-ident)) ## (#error.Error error) ## (compiler.throw cannot-load-definition ## (format "Definition: " (%ident def-ident) "\n" ## "Error:\n" ## error))))))))