From 3afb16f8acf3f1da0b4b4663c9fcf734ce315381 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 15 Sep 2019 04:54:14 -0400 Subject: Got the tests running again. --- stdlib/source/lux/host.jvm.lux | 2 +- stdlib/source/lux/target/jvm/constant.lux | 18 +++++++++------ stdlib/source/lux/target/jvm/constant/pool.lux | 8 ++++--- stdlib/source/lux/target/jvm/field.lux | 4 +++- stdlib/source/lux/target/jvm/instruction.lux | 26 ++++++++++++---------- .../source/lux/target/jvm/instruction/bytecode.lux | 7 +++--- stdlib/source/lux/target/jvm/method.lux | 10 +++++---- stdlib/source/lux/target/jvm/type/lux.lux | 20 +++++++++++++---- .../tool/compiler/phase/extension/analysis/jvm.lux | 19 ++++++++-------- .../compiler/phase/generation/jvm/function.lux | 1 - .../phase/generation/jvm/function/arity.lux | 3 ++- .../generation/jvm/function/field/foreign.lux | 8 ++++--- .../jvm/function/field/partial/count.lux | 5 +++-- .../phase/generation/jvm/function/method/apply.lux | 8 ++++--- .../jvm/function/method/implementation.lux | 8 ++++--- .../phase/generation/jvm/function/method/init.lux | 8 ++++--- .../phase/generation/jvm/function/method/new.lux | 8 ++++--- .../phase/generation/jvm/function/method/reset.lux | 8 ++++--- .../compiler/phase/generation/jvm/primitive.lux | 5 +++-- .../compiler/phase/generation/jvm/structure.lux | 5 +++-- .../tool/compiler/phase/generation/jvm/value.lux | 3 ++- stdlib/source/lux/world/file.lux | 18 +++++++-------- stdlib/source/test/lux/data/format/json.lux | 7 ++---- stdlib/source/test/lux/host.jvm.lux | 24 +++++++++++--------- stdlib/source/test/lux/macro.lux | 3 +-- stdlib/source/test/lux/macro/poly/equivalence.lux | 8 +++---- stdlib/source/test/lux/macro/poly/functor.lux | 12 +++++----- stdlib/source/test/lux/macro/poly/json.lux | 16 ++++++------- stdlib/source/test/lux/target/jvm.lux | 6 +++-- 29 files changed, 161 insertions(+), 117 deletions(-) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index c668431c8..d0952f71e 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -609,7 +609,7 @@ (<>@wrap (list))) (.form (<>.and (full-class-name^ imports) (<>.some (parameter^ imports type-vars))))))] - (wrap (type.class name parameters)))) + (wrap (type.class (name.sanitize name) parameters)))) (exception: #export (unexpected-type-variable {name Text} {type-vars (List (Type Var))}) diff --git a/stdlib/source/lux/target/jvm/constant.lux b/stdlib/source/lux/target/jvm/constant.lux index d900b9690..0cc7e16e1 100644 --- a/stdlib/source/lux/target/jvm/constant.lux +++ b/stdlib/source/lux/target/jvm/constant.lux @@ -21,10 +21,12 @@ [macro ["." template]]] ["." / #_ - ["#." tag ("#;." equivalence)] + ["#." tag] ["/#" // #_ - ["#." descriptor (#+ Descriptor)] ["#." index (#+ Index)] + [type + ["#." category] + ["#." descriptor (#+ Descriptor)]] [encoding ["#." unsigned]]]]) @@ -65,7 +67,9 @@ ("jvm feq" parameter subject) (~~ (static @.jvm)) - ("jvm float =" parameter subject)})))) + ("jvm float =" + ("jvm object cast" parameter) + ("jvm object cast" subject))})))) (import: #long java/lang/Double (#static doubleToRawLongBits [double] long)) @@ -110,7 +114,7 @@ (~~ (template.splice )))))] [integer-writer Integer [] [binaryF.bits/32]] - [float-writer Float [java/lang/Float::floatToRawIntBits host.int-to-long] [i32.i32 binaryF.bits/32]] + [float-writer Float [java/lang/Float::floatToRawIntBits host.int-to-long (:coerce I64)] [i32.i32 binaryF.bits/32]] [long-writer Long [] [binaryF.bits/64]] [double-writer Double [java/lang/Double::doubleToRawLongBits] [binaryF.bits/64]] [string-writer String [] [//index.writer]] @@ -150,9 +154,9 @@ (#Double Double) (#Class Class) (#String String) - (#Field (Reference //descriptor.Field)) - (#Method (Reference //descriptor.Method)) - (#Interface-Method (Reference //descriptor.Method)) + (#Field (Reference //category.Value)) + (#Method (Reference //category.Method)) + (#Interface-Method (Reference //category.Method)) (#Name-And-Type (Name-And-Type Any))) (def: #export (size constant) diff --git a/stdlib/source/lux/target/jvm/constant/pool.lux b/stdlib/source/lux/target/jvm/constant/pool.lux index bd8b7cb3d..c6dd5e45c 100644 --- a/stdlib/source/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/lux/target/jvm/constant/pool.lux @@ -30,7 +30,9 @@ ["#." name (#+ Internal External)] ["#." unsigned]] ["#." index (#+ Index)] - ["#." descriptor (#+ Field Method Descriptor)]]]) + [type + [category (#+ Value Method)] + ["#." descriptor (#+ Descriptor)]]]]) (type: #export Pool [Index (Row [Index Constant])]) @@ -152,7 +154,7 @@ (!find reference)))] [integer Integer #//.Integer (//.value-equivalence i32.equivalence) (|>> //.value .nat %.nat)] - [float Float #//.Float (//.value-equivalence //.float-equivalence) (|>> //.value host.float-to-double %.frac)] + [float Float #//.Float (//.value-equivalence //.float-equivalence) (|>> //.value host.float-to-double (:coerce Frac) %.frac)] [long Long #//.Long (//.value-equivalence int.equivalence) (|>> //.value %.int)] [double Double #//.Double (//.value-equivalence frac.equivalence) (|>> //.value %.frac)] [utf8 UTF8 #//.UTF8 text.equivalence %.text] @@ -203,7 +205,7 @@ {#//.class @class #//.name-and-type @name-and-type})))] - [field #//.Field Field] + [field #//.Field Value] [method #//.Method Method] [interface-method #//.Interface-Method Method] ) diff --git a/stdlib/source/lux/target/jvm/field.lux b/stdlib/source/lux/target/jvm/field.lux index b6dc1b946..012f7b5ee 100644 --- a/stdlib/source/lux/target/jvm/field.lux +++ b/stdlib/source/lux/target/jvm/field.lux @@ -21,7 +21,9 @@ ["#/." pool (#+ Pool)]] ["#." index (#+ Index)] ["#." attribute (#+ Attribute)] - ["#." descriptor (#+ Descriptor Value)]]) + [type + ["#." category (#+ Value)] + ["#." descriptor (#+ Descriptor)]]]) (type: #export #rec Field {#modifier (Modifier Field) diff --git a/stdlib/source/lux/target/jvm/instruction.lux b/stdlib/source/lux/target/jvm/instruction.lux index 36fa103dd..95e2b9a05 100644 --- a/stdlib/source/lux/target/jvm/instruction.lux +++ b/stdlib/source/lux/target/jvm/instruction.lux @@ -1,5 +1,5 @@ (.module: - [lux #* + [lux (#- Type) [abstract [monoid (#+ Monoid)] ["." monad (#+ Monad do)]] @@ -26,13 +26,15 @@ ["#." bytecode (#+ Primitive-Array-Type Bytecode) ("#@." monoid)] ["/#" // #_ ["#." index] - ["#." descriptor (#+ Descriptor Value Return Field)] [encoding ["#." name (#+ External)] ["#." unsigned (#+ U1 U2)] ["#." signed (#+ S4)]] ["#." constant (#+ UTF8) - ["#/."pool (#+ Pool)]]]]) + ["#/."pool (#+ Pool)]] + ["." type (#+ Type) + [category (#+ Value Return)] + ["." descriptor (#+ Descriptor)]]]]) (type: #export Label Nat) @@ -527,13 +529,13 @@ (..nullary (/bytecode.multianewarray index count)))) (def: (descriptor-size descriptor) - (-> (Descriptor (Return Any)) U1) + (-> (Descriptor Return) U1) (//unsigned.u1 - (cond (is? //descriptor.void descriptor) + (cond (is? descriptor.void descriptor) 0 - (or (is? //descriptor.long descriptor) - (is? //descriptor.double descriptor)) + (or (is? descriptor.long descriptor) + (is? descriptor.double descriptor)) 2 ## else @@ -541,12 +543,12 @@ (template [ ] [(def: #export ( class method [inputs output]) - (-> External Text [(List (Descriptor Value)) (Descriptor (Return Any))] (Instruction Any)) + (-> External Text [(List (Descriptor Value)) (Descriptor Return)] (Instruction Any)) (do ..monad [index (<| ..lift (//constant/pool.method class) {#//constant/pool.name method - #//constant/pool.descriptor (//descriptor.method [inputs output])})] + #//constant/pool.descriptor (descriptor.method [inputs output])})] (..nullary ( index (|> inputs @@ -562,16 +564,16 @@ (template [ <1> <2>] [(def: #export ( class field type) - (-> External Text (Descriptor Field) (Instruction Any)) + (-> External Text (Descriptor Value) (Instruction Any)) (do ..monad [index (<| ..lift (//constant/pool.field class) {#//constant/pool.name field #//constant/pool.descriptor type})] - (..nullary (cond (is? //descriptor.long type) + (..nullary (cond (is? descriptor.long type) (<2> index) - (is? //descriptor.double type) + (is? descriptor.double type) (<2> index) ## else diff --git a/stdlib/source/lux/target/jvm/instruction/bytecode.lux b/stdlib/source/lux/target/jvm/instruction/bytecode.lux index 4f4d594d7..11afb5ad0 100644 --- a/stdlib/source/lux/target/jvm/instruction/bytecode.lux +++ b/stdlib/source/lux/target/jvm/instruction/bytecode.lux @@ -27,11 +27,12 @@ ["#." jump (#+ Jump Big-Jump)] ["/#" // #_ ["#." index (#+ Index)] - ["#." descriptor (#+ Field Method)] ["#." constant (#+ Class Reference)] [encoding ["#." unsigned (#+ U1 U2 U4)] - ["#." signed (#+ S2 S4)]]]]) + ["#." signed (#+ S2 S4)]] + [type + [category (#+ Value Method)]]]]) (type: #export Bytecode (-> [Environment Specification] @@ -378,7 +379,7 @@ ["C6" ifnull 1 0] ["C7" ifnonnull 1 0]) (template [ ] - [[ [[index (Index (Reference Field))]] [(///index.number index)] []]] + [[ [[index (Index (Reference Value))]] [(///index.number index)] []]] ["B2" getstatic/1 0 1] ["B2" getstatic/2 0 2] ["B3" putstatic/1 1 1] ["B3" putstatic/2 1 2] diff --git a/stdlib/source/lux/target/jvm/method.lux b/stdlib/source/lux/target/jvm/method.lux index f3fcf3207..0c9de952a 100644 --- a/stdlib/source/lux/target/jvm/method.lux +++ b/stdlib/source/lux/target/jvm/method.lux @@ -19,19 +19,21 @@ ["." // #_ ["#." modifier (#+ Modifier modifiers:)] ["#." index (#+ Index)] - ["#." descriptor (#+ Descriptor)] ["#." attribute (#+ Attribute) ["#/." code]] ["#." constant (#+ UTF8) ["#/." pool (#+ Pool)]] ["#." instruction (#+ Instruction) ["#/." condition] - ["#/." bytecode]]]) + ["#/." bytecode]] + [type + ["#." category] + ["#." descriptor (#+ Descriptor)]]]) (type: #export #rec Method {#modifier (Modifier Method) #name (Index UTF8) - #descriptor (Index (Descriptor //descriptor.Method)) + #descriptor (Index (Descriptor //category.Method)) #attributes (Row Attribute)}) (modifiers: Method @@ -50,7 +52,7 @@ ) (def: #export (method modifier name descriptor attributes code) - (-> (Modifier Method) UTF8 (Descriptor //descriptor.Method) (List (State Pool Attribute)) (Instruction Any) + (-> (Modifier Method) UTF8 (Descriptor //category.Method) (List (State Pool Attribute)) (Instruction Any) (State Pool Method)) (do state.monad [@name (//constant/pool.utf8 name) diff --git a/stdlib/source/lux/target/jvm/type/lux.lux b/stdlib/source/lux/target/jvm/type/lux.lux index 59ead2071..0b7f8f31d 100644 --- a/stdlib/source/lux/target/jvm/type/lux.lux +++ b/stdlib/source/lux/target/jvm/type/lux.lux @@ -9,10 +9,10 @@ ["" text (#+ Parser)]]] [data ["." product] - ["." text + ["." text ("#@." equivalence) ["%" format (#+ format)]] [collection - [array (#+ Array)] + ["." array] ["." dictionary (#+ Dictionary)]]] [type abstract @@ -143,10 +143,22 @@ (|>> (<>@map (check@map (function (_ elementT) (case elementT (#.Primitive name #.Nil) - (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.Nil) + (if (`` (or (~~ (template [] + [(text@= (//reflection.reflection ) name)] + + [//reflection.boolean] + [//reflection.byte] + [//reflection.short] + [//reflection.int] + [//reflection.long] + [//reflection.float] + [//reflection.double] + [//reflection.char])))) + (#.Primitive (|> name //reflection.class //reflection.array //reflection.reflection) #.Nil) + (|> elementT array.Array .type)) _ - (|> elementT Array .type))))) + (|> elementT array.Array .type))))) (<>.after (.this //descriptor.array-prefix)))) (def: #export (type mapping) diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux index 769646ad0..2d1dec4b2 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux @@ -801,8 +801,7 @@ (def: (reflection-return mapping typeJ) (-> Mapping (Type Return) (Operation .Type)) - (case (|> typeJ jvm.signature signature.signature - (.run (luxT.return mapping))) + (case (|> typeJ ..signature (.run (luxT.return mapping))) (#try.Success check) (typeA.with-env check) @@ -1307,10 +1306,10 @@ [#let [argsT (list@map product.left argsTC)] [methodT exceptionsT] (method-candidate class-tvars class method-tvars method #Static argsT) [outputT argsA] (inferenceA.general analyse methodT (list@map product.right argsTC)) - outputJC (check-return outputT)] + outputJT (check-return outputT)] (wrap (#/////analysis.Extension extension-name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) - (/////analysis.text (..signature outputJC)) + (/////analysis.text (..signature outputJT)) (decorate-inputs argsT argsA))))))])) (def: invoke::virtual @@ -1328,10 +1327,10 @@ _ (undefined))] - outputJC (check-return outputT)] + outputJT (check-return outputT)] (wrap (#/////analysis.Extension extension-name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) - (/////analysis.text (..signature outputJC)) + (/////analysis.text (..signature outputJT)) objectA (decorate-inputs argsT argsA))))))])) @@ -1344,10 +1343,10 @@ [#let [argsT (list@map product.left argsTC)] [methodT exceptionsT] (method-candidate class-tvars class method-tvars method #Special argsT) [outputT argsA] (inferenceA.general analyse methodT (list& objectC (list@map product.right argsTC))) - outputJC (check-return outputT)] + outputJT (check-return outputT)] (wrap (#/////analysis.Extension extension-name (list& (/////analysis.text (..signature (jvm.class class (list)))) (/////analysis.text method) - (/////analysis.text (..signature outputJC)) + (/////analysis.text (..signature outputJT)) (decorate-inputs argsT argsA))))))])) (def: invoke::interface @@ -1368,11 +1367,11 @@ _ (undefined))] - outputJC (check-return outputT)] + outputJT (check-return outputT)] (wrap (#/////analysis.Extension extension-name (list& (/////analysis.text (..signature (jvm.class class-name (list)))) (/////analysis.text method) - (/////analysis.text (..signature outputJC)) + (/////analysis.text (..signature outputJT)) objectA (decorate-inputs argsT argsA))))))])) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function.lux index 12e1bc460..36f8d72c6 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function.lux @@ -13,7 +13,6 @@ ["." row]]] [target [jvm - ["." descriptor (#+ Descriptor Value Return)] ["." modifier (#+ Modifier) ("#@." monoid)] ["." field (#+ Field)] ["." method (#+ Method)] diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/arity.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/arity.lux index 08954a7c0..ac35be9ba 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/arity.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/arity.lux @@ -2,7 +2,8 @@ [lux (#- type) [target [jvm - ["." descriptor]]]]) + [type + ["." descriptor]]]]]) (def: #export field "arity") (def: #export type descriptor.int) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/foreign.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/foreign.lux index 91e06c383..1534a9683 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/foreign.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/foreign.lux @@ -1,5 +1,5 @@ (.module: - [lux #* + [lux (#- Type) [control [state (#+ State)]] [data @@ -8,10 +8,12 @@ ["." row]]] [target [jvm - [descriptor (#+ Descriptor Value)] ["." field (#+ Field)] [constant - [pool (#+ Pool)]]]]] + [pool (#+ Pool)]] + [type + [category (#+ Value)] + [descriptor (#+ Descriptor)]]]]] ["." // ["//#" /// #_ ["#." value] diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial/count.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial/count.lux index 625cad78d..9b611fb94 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial/count.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/partial/count.lux @@ -2,11 +2,12 @@ [lux (#- type) [target [jvm - ["." descriptor] ["_" instruction (#+ Instruction) ("#@." monad)] [encoding [name (#+ External)] - ["." unsigned]]]]] + ["." unsigned]] + [type + ["." descriptor]]]]] ["." //// #_ ["#." abstract] ["/#" // #_ diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux index d2f2b9380..e298ab187 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/apply.lux @@ -10,11 +10,13 @@ ["." list]]] [target [jvm - ["." descriptor (#+ Descriptor Value Return)] ["_" instruction (#+ Instruction) ("#@." monad)] ["." constant] [encoding - ["." unsigned]]]]] + ["." unsigned]] + [type + ["." category (#+ Value Return)] + ["." descriptor (#+ Descriptor)]]]]] ["." /// #_ ["#." abstract] ["#." arity] @@ -27,7 +29,7 @@ (def: #export name "apply") (def: #export (type arity) - (-> Arity [(List (Descriptor Value)) (Descriptor (Return Any))]) + (-> Arity [(List (Descriptor Value)) (Descriptor Return)]) [(list.repeat arity ////value.type) ////value.type]) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/implementation.lux index 9b8a19b59..18df43d9d 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/implementation.lux @@ -7,11 +7,13 @@ ["." list]]] [target [jvm - ["." descriptor (#+ Descriptor)] ["." method (#+ Method)] ["_" instruction (#+ Label Instruction)] [constant - [pool (#+ Pool)]]]]] + [pool (#+ Pool)]] + [type + ["." category] + ["." descriptor (#+ Descriptor)]]]]] ["." // ["//#" /// #_ ["#." value] @@ -21,7 +23,7 @@ (def: #export name "impl") (def: #export (type arity) - (-> Arity (Descriptor descriptor.Method)) + (-> Arity (Descriptor category.Method)) (descriptor.method [(list.repeat arity ////value.type) ////value.type])) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux index 5a53ff9e0..5f771abcd 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux @@ -2,10 +2,12 @@ [lux (#- type) [target [jvm - ["." descriptor (#+ Descriptor Value Return)] ["_" instruction (#+ Instruction)] [encoding - ["." unsigned]]]]] + ["." unsigned]] + [type + ["." category (#+ Value Return)] + ["." descriptor (#+ Descriptor)]]]]] ["." /// #_ ["#." abstract] ["#." arity] @@ -15,7 +17,7 @@ (def: #export type [(List (Descriptor Value)) - (Descriptor (Return Any))] + (Descriptor Return)] [(list ///arity.type) descriptor.void]) (def: #export (instruction environment-size arity) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/new.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/new.lux index 7196d60fd..f03d333b2 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/new.lux @@ -11,7 +11,6 @@ ["." list ("#@." monoid)]]] [target [jvm - ["." descriptor (#+ Descriptor Value Return)] ["." modifier (#+ Modifier) ("#@." monoid)] ["." field (#+ Field)] ["." method (#+ Method)] @@ -20,7 +19,10 @@ [pool (#+ Pool)]] [encoding [name (#+ External)] - ["." unsigned]]]]] + ["." unsigned]] + [type + ["." category (#+ Value Return)] + ["." descriptor (#+ Descriptor)]]]]] ["." // ["#." init] ["/#" // #_ @@ -43,7 +45,7 @@ (def: #export (type environment arity) (-> Environment Arity [(List (Descriptor Value)) - (Descriptor (Return Any))]) + (Descriptor Return)]) [(list@compose (///field/foreign.closure environment) (if (arity.multiary? arity) (list& ///arity.type (arguments arity)) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/reset.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/reset.lux index df9ea0ae8..e43fd1b9b 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/reset.lux @@ -10,13 +10,15 @@ [target [jvm [modifier (#+ Modifier)] - ["." descriptor (#+ Descriptor)] ["." method (#+ Method)] ["_" instruction] [constant [pool (#+ Pool)]] [encoding - [name (#+ External)]]]]] + [name (#+ External)]] + [type + ["." category] + ["." descriptor (#+ Descriptor)]]]]] ["." // ["#." new] ["/#" // #_ @@ -34,7 +36,7 @@ (def: #export name "reset") (def: #export type - (-> External (Descriptor descriptor.Method)) + (-> External (Descriptor category.Method)) (|>> descriptor.class [(list)] descriptor.method)) (def: #export (method class environment arity) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux index d2d51d992..0f4cdfec7 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/primitive.lux @@ -4,9 +4,10 @@ [monad (#+ do)]] [target [jvm - ["|" descriptor] ["." constant] - ["_" instruction (#+ Instruction)]]] + ["_" instruction (#+ Instruction)] + [type + ["|" descriptor]]]] [macro ["." template]]] ["." // #_ diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux index 380040fa5..1ea837947 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/structure.lux @@ -9,9 +9,10 @@ ["." list]]] [target [jvm - ["|" descriptor] ["_." constant] - ["_" instruction (#+ Instruction)]]]] + ["_" instruction (#+ Instruction)] + [type + ["|" descriptor]]]]] ["." // #_ ["#." runtime (#+ Operation Phase Generator)] ["#." primitive] diff --git a/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux b/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux index c0634ac25..0dfbe4861 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/jvm/value.lux @@ -2,7 +2,8 @@ [lux (#- type) [target [jvm - ["." descriptor (#+ Descriptor Value)]]]]) + [type + ["." descriptor]]]]]) (def: #export field "_value") diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 0318dcb12..6ed752f74 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -221,17 +221,17 @@ (import: #long java/lang/AutoCloseable (close [] #io #try void)) - (import: java/io/OutputStream + (import: #long java/io/OutputStream (write [[byte]] #io #try void) (flush [] #io #try void)) - (import: java/io/FileOutputStream + (import: #long java/io/FileOutputStream (new [java/io/File boolean] #io #try)) - (import: java/io/InputStream + (import: #long java/io/InputStream (read [[byte]] #io #try int)) - (import: java/io/FileInputStream + (import: #long java/io/FileInputStream (new [java/io/File] #io #try)) (structure: (file path) @@ -242,9 +242,9 @@ (..can-modify (function ( data) (do (try.with io.monad) - [stream (FileOutputStream::new (java/io/File::new path) ) - _ (OutputStream::write data stream) - _ (OutputStream::flush stream)] + [stream (java/io/FileOutputStream::new (java/io/File::new path) ) + _ (java/io/OutputStream::write data stream) + _ (java/io/OutputStream::flush stream)] (java/lang/AutoCloseable::close stream)))))] [over-write #0] @@ -258,8 +258,8 @@ [#let [file (java/io/File::new path)] size (java/io/File::length file) #let [data (binary.create (.nat size))] - stream (FileInputStream::new file) - bytes-read (InputStream::read data stream) + stream (java/io/FileInputStream::new file) + bytes-read (java/io/InputStream::read data stream) _ (java/lang/AutoCloseable::close stream)] (if (i.= size bytes-read) (wrap data) diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 6f16a0088..686edae01 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -25,9 +25,7 @@ ["d" dictionary] ["." list]]] [macro - [poly (#+ derived:)] - ["." poly/equivalence] - ["." poly/json]] + [poly (#+ derived:)]] [type ["." unit]] [math @@ -44,8 +42,7 @@ ## ["_." duration] ["_." date]]]] {1 - ["." / (#+ JSON)]} - ) + ["." / (#+ JSON)]}) (def: #export json (Random JSON) diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux index 8ff26e2e9..2bba4c4a7 100644 --- a/stdlib/source/test/lux/host.jvm.lux +++ b/stdlib/source/test/lux/host.jvm.lux @@ -16,6 +16,8 @@ (import: #long (java/util/concurrent/Callable a)) +(import: #long java/lang/Long) + (import: #long java/lang/String) (import: #long java/lang/Exception @@ -66,8 +68,8 @@ [] (call self) a #throws [java/lang/Exception] (undefined)))) -(interface: TestInterface - ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) +## (interface: TestInterface +## ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) (def: conversions Test @@ -76,9 +78,9 @@ (`` ($_ _.and (~~ (template [ ] [(_.test - (or (|> sample (i.= sample)) - (let [capped-sample (|> sample )] - (|> capped-sample (i.= capped-sample)))))] + (or (|> sample (:coerce java/lang/Long) (:coerce Int) (i.= sample)) + (let [capped-sample (|> sample (:coerce java/lang/Long) )] + (|> capped-sample (:coerce Int) (i.= (:coerce Int capped-sample))))))] [/.long-to-byte /.byte-to-long "Can succesfully convert to/from byte."] [/.long-to-short /.short-to-long "Can succesfully convert to/from short."] @@ -92,7 +94,8 @@ (def: miscellaneous Test (do r.monad - [sample (r.ascii 1)] + [sample (:: @ map (|>> (:coerce java/lang/Object )) + (r.ascii 1))] ($_ _.and (_.test "Can check if an object is of a certain class." (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) @@ -124,15 +127,16 @@ (do r.monad [size (|> r.nat (:: @ map (|>> (n.% 100) (n.max 1)))) idx (|> r.nat (:: @ map (n.% size))) - value r.int] + value (:: @ map (|>> (:coerce java/lang/Long)) r.int)] ($_ _.and (_.test "Can create arrays of some length." - (n.= size (/.array-length (/.array Long size)))) + (n.= size (/.array-length (/.array java/lang/Long size)))) (_.test "Can set and get array values." - (let [arr (/.array Long size)] + (let [arr (/.array java/lang/Long size)] (exec (/.array-write idx value arr) - (i.= value (/.array-read idx arr)))))))) + (i.= (:coerce Int value) + (:coerce Int (/.array-read idx arr))))))))) (def: #export test ($_ _.and diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index bc5ed349c..6d65a8c3f 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -12,8 +12,7 @@ ["#." poly #_ ["#/." equivalence] ["#/." functor] - ["#/." json]] - ]) + ["#/." json]]]) (def: #export test Test diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index 7b9d0b97c..7ba3bbd13 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -6,7 +6,9 @@ ["." random (#+ Random)]] [abstract [monad (#+ do)] - [equivalence (#+ Equivalence)]] + [equivalence (#+ Equivalence) + {[0 #poly] + ["." /]}]] [data ["." bit] ["." maybe] @@ -17,9 +19,7 @@ [collection ["." list]]] ["." macro - [poly (#+ derived:)]]] - {1 - ["." /]}) + [poly (#+ derived:)]]]) (type: Variant (#Case0 Bit) diff --git a/stdlib/source/test/lux/macro/poly/functor.lux b/stdlib/source/test/lux/macro/poly/functor.lux index 4eb05af3c..85d24bc5b 100644 --- a/stdlib/source/test/lux/macro/poly/functor.lux +++ b/stdlib/source/test/lux/macro/poly/functor.lux @@ -1,7 +1,11 @@ (.module: [lux #* ["%" data/text/format (#+ format)] - [abstract/monad (#+ do)] + [abstract + [monad (#+ do)] + [functor + {[0 #poly] + ["." /]}]] ["r" math/random (#+ Random)] ["_" test (#+ Test)] [control @@ -9,9 +13,7 @@ [data ["." identity]] [macro - [poly (#+ derived:)]]] - {1 - ["." /]}) + [poly (#+ derived:)]]]) (derived: maybe-functor (/.functor .Maybe)) (derived: list-functor (/.functor .List)) @@ -22,4 +24,4 @@ Test (<| (_.context (%.name (name-of /._))) (_.test "Can derive functors automatically." - #1))) + true))) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index 8a72e0e2b..92a8ce00c 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -5,7 +5,9 @@ [abstract codec [monad (#+ do)] - [equivalence (#+ Equivalence)] + [equivalence (#+ Equivalence) + {[0 #poly] + ["poly/equivalence" /]}] {[0 #test] [/ ["$." equivalence] @@ -23,14 +25,15 @@ ["n" nat] ["." frac]] [format - [json (#+)]] + [json (#+) + {[0 #poly] + ["." /]}]] [collection [row (#+ row)] ["d" dictionary] ["." list]]] [macro - [poly (#+ derived:)] - ["." poly/equivalence]] + [poly (#+ derived:)]] [type ["." unit]] [math @@ -45,10 +48,7 @@ [time ["_." instant] ## ["_." duration] - ["_." date]]]] - {1 - ["." /]} - ) + ["_." date]]]]) (type: Variant (#Bit Bit) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 9437fb38a..fc7c140b4 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -30,7 +30,6 @@ ["." / #_ ["#." loader (#+ Library)] ["#." version] - ["#." descriptor (#+ Descriptor Value)] ["#." modifier ("#@." monoid)] ["#." field] ["#." method] @@ -42,7 +41,10 @@ [encoding ["#." name]] ["#." instruction - ["#/." condition (#+ Environment)]]]}) + ["#/." condition (#+ Environment)]] + [type + [category (#+ Value)] + ["#." descriptor (#+ Descriptor)]]]}) ## (def: (write-class! name bytecode) ## (-> Text Binary (IO Text)) -- cgit v1.2.3