aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-07-18 23:44:29 -0400
committerEduardo Julian2018-07-18 23:44:29 -0400
commit8b4f0ded7bddaa42cf432f74523bfd6aa1e76fed (patch)
tree27840fac3765bf9f3411ca65dc1ef5d8de0b044b /new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux
parentc99909d6f03d9968cdd81c8a5c7e254372a3afcd (diff)
WIP: Fix new-luxc's JVM back-end.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/structure.jvm.lux62
1 files changed, 33 insertions, 29 deletions
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<Meta>
+(def: #export (tuple translate members)
+ (-> Compiler (List Synthesis) (Operation Inst))
+ (do compiler.Monad<Operation>
[#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<Meta>
+(def: #export (variant translate tag tail? member)
+ (-> Compiler Nat Bit Synthesis (Operation Inst))
+ (do compiler.Monad<Operation>
[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))