GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing clojure.github.io — clojure.tools.analyzer - tools.analyzer 1.1.2-SNAPSHOT API documentation API for clojure.tools.analyzer - tools.analyzer 1.1.2-SNAPSHOT (in development)Full namespace name: clojure.tools.analyzer OverviewProject home page is https://github.com/clojure/tools.analyzer/
Analyzer for clojure code, host agnostic. Entry point: * analyze Platform implementers must provide dynamic bindings for: * macroexpand-1 * parse * create-var * var? Setting up the global env is also required, see clojure.tools.analyzer.env See clojure.tools.analyzer.core-test for an example on how to setup the analyzer. Public Variables and Functions-parsefunctionUsage: (-parse form env) Takes a form and an env map and dispatches on the head of the form, that is a special form.Source analyzefunctionUsage: (analyze form env) Given a form to analyze and an environment, a map containing:
* :locals a map from binding symbol to AST of the binding value
* :context a keyword describing the form's context from the :ctx/* hierarchy.
** :ctx/expr the form is an expression: its value is used
** :ctx/return the form is an expression in return position, derives :ctx/expr
** :ctx/statement the value of the form is not used
* :ns a symbol representing the current namespace of the form to be
analyzed
returns an AST for that form.
Every node in the AST is a map that is *guaranteed* to have the following keys:
* :op a keyword describing the AST node
* :form the form represented by the AST node
* :env the environment map of the AST node
Additionally if the AST node contains sub-nodes, it is guaranteed to have:
* :children a vector of the keys of the AST node mapping to the sub-nodes,
ordered, when that makes sense
It is considered a node either the top-level node (marked with :top-level true)
or a node that can be reached via :children; if a node contains a node-like
map that is not reachable by :children, there's no guarantee that such a map
will contain the guaranteed keys.
Source
analyze-formdynamic multimethodNo usage documentation available Like analyze, but does not mark the form with :top-level trueSource analyze-in-envfunctionUsage: (analyze-in-env env) Takes an env map and returns a function that analyzes a form in that envSource macroexpandfunctionUsage: (macroexpand form env) Repeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it.Source macroexpand-1dynamic functionUsage: (macroexpand-1 form env) If form represents a macro form, returns its expansion, else returns form.Source parsedynamic functionUsage: (parse [op & args] env) Multimethod that dispatches on op, should default to -parseSource var?dynamic functionUsage: (var? obj) Returns true if obj represent a var form as returned by create-varSource clojure.tools.analyzer.astUtilities for AST walking/updating Public Variables and Functionsast->eavfunctionUsage: (ast->eav ast) Returns an EAV representation of the current AST that can be used by Datomic's Datalog.Source childrenfunctionUsage: (children ast) Return a vector of the children expression of the AST node, if it has any. The children expressions are kept in order and flattened so that the returning vector contains only nodes and not vectors of nodes.Source children*functionUsage: (children* {:keys [children], :as ast})
Return a vector of vectors of the children node key and the children expression of the AST node, if it has any. The returned vector returns the children in the order as they appear in the :children field of the AST, and the children expressions may be either a node or a vector of nodes.Source cyclingfunctionUsage: (cycling & fns*) Combine the given passes in a single pass that will be applied repeatedly to the AST until applying it another time will have no effectSource nodesfunctionUsage: (nodes ast) Returns a lazy-seq of all the nodes in the given AST, in depth-first pre-order.Source postwalkfunctionUsage: (postwalk ast f)
(postwalk ast f reversed?)
Shorthand for (walk ast identity f reversed?)Source update-childrenfunctionUsage: (update-children ast f)
(update-children ast f reversed?)
Applies `f` to each AST children node, replacing it with the returned value. If reversed? is not-nil, `pre` and `post` will be applied starting from the last children of the AST node to the first one. Short-circuits on reduced.Source update-children-reducedfunctionUsage: (update-children-reduced ast f)
(update-children-reduced ast f reversed?)
Like update-children but returns a reduced holding the AST if f short-circuited.Source walkfunctionUsage: (walk ast pre post)
(walk ast pre post reversed?)
Walk the ast applying `pre` when entering the nodes, and `post` when exiting. Both functions must return a valid node since the returned value will replace the node in the AST which was given as input to the function. If reversed? is not-nil, `pre` and `post` will be applied starting from the last children of the AST node to the first one. Short-circuits on reduced.Source clojure.tools.analyzer.ast.queryUtilities for querying tools.analyzer ASTs with Datomic Public Variables and FunctionsdbfunctionUsage: (db asts) Given a list of ASTs, returns a representation of those that can be used as a database in a Datomic Datalog query.Source qfunctionUsage: (q query asts & inputs) Execute a Datomic Datalog query against the ASTs. The first input is always assumed to be an AST database, if more are required, it's required to call `db` on them. `unfold-expression-clauses` is automatically applied to the query.Source query-mapfunctionUsage: (query-map query) Transforms a Datomic query from its vector representation to its map one. If the given query is already in its map representation, the original query is returned.Source resolve-callsfunctionUsage: (resolve-calls query) Automatically replace fn name symbols in expression clauses with their namespace qualified one if the symbol can be resolved in the current namespace.Source unfold-expression-clausesfunctionUsage: (unfold-expression-clauses query) Given a Datomic query, walk the :where clauses searching for
expression clauses with nested calls, unnesting those calls.
E.g {:where [[(inc (dec ?foo)) ?bar] ..] ..} will be transformed into
{:where [[(dec ?foo) ?1234] [(inc ?1234) ?bar] ..] ..}
Source
clojure.tools.analyzer.envPublic Variables and Functions*env*dynamic varGlobal env atom containing a map. Required options: * :namespaces a map from namespace symbol to namespace map, the namespace map contains at least the following keys: ** :mappings a map of mappings of the namespace, symbol to var/class ** :aliases a map of the aliases of the namespace, symbol to symbol ** :ns a symbol representing the namespaceSource deref-envfunctionUsage: (deref-env) Returns the value of the current global env if bound, otherwise throws an exception.Source ensuremacroUsage: (ensure env & body) If *env* is not bound it binds it to env before executing the bodySource with-envmacroUsage: (with-env env & body) Binds the global env to env, then executes the bodySource clojure.tools.analyzer.passesUtilities for pass scheduling Public Variables and Functionscalculate-depsfunctionUsage: (calculate-deps passes) Takes a map of pass-name -> pass-info and adds to each pass-info :dependencies and :dependants info, which also contains the transitive dependenciesSource desugar-depsfunctionUsage: (desugar-deps passes) Takes a map of pass-name -> pass deps and puts the :after :affects and :before passes in the appropriate pass :dependsSource groupfunctionUsage: (group state) Takes a scheduler state and returns a vector of three elements (or nil):
* the :walk of the current group
* a vector of consecutive passes that can be collapsed in a single pass (the current group)
* the remaining scheduler state
E.g. given:
[{:walk :any ..} {:walk :pre ..} {:walk :post ..} {:walk :pre ..}]
it will return:
[:pre [{:walk :any ..} {:walk :pre ..}] [{:walk :post ..} {:walk :pre ..}]]
Source
schedulefunctionUsage: (schedule passes & [opts]) Takes a set of Vars that represent tools.analyzer passes and returns a function
that takes an AST and applies all the passes and their dependencies to the AST,
trying to compose together as many passes as possible to reduce the number of
full tree traversals.
Each pass must have a :pass-info element in its Var's metadata and it must point
to a map with the following parameters (:before, :after, :affects and :state are
optional):
* :after a set of Vars, the passes that must be run before this pass
* :before a set of Vars, the passes that must be run after this pass
* :depends a set of Vars, the passes this pass depends on, implies :after
* :walk a keyword, one of:
- :none if the pass does its own tree walking and cannot be composed
with other passes
- :post if the pass requires a postwalk and can be composed with other
passes
- :pre if the pass requires a prewalk and can be composed with other
passes
- :any if the pass can be composed with other passes in both a prewalk
or a postwalk
* :affects a set of Vars, this pass must be the last in the same tree traversal that all
the specified passes must participate in
This pass must take a function as argument and return the actual pass, the
argument represents the reified tree traversal which the pass can use to
control a recursive traversal, implies :depends
* :state a no-arg function that should return an atom holding an init value that will be
passed as the first argument to the pass (the pass will thus take the ast
as the second parameter), the atom will be the same for the whole tree traversal
and thus can be used to preserve state across the traversal
An opts map might be provided, valid parameters:
* :debug? if true, returns a vector of the scheduled passes rather than the concrete
function
Source
clojure.tools.analyzer.passes.add-binding-atomPublic Variables and Functionsadd-binding-atomfunctionUsage: (add-binding-atom ast)
(add-binding-atom state ast)
Adds an atom-backed-map to every local binding,the same atom will be shared between all occurences of that local. The atom is put in the :atom field of the node.Source clojure.tools.analyzer.passes.collect-closed-oversPublic Variables and Functionscollect-closed-oversfunctionUsage: (collect-closed-overs ast) Attach closed-overs info to the AST as specified by the passes opts: * :where set of :op nodes where to attach the closed-overs * :top-level? if true attach closed-overs info to the top-level node The info will be attached in the :closed-overs field of the AST node and will be a map of local name -> binding AST nodeSource clojure.tools.analyzer.passes.constant-lifterPublic Variables and Functionsconstant-liftmultimethodNo usage documentation available If the node represents a collection with no metadata, and every item of that collection is a literal, transform the node to an equivalent :const node.Source clojure.tools.analyzer.passes.elide-metaPublic Variables and Functionselide-metafunctionUsage: (elide-meta ast) If elides is not empty and the AST node contains metadata, dissoc all the keys in elides from the metadata.Source elidesdynamic varA map of op keywords to predicate IFns.
The predicate will be used to indicate what map keys should be elided on
metadata of nodes for that op.
:all can be used to indicate what should be elided for every node with
metadata.
Defaults to {:all (set (:elide-meta *compiler-options*))}
Source
clojure.tools.analyzer.passes.emit-formPublic Variables and Functions-emit-form*dynamic functionUsage: (-emit-form* {:keys [form], :as ast} opts)
Extension point for custom emit-form implementations, should be rebound to a multimethod with custom emit-form :opts.Source emit-formfunctionUsage: (emit-form ast)
(emit-form ast opts)
Return the form represented by the given AST. Opts is a set of options, valid options are: * :hygienicSource emit-hygienic-formfunctionUsage: (emit-hygienic-form ast) Return an hygienic form represented by the given ASTSource clojure.tools.analyzer.passes.index-vector-nodesPublic Variables and Functionsindex-vector-nodesfunctionUsage: (index-vector-nodes ast) Adds an :idx attribute to nodes in a vector children, representing the position of the node vector.Source clojure.tools.analyzer.passes.source-infoPublic Variables and Functionssource-infofunctionUsage: (source-info ast) Adds (when avaliable) :line, :column, :end-line, :end-column and :file info to the AST :envSource clojure.tools.analyzer.passes.trimPublic Variables and Functionsclojure.tools.analyzer.passes.uniquifyPublic Variables and Functionsuniquify-localsfunctionUsage: (uniquify-locals ast) Walks the AST performing alpha-conversion on the :name field of :local/:binding nodes, invalidates :local map in :env field Passes opts: * :uniquify/uniquify-env If true, uniquifies the :env :locals mapSource clojure.tools.analyzer.passes.warn-earmuffPublic Variables and Functionswarn-earmufffunctionUsage: (warn-earmuff ast) Prints a warning to *err* if the AST node is a :def node and the var name contains earmuffs but the var is not marked dynamicSource clojure.tools.analyzer.utilsPublic Variables and Functionsarglist-for-arityfunctionUsage: (arglist-for-arity fn argc) Takes a fn node and an argc and returns the matching arglistSource butlast+lastfunctionUsage: (butlast+last s) Returns same value as (juxt butlast last), but slightly more efficient since it only traverses the input sequence s once, not twice.Source const-valfunctionUsage: (const-val {:keys [form val]})
Returns the value of a constant node (either :quote or :const)Source constant?functionUsage: (constant? var)
(constant? var m)
Returns true if the var is a constSource ctxfunctionUsage: (ctx env ctx) Returns a copy of the passed environment with :context set to ctxSource protocol-node?functionUsage: (protocol-node? var)
(protocol-node? var m)
Returns true if the var maps to a protocol functionSource resolve-nsfunctionUsage: (resolve-ns ns-sym {:keys [ns]})
Resolves the ns mapped by the given sym in the global envSource resolve-symfunctionUsage: (resolve-sym sym {:keys [ns], :as env})
Resolves the value mapped by the given sym in the global envSource select-keys'functionUsage: (select-keys' map keyseq) Like clojure.core/select-keys, but uses transients and doesn't preserve metaSource source-infofunctionUsage: (source-info m) Returns the available source-info keys from a mapSource Copyright 2007-2023 by Rich Hickey and the various contributors
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |