|
1009 | 1009 | :ns @utils/current-ns |
1010 | 1010 | :file @utils/current-file)] |
1011 | 1011 | #?(:clj (if (class? instance-expr) |
1012 | | - (if (nil? args) |
1013 | | - (if field-access |
1014 | | - (let [method-name (subs method-name 1)] |
1015 | | - (sci.impl.types/->Node |
1016 | | - (interop/get-static-field instance-expr method-name) |
1017 | | - stack)) |
1018 | | - ;; https://clojure.org/reference/java_interop |
1019 | | - ;; If the second operand is a symbol and no args are |
1020 | | - ;; supplied it is taken to be a field access - the |
1021 | | - ;; name of the field is the name of the symbol, and |
1022 | | - ;; the value of the expression is the value of the |
1023 | | - ;; field, unless there is a no argument public method |
1024 | | - ;; of the same name, in which case it resolves to a |
1025 | | - ;; call to the method. |
1026 | | - (if-let [_ |
1027 | | - (try (Reflector/getStaticField ^Class instance-expr ^String method-name) |
1028 | | - (catch IllegalArgumentException _ nil))] |
1029 | | - (sci.impl.types/->Node |
1030 | | - (interop/get-static-field instance-expr method-name) |
1031 | | - stack) |
1032 | | - (let [arg-count (count args) |
1033 | | - args (object-array args)] |
| 1012 | + (let [static-method |
| 1013 | + #(let [arg-count (count args) |
| 1014 | + args (object-array args) |
| 1015 | + class-expr (:class-expr (meta expr))] |
| 1016 | + ;; prefab static-methods |
| 1017 | + (if-let [f (some-> ctx :env deref |
| 1018 | + :class->opts :static-methods |
| 1019 | + (get (interop/fully-qualify-class ctx class-expr)) |
| 1020 | + (get method-expr))] |
| 1021 | + (return-call ctx expr f (cons instance-expr args) stack nil) |
| 1022 | + (sci.impl.types/->Node |
| 1023 | + (interop/invoke-static-method ctx bindings instance-expr method-name |
| 1024 | + args arg-count) |
| 1025 | + stack)))] |
| 1026 | + (if (nil? args) |
| 1027 | + (if field-access |
| 1028 | + (let [method-name (subs method-name 1)] |
| 1029 | + (sci.impl.types/->Node |
| 1030 | + (interop/get-static-field instance-expr method-name) |
| 1031 | + stack)) |
| 1032 | + ;; https://clojure.org/reference/java_interop |
| 1033 | + ;; If the second operand is a symbol and no args are |
| 1034 | + ;; supplied it is taken to be a field access - the |
| 1035 | + ;; name of the field is the name of the symbol, and |
| 1036 | + ;; the value of the expression is the value of the |
| 1037 | + ;; field, unless there is a no argument public method |
| 1038 | + ;; of the same name, in which case it resolves to a |
| 1039 | + ;; call to the method. |
| 1040 | + (if-let [_ |
| 1041 | + (try (Reflector/getStaticField ^Class instance-expr ^String method-name) |
| 1042 | + (catch IllegalArgumentException _ nil))] |
1034 | 1043 | (sci.impl.types/->Node |
1035 | | - (interop/invoke-static-method ctx bindings instance-expr method-name |
1036 | | - args arg-count) |
1037 | | - stack)))) |
1038 | | - (let [arg-count (count args) |
1039 | | - args (object-array args)] |
1040 | | - ;; prefab static-methods |
1041 | | - (if-let [f (some-> ctx :env deref |
1042 | | - :class->opts :static-methods |
1043 | | - (get (.getName ^Class instance-expr)) (get method-expr))] |
1044 | | - (return-call ctx expr f (cons instance-expr args) stack nil) |
1045 | | - (sci.impl.types/->Node |
1046 | | - (interop/invoke-static-method ctx bindings instance-expr method-name |
1047 | | - args arg-count) |
1048 | | - stack)))) |
| 1044 | + (interop/get-static-field instance-expr method-name) |
| 1045 | + stack) |
| 1046 | + (static-method))) |
| 1047 | + (static-method))) |
1049 | 1048 | (let [arg-count #?(:cljs nil :clj (count args)) |
1050 | 1049 | args (object-array args) |
1051 | 1050 | #?@(:clj [^"[Ljava.lang.Class;" arg-types (when (and (pos? arg-count)) |
|
1550 | 1549 | f (or fast-path f)] |
1551 | 1550 | (cond (and f-meta (::static-access f-meta)) |
1552 | 1551 | #?(:clj |
1553 | | - (expand-dot** ctx (with-meta (list* '. (first f) (second f) (rest expr)) |
1554 | | - m)) |
| 1552 | + (let [[clazz meth class-expr] f] |
| 1553 | + (analyze-dot ctx (with-meta (list* '. clazz meth (rest expr)) |
| 1554 | + (assoc m :class-expr class-expr)))) |
1555 | 1555 | :cljs |
1556 | 1556 | (let [[class method-path] f |
1557 | 1557 | last-path (last method-path) |
|
0 commit comments