aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux')
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux60
1 files changed, 60 insertions, 0 deletions
diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux
new file mode 100644
index 000000000..3fca5842f
--- /dev/null
+++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/reference.jvm.lux
@@ -0,0 +1,60 @@
+(.module:
+ [lux #*
+ [control
+ pipe]
+ [data
+ [text
+ format]]]
+ [//
+ [runtime (#+ Operation)]
+ [/// ("operation/." Monad<Operation>)
+ [analysis (#+ Variant Tuple)]
+ [synthesis (#+ Synthesis)]
+ [//
+ ["." reference (#+ Register Variable Reference)]
+ ["." name]
+ [//
+ [host
+ ["_" scheme (#+ Expression Var)]]]]]])
+
+(do-template [<name> <prefix>]
+ [(def: #export <name>
+ (-> Register Var)
+ (|>> .int %i (format <prefix>) _.var))]
+
+ [local' "l"]
+ [foreign' "f"]
+ )
+
+(def: #export variable'
+ (-> Variable Var)
+ (|>> (case> (#reference.Local register)
+ (local' register)
+
+ (#reference.Foreign register)
+ (foreign' register))))
+
+(def: #export variable
+ (-> Variable (Operation Var))
+ (|>> ..variable'
+ operation/wrap))
+
+(def: #export constant'
+ (-> Ident Var)
+ (|>> name.definition _.var))
+
+(def: #export constant
+ (-> Ident (Operation Var))
+ (|>> constant' operation/wrap))
+
+(def: #export reference'
+ (-> Reference Expression)
+ (|>> (case> (#reference.Constant value)
+ (..constant' value)
+
+ (#reference.Variable value)
+ (..variable' value))))
+
+(def: #export reference
+ (-> Reference (Operation Expression))
+ (|>> reference' operation/wrap))