aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2020-10-09 23:11:38 -0400
committerEduardo Julian2020-10-09 23:11:38 -0400
commitbefa21cea76282f8cd3509e0a7da1bdffd353101 (patch)
tree9f671c8a86ca43bcccb8105a668a271e72ef06ea
parentbae39f32cddb816a6123697269c20dbf4a65ac19 (diff)
Mandatory long names for JVM imports, instead of having "long" be optional and short be default.
-rw-r--r--documentation/research/text_editor & ide.md1
-rw-r--r--stdlib/source/lux/control/concurrency/atom.lux4
-rw-r--r--stdlib/source/lux/control/concurrency/process.lux28
-rw-r--r--stdlib/source/lux/data/binary.lux6
-rw-r--r--stdlib/source/lux/data/product.lux19
-rw-r--r--stdlib/source/lux/data/text/buffer.lux26
-rw-r--r--stdlib/source/lux/data/text/encoding.lux2
-rw-r--r--stdlib/source/lux/debug.lux12
-rw-r--r--stdlib/source/lux/host.jvm.lux414
-rw-r--r--stdlib/source/lux/host.old.lux516
-rw-r--r--stdlib/source/lux/target/jvm/bytecode.lux4
-rw-r--r--stdlib/source/lux/target/jvm/constant.lux4
-rw-r--r--stdlib/source/lux/target/jvm/loader.lux14
-rw-r--r--stdlib/source/lux/target/jvm/reflection.lux24
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux14
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/common-lisp/extension/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux8
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/meta/packager/jvm.lux26
-rw-r--r--stdlib/source/lux/world/console.lux16
-rw-r--r--stdlib/source/lux/world/db/jdbc.lux16
-rw-r--r--stdlib/source/lux/world/db/jdbc/input.lux6
-rw-r--r--stdlib/source/lux/world/db/jdbc/output.lux12
-rw-r--r--stdlib/source/lux/world/file.lux14
-rw-r--r--stdlib/source/lux/world/shell.lux20
-rw-r--r--stdlib/source/program/aedifex/command/auto.lux22
-rw-r--r--stdlib/source/program/aedifex/command/build.lux4
-rw-r--r--stdlib/source/program/aedifex/dependency.lux10
-rw-r--r--stdlib/source/program/aedifex/hash.lux4
-rw-r--r--stdlib/source/program/aedifex/shell.lux16
-rw-r--r--stdlib/source/program/aedifex/upload.lux16
-rw-r--r--stdlib/source/program/licentia.lux4
-rw-r--r--stdlib/source/spec/compositor/generation/structure.lux2
-rw-r--r--stdlib/source/test/aedifex.lux2
-rw-r--r--stdlib/source/test/aedifex/artifact.lux30
-rw-r--r--stdlib/source/test/aedifex/profile.lux14
-rw-r--r--stdlib/source/test/lux/control/parser/json.lux8
-rw-r--r--stdlib/source/test/lux/data/product.lux64
-rw-r--r--stdlib/source/test/lux/host.jvm.lux16
-rw-r--r--stdlib/source/test/lux/host.old.lux55
-rw-r--r--stdlib/source/test/lux/target/jvm.lux24
47 files changed, 661 insertions, 852 deletions
diff --git a/documentation/research/text_editor & ide.md b/documentation/research/text_editor & ide.md
index 148dc60bc..3b176f504 100644
--- a/documentation/research/text_editor & ide.md
+++ b/documentation/research/text_editor & ide.md
@@ -205,6 +205,7 @@
## Structured editing
+1. https://github.com/Raathigesh/waypoint
1. [Going beyond regular expressions with structural code search](https://about.sourcegraph.com/blog/going-beyond-regular-expressions-with-structural-code-search)
1. [俺のlisp](https://github.com/illiichi/orenolisp)
1. [豆腐 (Tofu): meaningful code editing](https://gregoor.github.io/tofu/)
diff --git a/stdlib/source/lux/control/concurrency/atom.lux b/stdlib/source/lux/control/concurrency/atom.lux
index 9bd1e1472..9ebd54bb8 100644
--- a/stdlib/source/lux/control/concurrency/atom.lux
+++ b/stdlib/source/lux/control/concurrency/atom.lux
@@ -14,13 +14,13 @@
abstract]])
(for {@.old
- (host.import: #long (java/util/concurrent/atomic/AtomicReference a)
+ (host.import: (java/util/concurrent/atomic/AtomicReference a)
(new [a])
(get [] a)
(compareAndSet [a a] boolean))
@.jvm
- (host.import: #long (java/util/concurrent/atomic/AtomicReference a)
+ (host.import: (java/util/concurrent/atomic/AtomicReference a)
(new [a])
(get [] a)
(compareAndSet [a a] boolean))}
diff --git a/stdlib/source/lux/control/concurrency/process.lux b/stdlib/source/lux/control/concurrency/process.lux
index afd24bb5c..7a4c46856 100644
--- a/stdlib/source/lux/control/concurrency/process.lux
+++ b/stdlib/source/lux/control/concurrency/process.lux
@@ -16,44 +16,44 @@
["." atom (#+ Atom)]])
(for {@.old
- (as-is (host.import: #long java/lang/Object)
+ (as-is (host.import: java/lang/Object)
- (host.import: #long java/lang/Runtime
+ (host.import: java/lang/Runtime
(#static getRuntime [] java/lang/Runtime)
(availableProcessors [] int))
- (host.import: #long java/lang/Runnable)
+ (host.import: java/lang/Runnable)
- (host.import: #long java/util/concurrent/TimeUnit
+ (host.import: java/util/concurrent/TimeUnit
(#enum MILLISECONDS))
- (host.import: #long java/util/concurrent/Executor
+ (host.import: java/util/concurrent/Executor
(execute [java/lang/Runnable] #io void))
- (host.import: #long (java/util/concurrent/ScheduledFuture a))
+ (host.import: (java/util/concurrent/ScheduledFuture a))
- (host.import: #long java/util/concurrent/ScheduledThreadPoolExecutor
+ (host.import: java/util/concurrent/ScheduledThreadPoolExecutor
(new [int])
(schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))))
@.jvm
- (as-is (host.import: #long java/lang/Object)
+ (as-is (host.import: java/lang/Object)
- (host.import: #long java/lang/Runtime
+ (host.import: java/lang/Runtime
(#static getRuntime [] java/lang/Runtime)
(availableProcessors [] int))
- (host.import: #long java/lang/Runnable)
+ (host.import: java/lang/Runnable)
- (host.import: #long java/util/concurrent/TimeUnit
+ (host.import: java/util/concurrent/TimeUnit
(#enum MILLISECONDS))
- (host.import: #long java/util/concurrent/Executor
+ (host.import: java/util/concurrent/Executor
(execute [java/lang/Runnable] #io void))
- (host.import: #long (java/util/concurrent/ScheduledFuture a))
+ (host.import: (java/util/concurrent/ScheduledFuture a))
- (host.import: #long java/util/concurrent/ScheduledThreadPoolExecutor
+ (host.import: java/util/concurrent/ScheduledThreadPoolExecutor
(new [int])
(schedule [java/lang/Runnable long java/util/concurrent/TimeUnit] #io (java/util/concurrent/ScheduledFuture java/lang/Object))))
diff --git a/stdlib/source/lux/data/binary.lux b/stdlib/source/lux/data/binary.lux
index 6bb5667bf..2d4fb0f63 100644
--- a/stdlib/source/lux/data/binary.lux
+++ b/stdlib/source/lux/data/binary.lux
@@ -38,12 +38,12 @@
(with-expansions [<for-jvm> (as-is (type: #export Binary (host.type [byte]))
- (host.import: #long java/lang/Object)
+ (host.import: java/lang/Object)
- (host.import: #long java/lang/System
+ (host.import: java/lang/System
(#static arraycopy [java/lang/Object int java/lang/Object int int] #try void))
- (host.import: #long java/util/Arrays
+ (host.import: java/util/Arrays
(#static copyOfRange [[byte] int int] [byte])
(#static equals [[byte] [byte]] boolean))
diff --git a/stdlib/source/lux/data/product.lux b/stdlib/source/lux/data/product.lux
index 5c7475833..f9d598433 100644
--- a/stdlib/source/lux/data/product.lux
+++ b/stdlib/source/lux/data/product.lux
@@ -7,7 +7,7 @@
(template [<name> <type> <output>]
[(def: #export (<name> xy)
- (All [a b] (-> [a b] <type>))
+ (All [a b] (-> (& a b) <type>))
(let [[x y] xy]
<output>))]
@@ -17,44 +17,45 @@
(def: #export (curry f)
(All [a b c]
- (-> (-> [a b] c)
+ (-> (-> (& a b) c)
(-> a b c)))
(function (_ x y)
(f [x y])))
(def: #export (uncurry f)
(All [a b c]
- (-> (-> a b c) (-> [a b] c)))
+ (-> (-> a b c)
+ (-> (& a b) c)))
(function (_ xy)
(let [[x y] xy]
(f x y))))
(def: #export (swap xy)
- (All [a b] (-> [a b] [b a]))
+ (All [a b] (-> (& a b) (& b a)))
(let [[x y] xy]
[y x]))
(def: #export (both f g)
(All [a b c d]
(-> (-> a c) (-> b d)
- (-> [a b] [c d])))
+ (-> (& a b) (& c d))))
(function (_ [x y])
[(f x) (g y)]))
(def: #export (fork f g)
(All [a l r]
(-> (-> a l) (-> a r)
- (-> a [l r])))
+ (-> a (& l r))))
(function (_ x)
[(f x) (g x)]))
-(structure: #export (equivalence l@= r@=)
+(structure: #export (equivalence leftE rightE)
(All [l r]
(-> (Equivalence l) (Equivalence r)
(Equivalence (& l r))))
(def: (= [lP rP] [lS rS])
- (and (l@= lP lS)
- (r@= rP rS))))
+ (and (:: leftE = lP lS)
+ (:: rightE = rP rS))))
(structure: #export (hash leftH rightH)
(All [l r]
diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux
index bbd1f0290..24416ea0d 100644
--- a/stdlib/source/lux/data/text/buffer.lux
+++ b/stdlib/source/lux/data/text/buffer.lux
@@ -8,7 +8,7 @@
[text
["%" format (#+ format)]]
[collection
- ["." row (#+ Row) ("#;." fold)]]]
+ ["." row (#+ Row) ("#@." fold)]]]
[compiler
["_" host]]
[type
@@ -19,15 +19,19 @@
(as-is (import: java/lang/CharSequence)
(import: java/lang/Appendable
- (append [CharSequence] Appendable))
+ (append [java/lang/CharSequence] java/lang/Appendable))
+
+ (import: java/lang/String
+ (new [int])
+ (toString [] java/lang/String))
(import: java/lang/StringBuilder
(new [int])
- (toString [] String)))}))
+ (toString [] java/lang/String)))}))
(`` (abstract: #export Buffer
(for {(~~ (static _.old))
- [Nat (-> StringBuilder StringBuilder)]}
+ [Nat (-> java/lang/StringBuilder java/lang/StringBuilder)]}
## default
(Row Text))
@@ -44,10 +48,10 @@
(-> Text Buffer Buffer)
(for {(~~ (static _.old))
(let [[capacity transform] (:representation buffer)
- append! (: (-> Text StringBuilder StringBuilder)
+ append! (: (-> Text java/lang/StringBuilder java/lang/StringBuilder)
(function (_ chunk builder)
- (exec (Appendable::append (:coerce CharSequence chunk)
- builder)
+ (exec (java/lang/Appendable::append (:coerce java/lang/CharSequence chunk)
+ builder)
builder)))]
(:abstraction [(n.+ (//.size chunk) capacity)
(|>> transform (append! chunk))]))}
@@ -59,7 +63,7 @@
(for {(~~ (static _.old))
(|> buffer :representation product.left)}
## default
- (row;fold (function (_ chunk total)
+ (row@fold (function (_ chunk total)
(n.+ (//.size chunk) total))
0
(:representation buffer))))
@@ -68,11 +72,11 @@
(-> Buffer Text)
(for {(~~ (static _.old))
(let [[capacity transform] (:representation buffer)]
- (|> (StringBuilder::new (.int capacity))
+ (|> (java/lang/StringBuilder::new (.int capacity))
transform
- StringBuilder::toString))}
+ java/lang/StringBuilder::toString))}
## default
- (row;fold (function (_ chunk total)
+ (row@fold (function (_ chunk total)
(format total chunk))
""
(:representation buffer))))
diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux
index bf9e71508..4d0da57cd 100644
--- a/stdlib/source/lux/data/text/encoding.lux
+++ b/stdlib/source/lux/data/text/encoding.lux
@@ -169,7 +169,7 @@
(|>> :representation))
)
-(with-expansions [<jvm> (as-is (host.import: #long java/lang/String
+(with-expansions [<jvm> (as-is (host.import: java/lang/String
(new [[byte] java/lang/String])
(getBytes [java/lang/String] [byte])))]
(for {@.old
diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux
index 135e33251..b34251760 100644
--- a/stdlib/source/lux/debug.lux
+++ b/stdlib/source/lux/debug.lux
@@ -28,23 +28,23 @@
[macro
["." template]]])
-(with-expansions [<jvm> (as-is (import: #long java/lang/String)
+(with-expansions [<jvm> (as-is (import: java/lang/String)
- (import: #long (java/lang/Class a)
+ (import: (java/lang/Class a)
(getCanonicalName [] java/lang/String))
- (import: #long java/lang/Object
+ (import: java/lang/Object
(new [])
(toString [] java/lang/String)
(getClass [] (java/lang/Class java/lang/Object)))
- (import: #long java/lang/Integer
+ (import: java/lang/Integer
(longValue [] long))
- (import: #long java/lang/Long
+ (import: java/lang/Long
(intValue [] int))
- (import: #long java/lang/Number
+ (import: java/lang/Number
(intValue [] int)
(longValue [] long)
(doubleValue [] double)))]
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index 14c8161c9..efd6042f1 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -294,18 +294,6 @@
(#MethodDecl [ImportMethodCommons ImportMethodDecl])
(#FieldAccessDecl ImportFieldDecl))
-(type: Context
- (List [Text Text]))
-
-(def: (short-class-name name)
- (-> Text Text)
- (case (list.reverse (text.split-all-with name.internal-separator name))
- (#.Cons short-name _)
- short-name
-
- #.Nil
- name))
-
(def: (primitive-type mode type)
(-> Primitive-Mode (Type Primitive) Code)
(case mode
@@ -386,44 +374,6 @@
(-> (Type Declaration) Code)
(|>> ..signature code.text))
-(def: fresh
- Context
- (list))
-
-(def: (get-import name imports)
- (-> Text Context (Maybe Text))
- (:: maybe.functor map product.right
- (list.find (|>> product.left (text@= name))
- imports)))
-
-(def: (add-import short+full imports)
- (-> [Text Text] Context Context)
- (#.Cons short+full imports))
-
-(def: (context compiler)
- (-> Lux Context)
- (case (meta.run compiler
- (: (Meta Context)
- (do meta.monad
- [current-module meta.current-module-name
- definitions (meta.definitions current-module)]
- (wrap (list@fold (: (-> [Text Definition] Context Context)
- (function (_ [short-name [_ _ meta _]] imports)
- (case (annotation.text (name-of #..jvm-class) meta)
- (#.Some full-class-name)
- (add-import [short-name full-class-name] imports)
-
- _
- imports)))
- ..fresh
- definitions)))))
- (#.Left _) (list)
- (#.Right imports) imports))
-
-(def: (qualify imports name)
- (-> Context Text Text)
- (|> imports (get-import name) (maybe.default name)))
-
(def: (make-get-const-parser class-name field-name)
(-> Text Text (Parser Code))
(do <>.monad
@@ -548,12 +498,6 @@
(#NativeMethod type-vars args return-type exs)
(make-virtual-method-parser class-name method-name args)))
-(def: (full-class-name^ imports)
- (-> Context (Parser Text))
- (do <>.monad
- [name <c>.local-identifier]
- (wrap (qualify imports name))))
-
(def: privacy-modifier^
(Parser Privacy)
(let [(^open ".") <>.monad]
@@ -596,23 +540,23 @@
(list@map parser.name type-vars)
name)))))
-(def: (valid-class-name imports type-vars)
- (-> Context (List (Type Var)) (Parser External))
+(def: (valid-class-name type-vars)
+ (-> (List (Type Var)) (Parser External))
(do <>.monad
- [name (full-class-name^ imports)
+ [name <c>.local-identifier
_ (assert-valid-class-name type-vars name)]
(wrap name)))
-(def: (class^' parameter^ imports type-vars)
- (-> (-> Context (List (Type Var)) (Parser (Type Parameter)))
- (-> Context (List (Type Var)) (Parser (Type Class))))
+(def: (class^' parameter^ type-vars)
+ (-> (-> (List (Type Var)) (Parser (Type Parameter)))
+ (-> (List (Type Var)) (Parser (Type Class))))
(do <>.monad
[[name parameters] (: (Parser [External (List (Type Parameter))])
($_ <>.either
- (<>.and (valid-class-name imports type-vars)
+ (<>.and (valid-class-name type-vars)
(<>@wrap (list)))
- (<c>.form (<>.and (full-class-name^ imports)
- (<>.some (parameter^ imports type-vars))))))]
+ (<c>.form (<>.and <c>.local-identifier
+ (<>.some (parameter^ type-vars))))))]
(wrap (type.class (name.sanitize name) parameters))))
(exception: #export (unexpected-type-variable {name Text}
@@ -621,10 +565,10 @@
["Unexpected Type Variable" (%.text name)]
["Expected Type Variables" (exception.enumerate parser.name type-vars)]))
-(def: (variable^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Type Parameter)))
+(def: (variable^ type-vars)
+ (-> (List (Type Var)) (Parser (Type Parameter)))
(do <>.monad
- [name (full-class-name^ imports)
+ [name <c>.local-identifier
_ (..assert ..unexpected-type-variable [name type-vars]
(list.member? text.equivalence (list@map parser.name type-vars) name))]
(wrap (type.var name))))
@@ -647,13 +591,13 @@
[lower^ > type.lower]
)
-(def: (parameter^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Type Parameter)))
+(def: (parameter^ type-vars)
+ (-> (List (Type Var)) (Parser (Type Parameter)))
(<>.rec
(function (_ recur^)
- (let [class^ (..class^' parameter^ imports type-vars)]
+ (let [class^ (..class^' parameter^ type-vars)]
($_ <>.either
- (..variable^ imports type-vars)
+ (..variable^ type-vars)
..wildcard^
(upper^ class^)
(lower^ class^)
@@ -686,13 +630,13 @@
(|>> <c>.tuple
(:: <>.monad map type.array)))
-(def: (type^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Type Value)))
+(def: (type^ type-vars)
+ (-> (List (Type Var)) (Parser (Type Value)))
(<>.rec
(function (_ type^)
($_ <>.either
..primitive^
- (..parameter^ imports type-vars)
+ (..parameter^ type-vars)
(..array^ type^)
))))
@@ -702,10 +646,10 @@
[_ (<c>.identifier! ["" (reflection.reflection reflection.void)])]
(wrap type.void)))
-(def: (return^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Type Return)))
+(def: (return^ type-vars)
+ (-> (List (Type Var)) (Parser (Type Return)))
(<>.either ..void^
- (..type^ imports type-vars)))
+ (..type^ type-vars)))
(def: var^
(Parser (Type Var))
@@ -715,61 +659,61 @@
(Parser (List (Type Var)))
(<c>.tuple (<>.some var^)))
-(def: (declaration^ imports)
- (-> Context (Parser (Type Declaration)))
+(def: declaration^
+ (Parser (Type Declaration))
(do <>.monad
[[name variables] (: (Parser [External (List (Type Var))])
- (<>.either (<>.and (valid-class-name imports (list))
+ (<>.either (<>.and (valid-class-name (list))
(<>@wrap (list)))
- (<c>.form (<>.and (valid-class-name imports (list))
+ (<c>.form (<>.and (valid-class-name (list))
(<>.some var^)))
))]
(wrap (type.declaration name variables))))
-(def: (class^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Type Class)))
- (class^' parameter^ imports type-vars))
+(def: (class^ type-vars)
+ (-> (List (Type Var)) (Parser (Type Class)))
+ (class^' parameter^ type-vars))
(def: annotation-parameters^
(Parser (List Annotation-Parameter))
(<c>.record (<>.some (<>.and <c>.local-tag <c>.any))))
-(def: (annotation^ imports)
- (-> Context (Parser Annotation))
+(def: annotation^
+ (Parser Annotation)
(<>.either (do <>.monad
- [ann-name (full-class-name^ imports)]
+ [ann-name <c>.local-identifier]
(wrap [ann-name (list)]))
- (<c>.form (<>.and (full-class-name^ imports)
+ (<c>.form (<>.and <c>.local-identifier
annotation-parameters^))))
-(def: (annotations^' imports)
- (-> Context (Parser (List Annotation)))
+(def: annotations^'
+ (Parser (List Annotation))
(do <>.monad
[_ (<c>.this! (' #ann))]
- (<c>.tuple (<>.some (annotation^ imports)))))
+ (<c>.tuple (<>.some ..annotation^))))
-(def: (annotations^ imports)
- (-> Context (Parser (List Annotation)))
+(def: annotations^
+ (Parser (List Annotation))
(do <>.monad
- [anns?? (<>.maybe (annotations^' imports))]
+ [anns?? (<>.maybe ..annotations^')]
(wrap (maybe.default (list) anns??))))
-(def: (throws-decl^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (List (Type Class))))
+(def: (throws-decl^ type-vars)
+ (-> (List (Type Var)) (Parser (List (Type Class))))
(<| (<>.default (list))
(do <>.monad
[_ (<c>.this! (' #throws))]
- (<c>.tuple (<>.some (..class^ imports type-vars))))))
+ (<c>.tuple (<>.some (..class^ type-vars))))))
-(def: (method-decl^ imports type-vars)
- (-> Context (List (Type Var)) (Parser [Member-Declaration MethodDecl]))
+(def: (method-decl^ type-vars)
+ (-> (List (Type Var)) (Parser [Member-Declaration MethodDecl]))
(<c>.form (do <>.monad
[tvars (<>.default (list) ..vars^)
name <c>.local-identifier
- anns (annotations^ imports)
- inputs (<c>.tuple (<>.some (..type^ imports type-vars)))
- output (..return^ imports type-vars)
- exs (throws-decl^ imports type-vars)]
+ anns ..annotations^
+ inputs (<c>.tuple (<>.some (..type^ type-vars)))
+ output (..return^ type-vars)
+ exs (throws-decl^ type-vars)]
(wrap [[name #PublicP anns] {#method-tvars tvars
#method-inputs inputs
#method-output output
@@ -782,42 +726,42 @@
(<c>.this! (' #final))
(:: <>.monad wrap [])))
-(def: (field-decl^ imports type-vars)
- (-> Context (List (Type Var)) (Parser [Member-Declaration FieldDecl]))
+(def: (field-decl^ type-vars)
+ (-> (List (Type Var)) (Parser [Member-Declaration FieldDecl]))
(<>.either (<c>.form (do <>.monad
[_ (<c>.this! (' #const))
name <c>.local-identifier
- anns (annotations^ imports)
- type (..type^ imports type-vars)
+ anns ..annotations^
+ type (..type^ type-vars)
body <c>.any]
(wrap [[name #PublicP anns] (#ConstantField [type body])])))
(<c>.form (do <>.monad
[pm privacy-modifier^
sm state-modifier^
name <c>.local-identifier
- anns (annotations^ imports)
- type (..type^ imports type-vars)]
+ anns ..annotations^
+ type (..type^ type-vars)]
(wrap [[name pm anns] (#VariableField [sm type])])))))
-(def: (argument^ imports type-vars)
- (-> Context (List (Type Var)) (Parser Argument))
+(def: (argument^ type-vars)
+ (-> (List (Type Var)) (Parser Argument))
(<c>.record (<>.and <c>.local-identifier
- (..type^ imports type-vars))))
+ (..type^ type-vars))))
-(def: (arguments^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (List Argument)))
- (<>.some (argument^ imports type-vars)))
+(def: (arguments^ type-vars)
+ (-> (List (Type Var)) (Parser (List Argument)))
+ (<>.some (..argument^ type-vars)))
-(def: (constructor-arg^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (Typed Code)))
- (<c>.record (<>.and (..type^ imports type-vars) <c>.any)))
+(def: (constructor-arg^ type-vars)
+ (-> (List (Type Var)) (Parser (Typed Code)))
+ (<c>.record (<>.and (..type^ type-vars) <c>.any)))
-(def: (constructor-args^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (List (Typed Code))))
- (<c>.tuple (<>.some (constructor-arg^ imports type-vars))))
+(def: (constructor-args^ type-vars)
+ (-> (List (Type Var)) (Parser (List (Typed Code))))
+ (<c>.tuple (<>.some (..constructor-arg^ type-vars))))
-(def: (constructor-method^ imports class-vars)
- (-> Context (List (Type Var)) (Parser [Member-Declaration Method-Definition]))
+(def: (constructor-method^ class-vars)
+ (List (Type Var)) (Parser [Member-Declaration Method-Definition])
(<c>.form (do <>.monad
[pm privacy-modifier^
strict-fp? (<>.parses? (<c>.this! (' #strict)))
@@ -826,18 +770,18 @@
[_ self-name arguments] (<c>.form ($_ <>.and
(<c>.this! (' new))
<c>.local-identifier
- (arguments^ imports total-vars)))
- constructor-args (constructor-args^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arguments^ total-vars)))
+ constructor-args (..constructor-args^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^
body <c>.any]
(wrap [{#member-name constructor-method-name
#member-privacy pm
#member-anns annotations}
(#ConstructorMethod strict-fp? method-vars self-name arguments constructor-args body exs)]))))
-(def: (virtual-method-def^ imports class-vars)
- (-> Context (List (Type Var)) (Parser [Member-Declaration Method-Definition]))
+(def: (virtual-method-def^ class-vars)
+ (-> (List (Type Var)) (Parser [Member-Declaration Method-Definition]))
(<c>.form (do <>.monad
[pm privacy-modifier^
strict-fp? (<>.parses? (<c>.this! (' #strict)))
@@ -847,39 +791,39 @@
[name self-name arguments] (<c>.form ($_ <>.and
<c>.local-identifier
<c>.local-identifier
- (arguments^ imports total-vars)))
- return-type (..return^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arguments^ total-vars)))
+ return-type (..return^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^
body <c>.any]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#VirtualMethod final? strict-fp? method-vars self-name arguments return-type body exs)]))))
-(def: (overriden-method-def^ imports)
- (-> Context (Parser [Member-Declaration Method-Definition]))
+(def: overriden-method-def^
+ (Parser [Member-Declaration Method-Definition])
(<c>.form (do <>.monad
[strict-fp? (<>.parses? (<c>.this! (' #strict)))
- owner-class (declaration^ imports)
+ owner-class ..declaration^
method-vars (<>.default (list) ..vars^)
#let [total-vars (list@compose (product.right (parser.declaration owner-class))
method-vars)]
[name self-name arguments] (<c>.form ($_ <>.and
<c>.local-identifier
<c>.local-identifier
- (arguments^ imports total-vars)))
- return-type (..return^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arguments^ total-vars)))
+ return-type (..return^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^
body <c>.any]
(wrap [{#member-name name
#member-privacy #PublicP
#member-anns annotations}
(#OverridenMethod strict-fp? owner-class method-vars self-name arguments return-type body exs)]))))
-(def: (static-method-def^ imports)
- (-> Context (Parser [Member-Declaration Method-Definition]))
+(def: static-method-def^
+ (Parser [Member-Declaration Method-Definition])
(<c>.form (do <>.monad
[pm privacy-modifier^
strict-fp? (<>.parses? (<c>.this! (' #strict)))
@@ -887,59 +831,59 @@
method-vars (<>.default (list) ..vars^)
#let [total-vars method-vars]
[name arguments] (<c>.form (<>.and <c>.local-identifier
- (arguments^ imports total-vars)))
- return-type (..return^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arguments^ total-vars)))
+ return-type (..return^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^
body <c>.any]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#StaticMethod strict-fp? method-vars arguments return-type body exs)]))))
-(def: (abstract-method-def^ imports)
- (-> Context (Parser [Member-Declaration Method-Definition]))
+(def: abstract-method-def^
+ (Parser [Member-Declaration Method-Definition])
(<c>.form (do <>.monad
[pm privacy-modifier^
_ (<c>.this! (' #abstract))
method-vars (<>.default (list) ..vars^)
#let [total-vars method-vars]
[name arguments] (<c>.form (<>.and <c>.local-identifier
- (arguments^ imports total-vars)))
- return-type (..return^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)]
+ (..arguments^ total-vars)))
+ return-type (..return^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#AbstractMethod method-vars arguments return-type exs)]))))
-(def: (native-method-def^ imports)
- (-> Context (Parser [Member-Declaration Method-Definition]))
+(def: native-method-def^
+ (Parser [Member-Declaration Method-Definition])
(<c>.form (do <>.monad
[pm privacy-modifier^
_ (<c>.this! (' #native))
method-vars (<>.default (list) ..vars^)
#let [total-vars method-vars]
[name arguments] (<c>.form (<>.and <c>.local-identifier
- (arguments^ imports total-vars)))
- return-type (..return^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)]
+ (..arguments^ total-vars)))
+ return-type (..return^ total-vars)
+ exs (throws-decl^ total-vars)
+ annotations ..annotations^]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#NativeMethod method-vars arguments return-type exs)]))))
-(def: (method-def^ imports class-vars)
- (-> Context (List (Type Var)) (Parser [Member-Declaration Method-Definition]))
+(def: (method-def^ class-vars)
+ (-> (List (Type Var)) (Parser [Member-Declaration Method-Definition]))
($_ <>.either
- (constructor-method^ imports class-vars)
- (virtual-method-def^ imports class-vars)
- (overriden-method-def^ imports)
- (static-method-def^ imports)
- (abstract-method-def^ imports)
- (native-method-def^ imports)))
+ (..constructor-method^ class-vars)
+ (..virtual-method-def^ class-vars)
+ ..overriden-method-def^
+ ..static-method-def^
+ ..abstract-method-def^
+ ..native-method-def^))
(def: partial-call^
(Parser Partial-Call)
@@ -961,10 +905,10 @@
[_ (<c>.this! (' #as))]
<c>.local-identifier)))
-(def: (import-member-args^ imports type-vars)
- (-> Context (List (Type Var)) (Parser (List [Bit (Type Value)])))
+(def: (import-member-args^ type-vars)
+ (-> (List (Type Var)) (Parser (List [Bit (Type Value)])))
(<c>.tuple (<>.some (<>.and (<>.parses? (<c>.tag! ["" "?"]))
- (..type^ imports type-vars)))))
+ (..type^ type-vars)))))
(def: import-member-return-flags^
(Parser [Bit Bit Bit])
@@ -978,8 +922,8 @@
(<>.or (<c>.tag! ["" "manual"])
(<c>.tag! ["" "auto"])))
-(def: (import-member-decl^ imports owner-vars)
- (-> Context (List (Type Var)) (Parser Import-Member-Declaration))
+(def: (import-member-decl^ owner-vars)
+ (-> (List (Type Var)) (Parser Import-Member-Declaration))
($_ <>.either
(<c>.form (do <>.monad
[_ (<c>.this! (' #enum))
@@ -991,7 +935,7 @@
?alias import-member-alias^
#let [total-vars (list@compose owner-vars tvars)]
?prim-mode (<>.maybe primitive-mode^)
- args (import-member-args^ imports total-vars)
+ args (..import-member-args^ total-vars)
[io? try? maybe?] import-member-return-flags^]
(wrap (#ConstructorDecl [{#import-member-mode (maybe.default #AutoPrM ?prim-mode)
#import-member-alias (maybe.default "new" ?alias)
@@ -1012,9 +956,9 @@
?alias import-member-alias^
#let [total-vars (list@compose owner-vars tvars)]
?prim-mode (<>.maybe primitive-mode^)
- args (import-member-args^ imports total-vars)
+ args (..import-member-args^ total-vars)
[io? try? maybe?] import-member-return-flags^
- return (..return^ imports total-vars)]
+ return (..return^ total-vars)]
(wrap (#MethodDecl [{#import-member-mode (maybe.default #AutoPrM ?prim-mode)
#import-member-alias (maybe.default name ?alias)
#import-member-kind kind
@@ -1029,7 +973,7 @@
[static? (<>.parses? (<c>.this! (' #static)))
name <c>.local-identifier
?prim-mode (<>.maybe primitive-mode^)
- gtype (..type^ imports owner-vars)
+ gtype (..type^ owner-vars)
maybe? (<>.parses? (<c>.this! (' #?)))
setter? (<>.parses? (<c>.this! (' #!)))]
(wrap (#FieldAccessDecl {#import-field-mode (maybe.default #AutoPrM ?prim-mode)
@@ -1222,19 +1166,16 @@
(type.class "java.lang.Object" (list)))
(syntax: #export (class:
- {#let [@ <>.monad
- imports (..context *compiler*)]}
+ {#let [@ <>.monad]}
{im inheritance-modifier^}
- {[full-class-name class-vars] (:: @ map parser.declaration (declaration^ imports))}
- {#let [imports (add-import [(short-class-name full-class-name) full-class-name]
- (..context *compiler*))]}
+ {[full-class-name class-vars] (:: @ map parser.declaration ..declaration^)}
{super (<>.default $Object
- (class^ imports class-vars))}
+ (class^ class-vars))}
{interfaces (<>.default (list)
- (<c>.tuple (<>.some (class^ imports class-vars))))}
- {annotations (annotations^ imports)}
- {fields (<>.some (field-decl^ imports class-vars))}
- {methods (<>.some (method-def^ imports class-vars))})
+ (<c>.tuple (<>.some (class^ class-vars))))}
+ {annotations ..annotations^}
+ {fields (<>.some (..field-decl^ class-vars))}
+ {methods (<>.some (..method-def^ class-vars))})
{#.doc (doc "Allows defining JVM classes in Lux code."
"For example:"
(class: #final (TestClass A) [Runnable]
@@ -1283,15 +1224,12 @@
[(~+ (list@map (method-def$ replacer super) methods))]))))))
(syntax: #export (interface:
- {#let [@ <>.monad
- imports (..context *compiler*)]}
- {[full-class-name class-vars] (:: @ map parser.declaration (declaration^ imports))}
- {#let [imports (add-import [(short-class-name full-class-name) full-class-name]
- (..context *compiler*))]}
+ {#let [@ <>.monad]}
+ {[full-class-name class-vars] (:: @ map parser.declaration ..declaration^)}
{supers (<>.default (list)
- (<c>.tuple (<>.some (class^ imports class-vars))))}
- {annotations (annotations^ imports)}
- {members (<>.some (method-decl^ imports class-vars))})
+ (<c>.tuple (<>.some (class^ class-vars))))}
+ {annotations ..annotations^}
+ {members (<>.some (..method-decl^ class-vars))})
{#.doc (doc "Allows defining JVM interfaces."
(interface: TestInterface
([] foo [boolean String] void #throws [Exception])))}
@@ -1304,14 +1242,13 @@
(~+ (list@map method-decl$ members))))))))
(syntax: #export (object
- {#let [imports (..context *compiler*)]}
{class-vars ..vars^}
{super (<>.default $Object
- (class^ imports class-vars))}
+ (class^ class-vars))}
{interfaces (<>.default (list)
- (<c>.tuple (<>.some (class^ imports class-vars))))}
- {constructor-args (constructor-args^ imports class-vars)}
- {methods (<>.some (overriden-method-def^ imports))})
+ (<c>.tuple (<>.some (class^ class-vars))))}
+ {constructor-args (..constructor-args^ class-vars)}
+ {methods (<>.some ..overriden-method-def^)})
{#.doc (doc "Allows defining anonymous classes."
"The 1st tuple corresponds to class-level type-variables."
"The 2nd tuple corresponds to parent interfaces."
@@ -1380,8 +1317,7 @@
(recover-from-failure error)))}
(wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-(syntax: #export (check {#let [imports (..context *compiler*)]}
- {class (..type^ imports (list))}
+(syntax: #export (check {class (..type^ (list))}
{unchecked (<>.maybe <c>.any)})
{#.doc (doc "Checks whether an object is an instance of a particular class."
"Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes."
@@ -1426,12 +1362,10 @@
(exec (~+ (list@map (complete-call$ g!obj) methods))
(~ g!obj))))))))
-(def: (class-import$ long-name? declaration)
- (-> Bit (Type Declaration) Code)
+(def: (class-import$ declaration)
+ (-> (Type Declaration) Code)
(let [[full-name params] (parser.declaration declaration)
- def-name (..internal (if long-name?
- full-name
- (short-class-name full-name)))
+ def-name (..internal full-name)
params' (list@map ..var$' params)]
(` (def: (~ (code.identifier ["" def-name]))
{#..jvm-class (~ (code.text (..internal full-name)))}
@@ -1740,12 +1674,10 @@
(wrap (list& getter-interop setter-interop)))
)))
-(def: (member-import$ vars long-name? kind class member)
- (-> (List (Type Var)) Bit Class-Kind (Type Declaration) Import-Member-Declaration (Meta (List Code)))
+(def: (member-import$ vars kind class member)
+ (-> (List (Type Var)) Class-Kind (Type Declaration) Import-Member-Declaration (Meta (List Code)))
(let [[full-name _] (parser.declaration class)
- method-prefix (..internal (if long-name?
- full-name
- (short-class-name full-name)))]
+ method-prefix (..internal full-name)]
(do meta.monad
[=args (member-def-arg-bindings vars member)]
(member-def-interop vars kind class =args member method-prefix))))
@@ -1777,20 +1709,13 @@
(meta.fail (format "Unknown class: " class-name)))))
(syntax: #export (import:
- {#let [imports (..context *compiler*)]}
- {long-name? (<>.parses? (<c>.this! (' #long)))}
- {declaration (declaration^ imports)}
- {#let [[full-class-name class-type-vars] (parser.declaration declaration)
- full-class-name (..internal full-class-name)
- imports (add-import [(short-class-name full-class-name) full-class-name]
- (..context *compiler*))]}
- {members (<>.some (import-member-decl^ imports class-type-vars))})
+ {declaration ..declaration^}
+ {members (<>.some (..import-member-decl^ class-type-vars))})
{#.doc (doc "Allows importing JVM classes, and using them as types."
"Their methods, fields and enum options can also be imported."
- "Also, classes which get imported into a module can also be referred-to with their short names in other macros that require JVM classes."
(import: java/lang/Object
(new [])
- (equals [Object] boolean)
+ (equals [java/lang/Object] boolean)
(wait [int] #io #try void))
"Special options can also be given for the return values."
@@ -1800,44 +1725,43 @@
"These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
(import: java/lang/String
(new [[byte]])
- (#static valueOf [char] String)
- (#static valueOf #as int-valueOf [int] String))
+ (#static valueOf [char] java/lang/String)
+ (#static valueOf #as int-valueOf [int] java/lang/String))
- (import: #long (java/util/List e)
+ (import: (java/util/List e)
(size [] int)
(get [int] e))
(import: (java/util/ArrayList a)
([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."
+ "The class-type that is generated is of the fully-qualified name."
+ "This avoids a clash between the java.util.List type, and Lux's own List type."
"All enum options to be imported must be specified."
(import: java/lang/Character$UnicodeScript
(#enum ARABIC CYRILLIC LATIN))
"It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars."
"Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
- (import: #long (lux/concurrency/promise/JvmPromise A)
+ (import: (lux/concurrency/promise/JvmPromise A)
(resolve [A] boolean)
(poll [] A)
(wasResolved [] boolean)
(waitOn [lux/Function] void)
- (#static [A] make [A] (JvmPromise A)))
+ (#static [A] make [A] (lux/concurrency/promise/JvmPromise A)))
"Also, the names of the imported members will look like Class::member"
- (Object::new [])
- (Object::equals [other-object] my-object)
+ (java/lang/Object::new [])
+ (java/lang/Object::equals [other-object] my-object)
(java/util/List::size [] my-list)
- Character$UnicodeScript::LATIN
+ java/lang/Character$UnicodeScript::LATIN
)}
(do {@ meta.monad}
[kind (class-kind declaration)
- =members (monad.map @ (member-import$ class-type-vars long-name? kind declaration) members)]
- (wrap (list& (class-import$ long-name? declaration) (list@join =members)))))
+ =members (monad.map @ (member-import$ class-type-vars kind declaration) members)]
+ (wrap (list& (class-import$ declaration) (list@join =members)))))
-(syntax: #export (array {#let [imports (..context *compiler*)]}
- {type (..type^ imports (list))}
+(syntax: #export (array {type (..type^ (list))}
size)
{#.doc (doc "Create an array of the given type, with the given size."
(array java/lang/Object 10))}
@@ -2070,26 +1994,10 @@
(wrap (list (` (let [(~ g!array) (~ array)]
(..array-write (~ idx) (~ value) (~ g!array)))))))))
-(syntax: #export (class-for {type (..type^ (..context *compiler*) (list))})
+(syntax: #export (class-for {type (..type^ (list))})
{#.doc (doc "Loads the class as a java.lang.Class object."
(class-for java/lang/String))}
(wrap (list (` ("jvm object class" (~ (code.text (..reflection type))))))))
-(def: get-compiler
- (Meta Lux)
- (function (_ compiler)
- (#.Right [compiler compiler])))
-
-(def: #export (resolve class)
- {#.doc (doc "Given a potentially unqualified class name, qualifies it if necessary."
- (resolve "String")
- =>
- "java.lang.String")}
- (-> External (Meta External))
- (do meta.monad
- [*compiler* get-compiler]
- (wrap (qualify (..context *compiler*) class))))
-
-(syntax: #export (type {#let [imports (..context *compiler*)]}
- {type (..type^ imports (list))})
+(syntax: #export (type {type (..type^ (list))})
(wrap (list (value-type #ManualPrM type))))
diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/host.old.lux
index ee37cc55d..9582464ba 100644
--- a/stdlib/source/lux/host.old.lux
+++ b/stdlib/source/lux/host.old.lux
@@ -226,19 +226,7 @@
(#MethodDecl [ImportMethodCommons ImportMethodDecl])
(#FieldAccessDecl ImportFieldDecl))
-(type: Class-Imports
- (List [Text Text]))
-
## Utils
-(def: (short-class-name name)
- (-> Text Text)
- (case (list.reverse (text.split-all-with "/" name))
- (#.Cons short-name _)
- short-name
-
- #.Nil
- name))
-
(def: (manual-primitive-to-type class)
(-> Text (Maybe Code))
(case class
@@ -350,132 +338,6 @@
(` (primitive (~ (code.text (sanitize class-name)))
[(~+ =params)]))))
-(def: empty-imports
- Class-Imports
- (list))
-
-(def: (get-import name imports)
- (-> Text Class-Imports (Maybe Text))
- (:: maybe.functor map product.right
- (list.find (|>> product.left (text@= name))
- imports)))
-
-(def: (add-import short+full imports)
- (-> [Text Text] Class-Imports Class-Imports)
- (#.Cons short+full imports))
-
-(def: (class-imports compiler)
- (-> Lux Class-Imports)
- (case (meta.run compiler
- (: (Meta Class-Imports)
- (do meta.monad
- [current-module meta.current-module-name
- definitions (meta.definitions current-module)]
- (wrap (list@fold (: (-> [Text Definition] Class-Imports Class-Imports)
- (function (_ [short-name [_ _ meta _]] imports)
- (case (annotation.text (name-of #..jvm-class) meta)
- (#.Some full-class-name)
- (add-import [short-name full-class-name] imports)
-
- _
- imports)))
- empty-imports
- definitions)))))
- (#.Left _)
- (list)
-
- (#.Right imports)
- imports))
-
-(def: java/lang/*
- (List Text)
- (list ## Interfaces
- "Appendable"
- "AutoCloseable"
- "CharSequence"
- "Cloneable"
- "Comparable"
- "Iterable"
- "Readable"
- "Runnable"
-
- ## Classes
- "Boolean"
- "Byte"
- "Character"
- "Class"
- "ClassLoader"
- "ClassValue"
- "Compiler"
- "Double"
- "Enum"
- "Float"
- "InheritableThreadLocal"
- "Integer"
- "Long"
- "Math"
- "Number"
- "Object"
- "Package"
- "Process"
- "ProcessBuilder"
- "Runtime"
- "RuntimePermission"
- "SecurityManager"
- "Short"
- "StackTraceElement"
- "StrictMath"
- "String"
- "StringBuffer"
- "StringBuilder"
- "System"
- "Thread"
- "ThreadGroup"
- "ThreadLocal"
- "Throwable"
- "Void"
-
- ## Exceptions
- "ArithmeticException"
- "ArrayIndexOutOfBoundsException"
- "ArrayStoreException"
- "ClassCastException"
- "ClassNotFoundException"
- "CloneNotSupportedException"
- "EnumConstantNotPresentException"
- "Exception"
- "IllegalAccessException"
- "IllegalArgumentException"
- "IllegalMonitorStateException"
- "IllegalStateException"
- "IllegalThreadStateException"
- "IndexOutOfBoundsException"
- "InstantiationException"
- "InterruptedException"
- "NegativeArraySizeException"
- "NoSuchFieldException"
- "NoSuchMethodException"
- "NullPointerException"
- "NumberFormatException"
- "ReflectiveOperationException"
- "RuntimeException"
- "SecurityException"
- "StringIndexOutOfBoundsException"
- "TypeNotPresentException"
- "UnsupportedOperationException"
-
- ## Annotations
- "Deprecated"
- "Override"
- "SafeVarargs"
- "SuppressWarnings"))
-
-(def: (qualify imports name)
- (-> Class-Imports Text Text)
- (if (list.member? text.equivalence java/lang/* name)
- (format "java/lang/" name)
- (maybe.default name (get-import name imports))))
-
(def: type-var-class Text "java.lang.Object")
(def: (simple-class$ env class)
@@ -639,12 +501,6 @@
(make-virtual-method-parser params class-name method-name args)))
## Parsers
-(def: (full-class-name^ imports)
- (-> Class-Imports (Parser Text))
- (do p.monad
- [name s.local-identifier]
- (wrap (qualify imports name))))
-
(def: privacy-modifier^
(Parser PrivacyModifier)
(let [(^open ".") p.monad]
@@ -672,8 +528,8 @@
(p.assert "Names in class declarations cannot contain periods."
(not (text.contains? "." name))))
-(def: (generic-type^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser GenericType))
+(def: (generic-type^ type-vars)
+ (-> (List Type-Parameter) (Parser GenericType))
(p.rec
(function (_ recur^)
($_ p.either
@@ -686,7 +542,7 @@
bound recur^]
(wrap (#GenericWildcard (#.Some [bound-kind bound])))))
(do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)]
(if (list.member? text.equivalence (list@map product.left type-vars) name)
(wrap (#GenericTypeVar name))
@@ -709,7 +565,7 @@
_
(wrap (#GenericArray component)))))
(s.form (do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)
params (p.some recur^)
_ (p.assert (format name " cannot be a type-parameter!")
@@ -717,91 +573,94 @@
(wrap (#GenericClass name params))))
))))
-(def: (type-param^ imports)
- (-> Class-Imports (Parser Type-Parameter))
+(def: type-param^
+ (Parser Type-Parameter)
(p.either (do p.monad
[param-name s.local-identifier]
(wrap [param-name (list)]))
(s.tuple (do p.monad
[param-name s.local-identifier
_ (s.this! (' <))
- bounds (p.many (generic-type^ imports (list)))]
+ bounds (p.many (..generic-type^ (list)))]
(wrap [param-name bounds])))))
-(def: (type-params^ imports)
- (-> Class-Imports (Parser (List Type-Parameter)))
- (s.tuple (p.some (type-param^ imports))))
+(def: type-params^
+ (Parser (List Type-Parameter))
+ (|> ..type-param^
+ p.some
+ s.tuple
+ (p.default (list))))
-(def: (class-decl^ imports)
- (-> Class-Imports (Parser Class-Declaration))
+(def: class-decl^
+ (Parser Class-Declaration)
(p.either (do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)]
(wrap [name (list)]))
(s.form (do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)
- params (p.some (type-param^ imports))]
+ params (p.some ..type-param^)]
(wrap [name params])))
))
-(def: (super-class-decl^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser Super-Class-Decl))
+(def: (super-class-decl^ type-vars)
+ (-> (List Type-Parameter) (Parser Super-Class-Decl))
(p.either (do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)]
(wrap [name (list)]))
(s.form (do p.monad
- [name (full-class-name^ imports)
+ [name s.local-identifier
_ (assert-no-periods name)
- params (p.some (generic-type^ imports type-vars))]
+ params (p.some (..generic-type^ type-vars))]
(wrap [name params])))))
(def: annotation-params^
(Parser (List AnnotationParam))
(s.record (p.some (p.and s.local-tag s.any))))
-(def: (annotation^ imports)
- (-> Class-Imports (Parser Annotation))
+(def: annotation^
+ (Parser Annotation)
(p.either (do p.monad
- [ann-name (full-class-name^ imports)]
+ [ann-name s.local-identifier]
(wrap [ann-name (list)]))
- (s.form (p.and (full-class-name^ imports)
+ (s.form (p.and s.local-identifier
annotation-params^))))
-(def: (annotations^' imports)
- (-> Class-Imports (Parser (List Annotation)))
+(def: annotations^'
+ (Parser (List Annotation))
(do p.monad
[_ (s.this! (' #ann))]
- (s.tuple (p.some (annotation^ imports)))))
+ (s.tuple (p.some ..annotation^))))
-(def: (annotations^ imports)
- (-> Class-Imports (Parser (List Annotation)))
+(def: annotations^
+ (Parser (List Annotation))
(do p.monad
- [anns?? (p.maybe (annotations^' imports))]
+ [anns?? (p.maybe ..annotations^')]
(wrap (maybe.default (list) anns??))))
-(def: (throws-decl'^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser (List GenericType)))
+(def: (throws-decl'^ type-vars)
+ (-> (List Type-Parameter) (Parser (List GenericType)))
(do p.monad
[_ (s.this! (' #throws))]
- (s.tuple (p.some (generic-type^ imports type-vars)))))
+ (s.tuple (p.some (..generic-type^ type-vars)))))
-(def: (throws-decl^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser (List GenericType)))
+(def: (throws-decl^ type-vars)
+ (-> (List Type-Parameter) (Parser (List GenericType)))
(do p.monad
- [exs? (p.maybe (throws-decl'^ imports type-vars))]
+ [exs? (p.maybe (throws-decl'^ type-vars))]
(wrap (maybe.default (list) exs?))))
-(def: (method-decl^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser [Member-Declaration MethodDecl]))
+(def: (method-decl^ type-vars)
+ (-> (List Type-Parameter) (Parser [Member-Declaration MethodDecl]))
(s.form (do p.monad
- [tvars (p.default (list) (type-params^ imports))
+ [tvars ..type-params^
name s.local-identifier
- anns (annotations^ imports)
- inputs (s.tuple (p.some (generic-type^ imports type-vars)))
- output (generic-type^ imports type-vars)
- exs (throws-decl^ imports type-vars)]
+ anns ..annotations^
+ inputs (s.tuple (p.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
@@ -814,73 +673,73 @@
(s.this! (' #final))
(:: p.monad wrap [])))
-(def: (field-decl^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser [Member-Declaration FieldDecl]))
+(def: (field-decl^ type-vars)
+ (-> (List Type-Parameter) (Parser [Member-Declaration FieldDecl]))
(p.either (s.form (do p.monad
[_ (s.this! (' #const))
name s.local-identifier
- anns (annotations^ imports)
- type (generic-type^ imports type-vars)
+ anns ..annotations^
+ type (..generic-type^ type-vars)
body s.any]
(wrap [[name #PublicPM anns] (#ConstantField [type body])])))
(s.form (do p.monad
[pm privacy-modifier^
sm state-modifier^
name s.local-identifier
- anns (annotations^ imports)
- type (generic-type^ imports type-vars)]
+ anns ..annotations^
+ type (..generic-type^ type-vars)]
(wrap [[name pm anns] (#VariableField [sm type])])))))
-(def: (arg-decl^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser ArgDecl))
+(def: (arg-decl^ type-vars)
+ (-> (List Type-Parameter) (Parser ArgDecl))
(s.record (p.and s.local-identifier
- (generic-type^ imports type-vars))))
+ (..generic-type^ type-vars))))
-(def: (arg-decls^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser (List ArgDecl)))
- (p.some (arg-decl^ imports type-vars)))
+(def: (arg-decls^ type-vars)
+ (-> (List Type-Parameter) (Parser (List ArgDecl)))
+ (p.some (arg-decl^ type-vars)))
-(def: (constructor-arg^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser ConstructorArg))
- (s.record (p.and (generic-type^ imports type-vars) s.any)))
+(def: (constructor-arg^ type-vars)
+ (-> (List Type-Parameter) (Parser ConstructorArg))
+ (s.record (p.and (..generic-type^ type-vars) s.any)))
-(def: (constructor-args^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser (List ConstructorArg)))
- (s.tuple (p.some (constructor-arg^ imports type-vars))))
+(def: (constructor-args^ type-vars)
+ (-> (List Type-Parameter) (Parser (List ConstructorArg)))
+ (s.tuple (p.some (constructor-arg^ type-vars))))
-(def: (constructor-method^ imports class-vars)
- (-> Class-Imports (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
+(def: (constructor-method^ class-vars)
+ (-> (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
(s.form (do p.monad
[pm privacy-modifier^
strict-fp? (p.parses? (s.this! (' #strict)))
- method-vars (p.default (list) (type-params^ imports))
+ method-vars ..type-params^
#let [total-vars (list@compose class-vars method-vars)]
[_ arg-decls] (s.form (p.and (s.this! (' new))
- (arg-decls^ imports total-vars)))
- constructor-args (constructor-args^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arg-decls^ total-vars)))
+ constructor-args (..constructor-args^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^
body s.any]
(wrap [{#member-name constructor-method-name
#member-privacy pm
#member-anns annotations}
(#ConstructorMethod strict-fp? method-vars arg-decls constructor-args body exs)]))))
-(def: (virtual-method-def^ imports class-vars)
- (-> Class-Imports (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
+(def: (virtual-method-def^ class-vars)
+ (-> (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
(s.form (do p.monad
[pm privacy-modifier^
strict-fp? (p.parses? (s.this! (' #strict)))
final? (p.parses? (s.this! (' #final)))
- method-vars (p.default (list) (type-params^ imports))
+ method-vars ..type-params^
#let [total-vars (list@compose class-vars method-vars)]
[name this-name arg-decls] (s.form ($_ p.and
s.local-identifier
s.local-identifier
- (arg-decls^ imports total-vars)))
- return-type (generic-type^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arg-decls^ total-vars)))
+ return-type (..generic-type^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^
body s.any]
(wrap [{#member-name name
#member-privacy pm
@@ -890,20 +749,20 @@
this-name arg-decls return-type
body exs)]))))
-(def: (overriden-method-def^ imports)
- (-> Class-Imports (Parser [Member-Declaration Method-Definition]))
+(def: overriden-method-def^
+ (Parser [Member-Declaration Method-Definition])
(s.form (do p.monad
[strict-fp? (p.parses? (s.this! (' #strict)))
- owner-class (class-decl^ imports)
- method-vars (p.default (list) (type-params^ imports))
+ owner-class ..class-decl^
+ method-vars ..type-params^
#let [total-vars (list@compose (product.right owner-class) method-vars)]
[name this-name arg-decls] (s.form ($_ p.and
s.local-identifier
s.local-identifier
- (arg-decls^ imports total-vars)))
- return-type (generic-type^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arg-decls^ total-vars)))
+ return-type (..generic-type^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^
body s.any]
(wrap [{#member-name name
#member-privacy #PublicPM
@@ -913,68 +772,68 @@
this-name arg-decls return-type
body exs)]))))
-(def: (static-method-def^ imports)
- (-> Class-Imports (Parser [Member-Declaration Method-Definition]))
+(def: static-method-def^
+ (Parser [Member-Declaration Method-Definition])
(s.form (do p.monad
[pm privacy-modifier^
strict-fp? (p.parses? (s.this! (' #strict)))
_ (s.this! (' #static))
- method-vars (p.default (list) (type-params^ imports))
+ method-vars ..type-params^
#let [total-vars method-vars]
[name arg-decls] (s.form (p.and s.local-identifier
- (arg-decls^ imports total-vars)))
- return-type (generic-type^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)
+ (..arg-decls^ total-vars)))
+ return-type (..generic-type^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^
body s.any]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#StaticMethod strict-fp? method-vars arg-decls return-type body exs)]))))
-(def: (abstract-method-def^ imports)
- (-> Class-Imports (Parser [Member-Declaration Method-Definition]))
+(def: abstract-method-def^
+ (Parser [Member-Declaration Method-Definition])
(s.form (do p.monad
[pm privacy-modifier^
_ (s.this! (' #abstract))
- method-vars (p.default (list) (type-params^ imports))
+ method-vars ..type-params^
#let [total-vars method-vars]
[name arg-decls] (s.form (p.and s.local-identifier
- (arg-decls^ imports total-vars)))
- return-type (generic-type^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)]
+ (..arg-decls^ total-vars)))
+ return-type (..generic-type^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#AbstractMethod method-vars arg-decls return-type exs)]))))
-(def: (native-method-def^ imports)
- (-> Class-Imports (Parser [Member-Declaration Method-Definition]))
+(def: native-method-def^
+ (Parser [Member-Declaration Method-Definition])
(s.form (do p.monad
[pm privacy-modifier^
_ (s.this! (' #native))
- method-vars (p.default (list) (type-params^ imports))
+ method-vars ..type-params^
#let [total-vars method-vars]
[name arg-decls] (s.form (p.and s.local-identifier
- (arg-decls^ imports total-vars)))
- return-type (generic-type^ imports total-vars)
- exs (throws-decl^ imports total-vars)
- annotations (annotations^ imports)]
+ (..arg-decls^ total-vars)))
+ return-type (..generic-type^ total-vars)
+ exs (..throws-decl^ total-vars)
+ annotations ..annotations^]
(wrap [{#member-name name
#member-privacy pm
#member-anns annotations}
(#NativeMethod method-vars arg-decls return-type exs)]))))
-(def: (method-def^ imports class-vars)
- (-> Class-Imports (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
+(def: (method-def^ class-vars)
+ (-> (List Type-Parameter) (Parser [Member-Declaration Method-Definition]))
($_ p.either
- (constructor-method^ imports class-vars)
- (virtual-method-def^ imports class-vars)
- (overriden-method-def^ imports)
- (static-method-def^ imports)
- (abstract-method-def^ imports)
- (native-method-def^ imports)))
+ (..constructor-method^ class-vars)
+ (..virtual-method-def^ class-vars)
+ ..overriden-method-def^
+ ..static-method-def^
+ ..abstract-method-def^
+ ..native-method-def^))
(def: partial-call^
(Parser Partial-Call)
@@ -996,9 +855,9 @@
[_ (s.this! (' #as))]
s.local-identifier)))
-(def: (import-member-args^ imports type-vars)
- (-> Class-Imports (List Type-Parameter) (Parser (List [Bit GenericType])))
- (s.tuple (p.some (p.and (p.parses? (s.this! (' #?))) (generic-type^ imports type-vars)))))
+(def: (import-member-args^ type-vars)
+ (-> (List Type-Parameter) (Parser (List [Bit GenericType])))
+ (s.tuple (p.some (p.and (p.parses? (s.this! (' #?))) (..generic-type^ type-vars)))))
(def: import-member-return-flags^
(Parser [Bit Bit Bit])
@@ -1009,20 +868,20 @@
(p.or (s.this! (' #manual))
(s.this! (' #auto))))
-(def: (import-member-decl^ imports owner-vars)
- (-> Class-Imports (List Type-Parameter) (Parser Import-Member-Declaration))
+(def: (import-member-decl^ owner-vars)
+ (-> (List Type-Parameter) (Parser Import-Member-Declaration))
($_ p.either
(s.form (do p.monad
[_ (s.this! (' #enum))
enum-members (p.some s.local-identifier)]
(wrap (#EnumDecl enum-members))))
(s.form (do p.monad
- [tvars (p.default (list) (type-params^ imports))
+ [tvars ..type-params^
_ (s.this! (' new))
?alias import-member-alias^
#let [total-vars (list@compose owner-vars tvars)]
?prim-mode (p.maybe primitive-mode^)
- args (import-member-args^ imports total-vars)
+ args (..import-member-args^ total-vars)
[io? try? maybe?] import-member-return-flags^]
(wrap (#ConstructorDecl [{#import-member-mode (maybe.default #AutoPrM ?prim-mode)
#import-member-alias (maybe.default "new" ?alias)
@@ -1038,14 +897,14 @@
[kind (: (Parser ImportMethodKind)
(p.or (s.this! (' #static))
(wrap [])))
- tvars (p.default (list) (type-params^ imports))
+ tvars ..type-params^
name s.local-identifier
?alias import-member-alias^
#let [total-vars (list@compose owner-vars tvars)]
?prim-mode (p.maybe primitive-mode^)
- args (import-member-args^ imports total-vars)
+ args (..import-member-args^ total-vars)
[io? try? maybe?] import-member-return-flags^
- return (generic-type^ imports total-vars)]
+ return (..generic-type^ total-vars)]
(wrap (#MethodDecl [{#import-member-mode (maybe.default #AutoPrM ?prim-mode)
#import-member-alias (maybe.default name ?alias)
#import-member-kind kind
@@ -1061,7 +920,7 @@
[static? (p.parses? (s.this! (' #static)))
name s.local-identifier
?prim-mode (p.maybe primitive-mode^)
- gtype (generic-type^ imports owner-vars)
+ gtype (..generic-type^ owner-vars)
maybe? (p.parses? (s.this! (' #?)))
setter? (p.parses? (s.this! (' #!)))]
(wrap (#FieldAccessDecl {#import-field-mode (maybe.default #AutoPrM ?prim-mode)
@@ -1300,20 +1159,17 @@
#super-class-params (list)})
(syntax: #export (class:
- {#let [imports (class-imports *compiler*)]}
{im inheritance-modifier^}
- {class-decl (class-decl^ imports)}
- {#let [full-class-name (product.left class-decl)
- imports (add-import [(short-class-name full-class-name) full-class-name]
- (class-imports *compiler*))]}
+ {class-decl ..class-decl^}
+ {#let [full-class-name (product.left class-decl)]}
{#let [class-vars (product.right class-decl)]}
{super (p.default object-super-class
- (super-class-decl^ imports class-vars))}
+ (..super-class-decl^ class-vars))}
{interfaces (p.default (list)
- (s.tuple (p.some (super-class-decl^ imports class-vars))))}
- {annotations (annotations^ imports)}
- {fields (p.some (field-decl^ imports class-vars))}
- {methods (p.some (method-def^ imports class-vars))})
+ (s.tuple (p.some (..super-class-decl^ class-vars))))}
+ {annotations ..annotations^}
+ {fields (p.some (..field-decl^ class-vars))}
+ {methods (p.some (..method-def^ class-vars))})
{#.doc (doc "Allows defining JVM classes in Lux code."
"For example:"
(class: #final (TestClass A) [Runnable]
@@ -1363,16 +1219,12 @@
(wrap (list (` ((~ (code.text def-code))))))))
(syntax: #export (interface:
- {#let [imports (class-imports *compiler*)]}
- {class-decl (class-decl^ imports)}
- {#let [full-class-name (product.left class-decl)
- imports (add-import [(short-class-name full-class-name) full-class-name]
- (class-imports *compiler*))]}
+ {class-decl ..class-decl^}
{#let [class-vars (product.right class-decl)]}
{supers (p.default (list)
- (s.tuple (p.some (super-class-decl^ imports class-vars))))}
- {annotations (annotations^ imports)}
- {members (p.some (method-decl^ imports class-vars))})
+ (s.tuple (p.some (..super-class-decl^ class-vars))))}
+ {annotations ..annotations^}
+ {members (p.some (..method-decl^ class-vars))})
{#.doc (doc "Allows defining JVM interfaces."
(interface: TestInterface
([] foo [boolean String] void #throws [Exception])))}
@@ -1385,14 +1237,13 @@
))
(syntax: #export (object
- {#let [imports (class-imports *compiler*)]}
- {class-vars (s.tuple (p.some (type-param^ imports)))}
+ {class-vars (s.tuple (p.some ..type-param^))}
{super (p.default object-super-class
- (super-class-decl^ imports class-vars))}
+ (..super-class-decl^ class-vars))}
{interfaces (p.default (list)
- (s.tuple (p.some (super-class-decl^ imports class-vars))))}
- {constructor-args (constructor-args^ imports class-vars)}
- {methods (p.some (overriden-method-def^ imports))})
+ (s.tuple (p.some (..super-class-decl^ class-vars))))}
+ {constructor-args (..constructor-args^ class-vars)}
+ {methods (p.some ..overriden-method-def^)})
{#.doc (doc "Allows defining anonymous classes."
"The 1st tuple corresponds to class-level type-variables."
"The 2nd tuple corresponds to parent interfaces."
@@ -1461,8 +1312,7 @@
(recover-from-failure error)))}
(wrap (list (` ("lux try" ((~! io.io) (~ expression)))))))
-(syntax: #export (check {#let [imports (class-imports *compiler*)]}
- {class (generic-type^ imports (list))}
+(syntax: #export (check {class (..generic-type^ (list))}
{unchecked (p.maybe s.any)})
{#.doc (doc "Checks whether an object is an instance of a particular class."
"Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes."
@@ -1507,13 +1357,10 @@
(exec (~+ (list@map (complete-call$ g!obj) methods))
(~ g!obj))))))))
-(def: (class-import$ long-name? [full-name params])
- (-> Bit Class-Declaration Code)
- (let [def-name (if long-name?
- full-name
- (short-class-name full-name))
- params' (list@map (|>> product.left code.local-identifier) params)]
- (` (def: (~ (code.identifier ["" def-name]))
+(def: (class-import$ [full-name params])
+ (-> Class-Declaration Code)
+ (let [params' (list@map (|>> product.left code.local-identifier) params)]
+ (` (def: (~ (code.identifier ["" full-name]))
{#..jvm-class (~ (code.text full-name))}
Type
(All [(~+ params')]
@@ -1768,12 +1615,9 @@
(wrap (list& getter-interop setter-interop)))
)))
-(def: (member-import$ type-params long-name? kind class member)
- (-> (List Type-Parameter) Bit Class-Kind Class-Declaration Import-Member-Declaration (Meta (List Code)))
- (let [[full-name _] class
- method-prefix (if long-name?
- full-name
- (short-class-name full-name))]
+(def: (member-import$ type-params kind class member)
+ (-> (List Type-Parameter) Class-Kind Class-Declaration Import-Member-Declaration (Meta (List Code)))
+ (let [[method-prefix _] class]
(do meta.monad
[=args (member-def-arg-bindings type-params class member)]
(member-def-interop type-params kind class =args member method-prefix))))
@@ -1799,19 +1643,13 @@
(meta.fail (format "Unknown class: " class-name)))))
(syntax: #export (import:
- {#let [imports (class-imports *compiler*)]}
- {long-name? (p.parses? (s.this! (' #long)))}
- {class-decl (class-decl^ imports)}
- {#let [full-class-name (product.left class-decl)
- imports (add-import [(short-class-name full-class-name) full-class-name]
- (class-imports *compiler*))]}
- {members (p.some (import-member-decl^ imports (product.right class-decl)))})
+ {class-decl ..class-decl^}
+ {members (p.some (..import-member-decl^ (product.right class-decl)))})
{#.doc (doc "Allows importing JVM classes, and using them as types."
"Their methods, fields and enum options can also be imported."
- "Also, classes which get imported into a module can also be referred-to with their short names in other macros that require JVM classes."
(import: java/lang/Object
(new [])
- (equals [Object] boolean)
+ (equals [java/lang/Object] boolean)
(wait [int] #io #try void))
"Special options can also be given for the return values."
@@ -1821,44 +1659,43 @@
"These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
(import: java/lang/String
(new [[byte]])
- (#static valueOf [char] String)
- (#static valueOf #as int-valueOf [int] String))
+ (#static valueOf [char] java/lang/String)
+ (#static valueOf #as int-valueOf [int] java/lang/String))
- (import: #long (java/util/List e)
+ (import: (java/util/List e)
(size [] int)
(get [int] e))
(import: (java/util/ArrayList a)
([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."
+ "The class-type that is generated is of the fully-qualified name."
+ "This avoids a clash between the java.util.List type, and Lux's own List type."
"All enum options to be imported must be specified."
(import: java/lang/Character$UnicodeScript
(#enum ARABIC CYRILLIC LATIN))
"It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-parameters."
"Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
- (import: #long (lux/concurrency/promise/JvmPromise A)
+ (import: (lux/concurrency/promise/JvmPromise A)
(resolve [A] boolean)
(poll [] A)
(wasResolved [] boolean)
(waitOn [lux/Function] void)
- (#static [A] make [A] (JvmPromise A)))
+ (#static [A] make [A] (lux/concurrency/promise/JvmPromise A)))
"Also, the names of the imported members will look like Class::member"
- (Object::new [])
- (Object::equals [other-object] my-object)
+ (java/lang/Object::new [])
+ (java/lang/Object::equals [other-object] my-object)
(java/util/List::size [] my-list)
- Character$UnicodeScript::LATIN
+ java/lang/Character$UnicodeScript::LATIN
)}
(do {@ meta.monad}
[kind (class-kind class-decl)
- =members (monad.map @ (member-import$ (product.right class-decl) long-name? kind class-decl) members)]
- (wrap (list& (class-import$ long-name? class-decl) (list@join =members)))))
+ =members (monad.map @ (member-import$ (product.right class-decl) kind class-decl) members)]
+ (wrap (list& (class-import$ class-decl) (list@join =members)))))
-(syntax: #export (array {#let [imports (class-imports *compiler*)]}
- {type (generic-type^ imports (list))}
+(syntax: #export (array {type (..generic-type^ (list))}
size)
{#.doc (doc "Create an array of the given type, with the given size."
(array Object 10))}
@@ -1963,27 +1800,10 @@
(wrap (list (` (let [(~ g!array) (~ array)]
(..array-write (~ idx) (~ value) (~ g!array)))))))))
-(syntax: #export (class-for {#let [imports (class-imports *compiler*)]}
- {type (generic-type^ imports (list))})
+(syntax: #export (class-for {type (..generic-type^ (list))})
{#.doc (doc "Loads the class as a java.lang.Class object."
(class-for java/lang/String))}
(wrap (list (` ("jvm object class" (~ (code.text (simple-class$ (list) type))))))))
-(def: get-compiler
- (Meta Lux)
- (function (_ compiler)
- (#.Right [compiler compiler])))
-
-(def: #export (resolve class)
- {#.doc (doc "Given a potentially unqualified class name, qualifies it if necessary."
- (resolve "String")
- =>
- "java.lang.String")}
- (-> Text (Meta Text))
- (do meta.monad
- [*compiler* get-compiler]
- (wrap (qualify (class-imports *compiler*) class))))
-
-(syntax: #export (type {#let [imports (class-imports *compiler*)]}
- {type (generic-type^ imports (list))})
+(syntax: #export (type {type (..generic-type^ (list))})
(wrap (list (class->type #ManualPrM (list) type))))
diff --git a/stdlib/source/lux/target/jvm/bytecode.lux b/stdlib/source/lux/target/jvm/bytecode.lux
index a22b416e4..a0856e34c 100644
--- a/stdlib/source/lux/target/jvm/bytecode.lux
+++ b/stdlib/source/lux/target/jvm/bytecode.lux
@@ -456,10 +456,10 @@
(#try.Failure _)
(..bytecode $0 $1 @_ _.ldc-w/string [index]))))
-(import: #long java/lang/Float
+(import: java/lang/Float
(#static floatToRawIntBits #manual [float] int))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static doubleToRawLongBits #manual [double] int))
(template [<name> <type> <constructor> <constant> <wide> <to-lux> <specializations>]
diff --git a/stdlib/source/lux/target/jvm/constant.lux b/stdlib/source/lux/target/jvm/constant.lux
index 68641bcd9..b114ba945 100644
--- a/stdlib/source/lux/target/jvm/constant.lux
+++ b/stdlib/source/lux/target/jvm/constant.lux
@@ -58,7 +58,7 @@
(|>> :representation //index.writer))
)
-(import: #long java/lang/Float
+(import: java/lang/Float
(#static floatToRawIntBits #manual [float] int))
(structure: #export float-equivalence
@@ -73,7 +73,7 @@
("jvm object cast" parameter)
("jvm object cast" subject))})))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static doubleToRawLongBits [double] long))
(abstract: #export (Value kind)
diff --git a/stdlib/source/lux/target/jvm/loader.lux b/stdlib/source/lux/target/jvm/loader.lux
index 33a16f782..e17496ffb 100644
--- a/stdlib/source/lux/target/jvm/loader.lux
+++ b/stdlib/source/lux/target/jvm/loader.lux
@@ -35,24 +35,24 @@
["Class" class]
["Error" error]))
-(import: #long java/lang/Object
+(import: java/lang/Object
(getClass [] (java/lang/Class java/lang/Object)))
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/lang/reflect/Method
+(import: java/lang/reflect/Method
(invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object))
-(import: #long (java/lang/Class a)
+(import: (java/lang/Class a)
(getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method))
-(import: #long java/lang/Integer
+(import: java/lang/Integer
(#static TYPE (java/lang/Class java/lang/Integer)))
-(import: #long java/lang/reflect/AccessibleObject
+(import: java/lang/reflect/AccessibleObject
(setAccessible [boolean] void))
-(import: #long java/lang/ClassLoader
+(import: java/lang/ClassLoader
(loadClass [java/lang/String]
#io #try (java/lang/Class java/lang/Object)))
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index 086de8175..688bf3e02 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -28,42 +28,42 @@
["#." reflection]
["#." parser]]])
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/lang/Object
+(import: java/lang/Object
(toString [] java/lang/String)
(getClass [] (java/lang/Class java/lang/Object)))
-(import: #long java/lang/reflect/Type
+(import: java/lang/reflect/Type
(getTypeName [] java/lang/String))
-(import: #long java/lang/reflect/GenericArrayType
+(import: java/lang/reflect/GenericArrayType
(getGenericComponentType [] java/lang/reflect/Type))
-(import: #long java/lang/reflect/ParameterizedType
+(import: java/lang/reflect/ParameterizedType
(getRawType [] java/lang/reflect/Type)
(getActualTypeArguments [] [java/lang/reflect/Type]))
-(import: #long (java/lang/reflect/TypeVariable d)
+(import: (java/lang/reflect/TypeVariable d)
(getName [] java/lang/String)
(getBounds [] [java/lang/reflect/Type]))
-(import: #long (java/lang/reflect/WildcardType d)
+(import: (java/lang/reflect/WildcardType d)
(getLowerBounds [] [java/lang/reflect/Type])
(getUpperBounds [] [java/lang/reflect/Type]))
-(import: #long java/lang/reflect/Modifier
+(import: java/lang/reflect/Modifier
(#static isStatic [int] boolean)
(#static isFinal [int] boolean)
(#static isInterface [int] boolean)
(#static isAbstract [int] boolean))
-(import: #long java/lang/reflect/Field
+(import: java/lang/reflect/Field
(getDeclaringClass [] (java/lang/Class java/lang/Object))
(getModifiers [] int)
(getGenericType [] java/lang/reflect/Type))
-(import: #long java/lang/reflect/Method
+(import: java/lang/reflect/Method
(getName [] java/lang/String)
(getModifiers [] int)
(getDeclaringClass [] (java/lang/Class java/lang/Object))
@@ -72,14 +72,14 @@
(getGenericReturnType [] java/lang/reflect/Type)
(getGenericExceptionTypes [] [java/lang/reflect/Type]))
-(import: #long (java/lang/reflect/Constructor c)
+(import: (java/lang/reflect/Constructor c)
(getModifiers [] int)
(getDeclaringClass [] (java/lang/Class c))
(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)
+(import: (java/lang/Class c)
(#static forName [java/lang/String] #try (java/lang/Class java/lang/Object))
(getName [] java/lang/String)
(getModifiers [] int)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index 7174516a3..3517a261c 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -755,22 +755,22 @@
(wrap (#/////analysis.Extension extension-name (list (/////analysis.text sub-class) objectA)))
(/////analysis.throw cannot-possibly-be-an-instance (format sub-class " !<= " object-class)))))]))
-(import: #long java/lang/Object
+(import: java/lang/Object
(equals [java/lang/Object] boolean))
-(import: #long java/lang/reflect/Type)
+(import: java/lang/reflect/Type)
-(import: #long (java/lang/reflect/TypeVariable d)
+(import: (java/lang/reflect/TypeVariable d)
(getName [] java/lang/String)
(getBounds [] [java/lang/reflect/Type]))
-(import: #long java/lang/reflect/Modifier
+(import: java/lang/reflect/Modifier
(#static isStatic [int] boolean)
(#static isFinal [int] boolean)
(#static isInterface [int] boolean)
(#static isAbstract [int] boolean))
-(import: #long java/lang/reflect/Method
+(import: java/lang/reflect/Method
(getName [] java/lang/String)
(getModifiers [] int)
(getDeclaringClass [] (java/lang/Class java/lang/Object))
@@ -779,14 +779,14 @@
(getGenericReturnType [] java/lang/reflect/Type)
(getGenericExceptionTypes [] [java/lang/reflect/Type]))
-(import: #long (java/lang/reflect/Constructor c)
+(import: (java/lang/reflect/Constructor c)
(getModifiers [] int)
(getDeclaringClass [] (java/lang/Class c))
(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)
+(import: (java/lang/Class c)
(#static forName [java/lang/String] #try (java/lang/Class java/lang/Object))
(getName [] java/lang/String)
(getModifiers [] int)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
index b87e6b901..546477aac 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux
@@ -58,7 +58,7 @@
## [[Numbers]]
(for {@.old
- (as-is (import: #long java/lang/Double
+ (as-is (import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
index f925a2877..313620611 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux
@@ -187,7 +187,7 @@
[i64::logical-right-shift _.lushr]
)
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index e7e4ce933..eb3529f6d 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -57,7 +57,7 @@
(/.install "frac" (unary (_./ (_.float +1.0))))
(/.install "char" (unary (!unary "string.char"))))))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
index 5c6a0cee5..2c43370a6 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
@@ -54,7 +54,7 @@
(/.install "frac" (unary _.float/1))
(/.install "char" (unary _.chr/1)))))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
index b7131e02b..ec5ba8e26 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux
@@ -50,7 +50,7 @@
(/.install "-" (binary (..keep-i64 (product.uncurry _.-))))
)))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common-lisp/extension/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common-lisp/extension/common.lux
index 0d56d70b6..701738854 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common-lisp/extension/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/common-lisp/extension/common.lux
@@ -64,7 +64,7 @@
(bundle.install "char" (unary (|>> _.code-char/1 _.string/1)))
)))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
index 543c14a4b..cdf03d7b0 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
@@ -41,16 +41,16 @@
["#." runtime (#+ Definition)]]
)
-(import: #long java/lang/reflect/Field
+(import: java/lang/reflect/Field
(get [#? java/lang/Object] #try #? java/lang/Object))
-(import: #long (java/lang/Class a)
+(import: (java/lang/Class a)
(getField [java/lang/String] #try java/lang/reflect/Field))
-(import: #long java/lang/Object
+(import: java/lang/Object
(getClass [] (java/lang/Class java/lang/Object)))
-(import: #long java/lang/ClassLoader)
+(import: java/lang/ClassLoader)
(def: value::field "value")
(def: value::type (type.class "java.lang.Object" (list)))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
index 8f281fb3a..b6004b6c6 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux
@@ -72,7 +72,7 @@
(def: wrap-f64
(_.invokestatic $Double "valueOf" (type.method [(list type.double) $Double (list)])))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static doubleToRawLongBits #manual [double] int))
(def: #export (f64 value)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux
index 07f76e258..234192ede 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux
@@ -56,7 +56,7 @@
(bundle.install "frac" (unary _.floatval/1))
(bundle.install "char" (unary _.chr/1)))))
-(import: #long java/lang/Double
+(import: java/lang/Double
(#static MIN_VALUE double)
(#static MAX_VALUE double))
diff --git a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
index 7478a3bc2..f4cf769eb 100644
--- a/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/meta/packager/jvm.lux
@@ -44,43 +44,43 @@
[jvm
["." runtime (#+ Definition)]]]]]]]]])
-(import: #long java/lang/Object)
+(import: java/lang/Object)
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/util/jar/Attributes
+(import: java/util/jar/Attributes
(put [java/lang/Object java/lang/Object] #? java/lang/Object))
-(import: #long java/util/jar/Attributes$Name
+(import: java/util/jar/Attributes$Name
(#static MAIN_CLASS java/util/jar/Attributes$Name)
(#static MANIFEST_VERSION java/util/jar/Attributes$Name))
-(import: #long java/util/jar/Manifest
+(import: java/util/jar/Manifest
(new [])
(getMainAttributes [] java/util/jar/Attributes))
-(import: #long java/io/Flushable
+(import: java/io/Flushable
(flush [] void))
-(import: #long java/io/Closeable
+(import: java/io/Closeable
(close [] void))
-(import: #long java/io/OutputStream)
+(import: java/io/OutputStream)
-(import: #long java/io/ByteArrayOutputStream
+(import: java/io/ByteArrayOutputStream
(new [int])
(toByteArray [] [byte]))
-(import: #long java/util/zip/ZipEntry)
+(import: java/util/zip/ZipEntry)
-(import: #long java/util/zip/ZipOutputStream
+(import: java/util/zip/ZipOutputStream
(write [[byte] int int] void)
(closeEntry [] void))
-(import: #long java/util/jar/JarEntry
+(import: java/util/jar/JarEntry
(new [java/lang/String]))
-(import: #long java/util/jar/JarOutputStream
+(import: java/util/jar/JarOutputStream
(new [java/io/OutputStream java/util/jar/Manifest])
(putNextEntry [java/util/zip/ZipEntry] void))
diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux
index 018cb3c41..a66743b65 100644
--- a/stdlib/source/lux/world/console.lux
+++ b/stdlib/source/lux/world/console.lux
@@ -57,14 +57,14 @@
(with-expansions [<jvm> (as-is (import: java/lang/String)
- (import: #long java/io/Console
- (readLine [] #io #try String))
+ (import: java/io/Console
+ (readLine [] #io #try java/lang/String))
(import: java/io/InputStream
(read [] #io #try int))
(import: java/io/PrintStream
- (print [String] #io #try void))
+ (print [java/lang/String] #io #try void))
(import: java/lang/System
(#static console [] #io #? java/io/Console)
@@ -74,14 +74,14 @@
(def: #export system
(IO (Try (Console IO)))
(do io.monad
- [?jvm-console (System::console)]
+ [?jvm-console (java/lang/System::console)]
(case ?jvm-console
#.None
(wrap (ex.throw cannot-open []))
(#.Some jvm-console)
- (let [jvm-input (System::in)
- jvm-output (System::out)]
+ (let [jvm-input (java/lang/System::in)
+ jvm-output (java/lang/System::out)]
(<| wrap
ex.return
(: (Console IO)) ## TODO: Remove ASAP
@@ -90,7 +90,7 @@
(..can-read
(function (_ _)
(|> jvm-input
- InputStream::read
+ java/io/InputStream::read
(:: (try.with io.monad) map .nat)))))
(def: can-read-line
@@ -101,7 +101,7 @@
(def: can-write
(..can-write
(function (_ message)
- (PrintStream::print message jvm-output))))
+ (java/io/PrintStream::print message jvm-output))))
(def: can-close
(..can-close
diff --git a/stdlib/source/lux/world/db/jdbc.lux b/stdlib/source/lux/world/db/jdbc.lux
index d2a6f3db2..ab0c0f03f 100644
--- a/stdlib/source/lux/world/db/jdbc.lux
+++ b/stdlib/source/lux/world/db/jdbc.lux
@@ -26,28 +26,30 @@
["#." input (#+ Input)]
["#." output (#+ Output)]])
-(import: #long java/sql/ResultSet
+(import: java/lang/String)
+
+(import: java/sql/ResultSet
(getRow [] #try int)
(next [] #try boolean)
(close [] #io #try void))
-(import: #long java/sql/Statement
+(import: java/sql/Statement
(#static NO_GENERATED_KEYS int)
(#static RETURN_GENERATED_KEYS int)
(getGeneratedKeys [] #try java/sql/ResultSet)
(close [] #io #try void))
-(import: #long java/sql/PreparedStatement
+(import: java/sql/PreparedStatement
(executeUpdate [] #io #try int)
(executeQuery [] #io #try java/sql/ResultSet))
-(import: #long java/sql/Connection
- (prepareStatement [String int] #try java/sql/PreparedStatement)
+(import: java/sql/Connection
+ (prepareStatement [java/lang/String int] #try java/sql/PreparedStatement)
(isValid [int] #try boolean)
(close [] #io #try void))
-(import: #long java/sql/DriverManager
- (#static getConnection [String String String] #io #try java/sql/Connection))
+(import: java/sql/DriverManager
+ (#static getConnection [java/lang/String java/lang/String java/lang/String] #io #try java/sql/Connection))
(type: #export Credentials
{#url URL
diff --git a/stdlib/source/lux/world/db/jdbc/input.lux b/stdlib/source/lux/world/db/jdbc/input.lux
index 30634a3df..065327f06 100644
--- a/stdlib/source/lux/world/db/jdbc/input.lux
+++ b/stdlib/source/lux/world/db/jdbc/input.lux
@@ -14,16 +14,16 @@
[binary (#+ Binary)]]
[host (#+ import:)]])
-(import: #long java/lang/String)
+(import: java/lang/String)
(template [<class>]
- [(import: #long <class>
+ [(import: <class>
(new [long]))]
[java/sql/Date] [java/sql/Time] [java/sql/Timestamp]
)
-(`` (import: #long java/sql/PreparedStatement
+(`` (import: java/sql/PreparedStatement
(~~ (template [<name> <type>]
[(<name> [int <type>] #try void)]
diff --git a/stdlib/source/lux/world/db/jdbc/output.lux b/stdlib/source/lux/world/db/jdbc/output.lux
index 5d76b69bc..08a74a4b0 100644
--- a/stdlib/source/lux/world/db/jdbc/output.lux
+++ b/stdlib/source/lux/world/db/jdbc/output.lux
@@ -13,16 +13,16 @@
[binary (#+ Binary)]]
[host (#+ import:)]])
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/util/Date
+(import: java/util/Date
(getTime [] long))
-(import: #long java/sql/Date)
-(import: #long java/sql/Time)
-(import: #long java/sql/Timestamp)
+(import: java/sql/Date)
+(import: java/sql/Time)
+(import: java/sql/Timestamp)
-(`` (import: #long java/sql/ResultSet
+(`` (import: java/sql/ResultSet
(~~ (template [<method-name> <return-class>]
[(<method-name> [int] #try <return-class>)]
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 8720c9ce9..81ab60faa 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -213,9 +213,9 @@
["Instant" (%.instant instant)]
["Path" file]))
- (import: #long java/lang/String)
+ (import: java/lang/String)
- (`` (import: #long java/io/File
+ (`` (import: java/io/File
(new [java/lang/String])
(~~ (template [<name>]
[(<name> [] #io #try boolean)]
@@ -244,20 +244,20 @@
_
(wrap (exception.throw exception [path])))))
- (import: #long java/lang/AutoCloseable
+ (import: java/lang/AutoCloseable
(close [] #io #try void))
- (import: #long java/io/OutputStream
+ (import: java/io/OutputStream
(write [[byte]] #io #try void)
(flush [] #io #try void))
- (import: #long java/io/FileOutputStream
+ (import: java/io/FileOutputStream
(new [java/io/File boolean] #io #try))
- (import: #long java/io/InputStream
+ (import: java/io/InputStream
(read [[byte]] #io #try int))
- (import: #long java/io/FileInputStream
+ (import: java/io/FileInputStream
(new [java/io/File] #io #try))
(`` (structure: (file path)
diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux
index 50121d653..90bdac6b1 100644
--- a/stdlib/source/lux/world/shell.lux
+++ b/stdlib/source/lux/world/shell.lux
@@ -62,7 +62,7 @@
(text.enclose' "'"))))
(`` (for {(~~ (static host.old))
- (as-is (import: #long java/lang/String
+ (as-is (import: java/lang/String
(toLowerCase [] java/lang/String))
(def: (arguments-array arguments)
@@ -73,7 +73,7 @@
[0 (jvm.array java/lang/String (list.size arguments))]
arguments)))
- (import: #long (java/util/Map k v)
+ (import: (java/util/Map k v)
(put [k v] v))
(def: (load-environment input target)
@@ -86,22 +86,22 @@
target
(dictionary.entries input)))
- (import: #long java/io/Reader
+ (import: java/io/Reader
(read [] #io #try int))
- (import: #long java/io/BufferedReader
+ (import: java/io/BufferedReader
(new [java/io/Reader])
(readLine [] #io #try java/lang/String))
- (import: #long java/io/InputStream)
+ (import: java/io/InputStream)
- (import: #long java/io/InputStreamReader
+ (import: java/io/InputStreamReader
(new [java/io/InputStream]))
- (import: #long java/io/OutputStream
+ (import: java/io/OutputStream
(write [[byte]] #io #try void))
- (import: #long java/lang/Process
+ (import: java/lang/Process
(getInputStream [] #io #try java/io/InputStream)
(getOutputStream [] #io #try java/io/OutputStream)
(destroy [] #io #try void))
@@ -141,12 +141,12 @@
(|> process
java/lang/Process::destroy)))))))))
- (import: #long java/lang/ProcessBuilder
+ (import: java/lang/ProcessBuilder
(new [[java/lang/String]])
(environment [] #io #try (java/util/Map java/lang/String java/lang/String))
(start [] #io #try java/lang/Process))
- (import: #long java/lang/System
+ (import: java/lang/System
(#static getProperty [java/lang/String] #io #try java/lang/String))
)}))
diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux
index cbb76edbb..738cae467 100644
--- a/stdlib/source/program/aedifex/command/auto.lux
+++ b/stdlib/source/program/aedifex/command/auto.lux
@@ -21,37 +21,37 @@
["#." action (#+ Action)]
["#." command (#+ Command)]]])
-(import: #long java/nio/file/WatchKey
+(import: java/nio/file/WatchKey
(reset [] #io boolean))
-(import: #long java/util/concurrent/TimeUnit
+(import: java/util/concurrent/TimeUnit
(#enum SECONDS))
-(import: #long java/nio/file/WatchService
+(import: java/nio/file/WatchService
(poll [long java/util/concurrent/TimeUnit] #io #try #? java/nio/file/WatchKey)
(poll #as fetch [] #io #try #? java/nio/file/WatchKey))
-(import: #long java/nio/file/FileSystem
+(import: java/nio/file/FileSystem
(newWatchService [] #io #try java/nio/file/WatchService))
-(import: #long java/nio/file/FileSystems
+(import: java/nio/file/FileSystems
(#static getDefault [] java/nio/file/FileSystem))
-(import: #long java/lang/Object)
+(import: java/lang/Object)
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long (java/nio/file/WatchEvent$Kind a))
+(import: (java/nio/file/WatchEvent$Kind a))
-(import: #long java/nio/file/StandardWatchEventKinds
+(import: java/nio/file/StandardWatchEventKinds
(#static ENTRY_CREATE (java/nio/file/WatchEvent$Kind java/nio/file/Path))
(#static ENTRY_MODIFY (java/nio/file/WatchEvent$Kind java/nio/file/Path))
(#static ENTRY_DELETE (java/nio/file/WatchEvent$Kind java/nio/file/Path)))
-(import: #long java/nio/file/Path
+(import: java/nio/file/Path
(register [java/nio/file/WatchService [(java/nio/file/WatchEvent$Kind ?)]] #io #try java/nio/file/WatchKey))
-(import: #long java/io/File
+(import: java/io/File
(new [java/lang/String])
(exists [] #io #try boolean)
(isDirectory [] #io #try boolean)
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index f505f1d0a..eb7842e45 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -89,10 +89,10 @@
(list.filter (|>> (get@ #///dependency.type) (text@= ///dependency.lux-library)))
(list@map (|>> (get@ #///dependency.artifact) (///local.path file.system)))))
-(import: #long java/lang/String)
+(import: java/lang/String)
## https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
-(import: #long java/lang/System
+(import: java/lang/System
(#static getProperty [java/lang/String] #io #? java/lang/String))
(def: #export working-directory
diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux
index 18b6719ed..2086a4d06 100644
--- a/stdlib/source/program/aedifex/dependency.lux
+++ b/stdlib/source/program/aedifex/dependency.lux
@@ -68,18 +68,18 @@
["pom" pom]
)
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/lang/AutoCloseable
+(import: java/lang/AutoCloseable
(close [] #io #try void))
-(import: #long java/io/InputStream)
+(import: java/io/InputStream)
-(import: #long java/net/URL
+(import: java/net/URL
(new [java/lang/String])
(openStream [] #io #try java/io/InputStream))
-(import: #long java/io/BufferedInputStream
+(import: java/io/BufferedInputStream
(new [java/io/InputStream])
(read [[byte] int int] #io #try int))
diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux
index 63511a74d..86fe4319d 100644
--- a/stdlib/source/program/aedifex/hash.lux
+++ b/stdlib/source/program/aedifex/hash.lux
@@ -11,9 +11,9 @@
## TODO: Replace with pure-Lux implementations of these algorithms
## https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode
## https://en.wikipedia.org/wiki/MD5#Algorithm
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/security/MessageDigest
+(import: java/security/MessageDigest
(#static getInstance [java/lang/String] java/security/MessageDigest)
(digest [[byte]] [byte]))
diff --git a/stdlib/source/program/aedifex/shell.lux b/stdlib/source/program/aedifex/shell.lux
index 373f9b739..72150a016 100644
--- a/stdlib/source/program/aedifex/shell.lux
+++ b/stdlib/source/program/aedifex/shell.lux
@@ -19,28 +19,28 @@
["." // #_
["#." action (#+ Action)]])
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/io/InputStream)
+(import: java/io/InputStream)
-(import: #long java/io/Reader)
+(import: java/io/Reader)
-(import: #long java/io/InputStreamReader
+(import: java/io/InputStreamReader
(new [java/io/InputStream]))
-(import: #long java/io/BufferedReader
+(import: java/io/BufferedReader
(new [java/io/Reader])
(readLine [] #io #try java/lang/String))
-(import: #long java/lang/Process
+(import: java/lang/Process
(getInputStream [] java/io/InputStream)
(getErrorStream [] java/io/InputStream)
(waitFor [] #io #try int))
-(import: #long java/io/File
+(import: java/io/File
(new [java/lang/String]))
-(import: #long java/lang/Runtime
+(import: java/lang/Runtime
(#static getRuntime [] #io java/lang/Runtime)
(exec [java/lang/String #? [java/lang/String] java/io/File] #io #try java/lang/Process))
diff --git a/stdlib/source/program/aedifex/upload.lux b/stdlib/source/program/aedifex/upload.lux
index 8b849ed10..c4572de9d 100644
--- a/stdlib/source/program/aedifex/upload.lux
+++ b/stdlib/source/program/aedifex/upload.lux
@@ -42,32 +42,32 @@
"."
(get@ #//dependency.type dependency)))
-(import: #long java/lang/AutoCloseable
+(import: java/lang/AutoCloseable
(close [] #io #try void))
-(import: #long java/io/OutputStream
+(import: java/io/OutputStream
(flush [] #io #try void)
(write [[byte]] #io #try void))
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/net/URLConnection
+(import: java/net/URLConnection
(setDoOutput [boolean] #io #try void)
(setRequestProperty [java/lang/String java/lang/String] #io #try void)
(getOutputStream [] #io #try java/io/OutputStream))
-(import: #long java/net/HttpURLConnection
+(import: java/net/HttpURLConnection
(setRequestMethod [java/lang/String] #io #try void)
(getResponseCode [] #io #try int))
-(import: #long java/net/URL
+(import: java/net/URL
(new [java/lang/String])
(openConnection [] #io #try java/net/URLConnection))
-(import: #long java/util/Base64$Encoder
+(import: java/util/Base64$Encoder
(encodeToString [[byte]] java/lang/String))
-(import: #long java/util/Base64
+(import: java/util/Base64
(#static getEncoder [] java/util/Base64$Encoder))
(exception: #export (failure {code Int})
diff --git a/stdlib/source/program/licentia.lux b/stdlib/source/program/licentia.lux
index b3765916f..7eab5b444 100644
--- a/stdlib/source/program/licentia.lux
+++ b/stdlib/source/program/licentia.lux
@@ -41,8 +41,8 @@
(to-do <expiry> "Replace _.work with _.covered-work or _.licensed-work")
(to-do <expiry> "Create a short notice to add as a comment to each file in the _.work"))
-(import: #long java/lang/String
- (trim [] String))
+(import: java/lang/String
+ (trim [] java/lang/String))
(def: default-output-file "LICENSE")
diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux
index e16702d3e..fe5de3520 100644
--- a/stdlib/source/spec/compositor/generation/structure.lux
+++ b/stdlib/source/spec/compositor/generation/structure.lux
@@ -26,7 +26,7 @@
[///
[common (#+ Runner)]])
-(import: #long java/lang/Integer)
+(import: java/lang/Integer)
(def: (variant run)
(-> Runner Test)
diff --git a/stdlib/source/test/aedifex.lux b/stdlib/source/test/aedifex.lux
index 8699ad8b9..de52e6a9e 100644
--- a/stdlib/source/test/aedifex.lux
+++ b/stdlib/source/test/aedifex.lux
@@ -6,6 +6,7 @@
[parser
[cli (#+ program:)]]]]
["." / #_
+ ["#." artifact]
["#." profile]
["#." cli]
["#." parser]])
@@ -13,6 +14,7 @@
(def: test
Test
($_ _.and
+ /artifact.test
/profile.test
/cli.test
/parser.test
diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux
new file mode 100644
index 000000000..1ba27d0b6
--- /dev/null
+++ b/stdlib/source/test/aedifex/artifact.lux
@@ -0,0 +1,30 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ [hash (#+ Hash)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
+ [math
+ ["." random (#+ Random)]]]
+ {#program
+ ["." /]})
+
+(def: #export random
+ (Random /.Artifact)
+ ($_ random.and
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)
+ (random.ascii/alpha 1)))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [/.Group /.Name /.Version
+ /.Artifact]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ ))))
diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux
index 3f1e08cc7..94f695a9b 100644
--- a/stdlib/source/test/aedifex/profile.lux
+++ b/stdlib/source/test/aedifex/profile.lux
@@ -22,10 +22,11 @@
["." dictionary (#+ Dictionary)]]]
[math
["." random (#+ Random) ("#@." monad)]]]
+ [//
+ ["@." artifact]]
{#program
["." /
["/#" // #_
- ["#." artifact (#+ Artifact)]
["#." dependency (#+ Repository Dependency)]
["#." format]]]})
@@ -100,13 +101,6 @@
(Random /.Name)
(random.ascii/alpha 1))
-(def: artifact
- (Random Artifact)
- ($_ random.and
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)
- (random.ascii/alpha 1)))
-
(def: repository
(Random Repository)
(random.ascii/alpha 1))
@@ -114,7 +108,7 @@
(def: dependency
(Random Dependency)
($_ random.and
- ..artifact
+ @artifact.random
(random.ascii/alpha 1)))
(def: source
@@ -129,7 +123,7 @@
(Random /.Profile)
($_ random.and
(..list-of ..name)
- (random.maybe ..artifact)
+ (random.maybe @artifact.random)
(random.maybe ..info)
(..set-of text.hash ..repository)
(..set-of //dependency.hash ..dependency)
diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux
index dbda12366..e3311f505 100644
--- a/stdlib/source/test/lux/control/parser/json.lux
+++ b/stdlib/source/test/lux/control/parser/json.lux
@@ -35,6 +35,10 @@
_
false))
+(def: safe-frac
+ (Random Frac)
+ (random.filter (|>> frac.not-a-number? not) random.frac))
+
(def: #export test
Test
(<| (_.covering /._)
@@ -70,7 +74,7 @@
(!expect (#try.Failure _)))))))]
[/.boolean /.boolean? /.boolean! random.bit #json.Boolean bit.equivalence]
- [/.number /.number? /.number! random.frac #json.Number frac.equivalence]
+ [/.number /.number? /.number! ..safe-frac #json.Number frac.equivalence]
[/.string /.string? /.string! (random.unicode 1) #json.String text.equivalence]
))
(do {@ random.monad}
@@ -118,7 +122,7 @@
(exception.match? /.empty-input error)))))
(do {@ random.monad}
[expected-boolean random.bit
- expected-number random.frac
+ expected-number ..safe-frac
expected-string (random.unicode 1)
[boolean-field number-field string-field] (|> (random.set text.hash 3 (random.unicode 3))
(:: @ map (|>> set.to-list
diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux
index 7c962804b..20e62ef86 100644
--- a/stdlib/source/test/lux/data/product.lux
+++ b/stdlib/source/test/lux/data/product.lux
@@ -1,23 +1,61 @@
(.module:
[lux #*
["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
[data
- ["%" text/format (#+ format)]
[number
- ["i" int]]]]
+ ["n" nat]
+ ["i" int]]]
+ [math
+ ["." random]]]
{1
["." /]})
(def: #export test
Test
- (<| (_.context (%.name (name-of .&)))
- ($_ _.and
- (_.test "Can access the sides of a pair."
- (and (i.= +1 (/.left [+1 +2]))
- (i.= +2 (/.right [+1 +2]))))
-
- (_.test "Can swap the sides of a pair."
- (let [[_left _right] (/.swap [+1 +2])]
- (and (i.= +2 _left)
- (i.= +1 _right))))
- )))
+ (<| (_.covering /._)
+ (do random.monad
+ [expected random.nat
+ shift random.nat
+ dummy (random.filter (|>> (n.= expected) not)
+ random.nat)]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec (/.equivalence n.equivalence i.equivalence)
+ (random.and random.nat random.int)))
+
+ (<| (_.cover [/.left])
+ (n.= expected (/.left [expected dummy])))
+ (<| (_.cover [/.right])
+ (n.= expected (/.right [dummy expected])))
+ (<| (_.cover [/.fork])
+ (let [[left right] ((/.fork (n.+ shift) (n.- shift)) expected)]
+ (and (n.= (n.+ shift expected)
+ left)
+ (n.= (n.- shift expected)
+ right))))
+ (do random.monad
+ [left random.nat
+ right random.nat]
+ ($_ _.and
+ (<| (_.cover [/.swap])
+ (let [pair [left right]]
+ (and (n.= (/.left pair)
+ (/.right (/.swap pair)))
+ (n.= (/.right pair)
+ (/.left (/.swap pair))))))
+ (<| (_.cover [/.uncurry])
+ (n.= (n.+ left right)
+ ((/.uncurry n.+) [left right])))
+ (<| (_.cover [/.curry])
+ (n.= (n.+ left right)
+ ((/.curry (/.uncurry n.+)) left right)))
+ (<| (_.cover [/.both])
+ (let [[left' right'] (/.both (n.+ shift) (n.- shift) [left right])]
+ (and (n.= (n.+ shift left) left')
+ (n.= (n.- shift right) right'))))))
+ ))))
diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux
index 65011a929..d5b44b481 100644
--- a/stdlib/source/test/lux/host.jvm.lux
+++ b/stdlib/source/test/lux/host.jvm.lux
@@ -14,23 +14,23 @@
{1
["." / (#+ import: class: interface: object)]})
-(import: #long (java/util/concurrent/Callable a))
+(import: (java/util/concurrent/Callable a))
-(import: #long java/lang/Long)
+(import: java/lang/Long)
-(import: #long java/lang/String)
+(import: java/lang/String)
-(import: #long java/lang/Exception
+(import: java/lang/Exception
(new [java/lang/String]))
-(import: #long java/lang/Object)
+(import: java/lang/Object)
-(import: #long (java/lang/Class a)
+(import: (java/lang/Class a)
(getName [] java/lang/String))
-(import: #long java/lang/Runnable)
+(import: java/lang/Runnable)
-(import: #long java/lang/System
+(import: java/lang/System
(#static out java/io/PrintStream)
(#static currentTimeMillis [] #io long)
(#static getenv [java/lang/String] #io #? java/lang/String))
diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux
index e297c1411..457caee6a 100644
--- a/stdlib/source/test/lux/host.old.lux
+++ b/stdlib/source/test/lux/host.old.lux
@@ -16,20 +16,23 @@
(import: (java/util/concurrent/Callable a))
+(import: java/lang/Object)
+(import: java/lang/String)
+
(import: java/lang/Exception
- (new [String]))
+ (new [java/lang/String]))
-(import: java/lang/Object)
+(import: java/lang/Runnable)
(import: (java/lang/Class a)
- (getName [] String))
+ (getName [] java/lang/String))
(import: java/lang/System
(#static out java/io/PrintStream)
(#static currentTimeMillis [] #io long)
- (#static getenv [String] #io #? String))
+ (#static getenv [java/lang/String] #io #? java/lang/String))
-(class: #final (TestClass A) [Runnable]
+(class: #final (TestClass A) [java/lang/Runnable]
## Fields
(#private foo boolean)
(#private bar A)
@@ -44,23 +47,23 @@
"")
(#public #static (static) java/lang/Object
"")
- (Runnable [] (run self) void
- []))
+ (java/lang/Runnable [] (run self) void
+ []))
(def: test-runnable
- (object [] [Runnable]
+ (object [] [java/lang/Runnable]
[]
- (Runnable [] (run self) void
- [])))
+ (java/lang/Runnable [] (run self) void
+ [])))
(def: test-callable
- (object [a] [(Callable a)]
+ (object [a] [(java/util/concurrent/Callable a)]
[]
- (Callable [] (call self) a
- (undefined))))
+ (java/util/concurrent/Callable [] (call self) a
+ (undefined))))
(interface: TestInterface
- ([] foo [boolean String] void #throws [Exception]))
+ ([] foo [boolean java/lang/String] void #throws [java/lang/Exception]))
(def: conversions
Test
@@ -88,26 +91,26 @@
[sample (r.ascii 1)]
($_ _.and
(_.test "Can check if an object is of a certain class."
- (and (case (/.check String sample) (#.Some _) true #.None false)
- (case (/.check Long sample) (#.Some _) false #.None true)
- (case (/.check Object sample) (#.Some _) true #.None false)
- (case (/.check Object (/.null)) (#.Some _) false #.None true)))
+ (and (case (/.check java/lang/String sample) (#.Some _) true #.None false)
+ (case (/.check java/lang/Long sample) (#.Some _) false #.None true)
+ (case (/.check java/lang/Object sample) (#.Some _) true #.None false)
+ (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true)))
(_.test "Can run code in a 'synchronized' block."
(/.synchronized sample #1))
(_.test "Can access Class instances."
- (text;= "java.lang.Class" (Class::getName (/.class-for java/lang/Class))))
+ (text;= "java.lang.Class" (java/lang/Class::getName (/.class-for java/lang/Class))))
(_.test "Can check if a value is null."
(and (/.null? (/.null))
(not (/.null? sample))))
(_.test "Can safely convert nullable references into Maybe values."
- (and (|> (: (Maybe Object) (/.??? (/.null)))
+ (and (|> (: (Maybe java/lang/Object) (/.??? (/.null)))
(case> #.None #1
_ #0))
- (|> (: (Maybe Object) (/.??? sample))
+ (|> (: (Maybe java/lang/Object) (/.??? sample))
(case> (#.Some _) #1
_ #0))))
)))
@@ -120,12 +123,13 @@
value 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.= value (/.array-read idx arr)))))
+ )))
(def: #export test
($_ _.and
@@ -134,4 +138,5 @@
(<| (_.context "Miscellaneous.")
..miscellaneous)
(<| (_.context "Arrays.")
- ..arrays)))
+ ..arrays)
+ ))
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index 26d3cb42f..28ea97944 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -58,24 +58,24 @@
/method.public
/method.static))
-(import: #long java/lang/Boolean)
-(import: #long java/lang/Byte)
-(import: #long java/lang/Short)
-(import: #long java/lang/Integer)
-(import: #long java/lang/Long)
-(import: #long java/lang/Float)
-(import: #long java/lang/Double
+(import: java/lang/Boolean)
+(import: java/lang/Byte)
+(import: java/lang/Short)
+(import: java/lang/Integer)
+(import: java/lang/Long)
+(import: java/lang/Float)
+(import: java/lang/Double
(#static compare [double double] int))
-(import: #long java/lang/Character)
-(import: #long java/lang/String)
+(import: java/lang/Character)
+(import: java/lang/String)
-(import: #long java/lang/reflect/Method
+(import: java/lang/reflect/Method
(invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object))
-(import: #long (java/lang/Class c)
+(import: (java/lang/Class c)
(getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method))
-(import: #long java/lang/Object
+(import: java/lang/Object
(getClass [] (java/lang/Class java/lang/Object))
(toString [] java/lang/String))