aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2021-07-22 01:16:40 -0400
committerEduardo Julian2021-07-22 01:16:40 -0400
commit51a5c28b0f9efd514e3fae7c2634fd5e9bd714e2 (patch)
treecbd24da4230577ef5bbf66161cb825216d924ba5
parent461a6ce673de9b2c3d77714c4884c2a316fe7e8f (diff)
New JVM compiler can now compile JVM classes.
-rw-r--r--documentation/bookmark/music.md4
-rw-r--r--documentation/bookmark/type_driven.md4
-rw-r--r--lux-jvm/source/luxc/lang/directive/jvm.lux844
-rw-r--r--lux-jvm/source/luxc/lang/host/jvm.lux9
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux41
-rw-r--r--stdlib/source/library/lux/ffi.jvm.lux183
-rw-r--r--stdlib/source/library/lux/ffi.old.lux78
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/directive.lux14
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux40
-rw-r--r--stdlib/source/test/lux.lux80
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux239
11 files changed, 1283 insertions, 253 deletions
diff --git a/documentation/bookmark/music.md b/documentation/bookmark/music.md
index e68491b50..1e3bba2c5 100644
--- a/documentation/bookmark/music.md
+++ b/documentation/bookmark/music.md
@@ -1,3 +1,7 @@
+# Language
+
+1. [alda: Alda is a text-based programming language for music composition. It allows you to write and play back music using only a text editor and the command line.](https://alda.io/)
+
# Async music
1. [async music](https://async.art/music)
diff --git a/documentation/bookmark/type_driven.md b/documentation/bookmark/type_driven.md
new file mode 100644
index 000000000..22d99998e
--- /dev/null
+++ b/documentation/bookmark/type_driven.md
@@ -0,0 +1,4 @@
+# Reference
+
+1. [Deltoid](https://github.com/jjpe/deltoid)
+
diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux
index 3ebcfe641..841f31b92 100644
--- a/lux-jvm/source/luxc/lang/directive/jvm.lux
+++ b/lux-jvm/source/luxc/lang/directive/jvm.lux
@@ -1,22 +1,23 @@
(.module:
[library
- [lux (#- Type)
- [ffi (#+ import:)]
- [type (#+ :share)]
+ [lux (#- Type static)
+ ["." ffi (#+ Inheritance Privacy State import:)]
[abstract
["." monad (#+ do)]]
[control
+ [pipe (#+ case>)]
["." try (#+ Try)]
["<>" parser
["<.>" code (#+ Parser)]
["<.>" text]]]
[data
[identity (#+ Identity)]
+ [binary (#+ Binary)]
["." product]
[text
["%" format (#+ format)]]
[collection
- ["." list ("#\." fold functor)]
+ ["." list ("#\." fold functor monoid)]
["." dictionary (#+ Dictionary)]
["." row (#+ Row) ("#\." functor fold)]]]
[math
@@ -26,9 +27,10 @@
["/" jvm
[encoding
["." name (#+ External)]]
- ["#." type (#+ Type)
- [category (#+ Void Value Return Method Primitive Object Class Array Var Parameter Declaration)]
+ ["#." type (#+ Type Constraint)
+ [category (#+ Void Value Return Primitive Object Class Array Var Parameter)]
["." parser]
+ [".T" lux]
["#/." signature]
["#/." descriptor]]]]
[tool
@@ -36,12 +38,18 @@
["." phase]
[language
[lux
- [synthesis (#+ Synthesis)]
+ ["." analysis (#+ Analysis)]
+ ["." synthesis (#+ Synthesis)]
["." generation]
["." directive (#+ Requirements)]
[phase
+ [analysis
+ [".A" scope]
+ [".A" type]]
["." extension
["." bundle]
+ [analysis
+ ["//A" jvm]]
[directive
["./" lux]]]]]]
[meta
@@ -50,7 +58,11 @@
[host
["." jvm (#+ Inst)
["_" inst]
- ["." def]]]])
+ ["." def]]]
+ [translation
+ [jvm
+ [extension
+ ["//G" host]]]]])
(import: org/objectweb/asm/Label
["#::."
@@ -580,6 +592,9 @@
(#try.Failure error)
(phase.throw extension.invalid_syntax [extension_name %.code input]))))
+(type: Declaration
+ [External (List (Type Var))])
+
(template [<name> <type> <parser>]
[(def: <name>
(Parser <type>)
@@ -587,19 +602,23 @@
[raw <code>.text]
(<>.lift (<text>.run <parser> raw))))]
- [class_declaration [External (List (Type Var))] parser.declaration']
+ [class_declaration Declaration parser.declaration']
[class (Type Class) parser.class]
[type_variable (Type Var) parser.var]
[value (Type Value) parser.value]
+ [return_type (Type Return) parser.return]
)
+(type: Annotation
+ Code)
+
(def: annotation
- (Parser Code)
+ (Parser Annotation)
<code>.any)
(type: Method_Declaration
{#name Text
- #annotations (List Code)
+ #annotations (List Annotation)
#type_variables (List (Type Var))
#exceptions (List (Type Class))
#arguments (List (Type Value))
@@ -620,6 +639,799 @@
(def: java/lang/Object
(/type.class "java.lang.Object" (list)))
+(def: inheritance
+ (Parser Inheritance)
+ ($_ <>.or
+ (<code>.text! "final")
+ (<code>.text! "abstract")
+ (<code>.text! "default")
+ ))
+
+(def: privacy
+ (Parser Privacy)
+ ($_ <>.or
+ (<code>.text! "public")
+ (<code>.text! "private")
+ (<code>.text! "protected")
+ (<code>.text! "default")
+ ))
+
+(def: state
+ (Parser State)
+ ($_ <>.or
+ (<code>.text! "volatile")
+ (<code>.text! "final")
+ (<code>.text! "default")
+ ))
+
+(type: Field
+ [Text Privacy State (List Annotation) (Type Value)])
+
+(def: field
+ (Parser Field)
+ (<code>.form
+ (do <>.monad
+ [_ (<code>.text! "variable")
+ name <code>.text
+ privacy ..privacy
+ state ..state
+ _ (<code>.tuple (<>.some ..annotation))
+ type ..value]
+ (wrap [name privacy state (list) type]))))
+
+(type: Argument
+ [Text (Type Value)])
+
+(def: argument
+ (Parser Argument)
+ (<code>.tuple
+ (<>.and <code>.text
+ ..value)))
+
+(type: (Constructor a)
+ [Privacy Bit (List Annotation) (List (Type Var)) (List (Type Class))
+ Text (List Argument) (List [(Type Value) a])
+ a])
+
+(type: (Override a)
+ [Declaration Text Bit (List Annotation) (List (Type Var))
+ Text (List Argument) (Type Return) (List (Type Class))
+ a])
+
+(type: (Virtual a)
+ [Text Privacy Bit Bit (List Annotation) (List (Type Var))
+ Text (List Argument) (Type Return) (List (Type Class))
+ a])
+
+(type: (Static a)
+ [Text Privacy Bit (List Annotation) (List (Type Var))
+ (List Argument) (Type Return) (List (Type Class))
+ a])
+
+(type: Abstract
+ [Text Privacy (List Annotation) (List (Type Var))
+ (List Argument) (Type Return) (List (Type Class))])
+
+(type: (Method a)
+ (#Constructor (Constructor a))
+ (#Override (Override a))
+ (#Virtual (Virtual a))
+ (#Static (Static a))
+ (#Abstract Abstract))
+
+(def: constructor
+ (Parser (Constructor Code))
+ (let [constructor_argument (: (Parser [(Type Value) Code])
+ (<code>.tuple
+ (<>.and ..value
+ <code>.any)))]
+ (<| <code>.form
+ (<>.after (<code>.text! "init"))
+ ($_ <>.and
+ ..privacy
+ <code>.bit
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ (<code>.tuple (<>.some ..class))
+ <code>.text
+ (<code>.tuple (<>.some ..argument))
+ (<code>.tuple (<>.some constructor_argument))
+ <code>.any
+ ))))
+
+(def: override
+ (Parser (Override Code))
+ (<| <code>.form
+ (<>.after (<code>.text! "override"))
+ ($_ <>.and
+ ..class_declaration
+ <code>.text
+ <code>.bit
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ <code>.text
+ (<code>.tuple (<>.some ..argument))
+ ..return_type
+ (<code>.tuple (<>.some ..class))
+ <code>.any
+ )))
+
+(def: virtual
+ (Parser (Virtual Code))
+ (<| <code>.form
+ (<>.after (<code>.text! "virtual"))
+ ($_ <>.and
+ <code>.text
+ ..privacy
+ <code>.bit
+ <code>.bit
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ <code>.text
+ (<code>.tuple (<>.some ..argument))
+ ..return_type
+ (<code>.tuple (<>.some ..class))
+ <code>.any
+ )))
+
+(def: static
+ (Parser (Static Code))
+ (<| <code>.form
+ (<>.after (<code>.text! "static"))
+ ($_ <>.and
+ <code>.text
+ ..privacy
+ <code>.bit
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ (<code>.tuple (<>.some ..argument))
+ ..return_type
+ (<code>.tuple (<>.some ..class))
+ <code>.any
+ )))
+
+(def: abstract
+ (Parser Abstract)
+ (<| <code>.form
+ (<>.after (<code>.text! "abstract"))
+ ($_ <>.and
+ <code>.text
+ ..privacy
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..type_variable))
+ (<code>.tuple (<>.some ..argument))
+ ..return_type
+ (<code>.tuple (<>.some ..class))
+ )))
+
+(def: method
+ (Parser (Method Code))
+ ($_ <>.or
+ ..constructor
+ ..override
+ ..virtual
+ ..static
+ ..abstract
+ ))
+
+(def: (constraint tv)
+ (-> (Type Var) Constraint)
+ {#/type.name (parser.name tv)
+ #/type.super_class java/lang/Object
+ #/type.super_interfaces (list)})
+
+(def: visibility
+ (-> ffi.Privacy jvm.Visibility)
+ (|>> (case> #ffi.PublicP #jvm.Public
+ #ffi.PrivateP #jvm.Private
+ #ffi.ProtectedP #jvm.Protected
+ #ffi.DefaultP #jvm.Default)))
+
+(def: field_config
+ (-> ffi.State jvm.Field_Config)
+ (|>> (case> #ffi.VolatileS jvm.volatileF
+ #ffi.FinalS jvm.finalF
+ #ffi.DefaultS jvm.noneF)))
+
+(def: (field_header [name privacy state annotations type])
+ (-> Field jvm.Def)
+ (def.field (..visibility privacy) (..field_config state) name type))
+
+(def: (header_value valueT)
+ (-> (Type Value) Inst)
+ (case (/type.primitive? valueT)
+ (#.Left classT)
+ _.NULL
+
+ (#.Right primitiveT)
+ (cond (or (\ /type.equivalence = /type.boolean primitiveT)
+ (\ /type.equivalence = /type.byte primitiveT)
+ (\ /type.equivalence = /type.short primitiveT)
+ (\ /type.equivalence = /type.int primitiveT)
+ (\ /type.equivalence = /type.char primitiveT))
+ _.ICONST_0
+
+ (\ /type.equivalence = /type.long primitiveT)
+ _.LCONST_0
+
+ (\ /type.equivalence = /type.float primitiveT)
+ _.FCONST_0
+
+ ## (\ /type.equivalence = /type.double primitiveT)
+ _.DCONST_0)))
+
+(def: (header_return returnT)
+ (-> (Type Return) Inst)
+ (case (/type.void? returnT)
+ (#.Right returnT)
+ _.RETURN
+
+ (#.Left valueT)
+ (case (/type.primitive? valueT)
+ (#.Left classT)
+ (|>> (header_value classT)
+ _.ARETURN)
+
+ (#.Right primitiveT)
+ (cond (or (\ /type.equivalence = /type.boolean primitiveT)
+ (\ /type.equivalence = /type.byte primitiveT)
+ (\ /type.equivalence = /type.short primitiveT)
+ (\ /type.equivalence = /type.int primitiveT)
+ (\ /type.equivalence = /type.char primitiveT))
+ (|>> (header_value primitiveT)
+ _.IRETURN)
+
+ (\ /type.equivalence = /type.long primitiveT)
+ (|>> (header_value primitiveT)
+ _.LRETURN)
+
+ (\ /type.equivalence = /type.float primitiveT)
+ (|>> (header_value primitiveT)
+ _.FRETURN)
+
+ ## (\ /type.equivalence = /type.double primitiveT)
+ (|>> (header_value primitiveT)
+ _.DRETURN)))))
+
+(def: constructor_name
+ "<init>")
+
+(def: (abstract_method_generation method)
+ (-> Abstract jvm.Def)
+ (let [[name privacy annotations variables
+ arguments return exceptions] method]
+ (def.abstract_method (..visibility privacy)
+ jvm.noneM
+ name
+ (/type.method [variables (list\map product.right arguments) return exceptions]))))
+
+(def: (method_header super_class method)
+ (-> (Type Class) (Method Code) jvm.Def)
+ (case method
+ (#Constructor [privacy strict_floating_point? annotations variables exceptions
+ self arguments constructor_arguments
+ body])
+ (let [[super_name super_vars] (parser.read_class super_class)
+ init_constructor_arguments (|> constructor_arguments
+ (list\map (|>> product.left ..header_value))
+ _.fuse)
+ super_constructorT (/type.method [(list)
+ (list\map product.left constructor_arguments)
+ /type.void
+ (list)])]
+ (def.method (..visibility privacy)
+ (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)
+ ..constructor_name
+ (/type.method [variables (list\map product.right arguments) /type.void exceptions])
+ (|>> (_.ALOAD 0)
+ init_constructor_arguments
+ (_.INVOKESPECIAL super_class ..constructor_name super_constructorT)
+ _.RETURN)))
+
+ (#Override [[parent_name parent_variables] name strict_floating_point? annotations variables
+ self arguments return exceptions
+ body])
+ (def.method #jvm.Public
+ (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)
+ name
+ (/type.method [variables (list\map product.right arguments) return exceptions])
+ (..header_return return))
+
+ (#Virtual [name privacy final? strict_floating_point? annotations variables
+ self arguments return exceptions
+ body])
+ (def.method (..visibility privacy)
+ (|> jvm.noneM
+ (jvm.++M (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM))
+ (jvm.++M (if final?
+ jvm.finalM
+ jvm.noneM)))
+ name
+ (/type.method [variables (list\map product.right arguments) return exceptions])
+ (..header_return return))
+
+ (#Static [name privacy strict_floating_point? annotations variables
+ arguments return exceptions
+ body])
+ (def.method (..visibility privacy)
+ (|> jvm.staticM
+ (jvm.++M (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)))
+ name
+ (/type.method [variables (list\map product.right arguments) return exceptions])
+ (..header_return return))
+
+ (#Abstract method)
+ (..abstract_method_generation method)
+ ))
+
+(def: (header [class_name type_variables]
+ super_class
+ super_interfaces
+ inheritance
+ fields
+ methods)
+ (-> Declaration
+ (Type Class)
+ (List (Type Class))
+ Inheritance
+ (List Field)
+ (List (Method Code))
+ [External Binary])
+ (let [constraints (list\map ..constraint type_variables)
+ field_definitions (list\map ..field_header fields)
+ method_definitions (list\map (..method_header super_class) methods)
+ definitions (def.fuse (list\compose field_definitions
+ method_definitions))]
+ [class_name
+ (case inheritance
+ #ffi.DefaultI
+ (def.class #jvm.V1_6 #jvm.Public jvm.noneC class_name constraints super_class super_interfaces
+ definitions)
+
+ #ffi.FinalI
+ (def.class #jvm.V1_6 #jvm.Public jvm.finalC class_name constraints super_class super_interfaces
+ definitions)
+
+ #ffi.AbstractI
+ (def.abstract #jvm.V1_6 #jvm.Public jvm.noneC class_name constraints super_class super_interfaces
+ definitions))]))
+
+(def: (constructor_method_analysis archive [class_name class_tvars] method)
+ (-> Archive Declaration (Constructor Code) (Operation (Constructor Analysis)))
+ (do {! phase.monad}
+ [#let [[privacy strict_floating_point? annotations method_tvars exceptions
+ self arguments constructor_argumentsC
+ bodyC] method]
+ analyse directive.analysis]
+ (directive.lift_analysis
+ (do !
+ [mapping (//A.with_fresh_type_vars class_tvars luxT.fresh)
+ mapping (//A.with_fresh_type_vars method_tvars mapping)
+ constructor_argumentsA (monad.map ! (function (_ [typeJ termC])
+ (do !
+ [typeL (//A.reflection_type mapping typeJ)
+ termA (typeA.with_type typeL
+ (analyse archive termC))]
+ (wrap [typeJ termA])))
+ constructor_argumentsC)
+ selfT (//A.reflection_type mapping (/type.class class_name class_tvars))
+ arguments' (monad.map !
+ (function (_ [name type])
+ (\ ! map (|>> [name])
+ (//A.reflection_type mapping type)))
+ arguments)
+ returnT (//A.reflection_return mapping /type.void)
+ [_scope bodyA] (|> arguments'
+ (#.Cons [self selfT])
+ list.reverse
+ (list\fold scopeA.with_local (analyse archive bodyC))
+ (typeA.with_type returnT)
+ analysis.with_scope)]
+ (wrap [privacy strict_floating_point? annotations method_tvars exceptions
+ self arguments constructor_argumentsA
+ bodyA])))))
+
+(def: (override_method_analysis archive [class_name class_tvars] supers method)
+ (-> Archive Declaration (List (Type Class)) (Override Code) (Operation (Override Analysis)))
+ (do {! phase.monad}
+ [#let [[[super_name super_tvars] method_name strict_floating_point? annotations
+ method_tvars self arguments returnJ exceptionsJ
+ bodyC] method]
+ analyse directive.analysis]
+ (directive.lift_analysis
+ (do !
+ [mapping (//A.with_fresh_type_vars class_tvars luxT.fresh)
+ #let [parent_type (/type.class super_name super_tvars)]
+ mapping (//A.with_override_mapping supers parent_type mapping)
+ mapping (//A.with_fresh_type_vars method_tvars mapping)
+ selfT (//A.reflection_type mapping (/type.class class_name class_tvars))
+ arguments' (monad.map !
+ (function (_ [name type])
+ (\ ! map (|>> [name])
+ (//A.reflection_type mapping type)))
+ arguments)
+ returnT (//A.reflection_return mapping returnJ)
+ [_scope bodyA] (|> arguments'
+ (#.Cons [self selfT])
+ list.reverse
+ (list\fold scopeA.with_local (analyse archive bodyC))
+ (typeA.with_type returnT)
+ analysis.with_scope)]
+ (wrap [[super_name super_tvars] method_name strict_floating_point? annotations
+ method_tvars self arguments returnJ exceptionsJ
+ bodyA])))))
+
+(def: (virtual_method_analysis archive [class_name class_tvars] method)
+ (-> Archive Declaration (Virtual Code) (Operation (Virtual Analysis)))
+ (do {! phase.monad}
+ [#let [[name privacy final? strict_floating_point? annotations method_tvars
+ self arguments returnJ exceptionsJ
+ bodyC] method]
+ analyse directive.analysis]
+ (directive.lift_analysis
+ (do !
+ [mapping (//A.with_fresh_type_vars class_tvars luxT.fresh)
+ mapping (//A.with_fresh_type_vars method_tvars mapping)
+ selfT (//A.reflection_type mapping (/type.class class_name class_tvars))
+ arguments' (monad.map !
+ (function (_ [name type])
+ (\ ! map (|>> [name])
+ (//A.reflection_type mapping type)))
+ arguments)
+ returnT (//A.reflection_return mapping returnJ)
+ [_scope bodyA] (|> arguments'
+ (#.Cons [self selfT])
+ list.reverse
+ (list\fold scopeA.with_local (analyse archive bodyC))
+ (typeA.with_type returnT)
+ analysis.with_scope)]
+ (wrap [name privacy final? strict_floating_point? annotations method_tvars
+ self arguments returnJ exceptionsJ
+ bodyA])))))
+
+(def: (static_method_analysis archive method)
+ (-> Archive (Static Code) (Operation (Static Analysis)))
+ (do {! phase.monad}
+ [#let [[name privacy strict_floating_point? annotations method_tvars
+ arguments returnJ exceptionsJ
+ bodyC] method]
+ analyse directive.analysis]
+ (directive.lift_analysis
+ (do !
+ [mapping (//A.with_fresh_type_vars method_tvars luxT.fresh)
+ arguments' (monad.map !
+ (function (_ [name type])
+ (\ ! map (|>> [name])
+ (//A.reflection_type mapping type)))
+ arguments)
+ returnT (//A.reflection_return mapping returnJ)
+ [_scope bodyA] (|> arguments'
+ list.reverse
+ (list\fold scopeA.with_local (analyse archive bodyC))
+ (typeA.with_type returnT)
+ analysis.with_scope)]
+ (wrap [name privacy strict_floating_point? annotations method_tvars
+ arguments returnJ exceptionsJ
+ bodyA])))))
+
+(def: (method_analysis archive declaration supers method)
+ (-> Archive Declaration (List (Type Class)) (Method Code) (Operation (Method Analysis)))
+ (case method
+ (#Constructor method)
+ (\ phase.monad map (|>> #Constructor)
+ (constructor_method_analysis archive declaration method))
+
+ (#Override method)
+ (\ phase.monad map (|>> #Override)
+ (override_method_analysis archive declaration supers method))
+
+ (#Virtual method)
+ (\ phase.monad map (|>> #Virtual)
+ (virtual_method_analysis archive declaration method))
+
+ (#Static method)
+ (\ phase.monad map (|>> #Static)
+ (static_method_analysis archive method))
+
+ (#Abstract method)
+ (\ phase.monad wrap (#Abstract method))
+ ))
+
+(template: (method_body <bodyS>)
+ (<| synthesis.function/abstraction [_ _]
+ synthesis.loop/scope [_ _]
+ synthesis.tuple
+ (list _)
+ <bodyS>))
+
+(def: (constructor_method_synthesis archive method)
+ (-> Archive (Constructor Analysis) (Operation (Constructor Synthesis)))
+ (do {! phase.monad}
+ [#let [[privacy strict_floating_point? annotations method_tvars exceptions
+ self arguments constructor_argumentsA
+ bodyA] method]
+ synthesise directive.synthesis]
+ (directive.lift_synthesis
+ (do !
+ [constructor_argumentsS (monad.map ! (function (_ [typeJ termA])
+ (\ ! map (|>> [typeJ])
+ (synthesise archive termA)))
+ constructor_argumentsA)
+ bodyS (synthesise archive
+ (list\fold (function (_ _)
+ (|>> (#analysis.Function (list))))
+ (analysis.tuple (list (analysis.unit) bodyA))
+ (list.repeat (|> arguments list.size (nat.max 1)) [])))]
+ (wrap [privacy strict_floating_point? annotations method_tvars exceptions
+ self arguments constructor_argumentsS
+ (case bodyS
+ (^ (method_body bodyS))
+ bodyS
+
+ _
+ bodyS)])))))
+
+(def: (override_method_synthesis archive method)
+ (-> Archive (Override Analysis) (Operation (Override Synthesis)))
+ (do {! phase.monad}
+ [#let [[[super_name super_tvars] method_name strict_floating_point? annotations
+ method_tvars self arguments returnJ exceptionsJ
+ bodyA] method]
+ synthesise directive.synthesis]
+ (directive.lift_synthesis
+ (do !
+ [bodyS (synthesise archive
+ (list\fold (function (_ _)
+ (|>> (#analysis.Function (list))))
+ (analysis.tuple (list (analysis.unit) bodyA))
+ (list.repeat (|> arguments list.size (nat.max 1)) [])))]
+ (wrap [[super_name super_tvars] method_name strict_floating_point? annotations
+ method_tvars self arguments returnJ exceptionsJ
+ (case bodyS
+ (^ (method_body bodyS))
+ bodyS
+
+ _
+ bodyS)])))))
+
+(def: (virtual_method_synthesis archive method)
+ (-> Archive (Virtual Analysis) (Operation (Virtual Synthesis)))
+ (do {! phase.monad}
+ [#let [[name privacy final? strict_floating_point? annotations method_tvars
+ self arguments returnJ exceptionsJ
+ bodyA] method]
+ synthesise directive.synthesis]
+ (directive.lift_synthesis
+ (do !
+ [bodyS (synthesise archive
+ (list\fold (function (_ _)
+ (|>> (#analysis.Function (list))))
+ (analysis.tuple (list (analysis.unit) bodyA))
+ (list.repeat (|> arguments list.size (nat.max 1)) [])))]
+ (wrap [name privacy final? strict_floating_point? annotations method_tvars
+ self arguments returnJ exceptionsJ
+ (case bodyS
+ (^ (method_body bodyS))
+ bodyS
+
+ _
+ bodyS)])))))
+
+(def: (static_method_synthesis archive method)
+ (-> Archive (Static Analysis) (Operation (Static Synthesis)))
+ (do {! phase.monad}
+ [#let [[name privacy strict_floating_point? annotations method_tvars
+ arguments returnJ exceptionsJ
+ bodyA] method]
+ synthesise directive.synthesis]
+ (directive.lift_synthesis
+ (do !
+ [bodyS (synthesise archive
+ (list\fold (function (_ _)
+ (|>> (#analysis.Function (list))))
+ (analysis.tuple (list (analysis.unit) bodyA))
+ (list.repeat (|> arguments list.size (nat.max 1)) [])))]
+ (wrap [name privacy strict_floating_point? annotations method_tvars
+ arguments returnJ exceptionsJ
+ (case bodyS
+ (^ (method_body bodyS))
+ bodyS
+
+ _
+ bodyS)])))))
+
+(def: (method_synthesis archive method)
+ (-> Archive (Method Analysis) (Operation (Method Synthesis)))
+ (case method
+ (#Constructor method)
+ (\ phase.monad map (|>> #Constructor)
+ (constructor_method_synthesis archive method))
+
+ (#Override method)
+ (\ phase.monad map (|>> #Override)
+ (override_method_synthesis archive method))
+
+ (#Virtual method)
+ (\ phase.monad map (|>> #Virtual)
+ (virtual_method_synthesis archive method))
+
+ (#Static method)
+ (\ phase.monad map (|>> #Static)
+ (static_method_synthesis archive method))
+
+ (#Abstract method)
+ (\ phase.monad wrap (#Abstract method))
+ ))
+
+(def: (constructor_method_generation archive super_class method)
+ (-> Archive (Type Class) (Constructor Synthesis) (Operation jvm.Def))
+ (do {! phase.monad}
+ [#let [[privacy strict_floating_point? annotations method_tvars exceptions
+ self arguments constructor_argumentsS
+ bodyS] method]
+ generate directive.generation]
+ (directive.lift_generation
+ (do !
+ [constructor_argumentsG (monad.map ! (|>> product.right (generate archive))
+ constructor_argumentsS)
+ bodyG (generate archive bodyS)
+ #let [[super_name super_vars] (parser.read_class super_class)
+ super_constructor_argument_values (_.fuse constructor_argumentsG)
+ super_constructorT (/type.method [(list)
+ (list\map product.left constructor_argumentsS)
+ /type.void
+ (list)])]]
+ (wrap (def.method (..visibility privacy)
+ (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)
+ ..constructor_name
+ (/type.method [method_tvars (list\map product.right arguments) /type.void exceptions])
+ (|>> (_.ALOAD 0)
+ super_constructor_argument_values
+ (_.INVOKESPECIAL super_class ..constructor_name super_constructorT)
+ bodyG
+ _.RETURN)))))))
+
+(def: (override_method_generation archive method)
+ (-> Archive (Override Synthesis) (Operation jvm.Def))
+ (do {! phase.monad}
+ [#let [[[super_name super_tvars] method_name strict_floating_point? annotations
+ method_tvars self arguments returnJ exceptionsJ
+ bodyS] method]
+ generate directive.generation]
+ (directive.lift_generation
+ (do !
+ [bodyG (generate archive bodyS)]
+ (wrap (def.method #jvm.Public
+ (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)
+ method_name
+ (/type.method [method_tvars (list\map product.right arguments) returnJ exceptionsJ])
+ (|>> bodyG
+ (//G.returnI returnJ))))))))
+
+(def: (virtual_method_generation archive method)
+ (-> Archive (Virtual Synthesis) (Operation jvm.Def))
+ (do {! phase.monad}
+ [#let [[method_name privacy final? strict_floating_point? annotations method_tvars
+ self arguments returnJ exceptionsJ
+ bodyS] method]
+ generate directive.generation]
+ (directive.lift_generation
+ (do !
+ [bodyG (generate archive bodyS)]
+ (wrap (def.method (..visibility privacy)
+ (|> jvm.noneM
+ (jvm.++M (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM))
+ (jvm.++M (if final?
+ jvm.finalM
+ jvm.noneM)))
+ method_name
+ (/type.method [method_tvars (list\map product.right arguments) returnJ exceptionsJ])
+ (|>> bodyG
+ (//G.returnI returnJ))))))))
+
+(def: (static_method_generation archive method)
+ (-> Archive (Static Synthesis) (Operation jvm.Def))
+ (do {! phase.monad}
+ [#let [[method_name privacy strict_floating_point? annotations method_tvars
+ arguments returnJ exceptionsJ
+ bodyS] method]
+ generate directive.generation]
+ (directive.lift_generation
+ (do !
+ [bodyG (generate archive bodyS)]
+ (wrap (def.method (..visibility privacy)
+ (|> jvm.staticM
+ (jvm.++M (if strict_floating_point?
+ jvm.strictM
+ jvm.noneM)))
+ method_name
+ (/type.method [method_tvars (list\map product.right arguments) returnJ exceptionsJ])
+ (|>> bodyG
+ (//G.returnI returnJ))))))))
+
+(def: (method_generation archive super_class method)
+ (-> Archive (Type Class) (Method Synthesis) (Operation jvm.Def))
+ (case method
+ (#Constructor method)
+ (..constructor_method_generation archive super_class method)
+
+ (#Override method)
+ (..override_method_generation archive method)
+
+ (#Virtual method)
+ (..virtual_method_generation archive method)
+
+ (#Static method)
+ (..static_method_generation archive method)
+
+ (#Abstract method)
+ (\ phase.monad wrap (..abstract_method_generation method))
+ ))
+
+(def: jvm::class
+ ..Handler
+ (..custom
+ [($_ <>.and
+ ..class_declaration
+ ..class
+ (<code>.tuple (<>.some ..class))
+ ..inheritance
+ (<code>.tuple (<>.some ..annotation))
+ (<code>.tuple (<>.some ..field))
+ (<code>.tuple (<>.some ..method)))
+ (function (_ extension_name phase archive
+ [declaration
+ super_class
+ super_interfaces
+ inheritance
+ annotations
+ fields
+ methodsC])
+ (do {! phase.monad}
+ [#let [[class_name type_variables] declaration
+ header (..header [class_name type_variables]
+ super_class
+ super_interfaces
+ inheritance
+ fields
+ methodsC)]
+ ## Necessary for reflection to work properly during analysis.
+ _ (directive.lift_generation
+ (generation.execute! header))
+ #let [supers (: (List (Type Class))
+ (list& super_class super_interfaces))]
+ methodsA (monad.map ! (method_analysis archive declaration supers) methodsC)
+ methodsS (monad.map ! (method_synthesis archive) methodsA)
+ methodsG (monad.map ! (method_generation archive super_class) methodsS)
+ #let [directive [class_name
+ (def.class #jvm.V1_6 #jvm.Public jvm.noneC class_name
+ (list\map ..constraint type_variables)
+ super_class
+ super_interfaces
+ (def.fuse (list\compose (list\map ..field_header fields)
+ methodsG)))]]]
+ (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 Class " (%.text class_name)))]
+ (wrap directive.no_requirements)))))]))
+
(def: jvm::class::interface
..Handler
(..custom
@@ -630,14 +1442,9 @@
(<>.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
+ [#let [directive [class_name
(def.interface #jvm.V1_6 #jvm.Public jvm.noneC class_name
- constraints
+ (list\map ..constraint type_variables)
supers
(|> method_declarations
(list\map (function (_ (^slots [#name #annotations #type_variables #exceptions #arguments #return]))
@@ -656,4 +1463,5 @@
(-> jvm.Extender (directive.Bundle jvm.Anchor jvm.Inst jvm.Definition))
(|> bundle.empty
(dictionary.put "lux def generation" (..def::generation extender))
+ (dictionary.put "jvm class" ..jvm::class)
(dictionary.put "jvm class interface" ..jvm::class::interface)))
diff --git a/lux-jvm/source/luxc/lang/host/jvm.lux b/lux-jvm/source/luxc/lang/host/jvm.lux
index de92a3ba5..1c81be667 100644
--- a/lux-jvm/source/luxc/lang/host/jvm.lux
+++ b/lux-jvm/source/luxc/lang/host/jvm.lux
@@ -61,11 +61,14 @@
#V1_7
#V1_8)
-(type: #export ByteCode Binary)
+(type: #export ByteCode
+ Binary)
-(type: #export Definition [Text ByteCode])
+(type: #export Definition
+ [Text ByteCode])
-(type: #export Anchor [Label Register])
+(type: #export Anchor
+ [Label Register])
(type: #export Host
(generation.Host Inst Definition))
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 33552c135..e647bf71b 100644
--- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
+++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux
@@ -149,7 +149,7 @@
[_.I2L conversion::short_to_long]
)
-(def: conversion
+(def: conversion_bundle
Bundle
(<| (bundle.prefix "conversion")
(|> (: Bundle bundle.empty)
@@ -274,7 +274,7 @@
[double::< _.DCMPG -1]
)
-(def: int
+(def: int_bundle
Bundle
(<| (bundle.prefix (reflection.reflection reflection.int))
(|> (: Bundle bundle.empty)
@@ -293,7 +293,7 @@
(bundle.install "ushr" (binary int::ushr))
)))
-(def: long
+(def: long_bundle
Bundle
(<| (bundle.prefix (reflection.reflection reflection.long))
(|> (: Bundle bundle.empty)
@@ -312,7 +312,7 @@
(bundle.install "ushr" (binary long::ushr))
)))
-(def: float
+(def: float_bundle
Bundle
(<| (bundle.prefix (reflection.reflection reflection.float))
(|> (: Bundle bundle.empty)
@@ -325,7 +325,7 @@
(bundle.install "<" (binary float::<))
)))
-(def: double
+(def: double_bundle
Bundle
(<| (bundle.prefix (reflection.reflection reflection.double))
(|> (: Bundle bundle.empty)
@@ -338,7 +338,7 @@
(bundle.install "<" (binary double::<))
)))
-(def: char
+(def: char_bundle
Bundle
(<| (bundle.prefix (reflection.reflection reflection.char))
(|> (: Bundle bundle.empty)
@@ -455,7 +455,7 @@
valueI
_.AASTORE))))]))
-(def: array
+(def: array_bundle
Bundle
(<| (bundle.prefix "array")
(|> bundle.empty
@@ -773,7 +773,7 @@
(_.fuse (list@map product.right inputsTI))
(_.INVOKESPECIAL class "<init>" (type.method [(list) (list@map product.left inputsTI) type.void (list)]))))))]))
-(def: member
+(def: member_bundle
Bundle
(<| (bundle.prefix "member")
(|> (: Bundle bundle.empty)
@@ -925,7 +925,8 @@
(#synthesis.Extension [name inputsS+])
(#synthesis.Extension [name (list@map recur inputsS+)]))))
-(def: $Object (type.class "java.lang.Object" (list)))
+(def: $Object
+ (type.class "java.lang.Object" (list)))
(def: (anonymous_init_method env)
(-> (Environment Synthesis) (Type Method))
@@ -960,7 +961,7 @@
(_.fuse captureI+)
(_.INVOKESPECIAL class "<init>" (anonymous_init_method env))))))
-(def: (returnI returnT)
+(def: #export (returnI returnT)
(-> (Type Return) Inst)
(case (type.void? returnT)
(#.Right returnT)
@@ -1074,7 +1075,7 @@
_ (generation.save! artifact_id #.None directive)]
(..anonymous_instance generate archive class total_environment)))]))
-(def: bundle::class
+(def: class_bundle
Bundle
(<| (bundle.prefix "class")
(|> (: Bundle bundle.empty)
@@ -1084,14 +1085,14 @@
(def: #export bundle
Bundle
(<| (bundle.prefix "jvm")
- (|> ..conversion
- (dictionary.merge ..int)
- (dictionary.merge ..long)
- (dictionary.merge ..float)
- (dictionary.merge ..double)
- (dictionary.merge ..char)
- (dictionary.merge ..array)
+ (|> ..conversion_bundle
+ (dictionary.merge ..int_bundle)
+ (dictionary.merge ..long_bundle)
+ (dictionary.merge ..float_bundle)
+ (dictionary.merge ..double_bundle)
+ (dictionary.merge ..char_bundle)
+ (dictionary.merge ..array_bundle)
(dictionary.merge ..object_bundle)
- (dictionary.merge ..member)
- (dictionary.merge ..bundle::class)
+ (dictionary.merge ..member_bundle)
+ (dictionary.merge ..class_bundle)
)))
diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux
index fbcd39119..c05a2afe2 100644
--- a/stdlib/source/library/lux/ffi.jvm.lux
+++ b/stdlib/source/library/lux/ffi.jvm.lux
@@ -187,21 +187,21 @@
#ManualPrM
#AutoPrM)
-(type: Privacy
+(type: #export Privacy
#PublicP
#PrivateP
#ProtectedP
#DefaultP)
-(type: StateModifier
- #VolatileSM
- #FinalSM
- #DefaultSM)
+(type: #export State
+ #VolatileS
+ #FinalS
+ #DefaultS)
-(type: InheritanceModifier
- #FinalIM
- #AbstractIM
- #DefaultIM)
+(type: #export Inheritance
+ #FinalI
+ #AbstractI
+ #DefaultI)
(type: Class_Kind
#Class
@@ -224,7 +224,7 @@
(type: FieldDecl
(#ConstantField (Type Value) Code)
- (#VariableField StateModifier (Type Value)))
+ (#VariableField State (Type Value)))
(type: MethodDecl
{#method_tvars (List (Type Var))
@@ -397,20 +397,24 @@
_ (<code>.this! (code.identifier ["" dotted_name]))]
(wrap (get_static_field class_name field_name))))
-(def: (make_get_var_parser class_name field_name)
- (-> Text Text (Parser Code))
+(def: (make_get_var_parser class_name field_name self_name)
+ (-> Text Text Text (Parser Code))
(do <>.monad
[#let [dotted_name (format "::" field_name)]
_ (<code>.this! (code.identifier ["" dotted_name]))]
- (wrap (get_virtual_field class_name field_name (' _jvm_this)))))
+ (wrap (get_virtual_field class_name field_name (code.local_identifier self_name)))))
-(def: (make_put_var_parser class_name field_name)
- (-> Text Text (Parser Code))
+(def: (make_put_var_parser class_name field_name self_name)
+ (-> Text Text Text (Parser Code))
(do <>.monad
[#let [dotted_name (format "::" field_name)]
[_ _ value] (: (Parser [Any Any Code])
(<code>.form ($_ <>.and (<code>.this! (' :=)) (<code>.this! (code.identifier ["" dotted_name])) <code>.any)))]
- (wrap (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value))))))
+ (wrap (`' ("jvm member put virtual"
+ (~ (code.text class_name))
+ (~ (code.text field_name))
+ (~ value)
+ (~ (code.local_identifier self_name)))))))
(def: (pre_walk_replace f input)
(-> (-> Code Code) Code Code)
@@ -440,15 +444,15 @@
ast
))
-(def: (field->parser class_name [[field_name _ _] field])
- (-> Text [Member_Declaration FieldDecl] (Parser Code))
+(def: (field->parser class_name self_name [[field_name _ _] field])
+ (-> Text Text [Member_Declaration FieldDecl] (Parser Code))
(case field
(#ConstantField _)
(make_get_const_parser class_name field_name)
(#VariableField _)
- (<>.either (make_get_var_parser class_name field_name)
- (make_put_var_parser class_name field_name))))
+ (<>.either (make_get_var_parser class_name field_name self_name)
+ (make_put_var_parser class_name field_name self_name))))
(def: (decorate_input [class value])
(-> [(Type Value) Code] Code)
@@ -478,15 +482,15 @@
(list\map ..decorate_input))))))))
(template [<name> <jvm_op>]
- [(def: (<name> class_name method_name arguments)
- (-> Text Text (List Argument) (Parser Code))
+ [(def: (<name> class_name method_name arguments self_name)
+ (-> Text Text (List Argument) Text (Parser Code))
(do <>.monad
[#let [dotted_name (format "::" method_name "!")]
args (: (Parser (List Code))
(<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name]))
(<code>.tuple (<>.exactly (list.size arguments) <code>.any)))))]
(wrap (` (<jvm_op> (~ (code.text class_name)) (~ (code.text method_name))
- (~' _jvm_this)
+ (~ (code.local_identifier self_name))
(~+ (|> args
(list.zip/2 (list\map product.right arguments))
(list\map ..decorate_input))))))))]
@@ -503,16 +507,18 @@
(#StaticMethod strict? type_vars args return_type return_expr exs)
(make_static_method_parser class_name method_name args)
+
+ (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
+ (make_virtual_method_parser class_name method_name args self_name)
- (^or (#VirtualMethod final? strict? type_vars self_name args return_type return_expr exs)
- (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs))
- (make_special_method_parser class_name method_name args)
+ (#OverridenMethod strict? owner_class type_vars self_name args return_type return_expr exs)
+ (make_special_method_parser class_name method_name args self_name)
(#AbstractMethod type_vars args return_type exs)
- (make_virtual_method_parser class_name method_name args)
+ (make_virtual_method_parser class_name method_name args "")
(#NativeMethod type_vars args return_type exs)
- (make_virtual_method_parser class_name method_name args)))
+ (make_virtual_method_parser class_name method_name args "")))
(def: privacy_modifier^
(Parser Privacy)
@@ -524,7 +530,7 @@
(wrap []))))
(def: inheritance_modifier^
- (Parser InheritanceModifier)
+ (Parser Inheritance)
(let [(^open ".") <>.monad]
($_ <>.or
(<code>.this! (' #final))
@@ -732,7 +738,7 @@
#method_exs exs}]))))
(def: state_modifier^
- (Parser StateModifier)
+ (Parser State)
($_ <>.or
(<code>.this! (' #volatile))
(<code>.this! (' #final))
@@ -1012,11 +1018,11 @@
#DefaultP (code.text "default")))
(def: (inheritance_modifier$ im)
- (-> InheritanceModifier Code)
+ (-> Inheritance Code)
(case im
- #FinalIM (code.text "final")
- #AbstractIM (code.text "abstract")
- #DefaultIM (code.text "default")))
+ #FinalI (code.text "final")
+ #AbstractI (code.text "abstract")
+ #DefaultI (code.text "default")))
(def: (annotation_parameter$ [name value])
(-> Annotation_Parameter Code)
@@ -1054,11 +1060,11 @@
(~ (return$ method_output))))))
(def: (state_modifier$ sm)
- (-> StateModifier Code)
+ (-> State Code)
(case sm
- #VolatileSM (' "volatile")
- #FinalSM (' "final")
- #DefaultSM (' "default")))
+ #VolatileS (' "volatile")
+ #FinalS (' "final")
+ #DefaultS (' "default")))
(def: (field_decl$ [[name pm anns] field])
(-> [Member_Declaration FieldDecl] Code)
@@ -1087,44 +1093,53 @@
(-> (Typed Code) Code)
(` [(~ (value$ class)) (~ term)]))
-(def: (method_def$ replacer super_class [[name pm anns] method_def])
- (-> (-> Code Code) (Type Class) [Member_Declaration Method_Definition] Code)
+(def: (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def])
+ (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] Code)
(case method_def
(#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs)
- (` ("init"
- (~ (privacy_modifier$ pm))
- (~ (code.bit strict_fp?))
- [(~+ (list\map annotation$ anns))]
- [(~+ (list\map var$ type_vars))]
- [(~+ (list\map class$ exs))]
- (~ (code.text self_name))
- [(~+ (list\map argument$ arguments))]
- [(~+ (list\map constructor_arg$ constructor_args))]
- (~ (pre_walk_replace replacer body))
- ))
+ (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields)
+ (list\fold <>.either method_parser)
+ parser->replacer)]
+ (` ("init"
+ (~ (privacy_modifier$ pm))
+ (~ (code.bit strict_fp?))
+ [(~+ (list\map annotation$ anns))]
+ [(~+ (list\map var$ type_vars))]
+ [(~+ (list\map class$ exs))]
+ (~ (code.text self_name))
+ [(~+ (list\map argument$ arguments))]
+ [(~+ (list\map constructor_arg$ constructor_args))]
+ (~ (pre_walk_replace replacer body))
+ )))
(#VirtualMethod final? strict_fp? type_vars self_name arguments return_type body exs)
- (` ("virtual"
- (~ (code.text name))
- (~ (privacy_modifier$ pm))
- (~ (code.bit final?))
- (~ (code.bit strict_fp?))
- [(~+ (list\map annotation$ anns))]
- [(~+ (list\map var$ type_vars))]
- (~ (code.text self_name))
- [(~+ (list\map argument$ arguments))]
- (~ (return$ return_type))
- [(~+ (list\map class$ exs))]
- (~ (pre_walk_replace replacer body))))
+ (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields)
+ (list\fold <>.either method_parser)
+ parser->replacer)]
+ (` ("virtual"
+ (~ (code.text name))
+ (~ (privacy_modifier$ pm))
+ (~ (code.bit final?))
+ (~ (code.bit strict_fp?))
+ [(~+ (list\map annotation$ anns))]
+ [(~+ (list\map var$ type_vars))]
+ (~ (code.text self_name))
+ [(~+ (list\map argument$ arguments))]
+ (~ (return$ return_type))
+ [(~+ (list\map class$ exs))]
+ (~ (pre_walk_replace replacer body)))))
(#OverridenMethod strict_fp? declaration type_vars self_name arguments return_type body exs)
- (let [super_replacer (parser->replacer (<code>.form (do <>.monad
+ (let [replacer (|> (list\map (field->parser fully_qualified_class_name self_name) fields)
+ (list\fold <>.either method_parser)
+ parser->replacer)
+ super_replacer (parser->replacer (<code>.form (do <>.monad
[_ (<code>.this! (' ::super!))
args (<code>.tuple (<>.exactly (list.size arguments) <code>.any))]
(wrap (` ("jvm member invoke special"
(~ (code.text (product.left (parser.read_class super_class))))
(~ (code.text name))
- (~' _jvm_this)
+ (~ (code.local_identifier self_name))
(~+ (|> args
(list.zip/2 (list\map product.right arguments))
(list\map ..decorate_input)))))))))]
@@ -1144,16 +1159,17 @@
)))
(#StaticMethod strict_fp? type_vars arguments return_type body exs)
- (` ("static"
- (~ (code.text name))
- (~ (privacy_modifier$ pm))
- (~ (code.bit strict_fp?))
- [(~+ (list\map annotation$ anns))]
- [(~+ (list\map var$ type_vars))]
- [(~+ (list\map class$ exs))]
- [(~+ (list\map argument$ arguments))]
- (~ (return$ return_type))
- (~ (pre_walk_replace replacer body))))
+ (let [replacer (parser->replacer (<>.fail ""))]
+ (` ("static"
+ (~ (code.text name))
+ (~ (privacy_modifier$ pm))
+ (~ (code.bit strict_fp?))
+ [(~+ (list\map annotation$ anns))]
+ [(~+ (list\map var$ type_vars))]
+ [(~+ (list\map argument$ arguments))]
+ (~ (return$ return_type))
+ [(~+ (list\map class$ exs))]
+ (~ (pre_walk_replace replacer body)))))
(#AbstractMethod type_vars arguments return_type exs)
(` ("abstract"
@@ -1161,9 +1177,9 @@
(~ (privacy_modifier$ pm))
[(~+ (list\map annotation$ anns))]
[(~+ (list\map var$ type_vars))]
- [(~+ (list\map class$ exs))]
[(~+ (list\map argument$ arguments))]
- (~ (return$ return_type))))
+ (~ (return$ return_type))
+ [(~+ (list\map class$ exs))]))
(#NativeMethod type_vars arguments return_type exs)
(` ("native"
@@ -1228,11 +1244,10 @@
)}
(do meta.monad
[#let [fully_qualified_class_name full_class_name
- field_parsers (list\map (field->parser fully_qualified_class_name) fields)
- method_parsers (list\map (method->parser fully_qualified_class_name) methods)
- replacer (parser->replacer (list\fold <>.either
- (<>.fail "")
- (list\compose field_parsers method_parsers)))]]
+ method_parser (: (Parser Code)
+ (|> methods
+ (list\map (method->parser fully_qualified_class_name))
+ (list\fold <>.either (<>.fail ""))))]]
(wrap (list (` ("jvm class"
(~ (declaration$ (type.declaration full_class_name class_vars)))
(~ (class$ super))
@@ -1240,7 +1255,7 @@
(~ (inheritance_modifier$ im))
[(~+ (list\map annotation$ annotations))]
[(~+ (list\map field_decl$ fields))]
- [(~+ (list\map (method_def$ replacer super) methods))]))))))
+ [(~+ (list\map (method_def$ fully_qualified_class_name method_parser super fields) methods))]))))))
(syntax: #export (interface:
{#let [! <>.monad]}
@@ -1282,7 +1297,7 @@
(~ (class$ super))
[(~+ (list\map class$ interfaces))]
[(~+ (list\map constructor_arg$ constructor_args))]
- [(~+ (list\map (method_def$ function.identity super) methods))])))))
+ [(~+ (list\map (method_def$ "" (<>.fail "") super (list)) methods))])))))
(syntax: #export (null)
{#.doc (doc "Null object reference."
diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux
index c8de0eb03..832d3907f 100644
--- a/stdlib/source/library/lux/ffi.old.lux
+++ b/stdlib/source/library/lux/ffi.old.lux
@@ -89,21 +89,21 @@
#ManualPrM
#AutoPrM)
-(type: PrivacyModifier
- #PublicPM
- #PrivatePM
- #ProtectedPM
- #DefaultPM)
-
-(type: StateModifier
- #VolatileSM
- #FinalSM
- #DefaultSM)
-
-(type: InheritanceModifier
- #FinalIM
- #AbstractIM
- #DefaultIM)
+(type: #export Privacy
+ #PublicP
+ #PrivateP
+ #ProtectedP
+ #DefaultP)
+
+(type: #export State
+ #VolatileS
+ #FinalS
+ #DefaultS)
+
+(type: #export Inheritance
+ #FinalI
+ #AbstractI
+ #DefaultI)
(type: Class_Kind
#Class
@@ -129,12 +129,12 @@
(type: Member_Declaration
{#member_name Text
- #member_privacy PrivacyModifier
+ #member_privacy Privacy
#member_anns (List Annotation)})
(type: FieldDecl
(#ConstantField GenericType Code)
- (#VariableField StateModifier GenericType))
+ (#VariableField State GenericType))
(type: MethodDecl
{#method_tvars (List Type_Parameter)
@@ -502,7 +502,7 @@
## Parsers
(def: privacy_modifier^
- (Parser PrivacyModifier)
+ (Parser Privacy)
(let [(^open ".") <>.monad]
($_ <>.or
(<code>.this! (' #public))
@@ -511,7 +511,7 @@
(wrap []))))
(def: inheritance_modifier^
- (Parser InheritanceModifier)
+ (Parser Inheritance)
(let [(^open ".") <>.monad]
($_ <>.or
(<code>.this! (' #final))
@@ -661,13 +661,13 @@
inputs (<code>.tuple (<>.some (..generic_type^ type_vars)))
output (..generic_type^ type_vars)
exs (..throws_decl^ type_vars)]
- (wrap [[name #PublicPM anns] {#method_tvars tvars
- #method_inputs inputs
- #method_output output
- #method_exs exs}]))))
+ (wrap [[name #PublicP anns] {#method_tvars tvars
+ #method_inputs inputs
+ #method_output output
+ #method_exs exs}]))))
(def: state_modifier^
- (Parser StateModifier)
+ (Parser State)
($_ <>.or
(<code>.this! (' #volatile))
(<code>.this! (' #final))
@@ -681,7 +681,7 @@
anns ..annotations^
type (..generic_type^ type_vars)
body <code>.any]
- (wrap [[name #PublicPM anns] (#ConstantField [type body])])))
+ (wrap [[name #PublicP anns] (#ConstantField [type body])])))
(<code>.form (do <>.monad
[pm privacy_modifier^
sm state_modifier^
@@ -765,7 +765,7 @@
annotations ..annotations^
body <code>.any]
(wrap [{#member_name name
- #member_privacy #PublicPM
+ #member_privacy #PublicP
#member_anns annotations}
(#OverridenMethod strict_fp?
owner_class method_vars
@@ -952,19 +952,19 @@
(text.join_with " "))
(def: (privacy_modifier$ pm)
- (-> PrivacyModifier JVM_Code)
+ (-> Privacy JVM_Code)
(case pm
- #PublicPM "public"
- #PrivatePM "private"
- #ProtectedPM "protected"
- #DefaultPM "default"))
+ #PublicP "public"
+ #PrivateP "private"
+ #ProtectedP "protected"
+ #DefaultP "default"))
(def: (inheritance_modifier$ im)
- (-> InheritanceModifier JVM_Code)
+ (-> Inheritance JVM_Code)
(case im
- #FinalIM "final"
- #AbstractIM "abstract"
- #DefaultIM "default"))
+ #FinalI "final"
+ #AbstractI "abstract"
+ #DefaultI "default"))
(def: (annotation_param$ [name value])
(-> AnnotationParam JVM_Code)
@@ -1023,11 +1023,11 @@
))))
(def: (state_modifier$ sm)
- (-> StateModifier JVM_Code)
+ (-> State JVM_Code)
(case sm
- #VolatileSM "volatile"
- #FinalSM "final"
- #DefaultSM "default"))
+ #VolatileS "volatile"
+ #FinalS "final"
+ #DefaultS "default"))
(def: (field_decl$ [[name pm anns] field])
(-> [Member_Declaration FieldDecl] JVM_Code)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux
index 49ab15299..bb8a578bd 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux
@@ -3,6 +3,8 @@
[lux (#- Module)
[abstract
[monad (#+ do)]]
+ [control
+ ["." try]]
[data
[collection
["." list ("#\." monoid)]]]]]
@@ -59,6 +61,18 @@
[Bundle extension.Bundle]
)
+(template [<name> <component> <phase>]
+ [(def: #export <name>
+ (All [anchor expression directive]
+ (Operation anchor expression directive <phase>))
+ (function (_ [bundle state])
+ (#try.Success [[bundle state] (get@ [<component> #..phase] state)])))]
+
+ [analysis #..analysis analysis.Phase]
+ [synthesis #..synthesis synthesis.Phase]
+ [generation #..generation (generation.Phase anchor expression directive)]
+ )
+
(template [<name> <component> <operation>]
[(def: #export <name>
(All [anchor expression directive output]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index 3c458c041..66f7271db 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -843,7 +843,7 @@
(/////analysis.throw cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))]))
(template [<name> <category> <parser>]
- [(def: (<name> mapping typeJ)
+ [(def: #export (<name> mapping typeJ)
(-> Mapping (Type <category>) (Operation .Type))
(case (|> typeJ ..signature (<text>.run (<parser> mapping)))
(#try.Success check)
@@ -1043,6 +1043,7 @@
(wrap (<| (#/////analysis.Extension extension_name)
(list (/////analysis.text class)
(/////analysis.text field)
+ (/////analysis.text (..reflection fieldJT))
objectA)))))]))
(def: (put::virtual class_loader)
@@ -1071,6 +1072,7 @@
(wrap (<| (#/////analysis.Extension extension_name)
(list (/////analysis.text class)
(/////analysis.text field)
+ (/////analysis.text (..reflection fieldJT))
valueA
objectA)))))]))
@@ -1919,6 +1921,29 @@
#.None
(phase.lift (exception.throw ..unknown_super [parent_name supers])))))
+(def: #export (with_fresh_type_vars vars mapping)
+ (-> (List (Type Var)) Mapping (Operation Mapping))
+ (do {! phase.monad}
+ [pairings (monad.map ! (function (_ var)
+ (do !
+ [[_ exT] (typeA.with_env
+ check.existential)]
+ (wrap [var exT])))
+ vars)]
+ (wrap (list\fold (function (_ [varJ varT] mapping)
+ (dictionary.put (jvm_parser.name varJ) varT mapping))
+ mapping
+ pairings))))
+
+(def: #export (with_override_mapping supers parent_type mapping)
+ (-> (List (Type Class)) (Type Class) Mapping (Operation Mapping))
+ (do phase.monad
+ [override_mapping (..override_mapping mapping supers parent_type)]
+ (wrap (list\fold (function (_ [super_var bound_type] mapping)
+ (dictionary.put super_var bound_type mapping))
+ mapping
+ override_mapping))))
+
(def: #export (analyse_overriden_method analyse archive selfT mapping supers method)
(-> Phase Archive .Type Mapping (List (Type Class)) (Overriden_Method Code) (Operation Analysis))
(let [[parent_type method_name
@@ -1926,15 +1951,8 @@
self_name arguments return exceptions
body] method]
(do {! phase.monad}
- [override_mapping (..override_mapping mapping supers parent_type)
- #let [mapping (list\fold (function (_ [super_var bound_type] mapping)
- (dictionary.put super_var bound_type mapping))
- mapping
- override_mapping)
- mapping (list\fold (function (_ varJ mapping)
- (dictionary.put (jvm_parser.name varJ) java/lang/Object mapping))
- mapping
- vars)]
+ [mapping (..with_override_mapping supers parent_type mapping)
+ mapping (..with_fresh_type_vars vars mapping)
annotationsA (monad.map ! (function (_ [name parameters])
(do !
[parametersA (monad.map ! (function (_ [name value])
@@ -1944,13 +1962,13 @@
parameters)]
(wrap [name parametersA])))
annotations)
- returnT (reflection_return mapping return)
arguments' (monad.map !
(function (_ [name jvmT])
(do !
[luxT (reflection_type mapping jvmT)]
(wrap [name luxT])))
arguments)
+ returnT (reflection_return mapping return)
[scope bodyA] (|> arguments'
(#.Cons [self_name selfT])
list.reverse
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index cbc63d90d..20d21d74d 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -93,40 +93,6 @@
value)))))
))
-(template: (quadrance cat0 cat1)
- (n.+ (n.* cat0 cat0) (n.* cat1 cat1)))
-
-(def: templates
- Test
- (do random.monad
- [cat0 random.nat
- cat1 random.nat]
- (_.test "Template application is a stand-in for the templated code."
- (n.= (n.+ (n.* cat0 cat0) (n.* cat1 cat1))
- (quadrance cat0 cat1)))))
-
-(def: cross_platform_support
- Test
- (do random.monad
- [on_default random.nat
- on_fake_host random.nat
- on_valid_host random.nat]
- ($_ _.and
- (_.test "Can provide default in case there is no particular host/platform support."
- (n.= on_default
- (for {"" on_fake_host}
- on_default)))
- (_.test "Can pick code depending on the host/platform being targeted."
- (n.= on_valid_host
- (for {@.old on_valid_host
- @.jvm on_valid_host
- @.js on_valid_host
- @.python on_valid_host
- @.lua on_valid_host
- @.ruby on_valid_host
- @.php on_valid_host}
- on_default))))))
-
(def: sub_tests
Test
(with_expansions [## TODO: Update & expand tests for this
@@ -732,6 +698,47 @@
(not (code\= (' <left_association>)
(' <right_association>))))))))
+(def: for_expansion
+ Test
+ (do random.monad
+ [left random.nat
+ right random.nat
+ dummy random.nat
+ #let [expected (n.+ left right)]]
+ ($_ _.and
+ (_.cover [/.as_is]
+ (`` (and (~~ (as_is true
+ true
+ true)))))
+ (_.cover [/.with_expansions]
+ (/.with_expansions [<operands> (as_is left right)]
+ (n.= expected
+ (n.+ <operands>))))
+ (_.cover [/.comment]
+ (/.with_expansions [<dummy> (/.comment dummy)
+ <operands> (as_is left right)]
+ (n.= expected
+ ($_ n.+ <operands> <dummy>))))
+ (_.cover [/.``]
+ (n.= expected
+ (/.`` ($_ n.+
+ (~~ (as_is left right))
+ (~~ (/.comment dummy))))))
+ (_.cover [/.for]
+ (and (n.= expected
+ (/.for {"fake host" dummy}
+ expected))
+ (n.= expected
+ (/.for {@.old expected
+ @.jvm expected
+ @.js expected
+ @.python expected
+ @.lua expected
+ @.ruby expected
+ @.php expected}
+ dummy))))
+ )))
+
(def: test
Test
(<| (_.covering /._)
@@ -740,10 +747,6 @@
..identity)
(<| (_.context "Prelude macros.")
..prelude_macros)
- (<| (_.context "Templates.")
- ..templates)
- (<| (_.context "Cross-platform support.")
- ..cross_platform_support)
..for_bit
..for_try
@@ -760,6 +763,7 @@
..for_static
..for_slot
..for_associative
+ ..for_expansion
..sub_tests
)))
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index e8e07e7e1..b0ae4fc0f 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -38,25 +38,6 @@
["#::."
(getName [] java/lang/String)])
-## TODO: Handle "/.class:" ASAP.
-## (/.class: #final (TestClass A) [java/lang/Runnable]
-## ## Fields
-## (#private foo boolean)
-## (#private bar A)
-## (#private baz java/lang/Object)
-## ## Methods
-## (#public [] (new self {value A}) []
-## (exec (:= ::foo #1)
-## (:= ::bar value)
-## (:= ::baz "")
-## []))
-## (#public (virtual self) java/lang/Object
-## "")
-## (#public #static (static) java/lang/Object
-## "")
-## (java/lang/Runnable [] (run self) void
-## []))
-
(template [<name> <type> <conversion> <lux> <=>]
[(def: (<name> left right)
(-> <type> <type> Bit)
@@ -83,14 +64,16 @@
(#try.Failure error)
(#try.Success [lux (list (code.text error))])))))
-(def: conversions
+(def: for_conversions
Test
(do {! random.monad}
[long (\ ! map (|>> (:as /.Long)) random.int)
integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int)
byte (\ ! map (|>> (:as /.Long) /.long_to_byte) random.int)
short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int)
- float (\ ! map (|>> (:as /.Double) /.double_to_float) random.frac)]
+ float (|> random.frac
+ (random.filter (|>> f.not_a_number? not))
+ (\ ! map (|>> (:as /.Double) /.double_to_float)))]
(`` ($_ _.and
(~~ (template [<sample> <=> <to> <from>]
[(_.cover [<to> <from>]
@@ -116,7 +99,7 @@
[float float\= /.float_to_double /.double_to_float]
))))))
-(def: arrays
+(def: for_arrays
Test
(do {! random.monad}
[size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1))))
@@ -142,7 +125,7 @@
..macro_error
(text.contains? (get@ #exception.label /.cannot_convert_to_jvm_type))))))))
-(def: miscellaneous
+(def: for_miscellaneous
Test
(`` (do {! random.monad}
[sample (\ ! map (|>> (:as java/lang/Object))
@@ -152,8 +135,12 @@
short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int)
integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int)
long (\ ! map (|>> (:as /.Long)) random.int)
- float (\ ! map (|>> (:as /.Double) /.double_to_float) random.frac)
- double (\ ! map (|>> (:as /.Double)) random.frac)
+ float (|> random.frac
+ (random.filter (|>> f.not_a_number? not))
+ (\ ! map (|>> (:as /.Double) /.double_to_float)))
+ double (|> random.frac
+ (random.filter (|>> f.not_a_number? not))
+ (\ ! map (|>> (:as /.Double))))
character (\ ! map (|>> (:as /.Long) /.long_to_int /.int_to_char) random.int)
string (\ ! map (|>> (:as java/lang/String))
(random.ascii 1))]
@@ -260,7 +247,8 @@
["#::."
(actual3 [] a)])
-(def: interface
+(def: for_interface
+ Test
(do random.monad
[expected random.nat
#let [object/0 (/.object [] [test/TestInterface0]
@@ -270,6 +258,10 @@
java/lang/Long
(:as java/lang/Long
expected)))
+ example/0!
+ (is? (: Any expected)
+ (: Any (test/TestInterface0::actual0 object/0)))
+
object/1 (/.object [] [test/TestInterface1]
[]
(test/TestInterface1
@@ -280,12 +272,31 @@
(error! "YOLO")
(:as java/lang/Long
expected))))
+ example/1!
+ (and (case (test/TestInterface1::actual1 false object/1)
+ (#try.Success actual)
+ (is? (: Any expected)
+ (: Any actual))
+
+ (#try.Failure error)
+ false)
+ (case (test/TestInterface1::actual1 true object/1)
+ (#try.Success actual)
+ false
+
+ (#try.Failure error)
+ true))
+
object/2 (/.object [] [test/TestInterface2]
[]
(test/TestInterface2
[a] (actual2 self {input a})
a
input))
+ example/2!
+ (is? (: Any expected)
+ (: Any (test/TestInterface2::actual2 (:as java/lang/Long expected) object/2)))
+
object/3 (/.object [] [(test/TestInterface3 java/lang/Long)]
[]
((test/TestInterface3 a)
@@ -293,16 +304,143 @@
a
(:as java/lang/Long
expected)))
+ example/3!
+ (is? (: Any expected)
+ (: Any (test/TestInterface3::actual3 object/3)))]]
+ (_.cover [/.interface: /.object]
+ (and example/0!
+ example/1!
+ example/2!
+ example/3!))))
+
+(/.class: #final test/TestClass0 [test/TestInterface0]
+ ## Fields
+ (#private value java/lang/Long)
+ ## Constructors
+ (#public [] (new self {value java/lang/Long}) []
+ (:= ::value value))
+ ## Methods
+ (test/TestInterface0 [] (actual0 self) java/lang/Long
+ ::value))
+
+(/.import: test/TestClass0
+ ["#::."
+ (new [java/lang/Long])])
+
+(/.class: #final test/TestClass1 [test/TestInterface1]
+ ## Fields
+ (#private value java/lang/Long)
+ ## Constructors
+ (#public [] (new self {value java/lang/Long}) []
+ (:= ::value value))
+ ## Methods
+ (test/TestInterface1 [] (actual1 self {throw? java/lang/Boolean}) java/lang/Long #throws [java/lang/Throwable]
+ (if (:as Bit throw?)
+ (error! "YOLO")
+ ::value)))
+
+(/.import: test/TestClass1
+ ["#::."
+ (new [java/lang/Long])])
+
+(/.class: #final test/TestClass2 [test/TestInterface2]
+ ## Constructors
+ (#public [] (new self) []
+ [])
+ ## Methods
+ (test/TestInterface2
+ [a] (actual2 self {input a})
+ a
+ input))
+
+(/.import: test/TestClass2
+ ["#::."
+ (new [])])
+
+(/.class: #final (test/TestClass3 a) [(test/TestInterface3 a)]
+ ## Fields
+ (#private value a)
+ ## Constructors
+ (#public [] (new self {value a}) []
+ (:= ::value value))
+ ## Methods
+ ((test/TestInterface3 a)
+ [] (actual3 self)
+ a
+ ::value))
+
+(/.import: (test/TestClass3 a)
+ ["#::."
+ (new [a])])
+
+(/.class: #final test/TestClass4 []
+ ## Constructors
+ (#public [] (new self) []
+ [])
+ ## Methods
+ (#public (actual4 self {value java/lang/Long}) java/lang/Long
+ value))
+
+(/.import: test/TestClass4
+ ["#::."
+ (new [])
+ (actual4 [java/lang/Long] java/lang/Long)])
+
+(/.class: #final test/TestClass5 []
+ ## Constructors
+ (#public [] (new self) []
+ [])
+ ## Methods
+ (#public #static (actual5 {value java/lang/Long})
+ java/lang/Long
+ value))
+
+(/.import: test/TestClass5
+ ["#::."
+ (#static actual5 [java/lang/Long] java/lang/Long)])
+
+(/.class: #abstract test/TestClass6 []
+ ## Constructors
+ (#public [] (new self) []
+ [])
+ ## Methods
+ (#public #abstract (actual6 {value java/lang/Long})
+ java/lang/Long))
+
+(/.import: test/TestClass6
+ ["#::."
+ (actual6 [java/lang/Long] java/lang/Long)])
+(/.class: #final test/TestClass7 test/TestClass6 []
+ ## Constructors
+ (#public [] (new self) []
+ [])
+ ## Methods
+ (test/TestClass6
+ [] (actual6 self {input java/lang/Long})
+ java/lang/Long
+ input))
+
+(/.import: test/TestClass7
+ ["#::."
+ (new [])])
+
+(def: for_class
+ Test
+ (do random.monad
+ [expected random.nat
+
+ #let [object/0 (test/TestClass0::new (.int expected))
example/0!
- (is? (: Any expected)
- (: Any (test/TestInterface0::actual0 object/0)))
+ (n.= expected
+ (:as Nat (test/TestInterface0::actual0 object/0)))
+ object/1 (test/TestClass1::new (.int expected))
example/1!
(and (case (test/TestInterface1::actual1 false object/1)
(#try.Success actual)
- (is? (: Any expected)
- (: Any actual))
+ (n.= expected
+ (:as Nat actual))
(#try.Failure error)
false)
@@ -313,24 +451,45 @@
(#try.Failure error)
true))
+ object/2 (test/TestClass2::new)
example/2!
- (is? (: Any expected)
- (: Any (test/TestInterface2::actual2 (:as /.Long expected) object/2)))
+ (n.= expected
+ (: Nat (test/TestInterface2::actual2 (:as java/lang/Long expected) object/2)))
+ object/3 (: (test/TestClass3 java/lang/Long)
+ (test/TestClass3::new (:as java/lang/Long expected)))
example/3!
- (is? (: Any expected)
- (: Any (test/TestInterface3::actual3 object/3)))]]
- (_.cover [/.interface:]
+ (n.= expected
+ (: Nat (test/TestInterface3::actual3 object/3)))
+
+ object/4 (test/TestClass4::new)
+ example/4!
+ (n.= expected
+ (.nat (test/TestClass4::actual4 (.int expected) object/4)))
+
+ example/5!
+ (n.= expected
+ (.nat (test/TestClass5::actual5 (.int expected))))
+
+ object/7 (test/TestClass7::new)
+ example/7!
+ (n.= expected
+ (.nat (test/TestClass6::actual6 (.int expected) object/7)))]]
+ (_.cover [/.class: /.import:]
(and example/0!
example/1!
example/2!
- example/3!))))
+ example/3!
+ example/4!
+ example/5!
+ example/7!))))
(def: #export test
(<| (_.covering /._)
($_ _.and
- ..conversions
- ..arrays
- ..miscellaneous
- ..interface
+ ..for_conversions
+ ..for_arrays
+ ..for_miscellaneous
+ ..for_interface
+ ..for_class
)))