From 8b4f0ded7bddaa42cf432f74523bfd6aa1e76fed Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 18 Jul 2018 23:44:29 -0400 Subject: WIP: Fix new-luxc's JVM back-end. --- .../luxc/lang/translation/jvm/structure.jvm.lux | 62 ++++++++++++---------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux index 8b636b1cf..bc4a3cb95 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux @@ -1,32 +1,36 @@ (.module: - lux - (lux (control [monad #+ do] - ["ex" exception #+ exception:]) - (data text/format - (coll [list])) - [macro] - [host #+ do-to]) - (luxc ["&" lang] - (lang [".L" host] - (host ["$" jvm] - (jvm ["$t" type] - ["$d" def] - ["$i" inst])) - ["la" analysis] - ["ls" synthesis])) - (// [".T" common])) + [lux #* + [control + [monad (#+ do)] + ["ex" exception (#+ exception:)]] + [data + [text + format] + [collection + ["." list]]] + [language + ["." compiler + [synthesis (#+ Synthesis)]]]] + [luxc + [lang + [host + ["." jvm (#+ Inst Operation Compiler) + ["$t" type] + ["$i" inst]]]]] + [//]) -(exception: #export (Not-A-Tuple {message Text}) - message) +(exception: #export (not-a-tuple {size Nat}) + (ex.report ["Expected size" ">= 2"] + ["Actual size" (%n size)])) -(def: $Object $.Type ($t.class "java.lang.Object" (list))) +(def: $Object jvm.Type ($t.class "java.lang.Object" (list))) -(def: #export (translate-tuple translate members) - (-> (-> ls.Synthesis (Meta $.Inst)) (List ls.Synthesis) (Meta $.Inst)) - (do macro.Monad +(def: #export (tuple translate members) + (-> Compiler (List Synthesis) (Operation Inst)) + (do compiler.Monad [#let [size (list.size members)] - _ (&.assert Not-A-Tuple (%code (` [(~+ members)])) - (n/>= +2 size)) + _ (compiler.assert not-a-tuple size + (n/>= +2 size)) membersI (|> members list.enumerate (monad.map @ (function (_ [idx member]) @@ -42,19 +46,19 @@ membersI)))) (def: (flagI tail?) - (-> Bit $.Inst) + (-> Bit Inst) (if tail? ($i.string "") $i.NULL)) -(def: #export (translate-variant translate tag tail? member) - (-> (-> ls.Synthesis (Meta $.Inst)) Nat Bit ls.Synthesis (Meta $.Inst)) - (do macro.Monad +(def: #export (variant translate tag tail? member) + (-> Compiler Nat Bit Synthesis (Operation Inst)) + (do compiler.Monad [memberI (translate member)] (wrap (|>> ($i.int (.int tag)) (flagI tail?) memberI - ($i.INVOKESTATIC hostL.runtime-class + ($i.INVOKESTATIC //.runtime-class "variant_make" ($t.method (list $t.int $Object $Object) (#.Some ($t.array +1 $Object)) -- cgit v1.2.3