aboutsummaryrefslogtreecommitdiff
path: root/src/lux/type/host.clj
diff options
context:
space:
mode:
authorEduardo Julian2015-10-13 15:38:21 -0400
committerEduardo Julian2015-10-13 15:38:21 -0400
commit2006e4787f113bccecbc8b27142e051f0d1678b8 (patch)
tree7da72d4c4ddcfdf48ca258c15a9e3348340ed21f /src/lux/type/host.clj
parent7aae4fa5d885e9cf6a3913e1252f6c85aef15c51 (diff)
- Separated type coercions from type annotations.
- Enriched type annotatins. - Improved class->type convertions. - Improved showing AST.
Diffstat (limited to '')
-rw-r--r--src/lux/type/host.clj24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/lux/type/host.clj b/src/lux/type/host.clj
index 38acf8162..9d83e0b58 100644
--- a/src/lux/type/host.clj
+++ b/src/lux/type/host.clj
@@ -64,19 +64,33 @@
(&/fold2 matcher (&/|table) sub-type-params params)))
;; [Exports]
-(let [class-name-re #"((\[+)L([\.a-zA-Z0-9]+);|([\.a-zA-Z0-9]+))"
- Unit (&/V &/$TupleT (&/|list))]
+(let [class-name-re #"((\[+)L([\.a-zA-Z0-9]+);|([\.a-zA-Z0-9]+)|(\[+)([ZBSIJFDC]))"
+ Unit (&/V &/$TupleT (&/|list))
+ jprim->lprim (fn [prim]
+ (case prim
+ "Z" "boolean"
+ "B" "byte"
+ "S" "short"
+ "I" "int"
+ "J" "long"
+ "F" "float"
+ "D" "double"
+ "C" "char"))]
(defn class->type [^Class class]
"(-> Class Type)"
- (if-let [[_ _ arr-brackets arr-base simple-base] (re-find class-name-re (.getName class))]
- (let [base (or arr-base simple-base)]
+ (if-let [[_ _ arr-obrackets arr-obase simple-base arr-pbrackets arr-pbase] (re-find class-name-re (.getName class))]
+ (let [base (or arr-obase simple-base (jprim->lprim arr-pbase))]
(if (.equals "void" base)
Unit
(reduce (fn [inner _] (&/V &/$DataT (&/T array-data-tag (&/|list inner))))
(&/V &/$DataT (&/T base &/Nil$))
- (range (count (or arr-brackets "")))))
+ (range (count (or arr-obrackets arr-pbrackets "")))))
))))
+;; (-> String (.getMethod "getBytes" (into-array Class [])) .getReturnType)
+;; (-> String (.getMethod "getBytes" (into-array Class [])) ^Class (.getGenericReturnType)
+;; .getName (->> (re-find #"((\[+)L([\.a-zA-Z0-9]+);|([\.a-zA-Z0-9]+)|(\[+)([ZBSIJFDC]))")))
+
(defn instance-param [existential matchings refl-type]
"(-> (List (, Text Type)) (^ java.lang.reflect.Type) (Lux Type))"
(cond (instance? Class refl-type)