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. --- .../luxc/lang/translation/jvm/extension/common.lux | 22 +++++++++++----------- .../luxc/lang/translation/jvm/extension/host.lux | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 19 deletions(-) (limited to 'lux-jvm/source/luxc/lang/translation/jvm/extension') diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux index d79362d79..70175b636 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux @@ -216,20 +216,20 @@ [i64::f64 (_.unwrap type.long) (<| (_.wrap type.double) _.L2D)] [i64::char (_.unwrap type.long) - ((|>> _.L2I _.I2C (_.INVOKESTATIC (type.class "java.lang.Character" (list)) "toString" (type.method [(list type.char) $String (list)]))))] + ((|>> _.L2I _.I2C (_.INVOKESTATIC (type.class "java.lang.Character" (list)) "toString" (type.method [(list) (list type.char) $String (list)]))))] [f64::i64 (_.unwrap type.double) (<| (_.wrap type.long) _.D2L)] [f64::encode (_.unwrap type.double) - (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "toString" (type.method [(list type.double) $String (list)]))] + (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "toString" (type.method [(list) (list type.double) $String (list)]))] [f64::decode ..check_stringI - (_.INVOKESTATIC ///.$Runtime "decode_frac" (type.method [(list $String) ///.$Variant (list)]))] + (_.INVOKESTATIC ///.$Runtime "decode_frac" (type.method [(list) (list $String) ///.$Variant (list)]))] ) (def: (text::size inputI) (Unary Inst) (|>> inputI ..check_stringI - (_.INVOKEVIRTUAL $String "length" (type.method [(list) type.int (list)])) + (_.INVOKEVIRTUAL $String "length" (type.method [(list) (list) type.int (list)])) lux_intI)) (template [ ] @@ -240,13 +240,13 @@ ))] [text::= (<|) (<|) - (_.INVOKEVIRTUAL $Object "equals" (type.method [(list $Object) type.boolean (list)])) + (_.INVOKEVIRTUAL $Object "equals" (type.method [(list) (list $Object) type.boolean (list)])) (_.wrap type.boolean)] [text::< ..check_stringI ..check_stringI - (_.INVOKEVIRTUAL $String "compareTo" (type.method [(list $String) type.int (list)])) + (_.INVOKEVIRTUAL $String "compareTo" (type.method [(list) (list $String) type.int (list)])) (predicateI _.IFLT)] [text::char ..check_stringI jvm_intI - (_.INVOKEVIRTUAL $String "charAt" (type.method [(list type.int) type.char (list)])) + (_.INVOKEVIRTUAL $String "charAt" (type.method [(list) (list type.int) type.char (list)])) lux_intI] ) @@ -254,7 +254,7 @@ (Binary Inst) (|>> leftI ..check_stringI rightI ..check_stringI - (_.INVOKEVIRTUAL $String "concat" (type.method [(list $String) $String (list)])))) + (_.INVOKEVIRTUAL $String "concat" (type.method [(list) (list $String) $String (list)])))) (def: (text::clip [offsetI lengthI subjectI]) (Trinary Inst) @@ -263,9 +263,9 @@ _.DUP lengthI jvm_intI _.IADD - (_.INVOKEVIRTUAL $String "substring" (type.method [(list type.int type.int) $String (list)])))) + (_.INVOKEVIRTUAL $String "substring" (type.method [(list) (list type.int type.int) $String (list)])))) -(def: index_method (type.method [(list $String type.int) type.int (list)])) +(def: index_method (type.method [(list) (list $String type.int) type.int (list)])) (def: (text::index [startI partI textI]) (Trinary Inst) (<| _.with_label (function (_ @not_found)) @@ -285,7 +285,7 @@ runtime.noneI (_.label @end)))) -(def: string_method (type.method [(list $String) type.void (list)])) +(def: string_method (type.method [(list) (list $String) type.void (list)])) (def: (io::log messageI) (Unary Inst) (let [$PrintStream (type.class "java.io.PrintStream" (list))] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 441a415ee..a9727fc9a 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -536,7 +536,7 @@ (do phase.monad [] (wrap (|>> (_.string class) - (_.INVOKESTATIC $Class "forName" (type.method [(list (type.class "java.lang.String" (list))) $Class (list)]))))) + (_.INVOKESTATIC $Class "forName" (type.method [(list) (list (type.class "java.lang.String" (list))) $Class (list)]))))) _ (phase.throw extension.invalid_syntax [extension_name %synthesis inputs]))) @@ -725,7 +725,7 @@ (do {@ phase.monad} [inputsTI (monad.map @ (generate_input generate archive) inputsTS)] (wrap (|>> (_.fuse (list@map product.right inputsTI)) - (_.INVOKESTATIC class method (type.method [(list@map product.left inputsTI) outputT (list)])) + (_.INVOKESTATIC class method (type.method [(list) (list@map product.left inputsTI) outputT (list)])) (prepare_output outputT)))))])) (template [ ] @@ -741,7 +741,8 @@ (_.CHECKCAST class) (_.fuse (list@map product.right inputsTI)) ( class method - (type.method [(list@map product.left inputsTI) + (type.method [(list) + (list@map product.left inputsTI) outputT (list)])) (prepare_output outputT)))))]))] @@ -761,7 +762,7 @@ (wrap (|>> (_.NEW class) _.DUP (_.fuse (list@map product.right inputsTI)) - (_.INVOKESPECIAL class "" (type.method [(list@map product.left inputsTI) type.void (list)]))))))])) + (_.INVOKESPECIAL class "" (type.method [(list) (list@map product.left inputsTI) type.void (list)]))))))])) (def: member Bundle @@ -919,7 +920,8 @@ (def: (anonymous_init_method env) (-> (Environment Synthesis) (Type Method)) - (type.method [(list.repeat (list.size env) $Object) + (type.method [(list) + (list.repeat (list.size env) $Object) type.void (list)])) @@ -936,7 +938,7 @@ (_def.method #$.Public $.noneM "" (anonymous_init_method env) (|>> (_.ALOAD 0) ((_.fuse (list@map product.right inputsTI))) - (_.INVOKESPECIAL super_class "" (type.method [(list@map product.left inputsTI) type.void (list)])) + (_.INVOKESPECIAL super_class "" (type.method [(list) (list@map product.left inputsTI) type.void (list)])) store_capturedI _.RETURN)))) @@ -986,7 +988,8 @@ (.tuple (<>.some ..class)) (.tuple (<>.some ..input)) (.tuple (<>.some ..overriden_method_definition))) - (function (_ extension_name generate archive [super_class super_interfaces + (function (_ extension_name generate archive [super_class + super_interfaces inputsTS overriden_methods]) (do {@ phase.monad} @@ -1040,7 +1043,8 @@ ($_ $.++M $.finalM $.strictM) $.finalM) name - (type.method [(list@map product.right arguments) + (type.method [(list) + (list@map product.right arguments) returnT exceptionsT]) (|>> bodyG (returnI returnT))))))) -- cgit v1.2.3