diff options
27 files changed, 329 insertions, 521 deletions
diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index 5c5a249c8..8d6218297 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -138,7 +138,7 @@ (`` (|> sub-value (~~ (template.splice <then>)))) #.None)] - [(Array java/lang/Object) [host-value]] + [[java/lang/Object] [host-value]] [java/lang/Boolean [..host-bit]] [java/lang/Integer [java/lang/Integer::longValue org/armedbear/lisp/Fixnum::getInstance]] [java/lang/Long [org/armedbear/lisp/Bignum::getInstance]] diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 1a2bfc8d8..30ab46ced 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -55,7 +55,7 @@ (doubleValue [] double)) (import: #long java/util/Arrays - (#static [t] copyOfRange [(Array t) int int] (Array t))) + (#static [t] copyOfRange [[t] int int] [t])) (import: #long javax/script/ScriptEngine (eval [java/lang/String] #try #? java/lang/Object)) @@ -72,7 +72,7 @@ (getSlot [int] #? java/lang/Object) (getMember [java/lang/String] #? java/lang/Object) (hasMember [java/lang/String] boolean) - (call [#? java/lang/Object (Array java/lang/Object)] #try java/lang/Object)) + (call [#? java/lang/Object [java/lang/Object]] #try java/lang/Object)) (import: #long jdk/nashorn/api/scripting/AbstractJSObject) @@ -132,7 +132,7 @@ (isFunction) boolean #1) (jdk/nashorn/api/scripting/AbstractJSObject - (call {this java/lang/Object} {args (Array java/lang/Object)}) java/lang/Object + (call {this java/lang/Object} {args [java/lang/Object]}) java/lang/Object (debug.inspect js-object)) )) @@ -144,7 +144,7 @@ (isFunction) boolean #1) (jdk/nashorn/api/scripting/AbstractJSObject - (call {this java/lang/Object} {args (Array java/lang/Object)}) java/lang/Object + (call {this java/lang/Object} {args [java/lang/Object]}) java/lang/Object (|> (java/util/Arrays::copyOfRange value (|> args (array.read 0) maybe.assume (:coerce Int)) (.int (array.size value))) @@ -156,7 +156,7 @@ (-> (Array java/lang/Object) jdk/nashorn/api/scripting/JSObject) (let [js-object (: (-> java/lang/Object jdk/nashorn/api/scripting/JSObject) (function (_ sub-value) - (<| (case (host.check (Array java/lang/Object) sub-value) + (<| (case (host.check [java/lang/Object] sub-value) (#.Some sub-value) (|> sub-value (:coerce (Array java/lang/Object)) js-structure) #.None) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 13d6862b0..2851fec7d 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -104,10 +104,7 @@ (import: #long net/sandius/rembulan/exec/DirectCallExecutor (#static newExecutor [] net/sandius/rembulan/exec/DirectCallExecutor) (schedulingContextFactory [] net/sandius/rembulan/runtime/SchedulingContextFactory) - (call [net/sandius/rembulan/StateContext - java/lang/Object - (Array java/lang/Object)] - #try (Array java/lang/Object))) + (call [net/sandius/rembulan/StateContext java/lang/Object [java/lang/Object]] #try [java/lang/Object])) (exception: (unknown-kind-of-object {object java/lang/Object}) (exception.report @@ -127,7 +124,7 @@ (def: (lux-structure value) (-> (Array java/lang/Object) program/StructureValue) (let [re-wrap (function (_ unwrapped) - (case (host.check (Array java/lang/Object) unwrapped) + (case (host.check [java/lang/Object] unwrapped) (#.Some sub-value) (|> sub-value (:coerce (Array java/lang/Object)) lux-structure (:coerce java/lang/Object)) diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index f3f445bd9..a65999526 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -79,7 +79,7 @@ (getValue [] php/runtime/Memory)) (import: #long php/runtime/memory/ArrayMemory - (new [(Array java/lang/Object)]) + (new [[java/lang/Object]]) (size [] int) (isMap [] boolean) (get [php/runtime/Memory] php/runtime/Memory)) @@ -98,11 +98,11 @@ (import: #long php/runtime/reflection/FunctionEntity) (import: #long php/runtime/invoke/InvokeHelper - (#static callAny [php/runtime/Memory (Array php/runtime/Memory) php/runtime/env/Environment php/runtime/env/TraceInfo] + (#static callAny [php/runtime/Memory [php/runtime/Memory] php/runtime/env/Environment php/runtime/env/TraceInfo] #try php/runtime/Memory)) (import: #long php/runtime/lang/Closure - (call [php/runtime/env/Environment (Array php/runtime/Memory)] #try php/runtime/Memory)) + (call [php/runtime/env/Environment [php/runtime/Memory]] #try php/runtime/Memory)) (template [<name>] [(interface: <name> diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index 41a720b36..756b27b9c 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -70,7 +70,7 @@ (__len__ [] int)) (import: #long org/python/core/PyFunction - (__call__ [(Array org/python/core/PyObject)] org/python/core/PyObject)) + (__call__ [[org/python/core/PyObject]] org/python/core/PyObject)) (import: #long org/python/core/PyArray (new [(java/lang/Class java/lang/Object) java/lang/Object]) @@ -150,7 +150,7 @@ [org/python/core/PyString org/python/core/PyObject::asString] [org/python/core/PyFunction (|>)] [org/python/core/PyArray org/python/core/PyArray::getArray] - [(Array java/lang/Object) (|>)] + [[java/lang/Object] (|>)] )) (~~ (template [<class> <processing>] [(case (host.check <class> host-object) diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 0eeed48ec..48a398233 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -114,8 +114,8 @@ [[org/jruby/runtime/ThreadContext int java/lang/String org/jruby/runtime/builtin/IRubyObject]] [[org/jruby/runtime/ThreadContext java/lang/String]] [[org/jruby/runtime/ThreadContext java/lang/String org/jruby/runtime/builtin/IRubyObject]] - ## [[org/jruby/runtime/ThreadContext java/lang/String (Array org/jruby/runtime/builtin/IRubyObject)]] - [[org/jruby/runtime/ThreadContext java/lang/String (Array org/jruby/runtime/builtin/IRubyObject) org/jruby/runtime/Block]] + ## [[org/jruby/runtime/ThreadContext java/lang/String [org/jruby/runtime/builtin/IRubyObject]]] + [[org/jruby/runtime/ThreadContext java/lang/String [org/jruby/runtime/builtin/IRubyObject] org/jruby/runtime/Block]] ) <placeholders> (template [<name> <inputs> <output>] [(org/jruby/runtime/builtin/IRubyObject @@ -155,7 +155,7 @@ [callSuper [org/jruby/runtime/ThreadContext - (Array org/jruby/runtime/builtin/IRubyObject) + [org/jruby/runtime/builtin/IRubyObject] org/jruby/runtime/Block] org/jruby/runtime/builtin/IRubyObject] @@ -187,7 +187,7 @@ (org/jruby/runtime/builtin/IRubyObject (callMethod {thread-context org/jruby/runtime/ThreadContext} {member java/lang/String} - {inputs (Array org/jruby/runtime/builtin/IRubyObject)}) + {inputs [org/jruby/runtime/builtin/IRubyObject]}) org/jruby/runtime/builtin/IRubyObject (exec (log! (format "Was called: " (%t member))) @@ -197,7 +197,7 @@ )))) (import: #long org/jruby/RubyProc - (call [org/jruby/runtime/ThreadContext (Array org/jruby/runtime/builtin/IRubyObject)] + (call [org/jruby/runtime/ThreadContext [org/jruby/runtime/builtin/IRubyObject]] org/jruby/runtime/builtin/IRubyObject)) (import: #long org/jruby/Ruby diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index b4adddec9..8eb29a3aa 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -86,7 +86,7 @@ (def: (variant? value) (-> Any Bit) - (case (host.check (Array java/lang/Object) (:coerce java/lang/Object value)) + (case (host.check [java/lang/Object] (:coerce java/lang/Object value)) (#.Some array) ## TODO: Get rid of this coercion ASAP. (let [array (:coerce (Array java/lang/Object) array)] @@ -194,7 +194,7 @@ (def: (lux-value value) (-> java/lang/Object java/lang/Object) - (<| (case (host.check (Array java/lang/Object) value) + (<| (case (host.check [java/lang/Object] value) (#.Some value) ## TODO: Get rid of the coercions below. (if (variant? value) diff --git a/new-luxc/source/luxc/lang/host/jvm/def.lux b/new-luxc/source/luxc/lang/host/jvm/def.lux index ce236c905..bf4abc8ed 100644 --- a/new-luxc/source/luxc/lang/host/jvm/def.lux +++ b/new-luxc/source/luxc/lang/host/jvm/def.lux @@ -57,11 +57,11 @@ (#static COMPUTE_MAXS int) (#static COMPUTE_FRAMES int) (new [int]) - (visit [int int String String String (Array String)] void) + (visit [int int String String String [String]] void) (visitEnd [] void) (visitField [int String String String Object] FieldVisitor) - (visitMethod [int String String String (Array String)] MethodVisitor) - (toByteArray [] (Array byte))) + (visitMethod [int String String String [String]] MethodVisitor) + (toByteArray [] [byte])) (def: (string-array values) (-> (List Text) (Array Text)) @@ -161,7 +161,7 @@ [(def: #export (<name> version visibility config name parameters super interfaces definitions) (-> //.Version //.Visibility //.Class-Config Text (List Parameter) Class (List Class) //.Def - (host.type (Array byte))) + (host.type [byte])) (let [writer (|> (do-to (ClassWriter::new class-computes) (ClassWriter::visit (version-flag version) ($_ i/+ @@ -188,7 +188,7 @@ (def: #export (interface version visibility config name parameters interfaces definitions) (-> //.Version //.Visibility //.Class-Config Text (List Parameter) (List Class) //.Def - (host.type (Array byte))) + (host.type [byte])) (let [writer (|> (do-to (ClassWriter::new class-computes) (ClassWriter::visit (version-flag version) ($_ i/+ diff --git a/new-luxc/source/luxc/lang/host/jvm/inst.lux b/new-luxc/source/luxc/lang/host/jvm/inst.lux index 040f6f04a..aeb9621ef 100644 --- a/new-luxc/source/luxc/lang/host/jvm/inst.lux +++ b/new-luxc/source/luxc/lang/host/jvm/inst.lux @@ -122,8 +122,8 @@ (visitLabel [org/objectweb/asm/Label] void) (visitJumpInsn [int org/objectweb/asm/Label] void) (visitTryCatchBlock [org/objectweb/asm/Label org/objectweb/asm/Label org/objectweb/asm/Label java/lang/String] void) - (visitLookupSwitchInsn [org/objectweb/asm/Label (Array int) (Array org/objectweb/asm/Label)] void) - (visitTableSwitchInsn [int int org/objectweb/asm/Label (Array org/objectweb/asm/Label)] void) + (visitLookupSwitchInsn [org/objectweb/asm/Label [int] [org/objectweb/asm/Label]] void) + (visitTableSwitchInsn [int int org/objectweb/asm/Label [org/objectweb/asm/Label]] void) ) ## [Insts] diff --git a/new-luxc/source/luxc/lang/translation/r.lux b/new-luxc/source/luxc/lang/translation/r.lux index d5a9f35fa..a4a3db1f5 100644 --- a/new-luxc/source/luxc/lang/translation/r.lux +++ b/new-luxc/source/luxc/lang/translation/r.lux @@ -31,7 +31,7 @@ (host.import: java/lang/Object) (host.import: java/lang/String - (getBytes [String] #try (Array byte))) + (getBytes [String] #try [byte])) (host.import: java/lang/CharSequence) diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index 46462ab34..8a00858b1 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -41,10 +41,10 @@ ["." host]]]]]]) (import: #long java/lang/reflect/Method - (invoke [java/lang/Object (Array java/lang/Object)] #try java/lang/Object)) + (invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)) (import: #long (java/lang/Class c) - (getMethod [java/lang/String (Array (java/lang/Class java/lang/Object))] #try java/lang/reflect/Method)) + (getMethod [java/lang/String [(java/lang/Class java/lang/Object)]] #try java/lang/reflect/Method)) (import: #long java/lang/Object (getClass [] (java/lang/Class java/lang/Object))) diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux index e1066bbcd..2752903a7 100644 --- a/stdlib/source/lux/data/text/encoding.lux +++ b/stdlib/source/lux/data/text/encoding.lux @@ -171,15 +171,14 @@ (|>> :representation)) ) -(`` (for {(~~ (static @.old)) - (as-is (import: #long java/lang/String - (new [(Array byte) java/lang/String]) - (getBytes [java/lang/String] (Array byte)))) - - (~~ (static @.jvm)) - (as-is (import: #long java/lang/String - (new [[byte] java/lang/String]) - (getBytes [java/lang/String] [byte])))})) +(with-expansions [<for-jvm> (as-is (import: #long java/lang/String + (new [[byte] java/lang/String]) + (getBytes [java/lang/String] [byte])))] + (`` (for {(~~ (static @.old)) + (as-is <for-jvm>) + + (~~ (static @.jvm)) + (as-is <for-jvm>)}))) (def: #export (to-utf8 value) (-> Text Binary) diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux index 43d3f4762..59b35a223 100644 --- a/stdlib/source/lux/debug.lux +++ b/stdlib/source/lux/debug.lux @@ -38,13 +38,13 @@ (getClass [] (java/lang/Class java/lang/Object))) (import: #long java/lang/Integer - (longValue [] java/lang/Long)) + (longValue [] long)) (import: #long java/lang/Long - (intValue [] java/lang/Integer)) + (intValue [] int)) (import: #long java/lang/Number - (intValue [] java/lang/Integer) + (intValue [] int) (longValue [] long) (doubleValue [] double)) @@ -57,12 +57,12 @@ (`` (|> value (~~ (template.splice <processing>)))) #.None)] - [java/lang/Boolean [%b]] - [java/lang/String [%t]] - [java/lang/Long [.int %i]] + [java/lang/Boolean [(:coerce .Bit) %b]] + [java/lang/String [(:coerce .Text) %t]] + [java/lang/Long [(:coerce .Int) %i]] [java/lang/Number [java/lang/Number::doubleValue %f]] )) - (case (host.check (Array java/lang/Object) object) + (case (host.check [java/lang/Object] object) (#.Some value) (let [value (:coerce (Array java/lang/Object) value)] (case (array.read 0 value) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index 88ffc16f6..d4bc8f3d1 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -1783,7 +1783,7 @@ "#io means the computation has side effects, and will be wrapped by the IO type." "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." (import: java/lang/String - (new [(Array byte)]) + (new [[byte]]) (#static valueOf [char] String) (#static valueOf #as int-valueOf [int] String)) @@ -1792,7 +1792,7 @@ (get [int] e)) (import: (java/util/ArrayList a) - ([T] toArray [(Array T)] (Array T))) + ([T] toArray [[T]] [T])) "#long makes it so the class-type that is generated is of the fully-qualified name." "In this case, it avoids a clash between the java.util.List type, and Lux's own List type." diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/host.old.lux index 32bb3887f..5c2ac40d9 100644 --- a/stdlib/source/lux/host.old.lux +++ b/stdlib/source/lux/host.old.lux @@ -669,47 +669,48 @@ (def: (generic-type^ imports type-vars) (-> Class-Imports (List Type-Parameter) (Parser GenericType)) - ($_ p.either - (do p.monad - [_ (s.this! (' ?))] - (wrap (#GenericWildcard #.None))) - (s.tuple (do p.monad - [_ (s.this! (' ?)) - bound-kind bound-kind^ - bound (generic-type^ imports type-vars)] - (wrap (#GenericWildcard (#.Some [bound-kind bound]))))) - (do p.monad - [name (full-class-name^ imports) - _ (assert-no-periods name)] - (if (list.member? text.equivalence (list@map product.left type-vars) name) - (wrap (#GenericTypeVar name)) - (wrap (#GenericClass name (list))))) - (s.form (do p.monad - [name (s.this! (' Array)) - component (generic-type^ imports type-vars)] - (case component - (^template [<class> <name>] - (#GenericClass <name> #.Nil) - (wrap (#GenericClass <class> (list)))) - (["[Z" "boolean"] - ["[B" "byte"] - ["[S" "short"] - ["[I" "int"] - ["[J" "long"] - ["[F" "float"] - ["[D" "double"] - ["[C" "char"]) - - _ - (wrap (#GenericArray component))))) - (s.form (do p.monad - [name (full-class-name^ imports) - _ (assert-no-periods name) - params (p.some (generic-type^ imports type-vars)) - _ (p.assert (format name " cannot be a type-parameter!") - (not (list.member? text.equivalence (list@map product.left type-vars) name)))] - (wrap (#GenericClass name params)))) - )) + (p.rec + (function (_ recur^) + ($_ p.either + (do p.monad + [_ (s.this! (' ?))] + (wrap (#GenericWildcard #.None))) + (s.tuple (do p.monad + [_ (s.this! (' ?)) + bound-kind bound-kind^ + bound recur^] + (wrap (#GenericWildcard (#.Some [bound-kind bound]))))) + (do p.monad + [name (full-class-name^ imports) + _ (assert-no-periods name)] + (if (list.member? text.equivalence (list@map product.left type-vars) name) + (wrap (#GenericTypeVar name)) + (wrap (#GenericClass name (list))))) + (s.tuple (do p.monad + [component recur^] + (case component + (^template [<class> <name>] + (#GenericClass <name> #.Nil) + (wrap (#GenericClass <class> (list)))) + (["[Z" "boolean"] + ["[B" "byte"] + ["[S" "short"] + ["[I" "int"] + ["[J" "long"] + ["[F" "float"] + ["[D" "double"] + ["[C" "char"]) + + _ + (wrap (#GenericArray component))))) + (s.form (do p.monad + [name (full-class-name^ imports) + _ (assert-no-periods name) + params (p.some recur^) + _ (p.assert (format name " cannot be a type-parameter!") + (not (list.member? text.equivalence (list@map product.left type-vars) name)))] + (wrap (#GenericClass name params)))) + )))) (def: (type-param^ imports) (-> Class-Imports (Parser Type-Parameter)) @@ -1816,7 +1817,7 @@ "#io means the computation has side effects, and will be wrapped by the IO type." "These options must show up in the following order [#io #try #?] (although, each option can be used independently)." (import: java/lang/String - (new [(Array byte)]) + (new [[byte]]) (#static valueOf [char] String) (#static valueOf #as int-valueOf [int] String)) @@ -1825,7 +1826,7 @@ (get [int] e)) (import: (java/util/ArrayList a) - ([T] toArray [(Array T)] (Array T))) + ([T] toArray [[T]] [T])) "#long makes it so the class-type that is generated is of the fully-qualified name." "In this case, it avoids a clash between the java.util.List type, and Lux's own List type." diff --git a/stdlib/source/lux/target/jvm/loader.old.lux b/stdlib/source/lux/target/jvm/loader.lux index 57a715107..ae4d0373c 100644 --- a/stdlib/source/lux/target/jvm/loader.old.lux +++ b/stdlib/source/lux/target/jvm/loader.lux @@ -42,12 +42,10 @@ (import: #long java/lang/String) (import: #long java/lang/reflect/Method - (invoke [java/lang/Object (Array java/lang/Object)] - #try java/lang/Object)) + (invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)) (import: #long (java/lang/Class a) - (getDeclaredMethod [java/lang/String (Array (java/lang/Class java/lang/Object))] - #try java/lang/reflect/Method)) + (getDeclaredMethod [java/lang/String [(java/lang/Class java/lang/Object)]] #try java/lang/reflect/Method)) (import: #long java/lang/Integer (#static TYPE (java/lang/Class java/lang/Integer))) diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux index 4ae3ce64f..090c5948f 100644 --- a/stdlib/source/lux/target/jvm/reflection.lux +++ b/stdlib/source/lux/target/jvm/reflection.lux @@ -35,15 +35,15 @@ (import: #long java/lang/reflect/ParameterizedType (getRawType [] java/lang/reflect/Type) - (getActualTypeArguments [] (Array java/lang/reflect/Type))) + (getActualTypeArguments [] [java/lang/reflect/Type])) (import: #long (java/lang/reflect/TypeVariable d) (getName [] java/lang/String) - (getBounds [] (Array java/lang/reflect/Type))) + (getBounds [] [java/lang/reflect/Type])) (import: #long (java/lang/reflect/WildcardType d) - (getLowerBounds [] (Array java/lang/reflect/Type)) - (getUpperBounds [] (Array java/lang/reflect/Type))) + (getLowerBounds [] [java/lang/reflect/Type]) + (getUpperBounds [] [java/lang/reflect/Type])) (import: #long java/lang/reflect/Modifier (#static isStatic [int] boolean) @@ -60,29 +60,29 @@ (getName [] java/lang/String) (getModifiers [] int) (getDeclaringClass [] (java/lang/Class java/lang/Object)) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable java/lang/reflect/Method))) - (getGenericParameterTypes [] (Array java/lang/reflect/Type)) + (getTypeParameters [] [(java/lang/reflect/TypeVariable java/lang/reflect/Method)]) + (getGenericParameterTypes [] [java/lang/reflect/Type]) (getGenericReturnType [] java/lang/reflect/Type) - (getGenericExceptionTypes [] (Array java/lang/reflect/Type))) + (getGenericExceptionTypes [] [java/lang/reflect/Type])) (import: #long (java/lang/reflect/Constructor c) (getModifiers [] int) (getDeclaringClass [] (java/lang/Class c)) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable (java/lang/reflect/Constructor c)))) - (getGenericParameterTypes [] (Array java/lang/reflect/Type)) - (getGenericExceptionTypes [] (Array java/lang/reflect/Type))) + (getTypeParameters [] [(java/lang/reflect/TypeVariable (java/lang/reflect/Constructor c))]) + (getGenericParameterTypes [] [java/lang/reflect/Type]) + (getGenericExceptionTypes [] [java/lang/reflect/Type])) (import: #long (java/lang/Class c) (#static forName [java/lang/String] #try (java/lang/Class java/lang/Object)) (getName [] java/lang/String) (getModifiers [] int) (isAssignableFrom [(java/lang/Class java/lang/Object)] boolean) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable (java/lang/Class c)))) - (getGenericInterfaces [] (Array java/lang/reflect/Type)) + (getTypeParameters [] [(java/lang/reflect/TypeVariable (java/lang/Class c))]) + (getGenericInterfaces [] [java/lang/reflect/Type]) (getGenericSuperclass [] #? java/lang/reflect/Type) (getDeclaredField [java/lang/String] #try java/lang/reflect/Field) - (getConstructors [] (Array (java/lang/reflect/Constructor java/lang/Object))) - (getDeclaredMethods [] (Array java/lang/reflect/Method))) + (getConstructors [] [(java/lang/reflect/Constructor java/lang/Object)]) + (getDeclaredMethods [] [java/lang/reflect/Method])) (exception: #export (unknown-class {class Text}) (exception.report 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 1f7cbe26e..616f030a9 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux @@ -654,7 +654,7 @@ (import: #long (java/lang/reflect/TypeVariable d) (getName [] java/lang/String) - (getBounds [] (Array java/lang/reflect/Type))) + (getBounds [] [java/lang/reflect/Type])) (import: #long java/lang/reflect/Modifier (#static isStatic [int] boolean) @@ -666,29 +666,29 @@ (getName [] java/lang/String) (getModifiers [] int) (getDeclaringClass [] (java/lang/Class java/lang/Object)) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable java/lang/reflect/Method))) - (getGenericParameterTypes [] (Array java/lang/reflect/Type)) + (getTypeParameters [] [(java/lang/reflect/TypeVariable java/lang/reflect/Method)]) + (getGenericParameterTypes [] [java/lang/reflect/Type]) (getGenericReturnType [] java/lang/reflect/Type) - (getGenericExceptionTypes [] (Array java/lang/reflect/Type))) + (getGenericExceptionTypes [] [java/lang/reflect/Type])) (import: #long (java/lang/reflect/Constructor c) (getModifiers [] int) (getDeclaringClass [] (java/lang/Class c)) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable (java/lang/reflect/Constructor c)))) - (getGenericParameterTypes [] (Array java/lang/reflect/Type)) - (getGenericExceptionTypes [] (Array java/lang/reflect/Type))) + (getTypeParameters [] [(java/lang/reflect/TypeVariable (java/lang/reflect/Constructor c))]) + (getGenericParameterTypes [] [java/lang/reflect/Type]) + (getGenericExceptionTypes [] [java/lang/reflect/Type])) (import: #long (java/lang/Class c) (#static forName [java/lang/String] #try (java/lang/Class java/lang/Object)) (getName [] java/lang/String) (getModifiers [] int) (isAssignableFrom [(java/lang/Class java/lang/Object)] boolean) - (getTypeParameters [] (Array (java/lang/reflect/TypeVariable (java/lang/Class c)))) - (getGenericInterfaces [] (Array java/lang/reflect/Type)) + (getTypeParameters [] [(java/lang/reflect/TypeVariable (java/lang/Class c))]) + (getGenericInterfaces [] [java/lang/reflect/Type]) (getGenericSuperclass [] #? java/lang/reflect/Type) (getDeclaredField [java/lang/String] #try java/lang/reflect/Field) - (getConstructors [] (Array (java/lang/reflect/Constructor java/lang/Object))) - (getDeclaredMethods [] (Array java/lang/reflect/Method))) + (getConstructors [] [(java/lang/reflect/Constructor java/lang/Object)]) + (getDeclaredMethods [] [java/lang/reflect/Method])) (def: (reflection-type mapping typeJ) (-> Mapping Type (Operation .Type)) diff --git a/stdlib/source/lux/world/binary.lux b/stdlib/source/lux/world/binary.lux index 56bf01620..9599ae2f0 100644 --- a/stdlib/source/lux/world/binary.lux +++ b/stdlib/source/lux/world/binary.lux @@ -15,7 +15,7 @@ [text format] [collection - [array (#+ Array)]]]]) + [array (#+)]]]]) (exception: #export (index-out-of-bounds {size Nat} {index Nat}) (exception.report @@ -33,29 +33,21 @@ [inverted-slice] ) -(`` (for {(~~ (static @.old)) - (as-is (type: #export Binary (host.type (Array byte))) +(with-expansions [<for-jvm> (as-is (type: #export Binary (host.type [byte])) - (import: #long java/lang/Object) + (import: #long java/lang/Object) + + (import: #long java/lang/System + (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)) - (import: #long java/lang/System - (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)) - - (import: #long java/util/Arrays - (#static copyOfRange [(Array byte) int int] (Array byte)) - (#static equals [(Array byte) (Array byte)] boolean))) - - (~~ (static @.jvm)) - (as-is (type: #export Binary (host.type [byte])) - - (import: #long java/lang/Object) - - (import: #long java/lang/System - (#static arraycopy [java/lang/Object int java/lang/Object int int] #try void)) + (import: #long java/util/Arrays + (#static copyOfRange [[byte] int int] [byte]) + (#static equals [[byte] [byte]] boolean)))] + (`` (for {(~~ (static @.old)) + (as-is <for-jvm>) - (import: #long java/util/Arrays - (#static copyOfRange [[byte] int int] [byte]) - (#static equals [[byte] [byte]] boolean)))})) + (~~ (static @.jvm)) + (as-is <for-jvm>)}))) (def: byte-mask I64 diff --git a/stdlib/source/lux/world/db/jdbc.old.lux b/stdlib/source/lux/world/db/jdbc.lux index 8fd0ecf4c..8fd0ecf4c 100644 --- a/stdlib/source/lux/world/db/jdbc.old.lux +++ b/stdlib/source/lux/world/db/jdbc.lux diff --git a/stdlib/source/lux/world/db/jdbc/input.old.lux b/stdlib/source/lux/world/db/jdbc/input.lux index 68045b058..b160c5a5c 100644 --- a/stdlib/source/lux/world/db/jdbc/input.old.lux +++ b/stdlib/source/lux/world/db/jdbc/input.lux @@ -38,7 +38,7 @@ [setDouble double] [setString java/lang/String] - [setBytes (Array byte)] + [setBytes [byte]] [setDate java/sql/Date] [setTime java/sql/Time] diff --git a/stdlib/source/lux/world/db/jdbc/output.old.lux b/stdlib/source/lux/world/db/jdbc/output.lux index 39c4cb92b..8c461bb68 100644 --- a/stdlib/source/lux/world/db/jdbc/output.old.lux +++ b/stdlib/source/lux/world/db/jdbc/output.lux @@ -38,7 +38,7 @@ [getFloat float] [getString java/lang/String] - [getBytes (Array byte)] + [getBytes [byte]] [getDate java/sql/Date] [getTime java/sql/Time] diff --git a/stdlib/source/lux/world/environment.old.lux b/stdlib/source/lux/world/environment.lux index 8ad10f1f9..8ad10f1f9 100644 --- a/stdlib/source/lux/world/environment.old.lux +++ b/stdlib/source/lux/world/environment.lux diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index f25a372fc..f60bb6974 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -17,7 +17,7 @@ ["." text format] [collection - ["." array (#+ Array)] + ["." array] ["." list ("#;." functor)]]] [time ["." instant (#+ Instant)] @@ -185,373 +185,194 @@ ["Instant" (%instant instant)] ["Path" file])) -(`` (for {(~~ (static @.old)) - (as-is (import: #long java/lang/String) - - (import: #long java/io/File - (new [java/lang/String]) - (~~ (template [<name>] - [(<name> [] #io #try boolean)] - - [createNewFile] [mkdir] - [exists] [delete] - [isFile] [isDirectory] - [canRead] [canWrite] [canExecute])) - - (length [] #io #try long) - (listFiles [] #io #try #? (Array java/io/File)) - (getAbsolutePath [] #io #try java/lang/String) - (renameTo [java/io/File] #io #try boolean) - (lastModified [] #io #try long) - (setLastModified [long] #io #try boolean) - (#static separator java/lang/String)) - - (template: (!delete path exception) - (do io.monad - [outcome (java/io/File::delete (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success [])) - - _ - (io.io (exception.throw exception [path]))))) - - (import: #long java/lang/AutoCloseable - (close [] #io #try void)) - - (import: java/io/OutputStream - (write [(Array byte)] #io #try void) - (flush [] #io #try void)) - - (import: java/io/FileOutputStream - (new [java/io/File boolean] #io #try)) - - (import: java/io/InputStream - (read [(Array byte)] #io #try int)) - - (import: java/io/FileInputStream - (new [java/io/File] #io #try)) - - (structure: (file path) - (-> Path (File IO)) - - (~~ (template [<name> <flag>] - [(def: <name> - (..can-modify - (function (<name> data) - (do (error.with io.monad) - [stream (FileOutputStream::new (java/io/File::new path) <flag>) - _ (OutputStream::write data stream) - _ (OutputStream::flush stream)] - (java/lang/AutoCloseable::close stream)))))] - - [over-write #0] - [append #1] - )) - - (def: content - (..can-query - (function (content _) - (do (error.with io.monad) - [#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) - _ (java/lang/AutoCloseable::close stream)] - (if (i/= size bytes-read) - (wrap data) - (io.io (exception.throw cannot-read-all-data path))))))) - - (def: size - (..can-query - (function (size _) - (|> path - java/io/File::new - java/io/File::length - (:: (error.with io.monad) map .nat))))) - - (def: last-modified - (..can-query - (function (last-modified _) - (|> path - java/io/File::new - (java/io/File::lastModified) - (:: (error.with io.monad) map (|>> duration.from-millis instant.absolute)))))) - - (def: can-execute? - (..can-query - (function (can-execute? _) - (|> path - java/io/File::new - java/io/File::canExecute)))) - - (def: move - (..can-open - (function (move destination) - (do io.monad - [outcome (java/io/File::renameTo (java/io/File::new destination) - (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success (file destination))) - - _ - (io.io (exception.throw cannot-move [destination path]))))))) - - (def: modify - (..can-modify - (function (modify time-stamp) - (do io.monad - [outcome (java/io/File::setLastModified (|> time-stamp instant.relative duration.to-millis) - (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success [])) - - _ - (io.io (exception.throw cannot-modify [time-stamp path]))))))) - - (def: delete - (..can-delete - (function (delete _) - (!delete path cannot-delete-file))))) - - (structure: (directory path) - (-> Path (Directory IO)) - - (~~ (template [<name> <method> <capability>] - [(def: <name> - (..can-query - (function (<name> _) - (do (error.with io.monad) - [?children (java/io/File::listFiles (java/io/File::new path))] - (case ?children - (#.Some children) - (|> children - array.to-list - (monad.filter @ (|>> <method>)) - (:: @ map (monad.map @ (|>> java/io/File::getAbsolutePath (:: @ map <capability>)))) - (:: @ join)) - - #.None - (io.io (exception.throw not-a-directory [path])))))))] - - [files java/io/File::isFile file] - [directories java/io/File::isDirectory directory] - )) - - (def: discard - (..can-delete - (function (discard _) - (!delete path cannot-discard-directory))))) - - (structure: #export system (System IO) - (~~ (template [<name> <method> <capability> <exception>] - [(def: <name> - (..can-open - (function (<name> path) - (do io.monad - [#let [file (java/io/File::new path)] - outcome (<method> file)] - (case outcome - (#error.Success #1) - (wrap (#error.Success (<capability> path))) - - _ - (wrap (exception.throw <exception> [path])))))))] - - [file java/io/File::isFile ..file cannot-find-file] - [create-file java/io/File::createNewFile ..file cannot-create-file] - [directory java/io/File::isDirectory ..directory cannot-find-directory] - [create-directory java/io/File::mkdir ..directory cannot-create-directory] - )) - - (def: separator (java/io/File::separator)) - )) - - (~~ (static @.jvm)) - (as-is (import: #long java/lang/String) - (import: #long java/lang/Boolean) - - (import: #long java/io/File - (new [java/lang/String]) - (~~ (template [<name>] - [(<name> [] #io #try boolean)] - - [createNewFile] [mkdir] - [exists] [delete] - [isFile] [isDirectory] - [canRead] [canWrite] [canExecute])) - - (length [] #io #try long) - (listFiles [] #io #try #? [java/io/File]) - (getAbsolutePath [] #io #try java/lang/String) - (renameTo [java/io/File] #io #try boolean) - (lastModified [] #io #try long) - (setLastModified [long] #io #try boolean) - (#static separator java/lang/String)) - - (template: (!delete path exception) - (do io.monad - [outcome (java/io/File::delete (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success [])) - - _ - (io.io (exception.throw exception [path]))))) - - (import: #long java/lang/AutoCloseable - (close [] #io #try void)) - - (import: java/io/OutputStream - (write [[byte]] #io #try void) - (flush [] #io #try void)) - - (import: java/io/FileOutputStream - (new [java/io/File boolean] #io #try)) - - (import: java/io/InputStream - (read [[byte]] #io #try int)) - - (import: java/io/FileInputStream - (new [java/io/File] #io #try)) - - (def: (file path) - (-> Path (File IO)) - (structure - (~~ (template [<name> <flag>] - [(def: <name> - (..can-modify - (function (<name> data) - (do (error.with io.monad) - [stream (FileOutputStream::new (java/io/File::new path) <flag>) - _ (OutputStream::write data stream) - _ (OutputStream::flush stream)] - (java/lang/AutoCloseable::close stream)))))] - - [over-write #0] - [append #1] - )) - - (def: content - (..can-query - (function (content _) - (do (error.with io.monad) - [#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) - _ (java/lang/AutoCloseable::close stream)] - (if (i/= size bytes-read) - (wrap data) - (io.io (exception.throw cannot-read-all-data path))))))) - - (def: size - (..can-query - (function (size _) - (|> (java/io/File::new path) - java/io/File::length - (:: (error.with io.monad) map .nat))))) - - (def: last-modified - (..can-query - (function (last-modified _) - (|> (java/io/File::new path) - java/io/File::lastModified - (:: (error.with io.monad) map (|>> duration.from-millis instant.absolute)))))) - - (def: can-execute? - (..can-query - (function (can-execute? _) - (java/io/File::canExecute (java/io/File::new path))))) - - (def: move - (..can-open - (function (move destination) - (do io.monad - [outcome (java/io/File::renameTo (java/io/File::new destination) - (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success (file destination))) - - _ - (io.io (exception.throw cannot-move [destination path]))))))) - - (def: modify - (..can-modify - (function (modify time-stamp) - (do io.monad - [outcome (java/io/File::setLastModified (|> time-stamp instant.relative duration.to-millis) - (java/io/File::new path))] - (case outcome - (#error.Success #1) - (wrap (#error.Success [])) - - _ - (io.io (exception.throw cannot-modify [time-stamp path]))))))) - - (def: delete - (..can-delete - (function (delete _) - (!delete path cannot-delete-file)))))) - - (structure: (directory path) - (-> Path (Directory IO)) - - (~~ (template [<name> <method> <capability>] - [(def: <name> - (..can-query - (function (<name> _) - (do (error.with io.monad) - [?children (java/io/File::listFiles (java/io/File::new path))] - (case ?children - (#.Some children) - (|> children - array.to-list - (monad.filter @ (|>> <method>)) - (:: @ map (monad.map @ (|>> java/io/File::getAbsolutePath - (:: @ map <capability>)))) - (:: @ join)) - - #.None - (io.io (exception.throw not-a-directory [path])))))))] - - [files java/io/File::isFile file] - [directories java/io/File::isDirectory directory] - )) - - (def: discard - (..can-delete - (function (discard _) - (!delete path cannot-discard-directory))))) - - (structure: #export system (System IO) - (~~ (template [<name> <method> <capability> <exception>] - [(def: <name> - (..can-open - (function (<name> path) - (do io.monad - [#let [file (java/io/File::new path)] - outcome (<method> file)] - (case outcome - (#error.Success #1) - (wrap (#error.Success (<capability> path))) - - _ - (wrap (exception.throw <exception> [path])))))))] - - [file java/io/File::isFile ..file cannot-find-file] - [create-file java/io/File::createNewFile ..file cannot-create-file] - [directory java/io/File::isDirectory ..directory cannot-find-directory] - [create-directory java/io/File::mkdir ..directory cannot-create-directory] - )) - - (def: separator (java/io/File::separator)) - ))})) +(with-expansions [<for-jvm> (as-is (import: #long java/lang/String) + + (import: #long java/io/File + (new [java/lang/String]) + (~~ (template [<name>] + [(<name> [] #io #try boolean)] + + [createNewFile] [mkdir] + [exists] [delete] + [isFile] [isDirectory] + [canRead] [canWrite] [canExecute])) + + (length [] #io #try long) + (listFiles [] #io #try #? [java/io/File]) + (getAbsolutePath [] #io #try java/lang/String) + (renameTo [java/io/File] #io #try boolean) + (lastModified [] #io #try long) + (setLastModified [long] #io #try boolean) + (#static separator java/lang/String)) + + (template: (!delete path exception) + (do io.monad + [outcome (java/io/File::delete (java/io/File::new path))] + (case outcome + (#error.Success #1) + (wrap (#error.Success [])) + + _ + (io.io (exception.throw exception [path]))))) + + (import: #long java/lang/AutoCloseable + (close [] #io #try void)) + + (import: java/io/OutputStream + (write [[byte]] #io #try void) + (flush [] #io #try void)) + + (import: java/io/FileOutputStream + (new [java/io/File boolean] #io #try)) + + (import: java/io/InputStream + (read [[byte]] #io #try int)) + + (import: java/io/FileInputStream + (new [java/io/File] #io #try)) + + (structure: (file path) + (-> Path (File IO)) + + (~~ (template [<name> <flag>] + [(def: <name> + (..can-modify + (function (<name> data) + (do (error.with io.monad) + [stream (FileOutputStream::new (java/io/File::new path) <flag>) + _ (OutputStream::write data stream) + _ (OutputStream::flush stream)] + (java/lang/AutoCloseable::close stream)))))] + + [over-write #0] + [append #1] + )) + + (def: content + (..can-query + (function (content _) + (do (error.with io.monad) + [#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) + _ (java/lang/AutoCloseable::close stream)] + (if (i/= size bytes-read) + (wrap data) + (io.io (exception.throw cannot-read-all-data path))))))) + + (def: size + (..can-query + (function (size _) + (|> path + java/io/File::new + java/io/File::length + (:: (error.with io.monad) map .nat))))) + + (def: last-modified + (..can-query + (function (last-modified _) + (|> path + java/io/File::new + (java/io/File::lastModified) + (:: (error.with io.monad) map (|>> duration.from-millis instant.absolute)))))) + + (def: can-execute? + (..can-query + (function (can-execute? _) + (|> path + java/io/File::new + java/io/File::canExecute)))) + + (def: move + (..can-open + (function (move destination) + (do io.monad + [outcome (java/io/File::renameTo (java/io/File::new destination) + (java/io/File::new path))] + (case outcome + (#error.Success #1) + (wrap (#error.Success (file destination))) + + _ + (io.io (exception.throw cannot-move [destination path]))))))) + + (def: modify + (..can-modify + (function (modify time-stamp) + (do io.monad + [outcome (java/io/File::setLastModified (|> time-stamp instant.relative duration.to-millis) + (java/io/File::new path))] + (case outcome + (#error.Success #1) + (wrap (#error.Success [])) + + _ + (io.io (exception.throw cannot-modify [time-stamp path]))))))) + + (def: delete + (..can-delete + (function (delete _) + (!delete path cannot-delete-file))))) + + (structure: (directory path) + (-> Path (Directory IO)) + + (~~ (template [<name> <method> <capability>] + [(def: <name> + (..can-query + (function (<name> _) + (do (error.with io.monad) + [?children (java/io/File::listFiles (java/io/File::new path))] + (case ?children + (#.Some children) + (|> children + array.to-list + (monad.filter @ (|>> <method>)) + (:: @ map (monad.map @ (|>> java/io/File::getAbsolutePath (:: @ map <capability>)))) + (:: @ join)) + + #.None + (io.io (exception.throw not-a-directory [path])))))))] + + [files java/io/File::isFile file] + [directories java/io/File::isDirectory directory] + )) + + (def: discard + (..can-delete + (function (discard _) + (!delete path cannot-discard-directory))))) + + (structure: #export system (System IO) + (~~ (template [<name> <method> <capability> <exception>] + [(def: <name> + (..can-open + (function (<name> path) + (do io.monad + [#let [file (java/io/File::new path)] + outcome (<method> file)] + (case outcome + (#error.Success #1) + (wrap (#error.Success (<capability> path))) + + _ + (wrap (exception.throw <exception> [path])))))))] + + [file java/io/File::isFile ..file cannot-find-file] + [create-file java/io/File::createNewFile ..file cannot-create-file] + [directory java/io/File::isDirectory ..directory cannot-find-directory] + [create-directory java/io/File::mkdir ..directory cannot-create-directory] + )) + + (def: separator (java/io/File::separator)) + ))] + (`` (for {(~~ (static @.old)) + (as-is <for-jvm>) + + (~~ (static @.jvm)) + (as-is <for-jvm>)}))) (template [<get> <signature> <create> <find> <exception>] [(def: #export (<get> monad system path) diff --git a/stdlib/source/lux/world/net/tcp.old.lux b/stdlib/source/lux/world/net/tcp.lux index 85d306799..a0fa13c8a 100644 --- a/stdlib/source/lux/world/net/tcp.old.lux +++ b/stdlib/source/lux/world/net/tcp.lux @@ -43,10 +43,10 @@ (flush [] #io #try void)) (import: java/io/InputStream - (read [(Array byte) int int] #io #try int)) + (read [[byte] int int] #io #try int)) (import: java/io/OutputStream - (write [(Array byte) int int] #io #try void)) + (write [[byte] int int] #io #try void)) (import: java/net/Socket (new [String int] #io #try) diff --git a/stdlib/source/lux/world/net/udp.old.lux b/stdlib/source/lux/world/net/udp.lux index 1f78f4b0d..df9244186 100644 --- a/stdlib/source/lux/world/net/udp.old.lux +++ b/stdlib/source/lux/world/net/udp.lux @@ -52,12 +52,12 @@ (flush [] #io #try void)) (import: java/net/InetAddress - (#static getAllByName [String] #io #try (Array InetAddress)) + (#static getAllByName [String] #io #try [InetAddress]) (getHostAddress [] String)) (import: java/net/DatagramPacket - (new #as new|send [(Array byte) int int InetAddress int]) - (new #as new|receive [(Array byte) int int]) + (new #as new|send [[byte] int int InetAddress int]) + (new #as new|receive [[byte] int int]) (getAddress [] InetAddress) (getPort [] int) (getLength [] int)) diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux index d7fedc6d0..3f0ae519e 100644 --- a/stdlib/source/lux/world/shell.lux +++ b/stdlib/source/lux/world/shell.lux @@ -96,7 +96,7 @@ (new [java/io/InputStream])) (import: #long java/io/OutputStream - (write [(Array byte)] #io #try void)) + (write [[byte]] #io #try void)) (import: #long java/lang/Process (getInputStream [] #io #try java/io/InputStream) @@ -139,7 +139,7 @@ java/lang/Process::destroy))))))))) (import: #long java/lang/ProcessBuilder - (new [(Array java/lang/String)]) + (new [[java/lang/String]]) (environment [] #io #try (java/util/Map java/lang/String java/lang/String)) (start [] #io #try java/lang/Process)) |