cleavir ast
1.0.0Abstract Syntax Tree representation for Common Lisp code.
We define the abstract syntax trees (ASTs) that represent Common Lisp code. The AST is a very close representation of the source code, except that the environment is no longer present, so that there are no longer any different namespaces for functions and variables. And of course, operations such as MACROLET are not present because they only alter the environment.
The AST form is the preferred representation for some operations; in particular for the first stage of PROCEDURE INTEGRATION (sometimes called INLINING). It is the first stage of IR used by Cleavir.
Particular AST classes
There is mostly a different type of AST for each Common Lisp
special operator, but there are some exceptions. Here are the
Common Lisp special operators: BLOCK
, CATCH
, EVAL-WHEN
, FLET
, FUNCTION
, GO
, IF
, LABELS
, LET
, LET*
, LOAD-TIME-VALUE
, LOCALLY
, MACROLET
, MULTIPLE-VALUE-CALL
, MULTIPLE-VALUE-PROG1
, PROGN
, PROGV
, QUOTE
, RETURN-FROM
, SETQ
, SYMBOL-MACROLET
, TAGBODY
, THE
, THROW
, UNWIND-PROTECT
.
Some of these only influence the environment and do not need a
representation as ASTs. These are: LOCALLY
, MACROLET
, and SYMBOL-MACROLET
.
FLET
and LABELS
are like LET
except that the symbols the bind are
in the function namespace, but the distinciton between namespeces
no longer exists in the AST.
A LAMBDA
expression, either inside (FUNCTION (LAMBDA ...))
or when
it is the CAR
of a compound form, compiles into a FUNCTION-AST
.
The other kind of FUNCTION
special form, a function lookup, will end
up as either a LEXICAL-AST
for local functions, or a CONSTANT-FDEFINITION-AST
for global.
We also define ASTs that do not correspond to any Common Lisp special operators, because we simplify later code generation that way.
System Information
Definition Index
-
CLEAVIR-AST
No documentation provided.-
EXTERNAL SPECIAL-VARIABLE *POLICY*
No documentation provided. -
EXTERNAL CLASS AST
The base class for all abstract syntax tree classes.
-
EXTERNAL CLASS BLOCK-AST
AST representing a cl:block.
-
EXTERNAL CLASS BRANCH-AST
This class is a generalization of IF-AST. Based on the TEST-AST, one of the zero or more BRANCH-ASTs, or else the DEFAULT-AST, will be evaluated and its values returned. This AST can be used for example in the implementation of fast CASE or TYPECASE operations.
-
EXTERNAL CLASS CALL-AST
A function call.
-
EXTERNAL CLASS CASE-AST
This AST can be used to select an execution path by comparing a given object against a fixed set of immediates. COMPAREES is a sequence of sequences of objects. If the primary value returned by the ARG-AST is EQ to one of the objects in the nth sequence, the nth branch is taken; if the value doesn't match any immediate the default branch is taken instead. This AST can only appear in the TEST position of a BRANCH-AST.
-
EXTERNAL CLASS CONSTANT-AST
This class represents Lisp constants in source code. If the constant that was found was wrapped in QUOTE, then the QUOTE is not part of the value here, because it was stripped off. If the constant that was found was a constant variable, then the value here represents the value of that constant variable at compile time.
-
EXTERNAL CLASS CONSTANT-DYNAMIC-BIND-AST
This AST represents the binding of a special variable.
-
EXTERNAL CLASS CONSTANT-FDEFINITION-AST
No documentation provided. -
EXTERNAL CLASS CONSTANT-SYMBOL-VALUE-AST
No documentation provided. -
EXTERNAL CLASS EQ-AST
This AST can be used to to test whether two objects are identical. It has two children. This AST can only appear in the TEST position of an IF-AST.
-
EXTERNAL CLASS FUNCTION-AST
A function AST represents an explicit lambda expression, but also implicit lambda expressions such as the ones found in FLET and LABELS. The lambda list is not a normal lambda list. It has the following form: ([r1 .. rl [&optional o1 ..om] [&rest r] [&key k1 .. kn &allow-other-keys]]]) where: - Each ri is a LEXICAL-VARIABLE. - r is a LEXICAL-VARIABLE. - Each oi is a list of two LEXICAL-VARIABLEs. The second of the two conceptually contains a Boolean value indicating whether the first one contains a value supplied by the caller. - Each ki is a list of a symbol and two LEXICAL-VARIABLEs. The symbol is the keyword-name that a caller must supply in order to pass the corresponding argument. The second of the two LEXICAL-VARIABLEs conceptually contains a Boolean value indicating whether the first LEXICAL-VARIABLE contains a value supplied by the caller. The LEXICAL-VARIABLEs in the lambda list are potentially unrelated to the variables that were given in the original lambda expression, and they are LEXICAL-VARIABLEs independently of whether the corresponding variable that was given in the original lambda expression is a lexical variable or a special variable. The body of the FUNCTION-AST must contain code that tests the second of the two LEXICAL-VARIABLEs and initializes variables if needed. The if the second LEXICAL-VARIABLE in any oi contains FALSE, then the code in the body is not allowed to test the second LEXICAL-VARIABLEs of any of the ki because they may not be set correctly (conceptually, they all have the value FALSE then).
-
EXTERNAL CLASS GO-AST
AST for a cl:go. Includes the destination TAG-AST directly, rather than a name. Note that the TAG-AST is not a child (subform).
-
EXTERNAL CLASS IF-AST
This AST corresponds directly to the IF special operator.
-
EXTERNAL CLASS INLINE-AST
An AST inserted around an inline function's AST, used to separate the inlined function from the rest of the code for AST-to-BIR.
-
EXTERNAL CLASS LEXICAL-AST
A reference to a lexical variable.
-
EXTERNAL CLASS LEXICAL-BIND-AST
AST representing the binding of a lexical variable.
-
EXTERNAL CLASS LEXICAL-VARIABLE
Representation of a lexical variable.
-
EXTERNAL CLASS LOAD-TIME-VALUE-AST
This AST corresponds directly to the LOAD-TIME-VALUE special operator. It has no child and it produces a single value. The optional argument READ-ONLY-P is not a child of the AST because it can only be a Boolean which is not evaluated, so we know at AST creation time whether it is true or false.
-
EXTERNAL CLASS MULTIPLE-VALUE-CALL-AST
AST for cl:multiple-value-call. Unlike the special operator, only actual functions are acceptable, not all function designators.
-
EXTERNAL CLASS MULTIPLE-VALUE-PROG1-AST
AST for cl:multiple-value-prog1
-
EXTERNAL CLASS PRIMOP-AST
A PRIMOP-AST represents the invocation of a primitive operator. See the cleavir-primop system for more information.
-
EXTERNAL CLASS PROGN-AST
An AST representing a cl:progn.
-
EXTERNAL CLASS RETURN-FROM-AST
AST representing cl:return-from. This points directly to the corresponding BLOCK-AST rather than recording the name of the block. Note that the BLOCK-AST is not a child (subform).
-
EXTERNAL CLASS SET-CONSTANT-SYMBOL-VALUE-AST
No documentation provided. -
EXTERNAL CLASS SETQ-AST
AST representing SETQ of a lexical variable.
-
EXTERNAL CLASS TAG-AST
The TAG-AST includes the tag itself, and also the code following it that is not after another tag.
-
EXTERNAL CLASS TAGBODY-AST
AST for a cl:tagbody.
-
EXTERNAL CLASS THE-AST
This AST can be generated by from the THE special operator, but also implicitly from type declarations and assignments to variables with type declarations.
-
EXTERNAL CLASS TOP-LEVEL-FUNCTION-AST
This AST is a subclass of FUNCTION-AST. It is used when an AST is transformed by hoisting all the LOAD-TIME-VALUE-ASTs in the tree by turning them into LEXIAL-ASTs that are also required parameters of the TOP-LEVEL-FUNCTION-AST. This AST class supplies a slot that contains a list of the forms that were contained in the LOAD-TIME-VALUE-ASTs. In order to evaluate the original AST, the transformed AST must be called with the values of those forms as arguments.
-
EXTERNAL CLASS TYPEQ-AST
This AST can be thought of as a translation to an AST of a special form (TYPEQ <form> <type-specifier>) which is like the function TYPEP, except that the type specifier is not evaluated.
-
EXTERNAL CLASS UNREACHABLE-AST
This AST indicates an unreachable control point. Control that leads inevitably from or to this AST is declared to be impossible. This impossibility is used by the analyzer without checking.
-
EXTERNAL CLASS UNWIND-PROTECT-AST
AST for a cl:unwind-protect. The cleanup is represented by a FUNCTION-AST with no arguments.
-
EXTERNAL FUNCTION MAKE-BLOCK-AST
- BODY-AST
- &KEY
- NAME
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-BRANCH-AST
- TEST-AST
- BRANCH-ASTS
- DEFAULT-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-CALL-AST
- CALLEE-AST
- ARGUMENT-ASTS
- &KEY
- ORIGIN
- INLINE
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-CASE-AST
- ARG-AST
- COMPAREES
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-CONSTANT-AST
- VALUE
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-CONSTANT-FDEFINITION-AST
- NAME
- &KEY
- ORIGIN
- POLICY
- ATTRIBUTES
No documentation provided. -
EXTERNAL FUNCTION MAKE-CONSTANT-SYMBOL-VALUE-AST
- NAME
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-EQ-AST
- ARG1-AST
- ARG2-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-FUNCTION-AST
- BODY-AST
- LAMBDA-LIST
- &KEY
- NAME
- DOCSTRING
- ORIGINAL-LAMBDA-LIST
- BOUND-DECLARATIONS
- ORIGIN
- POLICY
- ATTRIBUTES
No documentation provided. -
EXTERNAL FUNCTION MAKE-GO-AST
- TAG-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-IF-AST
- TEST-AST
- THEN-AST
- ELSE-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-LEXICAL-AST
- LEXICAL-VARIABLE
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-LEXICAL-BIND-AST
- LEXICAL-VARIABLE
- VALUE-AST
- &KEY
- IGNORE
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-LEXICAL-VARIABLE
- NAME
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-LOAD-TIME-VALUE-AST
- FORM
- &OPTIONAL
- READ-ONLY-P
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-MULTIPLE-VALUE-CALL-AST
- FUNCTION-FORM-AST
- FORM-ASTS
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-MULTIPLE-VALUE-PROG1-AST
- FIRST-FORM-AST
- FORM-ASTS
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-PROGN-AST
- FORM-ASTS
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-RETURN-FROM-AST
- BLOCK-AST
- FORM-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-SET-CONSTANT-SYMBOL-VALUE-AST
- NAME
- VALUE-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-SETQ-AST
- LEXICAL-VARIABLE
- VALUE-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-TAG-AST
- NAME
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-TAGBODY-AST
- PREFIX-AST
- ITEM-ASTS
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-THE-AST
- FORM-AST
- CTYPE
- TYPE-CHECK-FUNCTION-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-TOP-LEVEL-FUNCTION-AST
- BODY-AST
- LAMBDA-LIST
- FORMS
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-TYPEQ-AST
- FORM-AST
- TEST-CTYPE
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAKE-UNREACHABLE-AST
- &KEY
- ORIGIN
- POLICY
No documentation provided. -
EXTERNAL FUNCTION MAP-AST-DEPTH-FIRST-PREORDER
- FUNCTION
- AST
Call FUNCTION on AST and all of its CHILDREN, in depth-first order.
-
EXTERNAL GENERIC-FUNCTION ARG-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ARG1-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ARG2-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ARGUMENT-ASTS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ATTRIBUTES
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION BLOCK-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION BODY-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF BODY-AST)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION BOUND-DECLARATIONS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION BRANCH-ASTS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CALLEE-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CHILDREN
- AST
Return a list of children of an AST. Children are ASTs corresponding to subforms of the AST.
-
EXTERNAL GENERIC-FUNCTION CLEANUP-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION COMPAREES
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CTYPE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION DEFAULT-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION DOCSTRING
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ELSE-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FIRST-FORM-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FORM
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FORM-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FORM-ASTS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FORMS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION FUNCTION-FORM-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION IGNORE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION INFO
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION INLINE-DECLARATION
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ITEM-ASTS
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LAMBDA-LIST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION LEXICAL-VARIABLE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION MAP-CHILDREN
- FUNCTION
- AST
Call FUNCTION on all children of AST.
-
EXTERNAL GENERIC-FUNCTION NAME
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF NAME)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ORIGIN
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF ORIGIN)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION ORIGINAL-LAMBDA-LIST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF ORIGINAL-LAMBDA-LIST)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION POLICY
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION (SETF POLICY)
- NEW-VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION PREFIX-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION READ-ONLY-P
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION TAG-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION TEST-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION TEST-CTYPE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION THEN-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION TYPE-CHECK-FUNCTION-AST
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION VALUE
- OBJECT
No documentation provided. -
EXTERNAL GENERIC-FUNCTION VALUE-AST
- OBJECT
No documentation provided. -
EXTERNAL MACRO DEFINE-CHILDREN
- AST-CLASS
- CHILDREN-SPEC
No documentation provided.
-
-
CLEAVIR-AST-GRAPHVIZ
No documentation provided.