aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux18
1 files changed, 15 insertions, 3 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux
index 078a136b7..87a43fb02 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux
@@ -1,7 +1,10 @@
(.module:
[lux (#- Type Definition case)
[data
- [binary (#+ Binary)]]
+ [binary (#+ Binary)]
+ [number
+ ["." i64]
+ ["n" nat]]]
[target
[jvm
["_" instruction (#+ Label Instruction)]
@@ -10,8 +13,9 @@
["." // #_
["#." value]
["/#" //
- [///
- [reference (#+ Register)]]]]
+ ["/#" //
+ [//
+ [reference (#+ Register)]]]]]
)
(type: #export Byte-Code Binary)
@@ -83,3 +87,11 @@
(def: #export right
(..procedure "right" ..projection-type))
+
+(def: #export forge-label
+ (Operation Label)
+ (let [shift (n./ 2 i64.width)]
+ ## This shift is done to avoid the possibility of forged labels
+ ## to be in the range of the labels that are generated automatically
+ ## during the evaluation of Instruction expressions.
+ (:: ////.monad map (i64.left-shift shift) ///.next)))