tools.analyzer.jvm AST Quickref
Common AST fields
- :op
- The node op
- :form
- The clojure form from which the node originated
- :env
- The environment map
- :children
- optional A vector of keywords, representing the children nodes of this node, in order of evaluation
- :raw-forms
- optional If this node's
:formhas been macroexpanded, a sequence of all the intermediate forms from the original form to the macroexpanded form - :top-level
- optional
trueif this is the root node - :tag
- The tag this expression is required to have
- :o-tag
- The tag of this expression, based on the node's children
- :ignore-tag
- optional
trueif this node returns a statement rather than an expression - :loops
- optional A set of the loop-ids that might cause this node to recur
Nodes reference
#binding
Node for a binding symbol
- :op
-
:binding - :form
- The binding symbol
- :name
- The uniquified binding symbol
- :local
- One of
:arg,:catch,:fn,:let,:letfn,:loop,:fieldor:this - :arg-id
- optional When
:localis:arg, the parameter index - :variadic?
- optional When
:localis:arg, a boolean indicating whether this parameter binds to a variable number of arguments - :init
- optional When
:localis:let,:letfnor:loop, an AST node representing the bound value - :atom
- An atom shared by this
:bindingnode and all the:localnodes that refer to this binding - :children
-
[],[:init]
#case
Node for a case* special-form expression
- :op
-
:case - :form
(case* expr shift maks default case-map switch-type test-type skip-check?)- :test
- The AST node for the expression to test against
- :tests
- A vector of
:case-testAST nodes, each node has a corresponding:case-thennode in the:thensfield - :thens
- A vector of
:case-thenAST nodes, each node has a corresponding:case-testnode in the:testsfield - :default
- An AST node representing the default value of the case expression
- :shift
- :mask
- :low
- :high
- :switch-type
- One of
:sparseor:compact - :test-type
- One of
:int,:hash-equivor:hash-identity - :skip-check?
- A set of case ints for which equivalence checking should not be done
- :children
-
[:test :tests :thens :default]
#case-test
Node for a test value in a case* expression
- :op
-
:case-test - :test
- A
:constAST node representing the test value - :hash
- :children
-
[:test]
#case-then
Node for a then expression in a case* expression
- :op
-
:case-then - :then
- An AST node representing the expression the case will evaluate to when the
:testexpression matches this node's corresponding:case-testvalue - :hash
- :children
-
[:then]
#catch
Node for a catch expression
- :op
-
:catch - :form
(catch class local body*)- :class
- A
:constAST node with:type:classrepresenting the type of exception to catch - :local
- The
:bindingAST node for the caught exception - :body
- Synthetic
:doAST node (with:body?true) representing the body of the catch clause - :children
-
[:class :local :body]
#const
Node for a constant literal or a quoted collection literal
- :op
-
:const - :form
- A constant literal or a quoted collection literal
- :literal?
true- :type
- one of
:nil,:bool,:keyword,:symbol,:string,:number,:type,:record,:map,:vector,:set,:seq,:char,:regex,:class,:var, or:unknown - :val
- The value of the constant node
- :meta
- optional An AST node representing the metadata of the constant value, if present. The node will be either a
:mapnode or a:constnode with:type:map - :children
-
[],[:meta]
#def
Node for a def special-form expression
- :op
-
:def - :form
(def name docstring? init?)- :name
- The var symbol to define in the current namespace
- :var
- The Var object created (or found, if it already existed) named by the symbol
:namein the current namespace - :meta
- optional An AST node representing the metadata attached to
:name, if present. The node will be either a:mapnode or a:constnode with:type:map - :init
- optional An AST node representing the initial value of the var
- :doc
- optional The docstring for this var
- :children
-
[],[:init],[:meta],[:meta :init]
#deftype
Node for a deftype* special-form expression
- :op
-
:deftype - :form
(deftype* name class.name [arg*]:implements[interface*] method*)- :interfaces
- A set of the interfaces implemented by the type
- :name
- The symbol name of the deftype
- :class-name
- A class for the deftype, should *never* be instantiated or used on instance? checks as this will not be the same class the deftype will evaluate to after compilation
- :fields
- A vector of
:bindingAST nodes with:local:fieldrepresenting the deftype fields - :methods
- A vector
:methodAST nodes representing the deftype methods - :children
-
[:fields :methods]
#do
Node for a do special-form expression or for another special-form's body
- :op
-
:do - :form
(do statement* ret)- :statements
- A vector of AST nodes representing all but the last expression in the do body
- :ret
- An AST node representing the last expression in the do body (the block's return value)
- :body?
- optional
trueif this node is a synthetic body - :children
-
[:statements :ret]
#fn
Node for a fn* special-form expression
- :op
-
:fn - :form
(fn* name? [arg*] body*)or(fn* name? method*)- :variadic?
trueif this function contains a variadic arity method- :max-fixed-arity
- The number of arguments taken by the fixed-arity method taking the most arguments
- :local
- optional A
:bindingAST node with:local:fnrepresenting the function's local name, if one is supplied - :methods
- A vector of
:fn-methodAST nodes representing the fn method arities - :once
trueif the fn is marked as^, meaning it will only be executed once and thus allowing for the clearing of closed-over locals:oncefn*- :children
-
[:methods],[:local :methods]
#fn-method
Node for an arity method in a fn* expression
- :op
-
:fn-method - :form
([arg*] body*)- :loop-id
- Unique symbol identifying this method as a target for recursion
- :variadic?
trueif this fn-method takes a variable number of arguments- :params
- A vector of
:bindingAST nodes with:local:argrepresenting this fn-method args - :fixed-arity
- The number of non-variadic args this fn-method takes
- :body
- Synthetic
:donode (with:body?true) representing the body of this fn-method - :children
-
[:params :body]
#host-interop
Node for a no-arg instance-call or for an instance-field that couldn't be resolved at compile time
- :op
-
:host-interop - :form
(. target m-or-f)- :target
- An AST node representing the target object
- :m-or-f
- Symbol naming the no-arg method or field to lookup in the target
- :assignable?
true- :children
-
[:target]
#if
Node for an if special-form expression
- :op
-
:if - :form
(if test then else?)- :test
- An AST node representing the test expression
- :then
- An AST node representing the expression's return value if
:testevaluated to a truthy value - :else
- An AST node representing the expression's return value if
:testevaluated to a falsey value, if not supplied it will default to a:constnode representing nil - :children
-
[:test :then :else]
#import
Node for a clojure.core/import* special-form expression
- :op
-
:import - :form
(clojure.core/import* "qualified.class")- :class
- String representing the qualified class to import
#instance-call
Node for an instance method call
- :op
-
:instance-call - :form
(.method instance arg*)- :method
- Symbol naming the invoked method
- :instance
- An AST node representing the instance to call the method on
- :args
- A vector of AST nodes representing the args passed to the method call
- :validated?
- optional
trueif the method call could be resolved at compile time - :class
- optional If
:validated?the class or interface the method belongs to - :children
-
[:instance :args]
#instance-field
Node for an instance field access
- :op
-
:instance-field - :form
(.-field instance)- :field
- Symbol naming the field to access
- :instance
- An AST node representing the instance to lookup the symbol on
- :assignable?
trueif the field is set!able- :class
- The class the field belongs to
- :children
-
[:instance]
#instance?
Node for a clojure.core/instance? call where the Class is known at compile time
- :op
-
:instance? - :form
(clojure.core/instance? Class x)- :class
- The Class to test the
:targetfor instanceability - :target
- An AST node representing the object to test for instanceability
- :children
-
[:target]
#invoke
Node for an invoke expression
- :op
-
:invoke - :form
(f arg*)- :fn
- An AST node representing the function to invoke
- :args
- A vector of AST nodes representing the args to the function
- :meta
- optional Map of metadata attached to the invoke
:form - :children
-
[:fn :args]
#keyword-invoke
Node for an invoke expression where the fn is a not-namespaced keyword and thus a keyword callsite can be emitted
- :op
-
:keyword-invoke - :form
(:kinstance)- :keyword
- An AST node representing the keyword to lookup in the instance
- :target
- An AST node representing the instance to lookup the keyword in
- :children
-
[:keyword :target]
#let
Node for a let* special-form expression
- :op
-
:let - :form
(let* [binding*] body*)- :bindings
- A vector of
:bindingAST nodes with:local:let - :body
- Synthetic
:donode (with:body?true) representing the body of the let expression - :children
-
[:bindings :body]
#letfn
Node for a letfn* special-form expression
- :op
-
:letfn - :form
(letfn* [binding*] body*)- :bindings
- A vector of
:bindingAST nodes with:local:letfn - :body
- Synthetic
:donode (with:body?true) representing the body of the letfn expression - :children
-
[:bindings :body]
#local
Node for a local symbol
- :op
-
:local - :form
- The local symbol
- :assignable?
trueif the corresponding:bindingAST node is:local:fieldand is declared either ^:volatile-mutableor ^:unsynchronized-mutable- :name
- The uniquified local symbol
- :local
- One of
:arg,:catch,:fn,:let,:letfn,:loop,:fieldor:this - :arg-id
- optional When
:localis:arg, the parameter index - :variadic?
- optional When
:localis:arg, a boolean indicating whether this parameter binds to a variable number of arguments - :atom
- An atom shared by this
:localnode, the:bindingnode this local refers to and all the other:localnodes that refer to this same local
#loop
Node a loop* special-form expression
- :op
-
:loop - :form
(loop* [binding*] body*)- :bindings
- A vector of
:bindingAST nodes with:local:loop - :body
- Synthetic
:donode (with:body?true) representing the body of the loop expression - :loop-id
- Unique symbol identifying this loop as a target for recursion
- :children
-
[:bindings :body]
#map
Node for a map literal with attached metadata and/or non literal elements
- :op
-
:map - :form
{[key val]*}- :keys
- A vector of AST nodes representing the keys of the map
- :vals
- A vector of AST nodes representing the vals of the map
- :children
-
[:keys :vals]
#method
Node for a method in a deftype* or reify* special-form expression
- :op
-
:method - :form
(method [this arg*] body*)- :bridges
- A list of signature for bridge methods to emit
- :interface
- The interface (or Object) this method belongs to
- :this
- A
:bindingAST node with:local:thisrepresenting the "this" local - :loop-id
- Unique symbol identifying this method as a target for recursion
- :name
- The symbol name of this method
- :params
- A vector of AST
:bindingnodes with:local:argrepresenting the arguments of the method - :fixed-arity
- The number of args this method takes
- :body
- Synthetic
:donode (with:body?true) representing the body of this method - :children
-
[:this :params :body]
#monitor-enter
Node for a monitor-enter special-form statement
- :op
-
:monitor-enter - :form
(monitor-enter target)- :target
- An AST node representing the monitor-enter sentinel
- :children
-
[:target]
#monitor-exit
Node for a monitor-exit special-form statement
- :op
-
:monitor-exit - :form
(monitor-exit target)- :target
- An AST node representing the monitor-exit sentinel
- :children
-
[:target]
#new
Node for a new special-form expression
- :op
-
:new - :form
(new Class arg*)- :class
- A
:constAST node with:type:classrepresenting the Class to instantiate - :args
- A vector of AST nodes representing the arguments passed to the Class constructor
- :validated?
- optional
trueif the constructor call could be resolved at compile time - :children
-
[:class :args]
#prim-invoke
Node for an invoke expression that can be optimized using one of the primitive interfaces in IFn
- :op
-
:prim-invoke - :form
(prim-f arg*)- :fn
- An AST node representing the function to invoke
- :args
- A vector of AST nodes representing the args to the function
- :prim-interface
- The primitive interface in IFn that will be used
- :meta
- optional Map of metadata attached to the invoke
:form - :children
-
[:fn :args]
#protocol-invoke
Node for an invoke expression where the function is a protocol function var
- :op
-
:protocol-invoke - :form
(proto-fn target arg*)- :protocol-fn
- An AST node representing the protocol function var to invoke
- :target
- An AST node representing the target of the protocol function call
- :args
- A vector of AST nodes representing the args to the protocol function
- :children
-
[:protocol-fn :target :args]
#quote
Node for a quote special-form expression
- :op
-
:quote - :form
(quote expr)- :expr
- A
:constAST node representing the quoted value - :literal?
true- :children
-
[:expr]
#recur
Node for a recur special-form expression
- :op
-
:recur - :form
(recur expr*)- :exprs
- A vector of AST nodes representing the new bound values for the loop binding on the next loop iteration
- :loop-id
- Unique symbol identifying the enclosing loop target
- :children
-
[:exprs]
#reify
Node for a reify* special-form expression
- :op
-
:reify - :form
(reify* [interface*] method*)- :interfaces
- A set of the interfaces implemented by the generated type
- :class-name
- The generated class for the reify, should *never* be instantiated or used on instance? checks
- :methods
- A vector
:methodAST nodes representing the reify methods - :children
-
[:methods]
#set
Node for a set literal with attached metadata and/or non literal elements
- :op
-
:set - :form
#{item*}- :items
- A vector of AST nodes representing the items of the set
- :children
-
[:items]
#set!
Node for a set! special-form expression
- :op
-
:set! - :form
(set! target val)- :target
- An AST node representing the target of the set! expression, must be
:assignable? - :val
- An AST node representing the new value for the target
- :children
-
[:target :val]
#static-call
Node for a static method call
- :op
-
:static-call - :form
(Class/method arg*)- :class
- The Class the static method belongs to
- :method
- The symbol name of the static method
- :args
- A vector of AST nodes representing the args to the method call
- :validated?
- optional
trueif the static method could be resolved at compile time - :children
-
[:args]
#static-field
Node for a static field access
- :op
-
:static-field - :form
Class/field- :class
- The Class the static field belongs to
- :field
- The symbol name of the static field
- :assignable?
- optional
trueif the static field is set!able
#the-var
Node for a var special-form expression
- :op
-
:the-var - :form
(var var-name)- :var
- The Var object this expression refers to
#throw
Node for a throw special-form statement
- :op
-
:throw - :form
(throw exception)- :exception
- An AST node representing the exception to throw
- :children
-
[:exception]
#try
Node for a try special-form expression
- :op
-
:try - :form
(try body* catch* finally?)- :body
- Synthetic
:doAST node (with:body?true) representing the body of this try expression - :catches
- A vector of
:catchAST nodes representing the catch clauses of this try expression - :finally
- optional Synthetic
:doAST node (with:body?true) representing the final clause of this try expression - :children
-
[:body :catches],[:body :catches :finally]
#var
Node for a var symbol
- :op
-
:var - :form
- A symbol naming the var
- :var
- The Var object this symbol refers to
- :assignable?
- optional
trueif the Var is:dynamic
#vector
Node for a vector literal with attached metadata and/or non literal elements
- :op
-
:vector - :form
[item*]- :items
- A vector of AST nodes representing the items of the vector
- :children
-
[:items]
#with-meta
Node for a non quoted collection literal or fn/reify expression with attached metadata
- :op
-
:with-meta - :form
- Non quoted collection literal or fn/reify expression with attached metadata
- :meta
- An AST node representing the metadata of expression. The node will be either a
:mapnode or a:constnode with:type:map - :expr
- The expression this metadata is attached to,
:opis one of:vector,:map,:set,:fnor:reify - :children
-
[:meta :expr]