micropython

Annotated docs/annotations.txt

786:ff40924fa22a
2014-03-10 Paul Boddie Added some support for guard annotations, comparing concrete and deduced type information. syspython-as-target
paul@353 1
AST Node Annotations
paul@353 2
====================
paul@353 3
paul@603 4
These annotations are defined in the revised compiler.ast classes.
paul@498 5
paul@646 6
Deduction Results
paul@646 7
-----------------
paul@646 8
paul@698 9
_access_type        ("constant", "static", "positioned", "instance",
paul@698 10
                     "impossible")
paul@669 11
                    defines the kind of access involved for a particular node
paul@646 12
                    and determines which of the following annotations will be
paul@698 13
                    employed, except for "impossible" which indicates an error
paul@698 14
                    condition
paul@669 15
_value_deduced      (_access_type is "constant")
paul@669 16
                    defines a specific result associated with an attribute
paul@646 17
                    access during deduction and based on inspection results
paul@669 18
_attr_deduced       (_access_type is "static" or "instance")
paul@669 19
                    defines an attribute result according to deduction based
paul@646 20
                    on inspection results, with the accessor being the parent
paul@646 21
                    defined in this object for static attributes
paul@669 22
_position_deduced   (_access_type is "positioned")
paul@669 23
                    defines a common position employed by all deduced
paul@646 24
                    attributes for an access operation which is relative to
paul@646 25
                    the accessor evaluated at run time
paul@710 26
_set_context        (_access_type is "constant" or "static")
paul@710 27
                    ("set", "cond", None)
paul@710 28
                    indicates the deduced effect on the context in an access
paul@646 29
                    operation, whether the context would be replaced
paul@646 30
                    unconditionally or conditionally
paul@710 31
                    
paul@646 32
paul@710 33
_attrs_deduced_from_specific_usage
paul@646 34
_attrs_deduced_from_usage
paul@646 35
_attrs_deduced
paul@646 36
                    provided as additional annotations more suitable for
paul@646 37
                    report generation than code generation, since they
paul@646 38
                    describe a range of deduced attributes for a given node,
paul@646 39
                    but such ranges may not lend themselves to the generation
paul@646 40
                    of optimised code
paul@646 41
paul@556 42
Evaluation Results
paul@556 43
------------------
paul@556 44
paul@669 45
_attr               (may identify static attributes for classes and modules,
paul@669 46
                     is otherwise given as a general instance)
paul@669 47
                    notes the result associated with an attribute access
paul@664 48
                    operation during inspection; this may be a general
paul@664 49
                    instance providing no specific information about the
paul@664 50
                    nature of an attribute
paul@603 51
_expr               records the result of evaluating an expression used in an
paul@603 52
                    attribute access operation
paul@556 53
paul@388 54
Attribute Users
paul@388 55
---------------
paul@388 56
paul@571 57
_attrtypes          defines types deduced either from combined attribute usage
paul@571 58
                    details (for users)
paul@712 59
_values             defines a name-to-value mapping for objects that may be
paul@712 60
                    used to access attributes
paul@786 61
_guard_types        mapping from names to ("single", "multiple", "impossible")
paul@786 62
                    defines the nature of any type check upon assignment of an
paul@786 63
                    object to a name/user; an impossible guard occurs when
paul@786 64
                    concrete type information conflicts with deduced type
paul@786 65
                    information
paul@786 66
_guards             a mapping to a set of actual guard types to which the
paul@786 67
                    assigned object must comply
paul@571 68
paul@571 69
Attribute Contributors
paul@571 70
----------------------
paul@571 71
paul@571 72
_attrnames          defines a dictionary mapping local names to sets of
paul@571 73
                    attribute names found to be used with those names in a
paul@571 74
                    branch
paul@599 75
_attrbranches       indicates the immediate contributors to attribute usage
paul@599 76
                    known to a node
paul@599 77
_attrcontributors   defines nodes contributing to combined attribute usage known
paul@723 78
                    to a node (and is thus the accumulation of all contributors
paul@723 79
                    via branches)
paul@723 80
_attrdefs           defines definition-related users which consume usage details
paul@723 81
                    from the node (and is thus the accumulation of all
paul@723 82
                    definitions affected by the node)
paul@599 83
_attrcombined       defines a dictionary mapping local names to sets of
paul@599 84
                    attribute names found to be used with those names for the
paul@599 85
                    entire lifetime of a particular attribute user
paul@489 86
_attrmerged         defines a dictionary mapping local names to sets of
paul@489 87
                    attribute names merging combined observations with locally
paul@489 88
                    applicable observations, indicating usage specific to a
paul@489 89
                    region of the code
paul@490 90
_attrspecifictypes  defines specific types from merged attribute usage details
paul@490 91
                    (for non-user nodes)
paul@388 92
paul@388 93
Attribute Accessors
paul@388 94
-------------------
paul@388 95
paul@488 96
_attrusers          defines a dictionary mapping local names to sets of nodes
paul@488 97
                    defining those names
paul@603 98
_username           indicates the name of the attribute user involved in an
paul@603 99
                    access operation
paul@388 100
paul@388 101
Name Accessors
paul@388 102
--------------
paul@388 103
paul@488 104
_scope              set as "constant", "local", "global" or "builtins"
paul@388 105
paul@388 106
Program Units
paul@388 107
-------------
paul@388 108
paul@488 109
unit                refers to a micropython Class, Function or Module instance