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-js/source/program.lux | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lux-js/source') diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 6163c2dfa..295aba2ce 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -465,9 +465,10 @@ [?output (javax/script/ScriptEngine::eval (_.code input) interpreter)] (wrap []))) - (def: (define! interpreter context input) - (-> javax/script/ScriptEngine Context _.Expression (Try [Text Any _.Statement])) - (let [global (reference.artifact context) + (def: (define! interpreter context custom input) + (-> javax/script/ScriptEngine Context (Maybe Text) _.Expression (Try [Text Any _.Statement])) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.define @global input)] @@ -488,10 +489,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (..execute! interpreter content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (..execute! interpreter content)] (..evaluate! interpreter context (_.var (reference.artifact context)))))))))) @@ -525,9 +526,10 @@ [?output (..eval (_.code input))] (wrap []))) - (def: (define! context input) - (-> Context _.Expression (Try [Text Any _.Statement])) - (let [global (reference.artifact context) + (def: (define! context custom input) + (-> Context (Maybe Text) _.Expression (Try [Text Any _.Statement])) + (let [global (maybe.default (reference.artifact context) + custom) @global (_.var global)] (do try.monad [#let [definition (_.define @global input)] @@ -546,10 +548,10 @@ (def: (ingest context content) (|> content (\ utf8.codec decode) try.assume (:as _.Statement))) - (def: (re_learn context content) + (def: (re_learn context custom content) (..execute! content)) - (def: (re_load context content) + (def: (re_load context custom content) (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) -- cgit v1.2.3