diff options
Diffstat (limited to '')
30 files changed, 478 insertions, 743 deletions
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)) )})) |