aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source/luxc/lang/translation/jvm/function.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-08 23:59:00 -0400
committerEduardo Julian2021-07-08 23:59:00 -0400
commitf3e869d0246e956399ec31a074c6c6299ff73602 (patch)
treeba67c7713bbe4ec48232f58a4b324bd364111f95 /lux-jvm/source/luxc/lang/translation/jvm/function.lux
parent2b909032e7a0bd10cd7db52067d2fb701bfa95e5 (diff)
Made sure the "phase" parameter of extensions is always usable (even across language boundaries)
Diffstat (limited to '')
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/function.lux34
1 files changed, 26 insertions, 8 deletions
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
index 0b441c92f..a3583155b 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
@@ -30,7 +30,7 @@
[lux
[analysis (#+ Environment)]
[synthesis (#+ Synthesis Abstraction Apply)]
- ["." generation]]]
+ ["." generation (#+ Context)]]]
[meta
[archive (#+ Archive)]]]]]
[luxc
@@ -301,13 +301,22 @@
[instanceI (..instance generate archive classD arity env)]
(wrap [functionD instanceI]))))
-(def: #export (function generate archive [env arity bodyS])
- (Generator Abstraction)
- (do phase.monad
+(def: #export (function' forced_context generate archive [env arity bodyS])
+ (-> (Maybe Context) (Generator Abstraction))
+ (do {! phase.monad}
[@begin _.make_label
- [function_context bodyI] (generation.with_new_context archive
- (generation.with_anchor [@begin 1]
- (generate archive bodyS)))
+ [function_context bodyI] (case forced_context
+ (#.Some function_context)
+ (do !
+ [without_context (generation.with_anchor [@begin 1]
+ (generate archive bodyS))]
+ (wrap [function_context
+ without_context]))
+
+ #.None
+ (generation.with_new_context archive
+ (generation.with_anchor [@begin 1]
+ (generate archive bodyS))))
#let [function_class (//.class_name function_context)]
[functionD instanceI] (..with_function generate archive @begin function_class env arity bodyI)
#let [directive [function_class
@@ -316,9 +325,18 @@
//.$Function (list)
functionD)]]
_ (generation.execute! directive)
- _ (generation.save! (product.right function_context) directive)]
+ _ (case forced_context
+ #.None
+ (generation.save! (product.right function_context) directive)
+
+ (#.Some function_context)
+ (wrap []))]
(wrap instanceI)))
+(def: #export function
+ (Generator Abstraction)
+ (..function' #.None))
+
(def: #export (call generate archive [functionS argsS])
(Generator Apply)
(do {@ phase.monad}