Skip to content

Commit

Permalink
Remove redundant nestings
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 11, 2024
1 parent 6d9380f commit fd0cb73
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/sci/impl/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@
exprs (next exprs)]
(cond (and (seq? expr) (= 'catch (first expr)))
(recur exprs body-exprs (conj catch-exprs expr) finally-expr)
(and (not exprs) (and (seq? expr) (= 'finally (first expr))))
(and (not exprs) (seq? expr) (= 'finally (first expr)))
[body-exprs catch-exprs expr]
:else
;; TODO: cannot add body expression when catch is not empty
Expand Down
2 changes: 1 addition & 1 deletion src/sci/impl/deftype.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
(cons 'clojure.core/deftype (rest form))
(let [factory-fn-str (str "->" record-name)
factory-fn-sym (symbol factory-fn-str)
rec-type (symbol (str (munge (utils/current-ns-name)) "." (str record-name)))
rec-type (symbol (str (munge (utils/current-ns-name)) "." record-name))
protocol-impls (utils/split-when symbol? raw-protocol-impls)
field-set (set fields)
protocol-impls
Expand Down
6 changes: 3 additions & 3 deletions src/sci/impl/interop.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
sym))
(when (contains? class->opts sym)
sym)))
(or (get (:imports env) sym)
(let [cnn (utils/current-ns-name)]
(get-in env [:namespaces cnn :imports sym]))))))
(get (:imports env) sym)
(let [cnn (utils/current-ns-name)]
(get-in env [:namespaces cnn :imports sym])))))

(defn resolve-class-opts [ctx sym]
(let [env @(:env ctx)
Expand Down
2 changes: 1 addition & 1 deletion src/sci/impl/records.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
constructor-fn-sym (symbol (str "__" factory-fn-str "__ctor__"))
map-factory-sym (symbol (str "map" factory-fn-str))
keys (mapv keyword fields)
rec-type (symbol (str (munge (utils/current-ns-name)) "." (str record-name)))
rec-type (symbol (str (munge (utils/current-ns-name)) "." record-name))
protocol-impls (utils/split-when symbol? raw-protocol-impls)
field-set (set fields)
protocol-impls
Expand Down
62 changes: 31 additions & 31 deletions src/sci/impl/resolve.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,37 @@
(or (some-> env :namespaces (get 'clojure.core) (find sym-name))
(when-let [v (when call? (get ana-macros sym-name))]
[sym v])))
(or (some-> env :namespaces (get sym-ns) (find sym-name))
(when-not only-var?
(when-let [clazz (interop/resolve-class ctx sym-ns)]
[sym (if (and call? #?(:clj (not (str/starts-with? sym-name-str "."))))
(with-meta
[clazz #?(:clj sym-name
:cljs (.split (str sym-name) "."))]
#?(:clj
(if (= "new" sym-name-str)
{:sci.impl.analyzer/invoke-constructor true}
{:sci.impl.analyzer/static-access true})
:cljs
{:sci.impl.analyzer/static-access true}))
#?(:clj
(with-meta
[clazz sym-name]
{:sci.impl.analyzer/interop true})
:cljs
(let [stack (assoc (meta sym)
:file @utils/current-file
:ns @utils/current-ns)
path (.split (str sym-name) ".")
len (alength path)]
(if (== 1 len)
(->Node
(interop/get-static-field clazz sym-name)
stack)
(->Node
(interop/get-static-fields clazz path)
stack))
)))]))))
(some-> env :namespaces (get sym-ns) (find sym-name))
(when-not only-var?
(when-let [clazz (interop/resolve-class ctx sym-ns)]
[sym (if (and call? #?(:clj (not (str/starts-with? sym-name-str "."))))
(with-meta
[clazz #?(:clj sym-name
:cljs (.split (str sym-name) "."))]
#?(:clj
(if (= "new" sym-name-str)
{:sci.impl.analyzer/invoke-constructor true}
{:sci.impl.analyzer/static-access true})
:cljs
{:sci.impl.analyzer/static-access true}))
#?(:clj
(with-meta
[clazz sym-name]
{:sci.impl.analyzer/interop true})
:cljs
(let [stack (assoc (meta sym)
:file @utils/current-file
:ns @utils/current-ns)
path (.split (str sym-name) ".")
len (alength path)]
(if (== 1 len)
(->Node
(interop/get-static-field clazz sym-name)
stack)
(->Node
(interop/get-static-fields clazz path)
stack))
)))])))
;; no sym-ns
(or
;; prioritize refers over vars in the current namespace, see 527
Expand Down

0 comments on commit fd0cb73

Please sign in to comment.