diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/target/jvm/type/descriptor.lux | 196 |
1 files changed, 97 insertions, 99 deletions
diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 85d659e2c..7d7d4e7fe 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -22,105 +22,103 @@ ["[1][0]" name {"+" [Internal External]}]]]]) (abstract: .public (Descriptor category) - {} - Text - (def: .public descriptor - (-> (Descriptor Any) Text) - (|>> :representation)) - - (template [<sigil> <category> <name>] - [(def: .public <name> - (Descriptor <category>) - (:abstraction <sigil>))] - - ["V" Void void] - ["Z" Primitive boolean] - ["B" Primitive byte] - ["S" Primitive short] - ["I" Primitive int] - ["J" Primitive long] - ["F" Primitive float] - ["D" Primitive double] - ["C" Primitive char] - ) - - (def: .public class_prefix "L") - (def: .public class_suffix ";") - - (def: .public class - (-> External (Descriptor Class)) - (|>> ///name.internal - ///name.read - (text.enclosed [..class_prefix ..class_suffix]) - :abstraction)) - - (def: .public (declaration name) - (-> External (Descriptor Declaration)) - (:transmutation (..class name))) - - (def: .public as_class - (-> (Descriptor Declaration) (Descriptor Class)) - (|>> :transmutation)) - - (template [<name> <category>] - [(def: .public <name> - (Descriptor <category>) - (:transmutation - (..class "java.lang.Object")))] - - [var Var] - [wildcard Parameter] - ) - - (def: .public (lower descriptor) - (-> (Descriptor Class) (Descriptor Parameter)) - ..wildcard) - - (def: .public upper - (-> (Descriptor Class) (Descriptor Parameter)) - (|>> :transmutation)) - - (def: .public array_prefix "[") - - (def: .public array - (-> (Descriptor Value) - (Descriptor Array)) - (|>> :representation - (format ..array_prefix) - :abstraction)) - - (def: .public (method [inputs output]) - (-> [(List (Descriptor Value)) - (Descriptor Return)] - (Descriptor Method)) - (:abstraction - (format (|> inputs - (list\each ..descriptor) - text.together - (text.enclosed ["(" ")"])) - (:representation output)))) - - (implementation: .public equivalence - (All (_ category) (Equivalence (Descriptor category))) - - (def: (= parameter subject) - (text\= (:representation parameter) (:representation subject)))) - - (def: .public class_name - (-> (Descriptor Object) Internal) - (let [prefix_size (text.size ..class_prefix) - suffix_size (text.size ..class_suffix)] - (function (_ descriptor) - (let [repr (:representation descriptor)] - (if (text.starts_with? ..array_prefix repr) - (///name.internal repr) - (|> repr - (text.clip prefix_size - (|> (text.size repr) - (n.- prefix_size) - (n.- suffix_size))) - (\ maybe.monad each ///name.internal) - maybe.trusted)))))) + [(def: .public descriptor + (-> (Descriptor Any) Text) + (|>> :representation)) + + (template [<sigil> <category> <name>] + [(def: .public <name> + (Descriptor <category>) + (:abstraction <sigil>))] + + ["V" Void void] + ["Z" Primitive boolean] + ["B" Primitive byte] + ["S" Primitive short] + ["I" Primitive int] + ["J" Primitive long] + ["F" Primitive float] + ["D" Primitive double] + ["C" Primitive char] + ) + + (def: .public class_prefix "L") + (def: .public class_suffix ";") + + (def: .public class + (-> External (Descriptor Class)) + (|>> ///name.internal + ///name.read + (text.enclosed [..class_prefix ..class_suffix]) + :abstraction)) + + (def: .public (declaration name) + (-> External (Descriptor Declaration)) + (:transmutation (..class name))) + + (def: .public as_class + (-> (Descriptor Declaration) (Descriptor Class)) + (|>> :transmutation)) + + (template [<name> <category>] + [(def: .public <name> + (Descriptor <category>) + (:transmutation + (..class "java.lang.Object")))] + + [var Var] + [wildcard Parameter] + ) + + (def: .public (lower descriptor) + (-> (Descriptor Class) (Descriptor Parameter)) + ..wildcard) + + (def: .public upper + (-> (Descriptor Class) (Descriptor Parameter)) + (|>> :transmutation)) + + (def: .public array_prefix "[") + + (def: .public array + (-> (Descriptor Value) + (Descriptor Array)) + (|>> :representation + (format ..array_prefix) + :abstraction)) + + (def: .public (method [inputs output]) + (-> [(List (Descriptor Value)) + (Descriptor Return)] + (Descriptor Method)) + (:abstraction + (format (|> inputs + (list\each ..descriptor) + text.together + (text.enclosed ["(" ")"])) + (:representation output)))) + + (implementation: .public equivalence + (All (_ category) (Equivalence (Descriptor category))) + + (def: (= parameter subject) + (text\= (:representation parameter) (:representation subject)))) + + (def: .public class_name + (-> (Descriptor Object) Internal) + (let [prefix_size (text.size ..class_prefix) + suffix_size (text.size ..class_suffix)] + (function (_ descriptor) + (let [repr (:representation descriptor)] + (if (text.starts_with? ..array_prefix repr) + (///name.internal repr) + (|> repr + (text.clip prefix_size + (|> (text.size repr) + (n.- prefix_size) + (n.- suffix_size))) + (\ maybe.monad each ///name.internal) + maybe.trusted))))))] ) |