micropython

docs/annotations.txt

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