diff options
author | Eduardo Julian | 2019-04-27 23:41:47 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-27 23:41:47 -0400 |
commit | af7f85c4eb724f2888ecce9c8b52d6d3bb1cd807 (patch) | |
tree | 9d2b80257b5c82ebcc9f17bd32e9771ea51cc708 /new-luxc/source/luxc/lang/host/jvm/type.lux | |
parent | aa7f1d12ae98da9726bf8bbdd3c494a671e3f94b (diff) |
Moved JVM type machinery to stdlib.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/host/jvm/type.lux | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/new-luxc/source/luxc/lang/host/jvm/type.lux b/new-luxc/source/luxc/lang/host/jvm/type.lux deleted file mode 100644 index 909344d24..000000000 --- a/new-luxc/source/luxc/lang/host/jvm/type.lux +++ /dev/null @@ -1,154 +0,0 @@ -(.module: - [lux (#- int char) - [data - ["." maybe ("#@." functor)] - ["." text - format] - [collection - ["." list ("#@." functor)]]]] - ["." //]) - -(template [<name> <primitive>] - [(def: #export <name> //.Type (#//.Primitive <primitive>))] - - [boolean #//.Boolean] - [byte #//.Byte] - [short #//.Short] - [int #//.Int] - [long #//.Long] - [float #//.Float] - [double #//.Double] - [char #//.Char] - ) - -(template: #export (class name params) - (#//.Generic (#//.Class name params))) - -(template: #export (var name) - (#//.Generic (#//.Var name))) - -(template: #export (wildcard bound) - (#//.Generic (#//.Wildcard bound))) - -(def: #export (array depth elemT) - (-> Nat //.Type //.Type) - (case depth - 0 elemT - _ (#//.Array (array (dec depth) elemT)))) - -(def: #export binary-name - (-> Text Text) - (text.replace-all "." "/")) - -(def: #export (descriptor type) - (-> //.Type Text) - (case type - (#//.Primitive prim) - (case prim - #//.Boolean "Z" - #//.Byte "B" - #//.Short "S" - #//.Int "I" - #//.Long "J" - #//.Float "F" - #//.Double "D" - #//.Char "C") - - (#//.Array sub) - (format "[" (descriptor sub)) - - (#//.Generic generic) - (case generic - (#//.Class class params) - (format "L" (binary-name class) ";") - - (^or (#//.Var name) (#//.Wildcard ?bound)) - (descriptor (#//.Generic (#//.Class "java.lang.Object" (list))))) - )) - -(def: #export (class-name type) - (-> //.Type (Maybe Text)) - (case type - (#//.Primitive prim) - #.None - - (#//.Array sub) - (#.Some (descriptor type)) - - (#//.Generic generic) - (case generic - (#//.Class class params) - (#.Some class) - - (^or (#//.Var name) (#//.Wildcard ?bound)) - (#.Some "java.lang.Object")) - )) - -(def: #export (signature type) - (-> //.Type Text) - (case type - (#//.Primitive prim) - (case prim - #//.Boolean "Z" - #//.Byte "B" - #//.Short "S" - #//.Int "I" - #//.Long "J" - #//.Float "F" - #//.Double "D" - #//.Char "C") - - (#//.Array sub) - (format "[" (signature sub)) - - (#//.Generic generic) - (case generic - (#//.Class class params) - (let [=params (if (list.empty? params) - "" - (format "<" - (|> params - (list@map (|>> #//.Generic signature)) - (text.join-with "")) - ">"))] - (format "L" (binary-name class) =params ";")) - - (#//.Var name) - (format "T" name ";") - - (#//.Wildcard #.None) - "*" - - (^template [<tag> <prefix>] - (#//.Wildcard (#.Some [<tag> bound])) - (format <prefix> (signature (#//.Generic bound)))) - ([#//.Upper "+"] - [#//.Lower "-"])) - )) - -(def: #export (method args return exceptions) - (-> (List //.Type) (Maybe //.Type) (List //.Generic) //.Method) - {#//.args args #//.return return #//.exceptions exceptions}) - -(def: #export (method-descriptor method) - (-> //.Method Text) - (format "(" (text.join-with "" (list@map descriptor (get@ #//.args method))) ")" - (case (get@ #//.return method) - #.None - "V" - - (#.Some return) - (descriptor return)))) - -(def: #export (method-signature method) - (-> //.Method Text) - (format "(" (|> (get@ #//.args method) (list@map signature) (text.join-with "")) ")" - (case (get@ #//.return method) - #.None - "V" - - (#.Some return) - (signature return)) - (|> (get@ #//.exceptions method) - (list@map (|>> #//.Generic signature (format "^"))) - (text.join-with "")))) |