From a85bfc405e7acaf86c61fcd8f7987da0200d7b03 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 29 May 2019 23:34:17 -0400 Subject: Various fixes and tweaks. --- new-luxc/source/luxc/lang/host/jvm/def.lux | 31 ++++++++++++++++++++-- .../luxc/lang/translation/jvm/procedure/host.lux | 18 ++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) (limited to 'new-luxc') diff --git a/new-luxc/source/luxc/lang/host/jvm/def.lux b/new-luxc/source/luxc/lang/host/jvm/def.lux index bf4abc8ed..4d1b99da0 100644 --- a/new-luxc/source/luxc/lang/host/jvm/def.lux +++ b/new-luxc/source/luxc/lang/host/jvm/def.lux @@ -12,7 +12,8 @@ ["." list ("#/." functor)]]] [target [jvm - ["$t" type (#+ Method Class Type Parameter)]]]] + ["$t" type (#+ Method Class Type Parameter) + ["." reflection]]]]] ["." //]) (import: #long java/lang/Object) @@ -71,10 +72,36 @@ (list.enumerate values)) output))) +(def: (exception-class-name type) + (-> Type Text) + (case type + (#$t.Primitive prim) + (case prim + #$t.Boolean reflection.boolean + #$t.Byte reflection.byte + #$t.Short reflection.short + #$t.Int reflection.int + #$t.Long reflection.long + #$t.Float reflection.float + #$t.Double reflection.double + #$t.Char reflection.char) + + (#$t.Array sub) + (format $t.array-prefix (exception-class-name sub)) + + (#$t.Generic generic) + (case generic + (#$t.Class class params) + ($t.binary-name class) + + (^or (#$t.Var _) (#$t.Wildcard _)) + ($t.binary-name $t.object-class)) + )) + (def: exceptions-array (-> Method (Array Text)) (|>> (get@ #$t.exceptions) - (list/map (|>> #$t.Generic $t.descriptor)) + (list/map (|>> #$t.Generic ..exception-class-name)) string-array)) (def: (version-flag version) diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux index 83cbd017b..4239a89aa 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux @@ -4,6 +4,7 @@ ["." monad (#+ do)]] [control ["." exception (#+ exception:)] + ["." function] ["<>" parser ("#@." monad) ["" text] ["" synthesis (#+ Parser)]]] @@ -343,7 +344,7 @@ (do phase.monad [lengthI (generate lengthS)] (wrap (|>> lengthI - (_.array (jvm.array 1 jvm-primitive))))) + (_.array jvm-primitive)))) _ (phase.throw extension.invalid-syntax [extension-name %synthesis inputs])))) @@ -728,6 +729,15 @@ #.None argI)) +(def: (prepare-returnI return) + (-> Return Inst) + (case return + (#.Some _) + function.identity + + #.None + (_.string synthesis.unit))) + (def: invoke::static Handler (..custom @@ -739,7 +749,8 @@ (wrap (|>> (_.fuse (list@map ..prepare-argI argsTI)) (_.INVOKESTATIC class method (jvm.method (list@map product.left argsTI) returnT (list)) - false)))))])) + false) + (prepare-returnI returnT)))))])) (template [ ] [(def: @@ -756,7 +767,8 @@ (_.fuse (list@map ..prepare-argI argsTI)) ( class method (jvm.method (list@map product.left argsTI) returnT (list)) - )))))]))] + ) + (prepare-returnI returnT)))))]))] [invoke::virtual _.INVOKEVIRTUAL false] [invoke::special _.INVOKESPECIAL false] -- cgit v1.2.3