Full namespace name:
clojure.tools.analyzer OverviewAnalyzer 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.
Usage: (-parse form env)
Takes a form and an env map and dispatches on the head of the form, that is a special form.Source
Usage: (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
No usage documentation available
Like analyze, but does not mark the form with :top-level trueSource
Usage: (analyze-in-env env)
Takes an env map and returns a function that analyzes a form in that envSource
Usage: (create-var sym env)
Creates a var for sym and returns itSource
Usage: (empty-env)
Returns an empty envSource
Usage: (macroexpand form env)
Repeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it.Source
Usage: (macroexpand-1 form env)
If form represents a macro form, returns its expansion, else returns form.Source
Usage: (parse [op & args] env)
Multimethod that dispatches on op, should default to -parseSource
Set of special forms common to every clojure variantSource
Usage: (var? obj)
Returns true if obj represent a var form as returned by create-varSource
Utilities for AST walking/updating
Usage: (ast->eav ast)
Returns an EAV representation of the current AST that can be used by Datomic's Datalog.Source
Usage: (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
Usage: (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
Usage: (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
Usage: (nodes ast)
Returns a lazy-seq of all the nodes in the given AST, in depth-first pre-order.Source
Usage: (postwalk ast f) (postwalk ast f reversed?)
Shorthand for (walk ast identity f reversed?)Source
Usage: (prewalk ast f)
Shorthand for (walk ast f identity)Source
Usage: (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
Usage: (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
Usage: (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
Utilities for querying tools.analyzer ASTs with Datomic
Usage: (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
Usage: (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
Usage: (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
Usage: (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
Usage: (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
Global 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
Usage: (deref-env)
Returns the value of the current global env if bound, otherwise throws an exception.Source
Usage: (ensure env & body)
If *env* is not bound it binds it to env before executing the bodySource
Usage: (with-env env & body)
Binds the global env to env, then executes the bodySource
Utilities for pass scheduling
Usage: (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
Usage: (desugar-deps passes)
Takes a map of pass-name -> pass deps and puts the :after :affects and :before passes in the appropriate pass :dependsSource
Usage: (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
Usage: (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 functionSource
Usage: (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
Usage: (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
No 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
Usage: (elide-meta ast)
If elides is not empty and the AST node contains metadata, dissoc all the keys in elides from the metadata.Source
A 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
Usage: (-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
Usage: (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
Usage: (emit-hygienic-form ast)
Return an hygienic form represented by the given ASTSource
Usage: (index-vector-nodes ast)
Adds an :idx attribute to nodes in a vector children, representing the position of the node vector.Source
Usage: (source-info ast)
Adds (when avaliable) :line, :column, :end-line, :end-column and :file info to the AST :envSource
Usage: (trim ast)
Trims the AST of unnecessary nodes, e.g. (do (do 1)) -> 1Source
Usage: (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
Usage: (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
Usage: (-source-info x env)
Returns the source-info of xSource
Usage: (arglist-for-arity fn argc)
Takes a fn node and an argc and returns the matching arglistSource
Usage: (boolean? x)
Returns true if x is a booleanSource
Usage: (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
Usage: (classify form)
Returns a keyword describing the form typeSource
Usage: (const-val {:keys [form val]})
Returns the value of a constant node (either :quote or :const)Source
Usage: (constant? var) (constant? var m)
Returns true if the var is a constSource
Usage: (ctx env ctx)
Returns a copy of the passed environment with :context set to ctxSource
Usage: (dissoc-env ast)
Dissocs :env from the astSource
Usage: (dynamic? var) (dynamic? var m)
Returns true if the var is dynamicSource
Usage: (into! to from)
Like into, but for transientsSource
Usage: (macro? var) (macro? var m)
Returns true if the var maps to a macroSource
Usage: (mapv' f v)
Like mapv, but short-circuits on reducedSource
Usage: (merge' m & mms)
Like merge, but uses transientsSource
Same as (fn [m1 m2] (merge-with merge m2 m1))Source
Usage: (obj? x)
Returns true if x implements IObjSource
Usage: (private? var) (private? var m)
Returns true if the var is privateSource
Usage: (protocol-node? var) (protocol-node? var m)
Returns true if the var maps to a protocol functionSource
Usage: (record? x)
Returns true if x is a recordSource
Usage: (reference? x)
Returns true if x implements IReferenceSource
Usage: (regex? x)
Returns true if x is a regexSource
Usage: (resolve-ns ns-sym {:keys [ns]})
Resolves the ns mapped by the given sym in the global envSource
Usage: (resolve-sym sym {:keys [ns], :as env})
Resolves the value mapped by the given sym in the global envSource
Usage: (rseqv v)
Same as (comp vec rseq)Source
Usage: (select-keys' map keyseq)
Like clojure.core/select-keys, but uses transients and doesn't preserve metaSource
Usage: (source-info m)
Returns the available source-info keys from a mapSource
Usage: (type? x)
Returns true if x is a typeSource
Usage: (update-keys m f)
Applies f to all the keys in the mapSource
Usage: (update-kv m f)
Applies f to all the keys and vals in the mapSource
Usage: (update-vals m f)
Applies f to all the vals in the mapSource
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4