aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2019-08-21 22:30:21 -0400
committerEduardo Julian2019-08-21 22:30:21 -0400
commit4ee317f2e8a4b855966500500356b5997e07d923 (patch)
tree4ff47b3b64c48dcc7f85ebf2bcf798414a6cd74f /stdlib/source
parenta51eadf7065db89ac9a65ee854f6f134c9f9da60 (diff)
Factored-out the different categories of JVM types.
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/target/jvm/type.lux47
-rw-r--r--stdlib/source/lux/target/jvm/type/category.lux32
-rw-r--r--stdlib/source/lux/target/jvm/type/descriptor.lux54
-rw-r--r--stdlib/source/lux/target/jvm/type/reflection.lux46
-rw-r--r--stdlib/source/lux/target/jvm/type/signature.lux29
5 files changed, 84 insertions, 124 deletions
diff --git a/stdlib/source/lux/target/jvm/type.lux b/stdlib/source/lux/target/jvm/type.lux
index 4a2260aef..e28e9633a 100644
--- a/stdlib/source/lux/target/jvm/type.lux
+++ b/stdlib/source/lux/target/jvm/type.lux
@@ -19,41 +19,16 @@
[encoding
["#." name (#+ External)]]]
["." / #_
+ [category (#+ Void Value Return Method Primitive Object Class Array Parameter)]
["#." signature (#+ Signature)]
["#." descriptor (#+ Descriptor)]
["#." reflection (#+ Reflection)]])
-(abstract: #export Void' {} Any)
-(abstract: #export (Value' kind) {} Any)
-(abstract: #export (Return' kind) {} Any)
-(abstract: #export Method {} Any)
-
(abstract: #export (Type brand)
{}
[(Signature Any) (Descriptor Any) (Reflection Any)]
- (type: #export Return (<| Return' Any))
- (type: #export Value (<| Return' Value' Any))
- (type: #export Void (<| Return' Void'))
-
- (abstract: #export (Object' brand) {} Any)
- (type: #export Object (<| Return' Value' Object' Any))
-
- (abstract: #export (Parameter' brand) {} Any)
- (type: #export Parameter (<| Return' Value' Object' Parameter' Any))
-
- (template [<parents> <child>]
- [(with-expansions [<raw> (template.identifier [<child> "'"])]
- (abstract: #export <raw> {} Any)
- (type: #export <child>
- (`` (<| Return' Value' (~~ (template.splice <parents>)) <raw>))))]
-
- [[] Primitive]
- [[Object' Parameter'] Class]
- [[Object'] Array]
- )
-
(template [<name> <style>]
[(def: #export (<name> type)
(-> (Type Any) (<style> Any))
@@ -95,35 +70,33 @@
(/descriptor.class name)
(/reflection.class name)]))
- (def: object-class "java.lang.Object")
-
(def: #export wildcard
(Type Parameter)
(:abstraction
[/signature.wildcard
- (/descriptor.class ..object-class)
- (/reflection.class ..object-class)]))
+ /descriptor.wildcard
+ /reflection.wildcard]))
(def: #export (var name)
(-> Text (Type Parameter))
(:abstraction
[(/signature.var name)
- (/descriptor.class ..object-class)
- (/reflection.class ..object-class)]))
+ /descriptor.var
+ /reflection.var]))
(def: #export (lower bound)
(-> (Type Class) (Type Parameter))
(:abstraction
[(/signature.lower (..signature bound))
- (/descriptor.class ..object-class)
- (/reflection.class ..object-class)]))
+ (/descriptor.lower (..descriptor bound))
+ (/reflection.lower (..reflection bound))]))
(def: #export (upper bound)
(-> (Type Class) (Type Parameter))
(:abstraction
- [(/signature.lower (..signature bound))
- (..descriptor bound)
- (..reflection bound)]))
+ [(/signature.upper (..signature bound))
+ (/descriptor.upper (..descriptor bound))
+ (/reflection.upper (..reflection bound))]))
(def: #export (method [inputs output exceptions])
(-> [(List (Type Value))
diff --git a/stdlib/source/lux/target/jvm/type/category.lux b/stdlib/source/lux/target/jvm/type/category.lux
new file mode 100644
index 000000000..3bbf03783
--- /dev/null
+++ b/stdlib/source/lux/target/jvm/type/category.lux
@@ -0,0 +1,32 @@
+(.module:
+ [lux #*
+ [macro
+ ["." template]]
+ [type
+ abstract]])
+
+(abstract: #export Void' {} Any)
+(abstract: #export (Value' kind) {} Any)
+(abstract: #export (Return' kind) {} Any)
+(abstract: #export Method {} Any)
+
+(type: #export Return (<| Return' Any))
+(type: #export Value (<| Return' Value' Any))
+(type: #export Void (<| Return' Void'))
+
+(abstract: #export (Object' brand) {} Any)
+(type: #export Object (<| Return' Value' Object' Any))
+
+(abstract: #export (Parameter' brand) {} Any)
+(type: #export Parameter (<| Return' Value' Object' Parameter' Any))
+
+(template [<parents> <child>]
+ [(with-expansions [<raw> (template.identifier [<child> "'"])]
+ (abstract: #export <raw> {} Any)
+ (type: #export <child>
+ (`` (<| Return' Value' (~~ (template.splice <parents>)) <raw>))))]
+
+ [[] Primitive]
+ [[Object' Parameter'] Class]
+ [[Object'] Array]
+ )
diff --git a/stdlib/source/lux/target/jvm/type/descriptor.lux b/stdlib/source/lux/target/jvm/type/descriptor.lux
index 75b6d4284..4a46b5caa 100644
--- a/stdlib/source/lux/target/jvm/type/descriptor.lux
+++ b/stdlib/source/lux/target/jvm/type/descriptor.lux
@@ -10,44 +10,19 @@
["%" format (#+ format)]]
[collection
["." list ("#@." functor)]]]
- [macro
- ["." template]]
[type
abstract]]
- ["." /// #_
- [encoding
- ["#." name (#+ External)]]])
-
-(abstract: #export Void' {} Any)
-
-(abstract: #export (Value' brand) {} Any)
-(abstract: #export (Return' brand) {} Any)
-
-(abstract: #export Method {} Any)
+ ["." // #_
+ [category (#+ Void Value Return Method Primitive Object Class Array Parameter)]
+ ["/#" // #_
+ [encoding
+ ["#." name (#+ External)]]]])
(abstract: #export (Descriptor brand)
{}
Text
- (type: #export Return (<| Return' Any))
- (type: #export Value (<| Return' Value' Any))
- (type: #export Void (<| Return' Void'))
-
- (abstract: #export (Object' brand) {} Any)
- (type: #export Object (<| Return' Value' Object' Any))
-
- (template [<parents> <child>]
- [(with-expansions [<raw> (template.identifier [<child> "'"])]
- (abstract: #export <raw> {} Any)
- (type: #export <child>
- (`` (<| Return' Value' (~~ (template.splice <parents>)) <raw>))))]
-
- [[] Primitive]
- [[Object'] Class]
- [[Object'] Array]
- )
-
(def: #export descriptor
(-> (Descriptor Any) Text)
(|>> :representation))
@@ -78,9 +53,24 @@
(text.enclose [..class-prefix ..class-suffix])
:abstraction))
- (def: #export var (..class "java.lang.Object"))
- (def: #export wildcard (..class "java.lang.Object"))
+ (template [<name>]
+ [(def: #export <name>
+ (Descriptor Parameter)
+ (:transmutation
+ (..class "java.lang.Object")))]
+
+ [var]
+ [wildcard]
+ )
+
+ (def: #export (lower descriptor)
+ (-> (Descriptor Class) (Descriptor Parameter))
+ ..wildcard)
+ (def: #export upper
+ (-> (Descriptor Class) (Descriptor Parameter))
+ (|>> :transmutation))
+
(def: #export array-prefix "[")
(def: #export array
diff --git a/stdlib/source/lux/target/jvm/type/reflection.lux b/stdlib/source/lux/target/jvm/type/reflection.lux
index a80106e7a..08c51b391 100644
--- a/stdlib/source/lux/target/jvm/type/reflection.lux
+++ b/stdlib/source/lux/target/jvm/type/reflection.lux
@@ -3,46 +3,20 @@
[data
[text
["%" format (#+ format)]]]
- [macro
- ["." template]]
[type
abstract]]
["." //
+ [category (#+ Void Value Return Method Primitive Object Class Array Parameter)]
["#." descriptor]
[//
[encoding
["#." name (#+ External)]]]])
-(abstract: #export Void' {} Any)
-
-(abstract: #export (Value' brand) {} Any)
-(abstract: #export (Return' brand) {} Any)
-
-(abstract: #export Method {} Any)
-
(abstract: #export (Reflection brand)
{}
Text
- (type: #export Return (<| Return' Any))
- (type: #export Value (<| Return' Value' Any))
- (type: #export Void (<| Return' Void'))
-
- (abstract: #export (Object' brand) {} Any)
- (type: #export Object (<| Return' Value' Object' Any))
-
- (template [<parents> <child>]
- [(with-expansions [<raw> (template.identifier [<child> "'"])]
- (abstract: #export <raw> {} Any)
- (type: #export <child>
- (`` (<| Return' Value' (~~ (template.splice <parents>)) <raw>))))]
-
- [[] Primitive]
- [[Object'] Class]
- [[Object'] Array]
- )
-
(def: #export reflection
(-> (Reflection Any) Text)
(|>> :representation))
@@ -72,4 +46,22 @@
(|>> :representation
(format //descriptor.array-prefix)
:abstraction))
+
+ (template [<name>]
+ [(def: #export <name>
+ (Reflection Parameter)
+ (:transmutation
+ (..class "java.lang.Object")))]
+
+ [var]
+ [wildcard]
+ )
+
+ (def: #export (lower descriptor)
+ (-> (Descriptor Class) (Descriptor Parameter))
+ ..wildcard)
+
+ (def: #export upper
+ (-> (Descriptor Class) (Descriptor Parameter))
+ (|>> :transmutation))
)
diff --git a/stdlib/source/lux/target/jvm/type/signature.lux b/stdlib/source/lux/target/jvm/type/signature.lux
index 5af06d0ef..bfb3a14ba 100644
--- a/stdlib/source/lux/target/jvm/type/signature.lux
+++ b/stdlib/source/lux/target/jvm/type/signature.lux
@@ -7,47 +7,20 @@
["%" format (#+ format)]]
[collection
["." list ("#@." functor)]]]
- [macro
- ["." template]]
[type
abstract]]
["." // #_
+ [category (#+ Void Value Return Method Primitive Object Class Array Parameter)]
["#." descriptor]
["/#" // #_
[encoding
["#." name (#+ External)]]]])
-(abstract: #export Void' {} Any)
-(abstract: #export (Value' kind) {} Any)
-(abstract: #export (Return' kind) {} Any)
-(abstract: #export Method {} Any)
-
(abstract: #export (Signature brand)
{}
Text
- (type: #export Return (<| Return' Any))
- (type: #export Value (<| Return' Value' Any))
- (type: #export Void (<| Return' Void'))
-
- (abstract: #export (Object' brand) {} Any)
- (type: #export Object (<| Return' Value' Object' Any))
-
- (abstract: #export (Parameter' brand) {} Any)
- (type: #export Parameter (<| Return' Value' Object' Parameter' Any))
-
- (template [<parents> <child>]
- [(with-expansions [<raw> (template.identifier [<child> "'"])]
- (abstract: #export <raw> {} Any)
- (type: #export <child>
- (`` (<| Return' Value' (~~ (template.splice <parents>)) <raw>))))]
-
- [[] Primitive]
- [[Object' Parameter'] Class]
- [[Object'] Array]
- )
-
(def: #export signature
(-> (Signature Any) Text)
(|>> :representation))