From 442d1557b879a8a4bd76f441f72a17bfb71cf05f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 17 Jul 2021 22:48:54 -0400 Subject: Now allowing compilers to generate custom-named outputs. --- lux-jvm/source/luxc/lang/translation/jvm.lux | 32 ++++++++++++++-------- .../luxc/lang/translation/jvm/extension/host.lux | 2 +- .../source/luxc/lang/translation/jvm/function.lux | 2 +- .../source/luxc/lang/translation/jvm/runtime.lux | 12 ++++---- 4 files changed, 29 insertions(+), 19 deletions(-) (limited to 'lux-jvm/source/luxc/lang') diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux index 4cd521f9f..0f6ba6744 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm.lux @@ -14,6 +14,7 @@ [data [binary (#+ Binary)] ["." product] + ["." maybe] ["." text ("#@." hash) ["%" format (#+ format)]] [collection @@ -145,11 +146,13 @@ (loader.store class_name class_bytecode library))] (loader.load class_name loader)))) -(def: (define! library loader context valueI) - (-> Library java/lang/ClassLoader generation.Context Inst (Try [Text Any Definition])) +(def: (define! library loader context custom valueI) + (-> Library java/lang/ClassLoader generation.Context (Maybe Text) Inst (Try [Text Any Definition])) (do try.monad [[value definition] (evaluate! library loader context valueI)] - (wrap [(..class_name context) value definition]))) + (wrap [(maybe.default (..class_name context) + custom) + value definition]))) (def: #export host (IO Host) @@ -170,19 +173,26 @@ (def: (ingest context bytecode) [(..class_name context) bytecode]) - (def: (re_learn context [_ bytecode]) + (def: (re_learn context custom [_ bytecode]) (io.run - (loader.store (..class_name context) bytecode library))) + (loader.store (maybe.default (..class_name context) custom) bytecode library))) - (def: (re_load context [_ bytecode]) + (def: (re_load context custom [_ bytecode]) (io.run (do (try.with io.monad) - [#let [class_name (..class_name context)] + [#let [class_name (maybe.default (..class_name context) custom)] _ (loader.store class_name bytecode library) class (loader.load class_name loader)] (\ io.monad wrap (..class_value class_name class)))))))))) -(def: #export $Variant (type.array ..$Value)) -(def: #export $Tuple (type.array ..$Value)) -(def: #export $Runtime (type.class (..class_name [0 0]) (list))) -(def: #export $Function (type.class (..class_name [0 1]) (list))) +(def: #export $Variant + (type.array ..$Value)) + +(def: #export $Tuple + (type.array ..$Value)) + +(def: #export $Runtime + (type.class (..class_name [0 0]) (list))) + +(def: #export $Function + (type.class (..class_name [0 1]) (list))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 69e63ab71..441a415ee 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -1053,7 +1053,7 @@ (..with_anonymous_init class total_environment super_class inputsTI) method_definitions))]] _ (generation.execute! directive) - _ (generation.save! artifact_id directive)] + _ (generation.save! artifact_id #.None directive)] (..anonymous_instance generate archive class total_environment)))])) (def: bundle::class diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index f524dc097..394b0b7b5 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -328,7 +328,7 @@ _ (generation.execute! directive) _ (case forced_context #.None - (generation.save! (product.right function_context) directive) + (generation.save! (product.right function_context) #.None directive) (#.Some function_context) (wrap []))] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux index 20bd9bd9e..e0426f363 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux @@ -339,7 +339,7 @@ 0) (def: translate_runtime - (Operation [artifact.ID Binary]) + (Operation [artifact.ID (Maybe Text) Binary]) (let [runtime_class (..reflection //.$Runtime) bytecode ($d.class #$.V1_6 #$.Public $.finalC runtime_class (list) (type.class "java.lang.Object" (list)) (list) (|>> adt_methods @@ -349,14 +349,14 @@ directive [runtime_class bytecode]] (do phase.monad [_ (generation.execute! directive) - _ (generation.save! ..runtime_id directive)] - (wrap [..runtime_id bytecode])))) + _ (generation.save! ..runtime_id #.None directive)] + (wrap [..runtime_id #.None bytecode])))) (def: function_id 1) (def: translate_function - (Operation [artifact.ID Binary]) + (Operation [artifact.ID (Maybe Text) Binary]) (let [applyI (|> (enum.range n.enum 2 num_apply_variants) (list@map (function (_ arity) ($d.method #$.Public $.noneM apply_method (apply_signature arity) @@ -386,8 +386,8 @@ directive [function_class bytecode]] (do phase.monad [_ (generation.execute! directive) - _ (generation.save! ..function_id directive)] - (wrap [..function_id bytecode])))) + _ (generation.save! ..function_id #.None directive)] + (wrap [..function_id #.None bytecode])))) (def: #export translate (Operation [Registry Output]) -- cgit v1.2.3