1.1 --- a/docs/structures.txt Sun Feb 22 02:04:30 2009 +0100
1.2 +++ b/docs/structures.txt Sun Feb 22 22:31:21 2009 +0100
1.3 @@ -20,112 +20,28 @@
1.4 Stored Values and Contexts
1.5 --------------------------
1.6
1.7 -In a program image, generated attribute data will employ values, and these
1.8 -values will generally have the following context definitions according to the
1.9 -type of the referenced objects:
1.10 -
1.11 - Referenced Object Type Context
1.12 - ---------------------- -------
1.13 -
1.14 - Function None
1.15 -
1.16 - Method Parent object (class)
1.17 -
1.18 - Class None
1.19 -
1.20 -Value and Context Transformations
1.21 ----------------------------------
1.22 -
1.23 -Values are acquired through name lookups and attribute access, yielding
1.24 -the appropriate object reference together with a context reference as
1.25 -indicated in the following table:
1.26 -
1.27 - Type of Access Context Notes
1.28 - -------------- ------- -----
1.29 -
1.30 - Local name Preserved Functions provide no context
1.31 -
1.32 - Global name Preserved Modules provide no context
1.33 -
1.34 - Class-originating Accessor Class accessor preserves the stored
1.35 - attribute -or- context; instance accessor overrides
1.36 - Preserved the stored context if it is null or
1.37 - belongs to the instance's class
1.38 - hierarchy
1.39 -
1.40 - Instance-originating Preserved Methods retain their original context
1.41 - attribute
1.42 -
1.43 -There may be some scope for simplifying the above, to the detriment of Python
1.44 -compatibility, since the unbound vs. bound methods situation can be confusing.
1.45 +See assignment.txt for information about contexts and transformations.
1.46
1.47 Acquiring Values
1.48 ----------------
1.49
1.50 -According to the table describing value acquisition, different instructions
1.51 -must implement different operations when acquiring values:
1.52 -
1.53 - Instruction Purpose Context Operations
1.54 - ----------- ------- ------------------
1.55 -
1.56 - LoadConst Load class, function, Combine null context with loaded
1.57 - module, constant object
1.58 +There are two classes of instructions which provide values:
1.59
1.60 - LoadAddress Load attribute from Classes, functions and modules
1.61 - known object cause the loaded attribute to be
1.62 - (typically classes and retrieved unchanged; whereas
1.63 - modules) constants (representing instances)
1.64 - cause the constant to override the
1.65 - attribute's own context (since all
1.66 - attributes should belong to the
1.67 - constant's class hierarchy)
1.68 -
1.69 - LoadAddressContext Load attribute Override loaded context with a
1.70 - from known object predetermined object (provided
1.71 - (typically classes) that the object and context are
1.72 - for an instance compatible, which can be tested at
1.73 - compile-time)
1.74 + Instruction Purpose Context Operations
1.75 + ----------- ------- ------------------
1.76
1.77 - LoadAttr Load attribute from Contexts are preserved (since only
1.78 - instance values stored on instances can be
1.79 - accessed in this way, and their
1.80 - contexts would never be overridden
1.81 - upon access
1.82 -
1.83 - LoadAttrIndex Load attribute from Classes, functions and modules as
1.84 - object (can be the unknown object accessor cause
1.85 - classes, modules, the loaded attribute to be
1.86 - instances...) retrieved unchanged; instances
1.87 - cause the LoadAttr rules to apply
1.88 - (class compatibility applies)
1.89 -
1.90 -A certain amount of run-time testing might be required for both LoadAttr and
1.91 -LoadAttrIndex instructions. However, with certain restrictions in place around
1.92 -class attributes, some simplifications are possible:
1.93 + LoadConst Load class, function, Combine null context with
1.94 + module, constant loaded object
1.95
1.96 - * Since only class-originating attributes may cause context overriding, and
1.97 - since class attributes may only be defined within class definitions, the
1.98 - attributes whose context may be modified should be known at compile-time.
1.99 - (These will be those attributes whose context agrees with their parent
1.100 - class.)
1.101 -
1.102 - * By recording a special context value for attributes whose context can be
1.103 - overridden, this value can be tested efficiently at run-time where the
1.104 - appropriate conditions are satisfied. (This special context value or
1.105 - indicator will be present in the object table record for the attribute.)
1.106 -
1.107 - * It should be possible to move the instance compatibility condition testing
1.108 - to compile-time by testing the compatibility of the origin of an attribute
1.109 - with the class on which it is stored. However, some compatibility testing
1.110 - will still be required if invoking methods via classes, since the instance
1.111 - will be specified in the argument list instead of being presented in an
1.112 - attribute lookup instruction.
1.113 + LoadAddress Load attribute from Preserve or override stored
1.114 + LoadAddressContext class, module, context (as described in
1.115 + LoadAttr instance assignment.txt)
1.116 + LoadAttrIndex
1.117
1.118 Storing Values
1.119 --------------
1.120
1.121 -According to the table describing value acquisition, different instructions
1.122 -must implement different operations when acquiring values:
1.123 +There is only one class of instruction for storing values:
1.124
1.125 Instruction Purpose Context Operations
1.126 ----------- ------- ------------------
1.127 @@ -150,6 +66,7 @@
1.128 assignments to classes
1.129
1.130 Note that contexts are never changed in the stored value: they are preserved.
1.131 +See assignment.txt for more information.
1.132
1.133 Objects
1.134 -------