diff options
Diffstat (limited to 'stdlib/source/lux/target/jvm/type/reflection.lux')
-rw-r--r-- | stdlib/source/lux/target/jvm/type/reflection.lux | 116 |
1 files changed, 70 insertions, 46 deletions
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)) + ) |