diff options
author | Eduardo Julian | 2019-08-20 23:56:58 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-08-20 23:56:58 -0400 |
commit | 8dcbdff13bf679ead63a4c29e7f63d7cc0d86480 (patch) | |
tree | 47736bc71cd71e343a14c032da31d05669109b7a | |
parent | 9cbbf331a103d411ead15d57f83d3b6ed4b044d4 (diff) |
Improved machinery in "lux/target/jvm/type/reflection".
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/target/jvm/type/descriptor.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/target/jvm/type/reflection.lux | 116 | ||||
-rw-r--r-- | stdlib/source/lux/target/jvm/type/signature.lux | 4 |
3 files changed, 74 insertions, 50 deletions
diff --git a/stdlib/source/lux/target/jvm/type/descriptor.lux b/stdlib/source/lux/target/jvm/type/descriptor.lux index b47f0edf3..75b6d4284 100644 --- a/stdlib/source/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/lux/target/jvm/type/descriptor.lux @@ -127,7 +127,7 @@ (def: binary-name (|>> ///name.internal ///name.external)) (def: #export (class? descriptor) - (-> (Descriptor Value) (Maybe Text)) + (-> (Descriptor Value) (Maybe External)) (let [repr (:representation descriptor)] (if (and (text.starts-with? ..class-prefix repr) (text.ends-with? ..class-suffix repr)) @@ -139,7 +139,7 @@ #.None))) (def: #export class-name - (-> (Descriptor Object) Text) + (-> (Descriptor Object) External) (let [prefix-size (text.size ..class-prefix) suffix-size (text.size ..class-suffix)] (function (_ descriptor) diff --git a/stdlib/source/lux/target/jvm/type/reflection.lux b/stdlib/source/lux/target/jvm/type/reflection.lux index b49205f5e..a80106e7a 100644 --- a/stdlib/source/lux/target/jvm/type/reflection.lux +++ b/stdlib/source/lux/target/jvm/type/reflection.lux @@ -2,50 +2,74 @@ [lux (#- int char) [data [text - ["%" format (#+ format)]]]] - ["." //]) - -(template [<name> <reflection>] - [(def: #export <name> <reflection>)] - - [void "void"] - [boolean "boolean"] - [byte "byte"] - [short "short"] - [int "int"] - [long "long"] - [float "float"] - [double "double"] - [char "char"] - ) + ["%" format (#+ format)]]] + [macro + ["." template]] + [type + abstract]] + ["." // + ["#." 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)) -(def: #export (class type) - (-> //.Type Text) - (case type - (#//.Primitive prim) - (case prim - #//.Boolean ..boolean - #//.Byte ..byte - #//.Short ..short - #//.Int ..int - #//.Long ..long - #//.Float ..float - #//.Double ..double - #//.Char ..char) - - (#//.Array sub) - (|> sub class (format //.array-prefix)) - - (#//.Generic generic) - (case generic - (#//.Class name params) - name - - (^or (#//.Var name) - (#//.Wildcard #.None) - (#//.Wildcard (#.Some [#//.Lower bound]))) - "java.lang.Object" - - (#//.Wildcard (#.Some [#//.Upper bound])) - (class (#//.Generic bound))) - )) + (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)) + + (template [<brand> <name> <reflection>] + [(def: #export <name> + (Reflection <brand>) + (:abstraction <reflection>))] + + [Void void "void"] + [Primitive boolean "boolean"] + [Primitive byte "byte"] + [Primitive short "short"] + [Primitive int "int"] + [Primitive long "long"] + [Primitive float "float"] + [Primitive double "double"] + [Primitive char "char"] + ) + + (def: #export class + (-> External (Reflection Class)) + (|>> :abstraction)) + + (def: #export array + (-> (Reflection Class) (Reflection Array)) + (|>> :representation + (format //descriptor.array-prefix) + :abstraction)) + ) diff --git a/stdlib/source/lux/target/jvm/type/signature.lux b/stdlib/source/lux/target/jvm/type/signature.lux index d19708f1e..5af06d0ef 100644 --- a/stdlib/source/lux/target/jvm/type/signature.lux +++ b/stdlib/source/lux/target/jvm/type/signature.lux @@ -15,7 +15,7 @@ ["#." descriptor] ["/#" // #_ [encoding - ["#." name]]]]) + ["#." name (#+ External)]]]]) (abstract: #export Void' {} Any) (abstract: #export (Value' kind) {} Any) @@ -98,7 +98,7 @@ ) (def: #export (class name parameters) - (-> Text (List (Signature Parameter)) (Signature Class)) + (-> External (List (Signature Parameter)) (Signature Class)) (:abstraction (format //descriptor.class-prefix (|> name ///name.internal ///name.read) |