Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with tools analyzer #1441

Open
borkdude opened this issue Dec 7, 2022 · 0 comments
Open

Compatibility with tools analyzer #1441

borkdude opened this issue Dec 7, 2022 · 0 comments

Comments

@borkdude
Copy link
Collaborator

borkdude commented Dec 7, 2022

With a few hacks, I was able to make tools.analyzer work:

$ clojure -M:babashka/dev -Sdeps '{:paths ["src/main/clojure"] :deps {org.clojure/tools.analyzer.jvm {:mvn/version "RELEASE"}}}' -e "(require '[clojure.tools.analyzer.jvm :as ana.jvm]) (ana.jvm/analyze 1)"
{:val 1, :type :number, :op :const, :env {:context :ctx/expr, :locals {}, :ns user, :file "<expr>"}, :o-tag long, :literal? true, :top-level true, :form 1, :tag long}

Depends on babashka/sci#849 and the tools-analyzer branch in this repo (where add core memoize and core cache as built-in libs)

The diff:

diff --git a/src/main/clojure/clojure/tools/analyzer/jvm.clj b/src/main/clojure/clojure/tools/analyzer/jvm.clj
index 7cd5678..d2495c4 100644
--- a/src/main/clojure/clojure/tools/analyzer/jvm.clj
+++ b/src/main/clojure/clojure/tools/analyzer/jvm.clj
@@ -56,7 +56,7 @@
     #'clojure.core/and
     #'clojure.core/as->
     #'clojure.core/assert
-    #'clojure.core/case
+    #_#'clojure.core/case
     #'clojure.core/cond
     #'clojure.core/cond->
     #'clojure.core/cond->>
@@ -73,7 +73,7 @@
     #'clojure.core/future
     #'clojure.core/if-let
     #'clojure.core/if-not
-    #'clojure.core/lazy-seq
+    #_#'clojure.core/lazy-seq
     #'clojure.core/let
     #'clojure.core/letfn
     #'clojure.core/loop
@@ -99,7 +99,7 @@
 (defn build-ns-map []
   (into {} (mapv #(vector (ns-name %)
                           {:mappings (merge (ns-map %) {'in-ns #'clojure.core/in-ns
-                                                        'ns    #'clojure.core/ns})
+                                                        #_#_'ns    #'clojure.core/ns})
                            :aliases  (reduce-kv (fn [a k v] (assoc a k (ns-name v)))
                                                 {} (ns-aliases %))
                            :ns       (ns-name %)})
@@ -497,7 +497,7 @@
   ([form] (analyze form (empty-env) {}))
   ([form env] (analyze form env {}))
   ([form env opts]
-     (with-bindings (merge {Compiler/LOADER     (RT/makeClassLoader)
+     (with-bindings (merge {#_#_Compiler/LOADER     (RT/makeClassLoader)
                             #'ana/macroexpand-1 macroexpand-1
                             #'ana/create-var    create-var
                             #'ana/parse         parse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant