The analysis package takes standard compiler.ast
nodes and annotates them with additional information which is then used
in subsequent activities such as code generation and documentation.
Below are tables showing the annotations used for various AST nodes:
Node | Annotation | Purpose |
---|---|---|
* | _contexts | Indicates the types that the node is considered to have, along with the context in which it has them. A dictionary mapping contexts to types/references. |
Node | Annotation | Purpose |
---|---|---|
Function Module Class Reference Stmt |
_namespace | A dictionary mapping names to lists of defining nodes for each name. Some Stmt nodes have _namespace annotations when employed by conditional or loop nodes. |
Function | _globals | Provides a list of globals used in the function. |
Name | _scope | Indicates which scope the name uses to refer to a variable. Examples: "local", "global". |
Name AssName Class Function Getattr |
_name_context | Indicates
the kind of local scope in which the name resides, or in the case of
Getattr the kind of scope from which the attribute was retrieved. (This
does not apply to AssAttr since the kind of scope can be inferred from
the type of node involved, whereas Getattr may involve either class or
instance attribute access.) Examples: "class", "instance". |
Module | _constants_table | A list of constants in the module. |
Module | _module_name | Same as _qualified_name. |
Name AssName Module Class Function |
_qualified_name | Provides a qualified name for use in generated code (where appropriate) - see _name_context for additional guidance. |
Node | Annotation | Purpose |
---|---|---|
Reference | _class |
Indicates the class of a particular reference. |
Class | _instances | A list of instances (references) for a given class. |
CallFunc Const List Compare |
_instantiates | Indicates that the node instantiates a particular reference. |
Node | Annotation | Purpose |
---|---|---|
Compare | _ops |
A list of operator objects summarising the binary operations employed in the comparison. |
* | _ignored | Indicates that the block associated with a test in a conditional statement would be ignored due to the test always yielding a false value. |
* | _short_circuited | Indicates that the block associated with a test in a conditional statement would always be executed in preference to following blocks and that such following blocks and their associated test nodes need not be generated. |
* | _original | Indicates the original node used to produce a node within a specialisation. |
* | _parent | Indicates the parent node of a node - useful for adding sibling nodes (specialisations of functions) or for tracking the processing of expressions (assignment processing). |
Function | _specialisation | An attribute whose presence indicates that the node and its children represent a specialisation (as opposed to an original function). |
Function | _signatures | A list of signatures each corresponding to a specialisation in the _specialisations annotation; together, these annotations should be considered as a table. |
Function | _specialisations | A list of specialisations created for a particular function. |
CallFunc AssTuple AssList List |
_targets | A list, representing a sequence of invocations, containing lists of specialisations that may be involved in each invocation. |
CallFunc AssTuple AssList List |
_args | A list, representing a sequence of invocations, containing argument lists that are associated with each invocation's target specialisations. |
CallFunc AssTuple AssList List |
_refcontexts | A list containing the meaning of references employed in the node's _args attribute. Examples: "new" (used in instantiation), "context" (used in method calls), "pop" (used when obtaining temporary expressions), "top" (used to obtain the current subexpression). |
CallFunc | _star_args | A list, representing a sequence of invocations, containing argument lists that are associated with each invocation's target specialisations. |
CallFunc | _dstar_args | A list, representing a sequence of invocations, containing argument lists that are associated with each invocation's target specialisations. |