aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm
diff options
context:
space:
mode:
authorEduardo Julian2021-07-18 23:10:18 -0400
committerEduardo Julian2021-07-18 23:10:18 -0400
commita40f40f230e6312ae432f06e7f73aa5945d8fa49 (patch)
tree5005ef744b01f9327c2e4df23146928f1723c495 /lux-jvm
parent442d1557b879a8a4bd76f441f72a17bfb71cf05f (diff)
New JVM compiler can now compile JVM interfaces.
Diffstat (limited to 'lux-jvm')
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux138
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm/def.lux2
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm/inst.lux4
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm.lux58
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/case.lux12
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux22
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux20
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/function.lux11
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/program.lux3
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/runtime.lux39
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/structure.lux3
-rw-r--r--lux-jvm/source/program.lux31
12 files changed, 229 insertions, 114 deletions
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 4d78d729c..b03cf6bbc 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -1,26 +1,35 @@
(.module:
[library
- [lux #*
+ [lux (#- Type)
[ffi (#+ import:)]
[type (#+ :share)]
[abstract
["." monad (#+ do)]]
[control
- ["." try (#+ Try)]]
+ ["." try (#+ Try)]
+ ["<>" parser
+ ["<.>" code (#+ Parser)]
+ ["<.>" text]]]
[data
[identity (#+ Identity)]
["." product]
[text
["%" format (#+ format)]]
[collection
- ["." list ("#@." fold)]
+ ["." list ("#\." fold functor)]
["." dictionary (#+ Dictionary)]
- ["." row (#+ Row) ("#@." functor fold)]]]
+ ["." row (#+ Row) ("#\." functor fold)]]]
[math
[number
["." nat]]]
[target
- ["/" jvm]]
+ ["/" jvm
+ [encoding
+ ["." name (#+ External)]]
+ ["#." type (#+ Type)
+ [category (#+ Void Value Return Method Primitive Object Class Array Var Parameter Declaration)]
+ ["." parser]
+ ["#/." signature]]]]
[tool
[compiler
["." phase]
@@ -28,16 +37,19 @@
[lux
[synthesis (#+ Synthesis)]
["." generation]
- ["." directive]
+ ["." directive (#+ Requirements)]
[phase
["." extension
["." bundle]
[directive
- ["./" lux]]]]]]]]]]
+ ["./" lux]]]]]]
+ [meta
+ [archive (#+ Archive)]]]]]]
[///
[host
["." jvm (#+ Inst)
- ["_" inst]]]])
+ ["_" inst]
+ ["." def]]]])
(import: org/objectweb/asm/Label
["#::."
@@ -416,7 +428,7 @@
(#/.TABLESWITCH min max default labels)
(let [[mapping default] (..relabel [mapping default])
- [mapping labels] (list@fold (function (_ input [mapping output])
+ [mapping labels] (list\fold (function (_ input [mapping output])
(let [[mapping input] (..relabel [mapping input])]
[mapping (list& input output)]))
[mapping (list)] labels)]
@@ -424,7 +436,7 @@
(#/.LOOKUPSWITCH default keys+labels)
(let [[mapping default] (..relabel [mapping default])
- [mapping keys+labels] (list@fold (function (_ [expected input] [mapping output])
+ [mapping keys+labels] (list\fold (function (_ [expected input] [mapping output])
(let [[mapping input] (..relabel [mapping input])]
[mapping (list& [expected input] output)]))
[mapping (list)] keys+labels)]
@@ -489,7 +501,7 @@
(def: (relabel_bytecode [mapping bytecode])
(Re_labeler (/.Bytecode Inst))
- (row@fold (function (_ input [mapping output])
+ (row\fold (function (_ input [mapping output])
(let [[mapping input'] (..relabel_instruction [mapping input])]
[mapping (row.add input' output)]))
[mapping (row.row)]
@@ -504,7 +516,7 @@
(|>> [..fresh]
..relabel_bytecode
product.right
- (row@map ..instruction)
+ (row\map ..instruction)
row.to_list
_.fuse))
@@ -512,7 +524,7 @@
<expression> (as_is Inst)
<directive> (as_is jvm.Definition)
<type_vars> (as_is <anchor> <expression> <directive>)]
- (type: Handler
+ (type: Handler'
## (generation.Handler jvm.Anchor (/.Bytecode Inst /.Label) jvm.Definition)
(-> extension.Name
(phase.Phase [(extension.Bundle <type_vars>)
@@ -531,15 +543,18 @@
(|>> (:as (/.Bytecode Inst /.Label)) ..bytecode)
((extender pseudo) extension_name phase archive inputs))))
+(type: Phase (directive.Phase jvm.Anchor jvm.Inst jvm.Definition))
+(type: Operation (directive.Operation jvm.Anchor jvm.Inst jvm.Definition))
+(type: Handler (directive.Handler jvm.Anchor jvm.Inst jvm.Definition))
+
(def: (def::generation extender)
- (-> jvm.Extender
- (directive.Handler jvm.Anchor jvm.Inst jvm.Definition))
+ (-> jvm.Extender ..Handler)
(function (handler extension_name phase archive inputsC+)
(case inputsC+
(^ (list nameC valueC))
(do phase.monad
[[_ _ name] (lux/.evaluate! archive Text nameC)
- [_ handlerV] (lux/.generator archive (:as Text name) ..Handler valueC)
+ [_ handlerV] (lux/.generator archive (:as Text name) ..Handler' valueC)
_ (|> handlerV
(..true_handler extender)
(extension.install extender (:as Text name))
@@ -551,8 +566,93 @@
_
(phase.throw extension.invalid_syntax [extension_name %.code inputsC+]))))
+(def: #export (custom [parser handler])
+ (All [i]
+ (-> [(Parser i)
+ (-> Text ..Phase Archive i (..Operation Requirements))]
+ ..Handler))
+ (function (_ extension_name phase archive input)
+ (case (<code>.run parser input)
+ (#try.Success input')
+ (handler extension_name phase archive input')
+
+ (#try.Failure error)
+ (phase.throw extension.invalid_syntax [extension_name %.code input]))))
+
+(template [<name> <type> <parser>]
+ [(def: <name>
+ (Parser <type>)
+ (do {! <>.monad}
+ [raw <code>.text]
+ (<>.lift (<text>.run <parser> raw))))]
+
+ [class_declaration [External (List (Type Var))] parser.declaration']
+ [class (Type Class) parser.class]
+ [type_variable (Type Var) parser.var]
+ [value (Type Value) parser.value]
+ )
+
+(def: annotation
+ (Parser Code)
+ <code>.any)
+
+(type: Method_Declaration
+ {#name Text
+ #annotations (List Code)
+ #type_variables (List (Type Var))
+ #exceptions (List (Type Class))
+ #arguments (List (Type Value))
+ #return (Type Value)})
+
+(def: method_declaration
+ (Parser Method_Declaration)
+ (<code>.form
+ ($_ <>.and
+ <code>.text
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ (<code>.tuple (<>.some ..class))
+ (<code>.tuple (<>.some ..value))
+ ..value
+ )))
+
+(def: java/lang/Object
+ (/type.class "java.lang.Object" (list)))
+
+(def: jvm::class::interface
+ ..Handler
+ (..custom
+ [($_ <>.and
+ ..class_declaration
+ (<code>.tuple (<>.some ..class))
+ (<code>.tuple (<>.some ..annotation))
+ (<>.some ..method_declaration))
+ (function (_ extension_name phase archive [[class_name type_variables] supers annotations method_declarations])
+ (do {! phase.monad}
+ [#let [constraints (list\map (function (_ tv)
+ {#/type.name (parser.name tv)
+ #/type.super_class java/lang/Object
+ #/type.super_interfaces (list)})
+ type_variables)
+ directive [class_name
+ (def.interface #jvm.V1_6 #jvm.Public jvm.noneC class_name
+ constraints
+ supers
+ (|> method_declarations
+ (list\map (function (_ (^slots [#name #annotations #type_variables #exceptions #arguments #return]))
+ (def.abstract_method #jvm.Public jvm.noneM name
+ (/type.method [type_variables arguments return exceptions]))))
+ def.fuse))]]]
+ (directive.lift_generation
+ (do !
+ [artifact_id (generation.learn_custom class_name)
+ _ (generation.execute! directive)
+ _ (generation.save! artifact_id (#.Some class_name) directive)
+ _ (generation.log! (format "JVM Interface " (%.text class_name)))]
+ (wrap directive.no_requirements)))))]))
+
(def: #export (bundle extender)
- (-> jvm.Extender
- (directive.Bundle jvm.Anchor jvm.Inst jvm.Definition))
+ (-> jvm.Extender (directive.Bundle jvm.Anchor jvm.Inst jvm.Definition))
(|> bundle.empty
- (dictionary.put "lux def generation" (..def::generation extender))))
+ (dictionary.put "lux def generation" (..def::generation extender))
+ (dictionary.put "jvm class interface" ..jvm::class::interface)))
diff --git a/lux-jvm/source/luxc/lang/host/jvm/def.lux b/lux-jvm/source/luxc/lang/host/jvm/def.lux
index 58121502a..953dbf200 100644
--- a/lux-jvm/source/luxc/lang/host/jvm/def.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm/def.lux
@@ -202,7 +202,7 @@
(let [writer (|> (do_to (org/objectweb/asm/ClassWriter::new class_computes)
(org/objectweb/asm/ClassWriter::visit (version_flag version)
($_ i.+
- (org/objectweb/asm/Opcodes::ACC_SUPER)
+ (org/objectweb/asm/Opcodes::ACC_ABSTRACT)
(org/objectweb/asm/Opcodes::ACC_INTERFACE)
(visibility_flag visibility)
(class_flags config))
diff --git a/lux-jvm/source/luxc/lang/host/jvm/inst.lux b/lux-jvm/source/luxc/lang/host/jvm/inst.lux
index 8427e23e1..9447861e3 100644
--- a/lux-jvm/source/luxc/lang/host/jvm/inst.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm/inst.lux
@@ -448,13 +448,13 @@
(def: #export (wrap type)
(-> (Type Primitive) Inst)
(let [wrapper (type.class (primitive_wrapper type) (list))]
- (INVOKESTATIC wrapper "valueOf" (type.method [(list type) wrapper (list)]))))
+ (INVOKESTATIC wrapper "valueOf" (type.method [(list) (list type) wrapper (list)]))))
(def: #export (unwrap type)
(-> (Type Primitive) Inst)
(let [wrapper (type.class (primitive_wrapper type) (list))]
(|>> (CHECKCAST wrapper)
- (INVOKEVIRTUAL wrapper (primitive_unwrap type) (type.method [(list) type (list)])))))
+ (INVOKEVIRTUAL wrapper (primitive_unwrap type) (type.method [(list) (list) type (list)])))))
(def: #export (fuse insts)
(-> (List Inst) Inst)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux
index 0f6ba6744..425a259aa 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm.lux
@@ -122,7 +122,7 @@
..value_field ..$Value)
(def.method #jvm.Public ($_ jvm.++M jvm.staticM jvm.strictM)
"<clinit>"
- (type.method [(list) type.void (list)])
+ (type.method [(list) (list) type.void (list)])
(|>> valueI
(inst.PUTSTATIC (type.class bytecode_name (list)) ..value_field ..$Value)
inst.RETURN))))]
@@ -155,35 +155,37 @@
value definition])))
(def: #export host
- (IO Host)
+ (IO [java/lang/ClassLoader Host])
(io (let [library (loader.new_library [])
loader (loader.memory library)]
- (: Host
- (implementation
- (def: (evaluate! context valueI)
- (\ try.monad map product.left
- (..evaluate! library loader context valueI)))
-
- (def: execute!
- (..execute! library loader))
-
- (def: define!
- (..define! library loader))
-
- (def: (ingest context bytecode)
- [(..class_name context) bytecode])
-
- (def: (re_learn context custom [_ bytecode])
- (io.run
- (loader.store (maybe.default (..class_name context) custom) bytecode library)))
-
- (def: (re_load context custom [_ bytecode])
- (io.run
- (do (try.with io.monad)
- [#let [class_name (maybe.default (..class_name context) custom)]
- _ (loader.store class_name bytecode library)
- class (loader.load class_name loader)]
- (\ io.monad wrap (..class_value class_name class))))))))))
+ [loader
+ (: Host
+ (implementation
+ (def: (evaluate! context valueI)
+ (\ try.monad map product.left
+ (..evaluate! library loader context valueI)))
+
+ (def: execute!
+ (..execute! library loader))
+
+ (def: define!
+ (..define! library loader))
+
+ (def: (ingest context bytecode)
+ [(..class_name context) bytecode])
+
+ (def: (re_learn context custom [_ bytecode])
+ (io.run
+ (loader.store (maybe.default (..class_name context) custom) bytecode library)))
+
+ (def: (re_load context custom [directive_name bytecode])
+ (io.run
+ (do (try.with io.monad)
+ [#let [class_name (maybe.default (..class_name context)
+ custom)]
+ _ (loader.store class_name bytecode library)
+ class (loader.load class_name loader)]
+ (\ io.monad wrap (..class_value class_name class)))))))])))
(def: #export $Variant
(type.array ..$Value))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux
index 65e5dba62..b7b1d6b0f 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux
@@ -53,7 +53,7 @@
(def: pushI
Inst
- (_.INVOKESTATIC //.$Runtime "pm_push" (type.method [(list runtime.$Stack //.$Value) runtime.$Stack (list)])))
+ (_.INVOKESTATIC //.$Runtime "pm_push" (type.method [(list) (list runtime.$Stack //.$Value) runtime.$Stack (list)])))
(def: popI
(|>> (_.int +1)
@@ -80,7 +80,7 @@
lefts
[(leftsI lefts)
- (_.INVOKESTATIC //.$Runtime "tuple_left" (type.method [(list //.$Tuple runtime.$Index) //.$Value (list)]))])]
+ (_.INVOKESTATIC //.$Runtime "tuple_left" (type.method [(list) (list //.$Tuple runtime.$Index) //.$Value (list)]))])]
(|>> (_.CHECKCAST //.$Tuple)
indexI
accessI)))
@@ -89,7 +89,7 @@
(-> Nat Inst)
(|>> (_.CHECKCAST //.$Tuple)
(leftsI lefts)
- (_.INVOKESTATIC //.$Runtime "tuple_right" (type.method [(list //.$Tuple runtime.$Index) //.$Value (list)]))))
+ (_.INVOKESTATIC //.$Runtime "tuple_right" (type.method [(list) (list //.$Tuple runtime.$Index) //.$Value (list)]))))
(def: (path' stack_depth @else @end phase archive path)
(-> Nat Label Label Phase Archive Path (Operation Inst))
@@ -144,7 +144,7 @@
([#synthesis.I64_Fork (_.unwrap type.long) _.DUP2 _.POP2 (|>> .int _.long) _.LCMP _.IFNE]
[#synthesis.F64_Fork (_.unwrap type.double) _.DUP2 _.POP2 _.double _.DCMPL _.IFNE]
[#synthesis.Text_Fork (|>) _.DUP _.POP _.string
- (_.INVOKEVIRTUAL (type.class "java.lang.Object" (list)) "equals" (type.method [(list //.$Value) type.boolean (list)]))
+ (_.INVOKEVIRTUAL (type.class "java.lang.Object" (list)) "equals" (type.method [(list) (list //.$Value) type.boolean (list)]))
_.IFEQ])
(#synthesis.Then bodyS)
@@ -162,7 +162,7 @@
(_.CHECKCAST //.$Variant)
(structure.tagI lefts <right?>)
(structure.flagI <right?>)
- (_.INVOKESTATIC //.$Runtime "pm_variant" (type.method [(list //.$Variant runtime.$Tag runtime.$Flag) runtime.$Value (list)]))
+ (_.INVOKESTATIC //.$Runtime "pm_variant" (type.method [(list) (list //.$Variant runtime.$Tag runtime.$Flag) runtime.$Value (list)]))
_.DUP
(_.IFNULL @fail)
(_.GOTO @success)
@@ -220,7 +220,7 @@
(wrap (|>> pathI
(_.label @else)
_.POP
- (_.INVOKESTATIC //.$Runtime "pm_fail" (type.method [(list) type.void (list)]))
+ (_.INVOKESTATIC //.$Runtime "pm_fail" (type.method [(list) (list) type.void (list)]))
_.NULL
(_.GOTO @end)))))
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 [<name> <pre_subject> <pre_param> <op> <post>]
@@ -240,13 +240,13 @@
<op> <post>))]
[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 [<name> <invoke>]
@@ -741,7 +741,8 @@
(_.CHECKCAST class)
(_.fuse (list@map product.right inputsTI))
(<invoke> 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 "<init>" (type.method [(list@map product.left inputsTI) type.void (list)]))))))]))
+ (_.INVOKESPECIAL class "<init>" (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 "<init>" (anonymous_init_method env)
(|>> (_.ALOAD 0)
((_.fuse (list@map product.right inputsTI)))
- (_.INVOKESPECIAL super_class "<init>" (type.method [(list@map product.left inputsTI) type.void (list)]))
+ (_.INVOKESPECIAL super_class "<init>" (type.method [(list) (list@map product.left inputsTI) type.void (list)]))
store_capturedI
_.RETURN))))
@@ -986,7 +988,8 @@
(<synthesis>.tuple (<>.some ..class))
(<synthesis>.tuple (<>.some ..input))
(<synthesis>.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)))))))
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
index 394b0b7b5..9e0f9f225 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux
@@ -57,15 +57,16 @@
(def: (init_method env arity)
(-> (Environment Synthesis) Arity (Type Method))
(if (poly_arg? arity)
- (type.method [(list.concat (list (captured_args env)
+ (type.method [(list)
+ (list.concat (list (captured_args env)
(list type.int)
(list.repeat (dec arity) //.$Value)))
type.void
(list)])
- (type.method [(captured_args env) type.void (list)])))
+ (type.method [(list) (captured_args env) type.void (list)])))
(def: (implementation_method arity)
- (type.method [(list.repeat arity //.$Value) //.$Value (list)]))
+ (type.method [(list) (list.repeat arity //.$Value) //.$Value (list)]))
(def: get_amount_of_partialsI
Inst
@@ -122,7 +123,7 @@
(def: (reset_method return)
(-> (Type Class) (Type Method))
- (type.method [(list) return (list)]))
+ (type.method [(list) (list) return (list)]))
(def: (with_reset class arity env)
(-> (Type Class) Arity (Environment Synthesis) Def)
@@ -156,7 +157,7 @@
_.ARETURN)))
(def: function_init_method
- (type.method [(list type.int) type.void (list)]))
+ (type.method [(list) (list type.int) type.void (list)]))
(def: (function_init arity env_size)
(-> Arity Nat Inst)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/program.lux b/lux-jvm/source/luxc/lang/translation/jvm/program.lux
index 1ebdf33f0..9cd8eeb82 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/program.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/program.lux
@@ -73,7 +73,8 @@
run_ioI (|>> ($i.CHECKCAST jvm.$Function)
$i.NULL
($i.INVOKEVIRTUAL jvm.$Function runtime.apply_method (runtime.apply_signature 1)))
- main_type ($t.method [(list ($t.array ($t.class "java.lang.String" (list))))
+ main_type ($t.method [(list)
+ (list ($t.array ($t.class "java.lang.String" (list))))
$t.void
(list)])
class (artifact_name context)]
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
index e0426f363..cccdf42bf 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/runtime.lux
@@ -48,22 +48,22 @@
(def: $Throwable (type.class "java.lang.Throwable" (list)))
(def: nullary_init_methodT
- (type.method [(list) type.void (list)]))
+ (type.method [(list) (list) type.void (list)]))
(def: throw_methodT
- (type.method [(list) type.void (list)]))
+ (type.method [(list) (list) type.void (list)]))
(def: #export logI
Inst
(let [PrintStream (type.class "java.io.PrintStream" (list))
outI (_.GETSTATIC (type.class "java.lang.System" (list)) "out" PrintStream)
printI (function (_ method)
- (_.INVOKEVIRTUAL PrintStream method (type.method [(list $Value) type.void (list)])))]
+ (_.INVOKEVIRTUAL PrintStream method (type.method [(list) (list $Value) type.void (list)])))]
(|>> outI (_.string "LOG: ") (printI "print")
outI _.SWAP (printI "println"))))
(def: variant_method
- (type.method [(list $Tag $Flag $Value) //.$Variant (list)]))
+ (type.method [(list) (list $Tag $Flag $Value) //.$Variant (list)]))
(def: #export variantI
Inst
@@ -115,7 +115,7 @@
(def: #export (apply_signature arity)
(-> Arity (Type Method))
- (type.method [(list.repeat arity $Value) $Value (list)]))
+ (type.method [(list) (list.repeat arity $Value) $Value (list)]))
(def: adt_methods
Def
@@ -123,7 +123,7 @@
store_flagI (|>> _.DUP _.ICONST_1 (_.ALOAD 1) _.AASTORE)
store_valueI (|>> _.DUP _.ICONST_2 (_.ALOAD 2) _.AASTORE)]
(|>> ($d.method #$.Public $.staticM "variant_make"
- (type.method [(list $Tag $Flag $Value) //.$Variant (list)])
+ (type.method [(list) (list $Tag $Flag $Value) //.$Variant (list)])
(|>> _.ICONST_3
(_.ANEWARRAY $Value)
store_tagI
@@ -133,10 +133,10 @@
(def: frac_methods
Def
- (|>> ($d.method #$.Public $.staticM "decode_frac" (type.method [(list $Text) //.$Variant (list)])
+ (|>> ($d.method #$.Public $.staticM "decode_frac" (type.method [(list) (list $Text) //.$Variant (list)])
(tryI
(|>> (_.ALOAD 0)
- (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "parseDouble" (type.method [(list $Text) type.double (list)]))
+ (_.INVOKESTATIC (type.class "java.lang.Double" (list)) "parseDouble" (type.method [(list) (list $Text) type.double (list)]))
(_.wrap type.double))))
))
@@ -146,7 +146,7 @@
(|>> (_.NEW IllegalStateException)
_.DUP
(_.string message)
- (_.INVOKESPECIAL IllegalStateException "<init>" (type.method [(list $Text) type.void (list)])))))
+ (_.INVOKESPECIAL IllegalStateException "<init>" (type.method [(list) (list $Text) type.void (list)])))))
(def: pm_methods
Def
@@ -175,7 +175,7 @@
($d.method #$.Public $.staticM "apply_fail" throw_methodT
(|>> (illegal_state_exception "Error while applying function.")
_.ATHROW))
- ($d.method #$.Public $.staticM "pm_push" (type.method [(list $Stack $Value) $Stack (list)])
+ ($d.method #$.Public $.staticM "pm_push" (type.method [(list) (list $Stack $Value) $Stack (list)])
(|>> _.ICONST_2
(_.ANEWARRAY $Value)
_.DUP
@@ -187,7 +187,7 @@
(_.ALOAD 1)
_.AASTORE
_.ARETURN))
- ($d.method #$.Public $.staticM "pm_variant" (type.method [(list //.$Variant $Tag $Flag) $Value (list)])
+ ($d.method #$.Public $.staticM "pm_variant" (type.method [(list) (list //.$Variant $Tag $Flag) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @perfect_match!))
_.with_label (function (_ @tags_match!))
@@ -247,7 +247,7 @@
## _.POP2
not_found
_.ARETURN)))
- ($d.method #$.Public $.staticM "tuple_left" (type.method [(list //.$Tuple $Index) $Value (list)])
+ ($d.method #$.Public $.staticM "tuple_left" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @recursive))
(let [left_accessI (|>> (_.ALOAD 0) left_indexI _.AALOAD)])
@@ -258,7 +258,7 @@
(_.label @recursive)
## Recursive
(recurI @loop))))
- ($d.method #$.Public $.staticM "tuple_right" (type.method [(list //.$Tuple $Index) $Value (list)])
+ ($d.method #$.Public $.staticM "tuple_right" (type.method [(list) (list //.$Tuple $Index) $Value (list)])
(<| _.with_label (function (_ @loop))
_.with_label (function (_ @not_tail))
_.with_label (function (_ @slice))
@@ -272,7 +272,8 @@
right_indexI
tuple_sizeI
(_.INVOKESTATIC (type.class "java.util.Arrays" (list)) "copyOfRange"
- (type.method [(list //.$Tuple $Index $Index)
+ (type.method [(list)
+ (list //.$Tuple $Index $Index)
//.$Tuple
(list)])))])
(|>> (_.label @loop)
@@ -291,7 +292,7 @@
)))
)))
-(def: #export try (type.method [(list //.$Function) //.$Variant (list)]))
+(def: #export try (type.method [(list) (list //.$Function) //.$Variant (list)]))
(def: io_methods
Def
@@ -306,7 +307,7 @@
_.POP
_.SWAP
(_.boolean true)
- (_.INVOKESPECIAL PrintWriter "<init>" (type.method [(list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)]))
+ (_.INVOKESPECIAL PrintWriter "<init>" (type.method [(list) (list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)]))
)]
(|>> ($d.method #$.Public $.staticM "try" ..try
(<| _.with_label (function (_ @from))
@@ -324,8 +325,8 @@
string_writerI ## TW
_.DUP2 ## TWTW
print_writerI ## TWTP
- (_.INVOKEVIRTUAL $Throwable "printStackTrace" (type.method [(list (type.class "java.io.PrintWriter" (list))) type.void (list)])) ## TW
- (_.INVOKEVIRTUAL StringWriter "toString" (type.method [(list) $Text (list)])) ## TS
+ (_.INVOKEVIRTUAL $Throwable "printStackTrace" (type.method [(list) (list (type.class "java.io.PrintWriter" (list))) type.void (list)])) ## TW
+ (_.INVOKEVIRTUAL StringWriter "toString" (type.method [(list) (list) $Text (list)])) ## TS
_.SWAP _.POP leftI
_.ARETURN)))
)))
@@ -375,7 +376,7 @@
function_class (..reflection //.$Function)
bytecode ($d.abstract #$.V1_6 #$.Public $.noneC function_class (list) $Object (list)
(|>> ($d.field #$.Public $.finalF partials_field type.int)
- ($d.method #$.Public $.noneM "<init>" (type.method [(list type.int) type.void (list)])
+ ($d.method #$.Public $.noneM "<init>" (type.method [(list) (list type.int) type.void (list)])
(|>> (_.ALOAD 0)
(_.INVOKESPECIAL $Object "<init>" nullary_init_methodT)
(_.ALOAD 0)
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
index 16b320b6d..a9666958b 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/structure.lux
@@ -114,6 +114,7 @@
memberI
(_.INVOKESTATIC //.$Runtime
"variant_make"
- (type.method [(list //runtime.$Tag //runtime.$Flag //runtime.$Value)
+ (type.method [(list)
+ (list //runtime.$Tag //runtime.$Flag //runtime.$Value)
//.$Variant
(list)]))))))
diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux
index 185d2d9ba..13979573d 100644
--- a/lux-jvm/source/program.lux
+++ b/lux-jvm/source/program.lux
@@ -78,6 +78,8 @@
["#::."
(invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)])
+(import: java/lang/ClassLoader)
+
(import: (java/lang/Class c)
["#::."
(getMethod [java/lang/String [(java/lang/Class java/lang/Object)]] #try java/lang/reflect/Method)])
@@ -226,18 +228,20 @@
(def: #export platform
## (IO (Platform Anchor (Bytecode Any) Definition))
- (IO (Platform _.Anchor _.Inst _.Definition))
+ (IO [java/lang/ClassLoader
+ (Platform _.Anchor _.Inst _.Definition)])
(do io.monad
[## host jvm/host.host
- host jvm.host]
- (wrap {#platform.&file_system (file.async file.default)
- #platform.host host
- ## #platform.phase jvm.generate
- #platform.phase expression.translate
- ## #platform.runtime runtime.generate
- #platform.runtime runtime.translate
- #platform.phase_wrapper ..phase_wrapper
- #platform.write product.right})))
+ [loader host] jvm.host]
+ (wrap [loader
+ {#platform.&file_system (file.async file.default)
+ #platform.host host
+ ## #platform.phase jvm.generate
+ #platform.phase expression.translate
+ ## #platform.runtime runtime.generate
+ #platform.runtime runtime.translate
+ #platform.phase_wrapper ..phase_wrapper
+ #platform.write product.right}])))
(def: (extender phase_wrapper)
(-> platform.Phase_Wrapper Extender)
@@ -278,13 +282,14 @@
#/static.target (/cli.target service)
#/static.artifact_extension ".class"}]
(exec (do promise.monad
- [_ (/.compiler {#/static.host @.jvm
+ [[loader platform] (promise.future ..platform)
+ _ (/.compiler {#/static.host @.jvm
#/static.host_module_extension ".jvm"
#/static.target (/cli.target service)
#/static.artifact_extension ".class"}
..expander
- analysis.bundle
- ..platform
+ (analysis.bundle loader)
+ (io.io platform)
## generation.bundle
translation.bundle
(|>> ..extender directive.bundle)