aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/procedure
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux225
1 files changed, 114 insertions, 111 deletions
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 8b8ba87ee..55798c806 100644
--- a/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux
+++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/host.lux
@@ -20,8 +20,8 @@
["." dictionary (#+ Dictionary)]
["." set]]]
[target
- [jvm
- ["_t" type (#+ Primitive Bound Generic Class Type Method Var Typed Argument Return)]]]
+ ["." jvm #_
+ ["#" type (#+ Primitive Bound Generic Class Type Method Var Typed Argument Return)]]]
[tool
[compiler
[analysis (#+ Environment)]
@@ -69,30 +69,30 @@
(|>> inputI
<conversion>)))]
- [conversion::double-to-float #_t.Double _.D2F #_t.Float]
- [conversion::double-to-int #_t.Double _.D2I #_t.Int]
- [conversion::double-to-long #_t.Double _.D2L #_t.Long]
- [conversion::float-to-double #_t.Float _.F2D #_t.Double]
- [conversion::float-to-int #_t.Float _.F2I #_t.Int]
- [conversion::float-to-long #_t.Float _.F2L #_t.Long]
- [conversion::int-to-byte #_t.Int _.I2B #_t.Byte]
- [conversion::int-to-char #_t.Int _.I2C #_t.Char]
- [conversion::int-to-double #_t.Int _.I2D #_t.Double]
- [conversion::int-to-float #_t.Int _.I2F #_t.Float]
- [conversion::int-to-long #_t.Int _.I2L #_t.Long]
- [conversion::int-to-short #_t.Int _.I2S #_t.Short]
- [conversion::long-to-double #_t.Long _.L2D #_t.Double]
- [conversion::long-to-float #_t.Long _.L2F #_t.Float]
- [conversion::long-to-int #_t.Long _.L2I #_t.Int]
- [conversion::long-to-short #_t.Long L2S #_t.Short]
- [conversion::long-to-byte #_t.Long L2B #_t.Byte]
- [conversion::long-to-char #_t.Long L2C #_t.Char]
- [conversion::char-to-byte #_t.Char _.I2B #_t.Byte]
- [conversion::char-to-short #_t.Char _.I2S #_t.Short]
- [conversion::char-to-int #_t.Char _.NOP #_t.Int]
- [conversion::char-to-long #_t.Char _.I2L #_t.Long]
- [conversion::byte-to-long #_t.Byte _.I2L #_t.Long]
- [conversion::short-to-long #_t.Short _.I2L #_t.Long]
+ [conversion::double-to-float #jvm.Double _.D2F #jvm.Float]
+ [conversion::double-to-int #jvm.Double _.D2I #jvm.Int]
+ [conversion::double-to-long #jvm.Double _.D2L #jvm.Long]
+ [conversion::float-to-double #jvm.Float _.F2D #jvm.Double]
+ [conversion::float-to-int #jvm.Float _.F2I #jvm.Int]
+ [conversion::float-to-long #jvm.Float _.F2L #jvm.Long]
+ [conversion::int-to-byte #jvm.Int _.I2B #jvm.Byte]
+ [conversion::int-to-char #jvm.Int _.I2C #jvm.Char]
+ [conversion::int-to-double #jvm.Int _.I2D #jvm.Double]
+ [conversion::int-to-float #jvm.Int _.I2F #jvm.Float]
+ [conversion::int-to-long #jvm.Int _.I2L #jvm.Long]
+ [conversion::int-to-short #jvm.Int _.I2S #jvm.Short]
+ [conversion::long-to-double #jvm.Long _.L2D #jvm.Double]
+ [conversion::long-to-float #jvm.Long _.L2F #jvm.Float]
+ [conversion::long-to-int #jvm.Long _.L2I #jvm.Int]
+ [conversion::long-to-short #jvm.Long L2S #jvm.Short]
+ [conversion::long-to-byte #jvm.Long L2B #jvm.Byte]
+ [conversion::long-to-char #jvm.Long L2C #jvm.Char]
+ [conversion::char-to-byte #jvm.Char _.I2B #jvm.Byte]
+ [conversion::char-to-short #jvm.Char _.I2S #jvm.Short]
+ [conversion::char-to-int #jvm.Char _.NOP #jvm.Int]
+ [conversion::char-to-long #jvm.Char _.I2L #jvm.Long]
+ [conversion::byte-to-long #jvm.Byte _.I2L #jvm.Long]
+ [conversion::short-to-long #jvm.Short _.I2L #jvm.Long]
)
(def: conversion
@@ -169,7 +169,7 @@
[double::% _.DREM]
)
-(def: boolean-class (_t.class "java.lang.Boolean" (list)))
+(def: boolean-class (jvm.class "java.lang.Boolean" (list)))
(def: falseI (_.GETSTATIC "java.lang.Boolean" "FALSE" boolean-class))
(def: trueI (_.GETSTATIC "java.lang.Boolean" "TRUE" boolean-class))
@@ -294,17 +294,17 @@
(def: (array-java-type nesting elem-class)
(-> Nat Text Type)
- (_t.array nesting
- (case elem-class
- "boolean" _t.boolean
- "byte" _t.byte
- "short" _t.short
- "int" _t.int
- "long" _t.long
- "float" _t.float
- "double" _t.double
- "char" _t.char
- _ (_t.class elem-class (list)))))
+ (jvm.array nesting
+ (case elem-class
+ "boolean" jvm.boolean
+ "byte" jvm.byte
+ "short" jvm.short
+ "int" jvm.int
+ "long" jvm.long
+ "float" jvm.float
+ "double" jvm.double
+ "char" jvm.char
+ _ (jvm.class elem-class (list)))))
(def: (array::length extension-name generate inputs)
Handler
@@ -315,7 +315,7 @@
(do phase.monad
[arrayI (generate arrayS)]
(wrap (|>> arrayI
- (_.CHECKCAST (_t.descriptor (array-java-type (.nat nesting) elem-class)))
+ (_.CHECKCAST (jvm.descriptor (array-java-type (.nat nesting) elem-class)))
_.ARRAYLENGTH)))
_
@@ -329,7 +329,7 @@
(do phase.monad
[lengthI (generate lengthS)]
(wrap (|>> lengthI
- (_.array (_t.array 1 jvm-primitive)))))
+ (_.array (jvm.array 1 jvm-primitive)))))
_
(phase.throw extension.invalid-syntax [extension-name %synthesis inputs]))))
@@ -357,7 +357,7 @@
[arrayI (generate arrayS)
idxI (generate idxS)]
(wrap (|>> arrayI
- (_.CHECKCAST (_t.descriptor (_t.array 1 jvm-primitive)))
+ (_.CHECKCAST (jvm.descriptor (jvm.array 1 jvm-primitive)))
idxI
loadI)))
@@ -375,7 +375,7 @@
[arrayI (generate arrayS)
idxI (generate idxS)]
(wrap (|>> arrayI
- (_.CHECKCAST (_t.descriptor (array-java-type (.nat nesting) elem-class)))
+ (_.CHECKCAST (jvm.descriptor (array-java-type (.nat nesting) elem-class)))
idxI
_.AALOAD)))
@@ -392,7 +392,7 @@
idxI (generate idxS)
valueI (generate valueS)]
(wrap (|>> arrayI
- (_.CHECKCAST (_t.descriptor (_t.array 1 jvm-primitive)))
+ (_.CHECKCAST (jvm.descriptor (jvm.array 1 jvm-primitive)))
_.DUP
idxI
valueI
@@ -414,7 +414,7 @@
idxI (generate idxS)
valueI (generate valueS)]
(wrap (|>> arrayI
- (_.CHECKCAST (_t.descriptor (array-java-type (.nat nesting) elem-class)))
+ (_.CHECKCAST (jvm.descriptor (array-java-type (.nat nesting) elem-class)))
_.DUP
idxI
valueI
@@ -430,36 +430,36 @@
(bundle.install "length" array::length)
(dictionary.merge (<| (bundle.prefix "new")
(|> bundle.empty
- (bundle.install "boolean" (new-primitive-array-handler _t.boolean))
- (bundle.install "byte" (new-primitive-array-handler _t.byte))
- (bundle.install "short" (new-primitive-array-handler _t.short))
- (bundle.install "int" (new-primitive-array-handler _t.int))
- (bundle.install "long" (new-primitive-array-handler _t.long))
- (bundle.install "float" (new-primitive-array-handler _t.float))
- (bundle.install "double" (new-primitive-array-handler _t.double))
- (bundle.install "char" (new-primitive-array-handler _t.char))
+ (bundle.install "boolean" (new-primitive-array-handler jvm.boolean))
+ (bundle.install "byte" (new-primitive-array-handler jvm.byte))
+ (bundle.install "short" (new-primitive-array-handler jvm.short))
+ (bundle.install "int" (new-primitive-array-handler jvm.int))
+ (bundle.install "long" (new-primitive-array-handler jvm.long))
+ (bundle.install "float" (new-primitive-array-handler jvm.float))
+ (bundle.install "double" (new-primitive-array-handler jvm.double))
+ (bundle.install "char" (new-primitive-array-handler jvm.char))
(bundle.install "object" array::new::object))))
(dictionary.merge (<| (bundle.prefix "read")
(|> bundle.empty
- (bundle.install "boolean" (read-primitive-array-handler _t.boolean _.BALOAD))
- (bundle.install "byte" (read-primitive-array-handler _t.byte _.BALOAD))
- (bundle.install "short" (read-primitive-array-handler _t.short _.SALOAD))
- (bundle.install "int" (read-primitive-array-handler _t.int _.IALOAD))
- (bundle.install "long" (read-primitive-array-handler _t.long _.LALOAD))
- (bundle.install "float" (read-primitive-array-handler _t.float _.FALOAD))
- (bundle.install "double" (read-primitive-array-handler _t.double _.DALOAD))
- (bundle.install "char" (read-primitive-array-handler _t.char _.CALOAD))
+ (bundle.install "boolean" (read-primitive-array-handler jvm.boolean _.BALOAD))
+ (bundle.install "byte" (read-primitive-array-handler jvm.byte _.BALOAD))
+ (bundle.install "short" (read-primitive-array-handler jvm.short _.SALOAD))
+ (bundle.install "int" (read-primitive-array-handler jvm.int _.IALOAD))
+ (bundle.install "long" (read-primitive-array-handler jvm.long _.LALOAD))
+ (bundle.install "float" (read-primitive-array-handler jvm.float _.FALOAD))
+ (bundle.install "double" (read-primitive-array-handler jvm.double _.DALOAD))
+ (bundle.install "char" (read-primitive-array-handler jvm.char _.CALOAD))
(bundle.install "object" array::read::object))))
(dictionary.merge (<| (bundle.prefix "write")
(|> bundle.empty
- (bundle.install "boolean" (write-primitive-array-handler _t.boolean _.BASTORE))
- (bundle.install "byte" (write-primitive-array-handler _t.byte _.BASTORE))
- (bundle.install "short" (write-primitive-array-handler _t.short _.SASTORE))
- (bundle.install "int" (write-primitive-array-handler _t.int _.IASTORE))
- (bundle.install "long" (write-primitive-array-handler _t.long _.LASTORE))
- (bundle.install "float" (write-primitive-array-handler _t.float _.FASTORE))
- (bundle.install "double" (write-primitive-array-handler _t.double _.DASTORE))
- (bundle.install "char" (write-primitive-array-handler _t.char _.CASTORE))
+ (bundle.install "boolean" (write-primitive-array-handler jvm.boolean _.BASTORE))
+ (bundle.install "byte" (write-primitive-array-handler jvm.byte _.BASTORE))
+ (bundle.install "short" (write-primitive-array-handler jvm.short _.SASTORE))
+ (bundle.install "int" (write-primitive-array-handler jvm.int _.IASTORE))
+ (bundle.install "long" (write-primitive-array-handler jvm.long _.LASTORE))
+ (bundle.install "float" (write-primitive-array-handler jvm.float _.FASTORE))
+ (bundle.install "double" (write-primitive-array-handler jvm.double _.DASTORE))
+ (bundle.install "char" (write-primitive-array-handler jvm.char _.CASTORE))
(bundle.install "object" array::write::object))))
)))
@@ -501,9 +501,9 @@
[]
(wrap (|>> (_.string class)
(_.INVOKESTATIC "java.lang.Class" "forName"
- (_t.method (list (_t.class "java.lang.String" (list)))
- (#.Some (_t.class "java.lang.Class" (list)))
- (list))
+ (jvm.method (list (jvm.class "java.lang.String" (list)))
+ (#.Some (jvm.class "java.lang.Class" (list)))
+ (list))
false))))
_
@@ -517,7 +517,7 @@
[objectI (generate objectS)]
(wrap (|>> objectI
(_.INSTANCEOF class)
- (_.wrap #_t.Boolean))))
+ (_.wrap #jvm.Boolean))))
_
(phase.throw extension.invalid-syntax [extension-name %synthesis inputs])))
@@ -536,14 +536,14 @@
[<object> <primitive>]
(wrap (|>> valueI (_.unwrap <type>))))
- (["boolean" "java.lang.Boolean" #_t.Boolean]
- ["byte" "java.lang.Byte" #_t.Byte]
- ["short" "java.lang.Short" #_t.Short]
- ["int" "java.lang.Integer" #_t.Int]
- ["long" "java.lang.Long" #_t.Long]
- ["float" "java.lang.Float" #_t.Float]
- ["double" "java.lang.Double" #_t.Double]
- ["char" "java.lang.Character" #_t.Char])
+ (["boolean" "java.lang.Boolean" #jvm.Boolean]
+ ["byte" "java.lang.Byte" #jvm.Byte]
+ ["short" "java.lang.Short" #jvm.Short]
+ ["int" "java.lang.Integer" #jvm.Int]
+ ["long" "java.lang.Long" #jvm.Long]
+ ["float" "java.lang.Float" #jvm.Float]
+ ["double" "java.lang.Double" #jvm.Double]
+ ["char" "java.lang.Character" #jvm.Char])
_
(wrap valueI)))
@@ -566,14 +566,14 @@
(def: primitives
(Dictionary Text Primitive)
- (|> (list ["boolean" #_t.Boolean]
- ["byte" #_t.Byte]
- ["short" #_t.Short]
- ["int" #_t.Int]
- ["long" #_t.Long]
- ["float" #_t.Float]
- ["double" #_t.Double]
- ["char" #_t.Char])
+ (|> (list ["boolean" #jvm.Boolean]
+ ["byte" #jvm.Byte]
+ ["short" #jvm.Short]
+ ["int" #jvm.Int]
+ ["long" #jvm.Long]
+ ["float" #jvm.Float]
+ ["double" #jvm.Double]
+ ["char" #jvm.Char])
(dictionary.from-list text.hash)))
(def: (static::get extension-name generate inputs)
@@ -586,10 +586,10 @@
[]
(case (dictionary.get unboxed primitives)
(#.Some primitive)
- (wrap (_.GETSTATIC class field (#_t.Primitive primitive)))
+ (wrap (_.GETSTATIC class field (#jvm.Primitive primitive)))
#.None
- (wrap (_.GETSTATIC class field (_t.class unboxed (list))))))
+ (wrap (_.GETSTATIC class field (jvm.class unboxed (list))))))
_
(phase.throw extension.invalid-syntax [extension-name %synthesis inputs])))
@@ -606,13 +606,13 @@
(case (dictionary.get unboxed primitives)
(#.Some primitive)
(wrap (|>> valueI
- (_.PUTSTATIC class field (#_t.Primitive primitive))
+ (_.PUTSTATIC class field (#jvm.Primitive primitive))
(_.string synthesis.unit)))
#.None
(wrap (|>> valueI
(_.CHECKCAST class)
- (_.PUTSTATIC class field (_t.class class (list)))
+ (_.PUTSTATIC class field (jvm.class class (list)))
(_.string synthesis.unit)))))
_
@@ -631,12 +631,12 @@
(#.Some primitive)
(wrap (|>> objectI
(_.CHECKCAST class)
- (_.GETFIELD class field (#_t.Primitive primitive))))
+ (_.GETFIELD class field (#jvm.Primitive primitive))))
#.None
(wrap (|>> objectI
(_.CHECKCAST class)
- (_.GETFIELD class field (_t.class unboxed (list)))))))
+ (_.GETFIELD class field (jvm.class unboxed (list)))))))
_
(phase.throw extension.invalid-syntax [extension-name %synthesis inputs])))
@@ -658,7 +658,7 @@
(_.CHECKCAST class)
_.DUP
valueI
- (_.PUTFIELD class field (#_t.Primitive primitive))))
+ (_.PUTFIELD class field (#jvm.Primitive primitive))))
#.None
(wrap (|>> objectI
@@ -666,7 +666,7 @@
_.DUP
valueI
(_.CHECKCAST unboxed)
- (_.PUTFIELD class field (_t.class unboxed (list)))))))
+ (_.PUTFIELD class field (jvm.class unboxed (list)))))))
_
(phase.throw extension.invalid-syntax [extension-name %synthesis inputs])))
@@ -674,16 +674,16 @@
(def: base-type
(<t>.Parser Type)
($_ <>.either
- (<>.after (<t>.this "boolean") (<>@wrap _t.boolean))
- (<>.after (<t>.this "byte") (<>@wrap _t.byte))
- (<>.after (<t>.this "short") (<>@wrap _t.short))
- (<>.after (<t>.this "int") (<>@wrap _t.int))
- (<>.after (<t>.this "long") (<>@wrap _t.long))
- (<>.after (<t>.this "float") (<>@wrap _t.float))
- (<>.after (<t>.this "double") (<>@wrap _t.double))
- (<>.after (<t>.this "char") (<>@wrap _t.char))
+ (<>.after (<t>.this "boolean") (<>@wrap jvm.boolean))
+ (<>.after (<t>.this "byte") (<>@wrap jvm.byte))
+ (<>.after (<t>.this "short") (<>@wrap jvm.short))
+ (<>.after (<t>.this "int") (<>@wrap jvm.int))
+ (<>.after (<t>.this "long") (<>@wrap jvm.long))
+ (<>.after (<t>.this "float") (<>@wrap jvm.float))
+ (<>.after (<t>.this "double") (<>@wrap jvm.double))
+ (<>.after (<t>.this "char") (<>@wrap jvm.char))
(<>@map (function (_ name)
- (_t.class name (list)))
+ (jvm.class name (list)))
(<t>.many (<t>.none-of "[")))
))
@@ -692,7 +692,7 @@
(do <>.monad
[raw base-type
nesting (<>.some (<t>.this "[]"))]
- (wrap (_t.array (list.size nesting) raw))))
+ (wrap (jvm.array (list.size nesting) raw))))
(def: (generate-type argD)
(-> Text (Operation Type))
@@ -709,7 +709,10 @@
(case argS
(^ (synthesis.tuple (list (synthesis.text argD) argS)))
(do phase.monad
- [argT (generate-type argD)
+ [argD (phase.lift (:: error.monad map
+ jvm.reflection-class
+ (jvm.parse-signature argD)))
+ argT (generate-type argD)
argI (generate argS)]
(wrap [argT argI]))
@@ -727,7 +730,7 @@
(def: (prepare-argI [type argI])
(-> [Type Inst] Inst)
- (case (_t.class-name type)
+ (case (jvm.class-name type)
(#.Some class-name)
(|>> argI
(_.CHECKCAST class-name))
@@ -747,7 +750,7 @@
returnT (method-return-type unboxed)]
(wrap (|>> (_.fuse (list@map ..prepare-argI argsTI))
(_.INVOKESTATIC class method
- (_t.method (list@map product.left argsTI) returnT (list))
+ (jvm.method (list@map product.left argsTI) returnT (list))
false))))
_
@@ -770,7 +773,7 @@
(_.CHECKCAST class)
(_.fuse (list@map ..prepare-argI argsTI))
(<invoke> class method
- (_t.method (list@map product.left argsTI) returnT (list))
+ (jvm.method (list@map product.left argsTI) returnT (list))
<interface?>))))
_
@@ -791,7 +794,7 @@
_.DUP
(_.fuse (list@map ..prepare-argI argsTI))
(_.INVOKESPECIAL class "<init>"
- (_t.method (list@map product.left argsTI) #.None (list))
+ (jvm.method (list@map product.left argsTI) #.None (list))
false))))
_