1.1 --- a/docs/structures.txt Wed Aug 13 19:42:59 2008 +0200
1.2 +++ b/docs/structures.txt Sun Aug 17 02:16:35 2008 +0200
1.3 @@ -39,8 +39,8 @@
1.4 There may be some scope for simplifying the above, to the detriment of Python
1.5 compatibility, since the unbound vs. bound methods situation can be confusing.
1.6
1.7 -Manipulating Values
1.8 --------------------
1.9 +Acquiring Values
1.10 +----------------
1.11
1.12 According to the table describing value acquisition, different instructions
1.13 must implement different operations when acquiring values:
1.14 @@ -52,31 +52,75 @@
1.15 module, constant object
1.16
1.17 LoadAddress Load attribute from Classes, functions and modules
1.18 - known object stored as cause the loaded attribute to be
1.19 - an attribute retrieved unchanged; whereas
1.20 + known object cause the loaded attribute to be
1.21 + retrieved unchanged; whereas
1.22 constants (representing instances)
1.23 cause the constant to override the
1.24 attribute's own context (since all
1.25 attributes should belong to the
1.26 constant's class hierarchy)
1.27
1.28 + LoadAddressContext Override loaded context with a
1.29 + predetermined object
1.30 +
1.31 LoadAttr Load attribute from Attributes with null contexts or
1.32 - instance stored as an contexts compatible with the
1.33 - attribute instance cause loaded attributes
1.34 + instance contexts compatible with the
1.35 + instance cause loaded attributes
1.36 to combine the instance as context
1.37 with the object from the
1.38 attribute; other attributes have
1.39 their context preserved
1.40
1.41 LoadAttrIndex Load attribute from Classes, functions and modules as
1.42 - unknown object stored the unknown object accessor cause
1.43 - as an attribute the loaded attribute to be
1.44 + unknown object the unknown object accessor cause
1.45 + the loaded attribute to be
1.46 retrieved unchanged; whereas
1.47 instances cause the LoadAttr rules
1.48 to apply
1.49
1.50 -Consequently, a certain amount of run-time testing is required for both
1.51 -LoadAttr and LoadAttrIndex.
1.52 +A certain amount of run-time testing might be required for both LoadAttr and
1.53 +LoadAttrIndex instructions. However, with certain restrictions in place around
1.54 +class attributes, some simplifications are possible:
1.55 +
1.56 + * Since only class-originating attributes may cause context overriding, and
1.57 + since class attributes may only be defined within class definitions, the
1.58 + attributes whose context may be modified should be known at compile-time.
1.59 +
1.60 + * By recording a special context value for attributes whose context can be
1.61 + overridden, this value can be tested efficiently at run-time where the
1.62 + appropriate conditions are satisfied.
1.63 +
1.64 + * It should be possible to move the instance compatibility condition testing
1.65 + to compile-time by testing the compatibility of the origin of an attribute
1.66 + with the class on which it is stored.
1.67 +
1.68 +Storing Values
1.69 +--------------
1.70 +
1.71 +According to the table describing value acquisition, different instructions
1.72 +must implement different operations when acquiring values:
1.73 +
1.74 + Instruction Purpose Context Operations
1.75 + ----------- ------- ------------------
1.76 +
1.77 + StoreAddress Store attribute in a Preserve context; note that no
1.78 + known object test for class attribute
1.79 + assignment should be necessary
1.80 + since this instruction should only
1.81 + be generated for module globals
1.82 +
1.83 + StoreAttr Store attribute in an Preserve context; note that no
1.84 + instance test for class attribute
1.85 + assignment should be necessary
1.86 + since this instruction should only
1.87 + be generated for self accesses
1.88 +
1.89 + StoreAttrIndex Store attribute in an Preserve context; since the index
1.90 + unknown object lookup could yield a class
1.91 + attribute, a test of the nature of
1.92 + the nature of the structure is
1.93 + necessary in order to prevent
1.94 + assignments to classes
1.95
1.96 Objects
1.97 -------