diff options
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.lux | 63 |
1 files changed, 60 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 87a43fb02..3868b747f 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/runtime.lux @@ -3,19 +3,24 @@ [data [binary (#+ Binary)] [number + ["." i32] ["." i64] ["n" nat]]] [target [jvm ["_" instruction (#+ Label Instruction)] + ["." constant] ["." type (#+ Type) ["." category (#+ Method)]]]]] ["." // #_ ["#." value] + ["#." function #_ + ["#" abstract]] ["/#" // ["/#" // [// - [reference (#+ Register)]]]]] + [reference (#+ Register)] + ["." synthesis]]]]] ) (type: #export Byte-Code Binary) @@ -39,6 +44,8 @@ (def: #export class (type.class "LuxRuntime" (list))) +(def: $Text (type.class "java.lang.String" (list))) + (def: #export $Tag type.int) (def: #export $Flag //value.type) (def: #export $Variant (type.array //value.type)) @@ -82,12 +89,62 @@ (def: projection-type (type.method [(list ..$Tuple $Offset) //value.type (list)])) -(def: #export left +(def: #export left-projection (..procedure "left" ..projection-type)) -(def: #export right +(def: #export right-projection (..procedure "right" ..projection-type)) +(def: try-name + "try") + +(def: try-type + (type.method [(list //function.class) ..$Variant (list)])) + +(def: #export try + (_.invokestatic ..class ..try-name ..try-type)) + +(def: #export decode-frac + (..procedure "decode_frac" (type.method [(list ..$Text) ..$Variant (list)]))) + +(def: #export variant + (..procedure "variant" (type.method [(list ..$Tag ..$Flag //value.type) ..$Variant (list)]))) + +(def: ldc/integer + (-> (I64 Any) (Instruction Any)) + (|>> .i64 i32.i32 constant.integer _.ldc/integer)) + +(def: #export left-flag _.aconst-null) +(def: #export right-flag (_.ldc/string "")) + +(def: #export left-injection + (Instruction Any) + ($_ _.compose + (..ldc/integer +0) + ..left-flag + _.dup2-x1 + _.pop2 + ..variant)) + +(def: #export right-injection + (Instruction Any) + ($_ _.compose + (..ldc/integer +1) + ..right-flag + _.dup2-x1 + _.pop2 + ..variant)) + +(def: #export some-injection right-injection) + +(def: #export none-injection + (Instruction Any) + ($_ _.compose + (..ldc/integer +0) + _.aconst-null + (_.ldc/string synthesis.unit) + ..variant)) + (def: #export forge-label (Operation Label) (let [shift (n./ 2 i64.width)] |