From a40f40f230e6312ae432f06e7f73aa5945d8fa49 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 18 Jul 2021 23:10:18 -0400 Subject: New JVM compiler can now compile JVM interfaces. --- .../source/luxc/lang/translation/jvm/runtime.lux | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'lux-jvm/source/luxc/lang/translation/jvm/runtime.lux') diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux index e0426f363..cccdf42bf 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux @@ -48,22 +48,22 @@ (def: $Throwable (type.class "java.lang.Throwable" (list))) (def: nullary_init_methodT - (type.method [(list) type.void (list)])) + (type.method [(list) (list) type.void (list)])) (def: throw_methodT - (type.method [(list) type.void (list)])) + (type.method [(list) (list) type.void (list)])) (def: #export logI Inst (let [PrintStream (type.class "java.io.PrintStream" (list)) outI (_.GETSTATIC (type.class "java.lang.System" (list)) "out" PrintStream) printI (function (_ method) - (_.INVOKEVIRTUAL PrintStream method (type.method [(list $Value) type.void (list)])))] + (_.INVOKEVIRTUAL PrintStream method (type.method [(list) (list $Value) type.void (list)])))] (|>> outI (_.string "LOG: ") (printI "print") outI _.SWAP (printI "println")))) (def: variant_method - (type.method [(list $Tag $Flag $Value) //.$Variant (list)])) + (type.method [(list) (list $Tag $Flag $Value) //.$Variant (list)])) (def: #export variantI Inst @@ -115,7 +115,7 @@ (def: #export (apply_signature arity) (-> Arity (Type Method)) - (type.method [(list.repeat arity $Value) $Value (list)])) + (type.method [(list) (list.repeat arity $Value) $Value (list)])) (def: adt_methods Def @@ -123,7 +123,7 @@ store_flagI (|>> _.DUP _.ICONST_1 (_.ALOAD 1) _.AASTORE) store_valueI (|>> _.DUP _.ICONST_2 (_.ALOAD 2) _.AASTORE)] (|>> ($d.method #$.Public $.staticM "variant_make" - (type.method [(list $Tag $Flag $Value) //.$Variant (list)]) + (type.method [(list) (list $Tag $Flag $Value) //.$Variant (list)]) (|>> _.ICONST_3 (_.ANEWARRAY $Value) store_tagI @@ -133,10 +133,10 @@ (def: frac_methods Def - (|>> ($d.method #$.Public $.staticM "decode_frac" (type.method [(list $Text) //.$Variant (list)]) + (|>> ($d.method #$.Public $.staticM "decode_frac" (type.method [(list) (list $Text) //.$Variant (list)]) (tryI (|>> (_.ALOAD 0) - (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "parseDouble" (type.method [(list $Text) type.double (list)])) + (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "parseDouble" (type.method [(list) (list $Text) type.double (list)])) (_.wrap type.double)))) )) @@ -146,7 +146,7 @@ (|>> (_.NEW IllegalStateException) _.DUP (_.string message) - (_.INVOKESPECIAL IllegalStateException "" (type.method [(list $Text) type.void (list)]))))) + (_.INVOKESPECIAL IllegalStateException "" (type.method [(list) (list $Text) type.void (list)]))))) (def: pm_methods Def @@ -175,7 +175,7 @@ ($d.method #$.Public $.staticM "apply_fail" throw_methodT (|>> (illegal_state_exception "Error while applying function.") _.ATHROW)) - ($d.method #$.Public $.staticM "pm_push" (type.method [(list $Stack $Value) $Stack (list)]) + ($d.method #$.Public $.staticM "pm_push" (type.method [(list) (list $Stack $Value) $Stack (list)]) (|>> _.ICONST_2 (_.ANEWARRAY $Value) _.DUP @@ -187,7 +187,7 @@ (_.ALOAD 1) _.AASTORE _.ARETURN)) - ($d.method #$.Public $.staticM "pm_variant" (type.method [(list //.$Variant $Tag $Flag) $Value (list)]) + ($d.method #$.Public $.staticM "pm_variant" (type.method [(list) (list //.$Variant $Tag $Flag) $Value (list)]) (<| _.with_label (function (_ @loop)) _.with_label (function (_ @perfect_match!)) _.with_label (function (_ @tags_match!)) @@ -247,7 +247,7 @@ ## _.POP2 not_found _.ARETURN))) - ($d.method #$.Public $.staticM "tuple_left" (type.method [(list //.$Tuple $Index) $Value (list)]) + ($d.method #$.Public $.staticM "tuple_left" (type.method [(list) (list //.$Tuple $Index) $Value (list)]) (<| _.with_label (function (_ @loop)) _.with_label (function (_ @recursive)) (let [left_accessI (|>> (_.ALOAD 0) left_indexI _.AALOAD)]) @@ -258,7 +258,7 @@ (_.label @recursive) ## Recursive (recurI @loop)))) - ($d.method #$.Public $.staticM "tuple_right" (type.method [(list //.$Tuple $Index) $Value (list)]) + ($d.method #$.Public $.staticM "tuple_right" (type.method [(list) (list //.$Tuple $Index) $Value (list)]) (<| _.with_label (function (_ @loop)) _.with_label (function (_ @not_tail)) _.with_label (function (_ @slice)) @@ -272,7 +272,8 @@ right_indexI tuple_sizeI (_.INVOKESTATIC (type.class "java.util.Arrays" (list)) "copyOfRange" - (type.method [(list //.$Tuple $Index $Index) + (type.method [(list) + (list //.$Tuple $Index $Index) //.$Tuple (list)])))]) (|>> (_.label @loop) @@ -291,7 +292,7 @@ ))) ))) -(def: #export try (type.method [(list //.$Function) //.$Variant (list)])) +(def: #export try (type.method [(list) (list //.$Function) //.$Variant (list)])) (def: io_methods Def @@ -306,7 +307,7 @@ _.POP _.SWAP (_.boolean true) - (_.INVOKESPECIAL PrintWriter "" (type.method [(list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)])) + (_.INVOKESPECIAL PrintWriter "" (type.method [(list) (list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)])) )] (|>> ($d.method #$.Public $.staticM "try" ..try (<| _.with_label (function (_ @from)) @@ -324,8 +325,8 @@ string_writerI ## TW _.DUP2 ## TWTW print_writerI ## TWTP - (_.INVOKEVIRTUAL $Throwable "printStackTrace" (type.method [(list (type.class "java.io.PrintWriter" (list))) type.void (list)])) ## TW - (_.INVOKEVIRTUAL StringWriter "toString" (type.method [(list) $Text (list)])) ## TS + (_.INVOKEVIRTUAL $Throwable "printStackTrace" (type.method [(list) (list (type.class "java.io.PrintWriter" (list))) type.void (list)])) ## TW + (_.INVOKEVIRTUAL StringWriter "toString" (type.method [(list) (list) $Text (list)])) ## TS _.SWAP _.POP leftI _.ARETURN))) ))) @@ -375,7 +376,7 @@ function_class (..reflection //.$Function) bytecode ($d.abstract #$.V1_6 #$.Public $.noneC function_class (list) $Object (list) (|>> ($d.field #$.Public $.finalF partials_field type.int) - ($d.method #$.Public $.noneM "" (type.method [(list type.int) type.void (list)]) + ($d.method #$.Public $.noneM "" (type.method [(list) (list type.int) type.void (list)]) (|>> (_.ALOAD 0) (_.INVOKESPECIAL $Object "" nullary_init_methodT) (_.ALOAD 0) -- cgit v1.2.3