pax_global_header 0000666 0000000 0000000 00000000064 13122450003 0014500 g ustar 00root root 0000000 0000000 52 comment=da99d3a414cc74501714c96d1c60595f5d328935
tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/ 0000775 0000000 0000000 00000000000 13122450003 0021041 5 ustar 00root root 0000000 0000000 tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/.gitignore 0000664 0000000 0000000 00000000172 13122450003 0023031 0 ustar 00root root 0000000 0000000 /target
/lib
/classes
/checkouts
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
.lein-repl-history
.nrepl-port
tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/CHANGELOG.md 0000664 0000000 0000000 00000020650 13122450003 0022655 0 ustar 00root root 0000000 0000000 Changelog
========================================
Since tools.analyzer.jvm version are usually cut simultaneously with a tools.analyzer version, check also the tools.analyzer [CHANGELOG](https://github.com/clojure/tools.analyzer/blob/master/CHANGELOG.md) for changes on the corresponding version, since changes in that library will reflect on this one.
- - -
* Release 0.7.0 on 14 Feb 2017
* Release 0.7.0-alpha1 on 26 Jan 2017
* Added handle-evaluation-exception opts to `analyze+eval`
* Changed `analyze+eval`'s default behaviour on eval exception
* Stop caching maybe-class-from-string as it implicitely relies on dynamic state
* Make analyze work from nested invocations -- remove state mutation
* Release 0.6.10 on 17 Jun 2016
* Fix ns munging
* Release 0.6.9 on 10 Nov 2015
* Correctly check for recur on case :then branches
* Release 0.6.8 on 3 Nov 2015
* Fixed eof check in tools.reader usage
* Avoid reflection on catch local
* Fix context in analyze+eval statement
* Release 0.6.7 on 23 Apr 2015
* Add support for reader conditionals
* Ensure *file* is correctly bound in analyze-ns
* Fixed emit-form for :host-interop
* Release 0.6.6 on 23 Feb 2015
* Small performance enhancements
* Added validate-recur pass
* Renamed annotate-methods to annotate-host-info
* Fixed class resolution
* Added macroexpand-all
* Fixed ::resolved-op handling in analyze+eval
* Release 0.6.5 on 20 Nov 2014
* Ensure *ns* is correctly bound during analysis
* Removed analyze' and analyze+eval'
* Improvements in class resolution
* Release 0.6.4 on 03 Nov 2014
* Disallow def of a symbol that maps to a Class
* Made the target of a host interop expression privilege classnames over the lexical scope, as in clojure
* Preserve correct meta on emit-form
* Validate the target of a new expression
* Fixed bug that caused the symbols used as primitive type hints to be interpreted as classes in host interop expressions
* Made update-ns-map! an optional global-env field
* Enhanced source-info support on analyze+eval
* Release 0.6.3 on 27 Oct 2014
* Better interop method matcher
* Fixed a bug when using analyze+eval and lein uberjar caused by Compiler/LOADER being unbound during macroexpansion
* Faster maybe-class impl
* Release 0.6.1 on 13 Oct 2014
* Significant performance enhancements
* Made Class literals shadow Vars
* Fixed a bug in :arglists automatic tag qualification
* :env :locals are no longer uniquified by default, can be changed via pass-opts
* Fixed tag validation
* Removed annotate-class-id, annotate-internal-name, ensure-tag, collect, collect-closed-overs and clear-locals, moved to tools.emiter.jvm
* Fixed a bug in the method resolution code, caused some unnecessary reflection
* Added opts and env args to analyze-ns, consistent with the other analyze functions
* Made emit-form with :qualified-symbols qualify def symbol
* Release 0.6.0 on 18 Sep 2014
* Started using clojure.tools.analyzer.passes/schedule to schedule the default passes and configured all the passes
* Reduced the set of default passes, removed: annotate-class-id, annotate-internal-name, ensure-tag
* Changed the interface of the collect pass
* Added default-passes and default-passes-opts to the clojure.tools.analyzer.jvm namespace
* Release 0.5.6 on 02 Sep 2014
* Fixed a bug in classify-invoke that caused default-exprs in keyword invoke expressions to be lost
* Release 0.5.5 on 31 Aug 2014
* Fixed analyze-ns analysis caching
* Qualify :arglists class names
* Release 0.5.4 on 21 Aug 2014
* Added optional unresolved symbol handler, configurable via :passes-opts
* Release 0.5.3 on 14 Aug 2014
* Compare contexts with isa? rather than =
* Fixed a reflection warning
* Fixed a bug in the :protocol-invoke nodes that caused ast/children to crash
* Release 0.5.2 on 09 Aug 2014
* Fixed emit-form
* Imported collect pass from tools.analyzer
* Fixed infer-tag for :def
* Release 0.5.1 on 09 Aug 2014
* Allow ^:const values to be unboxed
* Made :keyword a children in :keyword-invoke
* Added optional Var tag inference, configurable via :passes-opts
* Added optional wrong tag handler, configurable via :passes-opts
* Added optional mismatched arity handler, configurable via :passes-opts
* Release 0.5.0 on 29 Jul 2014
* BREAKING CHANGE: changed :protocol-invoke and :keyword-invoke fields
* Made :host-interop :assignable?
* Release 0.4.0 on 26 Jul 2014
* BREAKING CHANGE: update to new :class field for :new and :catch nodes
* Elide source info metadata on :reify, :fn
* Fixed performance regression
* Added :qualified-symbols option to emit-form, deprecate :qualified-vars
* Don't promote :invoke to :keyword-invoke when the keyword is namespaced
* Added analyze-ns
* Fixed some wrong contexts
* Fixed and enhanced :tag/:arglists inference for :try nodes
* Fixed handling of void bodies in loops
* Collect closed-overs on :try
* Release 0.3.0 on 21 Jun 2014
* BREAKING API CHANGE: Updated to new :context
* Fixed 1-arity macroexpand-1
* validate throws on Var not found
* Release 0.2.2 on 13 Jun 2014
* Added 1-arity version of macroexpand-1
* Made analyze+eval handle exceptions via ExceptionThrown
* Fixed a bug in the validate pass that caused some instance-methods to stay unresolved
* Keep :raw-forms on analyze+eval
* Update \*ns\* in each call to analyze+eval
* Release 0.2.1 on 08 Jun 2014
* Made run-passes dynamic
* Made analyze-host-expr and classify-invoke preserve the original AST fields
* Release 0.2.0 on 05 Jun 2014
* BREAKING API CHANGE: Updated to new global env interface
* Made analyze+eval attach the result of evaluating the form to the AST
* Release 0.1.0-beta13 on 11 Mar 2014
* Don't run cleanup on analyze, added analyze' and analyze+eval' that run it
* Added :top-level true to constructed :do nodes
* Added 3-arity to analyze taking an optional map of options
* Fixes regarding :fn-method :o-tag/:tag handling
* Release 0.1.0-beta12 on 25 Apr 2014
* Default to (empty-env) if env not provided
* Fix a bug in check-recur with case
* Release 0.1.0-beta11 on 18 Apr 2014
* Performance enhancements on reflection utils
* Workaround for a weird behaviour of clojure.reflect on interfaces
* Fix for annotate-tag and validate-loop-locals interaction
* Improve logic of try-best-match
* Improve handling of Void tag
* Fix handling of tag on constructor that defer to runtime reflection
* Fix validate-loop-locals when the return type of the loop changed after the invalidation
* Added :qualified-vars option to emit-form
* Release 0.1.0-beta10 on 1 Apr 2014
* Fix validate-loop-locals handling of tag
* merge &form meta into mfrom meta to preserve source info during macroexpansion
* Release 0.1.0-beta9 on 29 Mar 2014
* Macroexpand evaluates :inline/:inline-arities to allow using the inlined version
in the fn body
* Fix fn name munging
* Fix annotate-loops handling of statements
* Update the ns map in the env after macroexpansion as some interning might
happen at macroexpansion time
* Added analyze+eval
* Pass (:locals env) as &env instead of env, macros that use (keys &env) now work
* Fix binding init tag
* Fix create-var handling of meta
* Release 0.1.0-beta8 on 11 Mar 2014
* Removed :name in env for the :fn name, moved in a tools.analyzer.jvm pass
* Added docstrings
* Add annotate-internal-name pass
* Add warn-on-reflection pass
* clear-locals is *compiler-options* aware
* Release 0.1.0-beta7 on 28 Feb 2014
* Moved :should-not-clear annotation from annotate-branch to clear-locals
* Release 0.1.0-beta6 on 27 Feb 2014
* Bind Compiler/LOADER to a new DynamicClassLoader on every analyze call to avoid
problems regarding deftype redefinitions
* Fix handling of meta by create-var
* Release 0.1.0-beta5 on 26 Feb 2014
* Clear :catch locals
* Added "this" clearing where possible (CLJ-1250)
* Clear unused bindings
* Attach the correct :tag on instance call/field instances
* Fixes to clear-locals pass regarding nested loops
* Release 0.1.0-beta4 on 17 Feb 2014
* Fix validate-loop-locals to short-circuit on nested loops
* Added docstrings
* Correctly clear closed-overs on :once fns
* Correctly clear closed-overs used in closure creation
* Release 0.1.0-beta3 on 15 Feb 2014
* Added annotate-class-id
* clear-locals clears loop locals when possible
* Release 0.1.0-beta2 on 14 Feb 2014
* Memoize only maybe-class and member*, a new deftype invalidates the cache
* Release 0.1.0-beta1 on 11 Feb 2014
* First beta release
tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/CONTRIBUTING.md 0000664 0000000 0000000 00000001221 13122450003 0023266 0 ustar 00root root 0000000 0000000 This is a [Clojure contrib] project.
Under the Clojure contrib [guidelines], this project cannot accept
pull requests. All patches must be submitted via [JIRA].
See [Contributing] and the [FAQ] on the Clojure development [wiki] for
more information on how to contribute.
[Clojure contrib]: http://dev.clojure.org/display/doc/Clojure+Contrib
[Contributing]: http://dev.clojure.org/display/community/Contributing
[FAQ]: http://dev.clojure.org/display/community/Contributing+FAQ
[JIRA]: http://dev.clojure.org/jira/browse/TANAL
[guidelines]: http://dev.clojure.org/display/community/Guidelines+for+Clojure+Contrib+committers
[wiki]: http://dev.clojure.org/
tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/README.md 0000664 0000000 0000000 00000015142 13122450003 0022323 0 ustar 00root root 0000000 0000000 # tools.analyzer.jvm
An analyzer for Clojure code, written on top of [tools.analyzer](https://github.com/clojure/tools.analyzer), providing additional jvm-specific passes.
* [Example Usage](#example-usage)
* [AST Quickref](#ast-quickref)
* [Releases and Dependency Information](#releases-and-dependency-information)
* [Changelog](#changelog)
* [API Index](#api-index)
* [Developer Information](#developer-information)
* [License](#license)
## Note for REPL usage
The AST `tools.analyzer.jvm` produces contains *a lot* of redundant information and while having this structure in memory will not require an excessive amount of memory thanks to structural sharing, attempting to print the AST of even a relatively small clojure expression can easily produce a several thousand lines output which might make your REPL irresponsive for several seconds or even crash it.
For this reason, when exploring `tools.analyzer.jvm` ASTs on the REPL, I encourage you to:
* set `*print-length*` and `*print-level*` to a small value, like 10
* interactively explore the AST structure, inspecting the `:children` and `:op` fields of a node and the `keys` function rather than printing it to see its content
## Example Usage
Calling `analyze` on the form is all it takes to get its AST (the output has been pretty printed for clarity):
```clojure
user> (require '[clojure.tools.analyzer.jvm :as ana.jvm])
nil
user> (ana.jvm/analyze 1)
{:op :const,
:env {:context :ctx/expr, :locals {}, :ns user},
:form 1,
:top-level true,
:val 1,
:type :number,
:literal? true,
:id 0,
:tag long,
:o-tag long}
```
To get a clojure form out of an AST, use the `emit-form` pass:
```clojure
user> (require '[clojure.tools.analyzer.passes.jvm.emit-form :as e])
nil
user> (e/emit-form (ana.jvm/analyze '(let [a 1] a)))
(let* [a 1] a)
```
Note that the output will be fully macroexpanded.
You can also get an hygienic form back, using the `emit-hygienic-form` pass:
```clojure
user> (e/emit-hygienic-form (ana.jvm/analyze '(let [a 1 a a] a)))
(let* [a__#0 1 a__#1 a__#0] a__#1)
```
As you can see the local names are renamed to resolve shadowing.
The `analyze` function can take an environment arg (when not provided it uses the default empty-env) which allows for more advanced usages, like injecting locals from an outer scope:
```clojure
user> (-> '(let [a a] a)
(ana.jvm/analyze (assoc (ana.jvm/empty-env)
:locals '{a {:op :binding
:name a
:form a
:local :let}}))
e/emit-hygienic-form)
(let* [a__#0 a] a__#0)
```
There's also an `analyze+eval` function that, as the name suggests, evaluates the form after its analysis and stores the resulting value in the `:result` field of the AST, this function should be used when analyzing multiple forms, as the analysis of a clojure form might require the evaluation of a previous one to make sense.
This would not work using `analyze` but works fine when using `analyze+eval`:
```clojure
user> (ana.jvm/analyze+eval '(defmacro x []))
{:op :do,
:top-level true,
:form (do (clojure.core/defn x ([&form &env])) (. (var x) (setMacro)) (var x)),
... ,
:result #'user/x}
user> (ana.jvm/analyze+eval '(x))
{:op :const,
:env {:context :ctx/expr, :locals {}, :ns user},
:form nil,
:top-level true,
:val nil,
:type :nil,
:literal? true,
:tag java.lang.Object,
:o-tag java.lang.Object,
:result nil}
```
To analyze a whole namespace, use `analyze-ns` which behaves like `analyze+eval` and puts the ASTs for each analyzed form in a vector, in order.
```clojure
user> (ana.jvm/analyze-ns 'clojure.string)
[{:op :do,
:result nil,
:top-level true,
:form (do (clojure.core/in-ns (quote clojure.string)) ..),
...}
..]
```
[AST Quickref](http://clojure.github.io/tools.analyzer.jvm/spec/quickref.html)
========================================
Note that the quickref refers to the last stable release of t.a.jvm and might not be valid for the current SNAPSHOT version or for previous ones.
Note also that the documented node fields refer to the output of t.a.jvm/analyze running the default passes and using the default configuration.
## SPONSORSHIP
* Cognitect (http://cognitect.com/) has sponsored tools.analyzer.jvm development (https://groups.google.com/d/msg/clojure/iaP16MHpX0E/EMtnGmOz-rgJ)
* Ambrose BS (https://twitter.com/ambrosebs) has sponsored tools.analyzer.jvm development in his typed clojure campaign (http://www.indiegogo.com/projects/typed-clojure).
## YourKit
YourKit has given an open source license for their profiler, greatly simplifying the profiling of tools.analyzer.jvm performance.
YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:
* YourKit Java Profiler and
* YourKit .NET Profiler.
Releases and Dependency Information
========================================
Latest stable release: 0.7.0
* [All Released Versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22tools.analyzer.jvm%22)
* [Development Snapshot Versions](https://oss.sonatype.org/index.html#nexus-search;gav%7Eorg.clojure%7Etools.analyzer.jvm%7E%7E%7E)
[Leiningen](https://github.com/technomancy/leiningen) dependency information:
```clojure
[org.clojure/tools.analyzer.jvm "0.7.0"]
```
[Maven](http://maven.apache.org/) dependency information:
```xml
org.clojure
tools.analyzer.jvm
0.7.0
```
[Changelog](CHANGELOG.md)
========================================
API Index
========================================
* [CrossClj Documentation](http://crossclj.info/doc/org.clojure/tools.analyzer.jvm/lastest/index.html)
* [API index](http://clojure.github.io/tools.analyzer.jvm)
Developer Information
========================================
* [GitHub project](https://github.com/clojure/tools.analyzer.jvm)
* [Bug Tracker](http://dev.clojure.org/jira/browse/TANAL)
* [Continuous Integration](http://build.clojure.org/job/tools.analyzer.jvm/)
* [Compatibility Test Matrix](http://build.clojure.org/job/tools.analyzer.jvm-test-matrix/)
## License
Copyright © 2013-2017 Nicola Mometto, Rich Hickey & contributors.
Distributed under the Eclipse Public License, the same as Clojure.
tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/docs/ 0000775 0000000 0000000 00000000000 13122450003 0021771 5 ustar 00root root 0000000 0000000 tools.analyzer.jvm-tools.analyzer.jvm-0.7.1/docs/ClojureX_slides.pdf 0000664 0000000 0000000 00000277645 13122450003 0025607 0 ustar 00root root 0000000 0000000 %PDF-1.3
%
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
x}Tn0+(BM F/R P'v!YhKRKpmșݙN'6gB5;xOqh fcɠ5C2>A1!b
dE7H;ZR(~":I.AJILj@3Wo|9Tm]SwǮ|I!%ߡx<&\NIWƗK.w\QJZTE>
endobj
6 0 obj
<< /ProcSet [ /PDF /Text ] /ColorSpace << /Cs2 9 0 R /Cs1 7 0 R >> /Font <<
/TT1 8 0 R >> >>
endobj
11 0 obj
[ 12 0 R 13 0 R ]
endobj
14 0 obj
<< /Length 15 0 R /N 1 /Alternate /DeviceGray /Filter /FlateDecode >>
stream
xWX>HJSF2dATbH!(
--RZ(.nPPKz >|g|= @]ȕHq @8_N¤
@GIp
=`Hr5q(|A:[?
'h%B q*
*kr!ܜ.љ-Mehɖ!6pvC|
ŏDIB