1.1 --- a/docs/structures.txt Sun Apr 05 17:15:59 2009 +0200
1.2 +++ b/docs/structures.txt Mon Apr 06 01:57:40 2009 +0200
1.3 @@ -1,79 +1,6 @@
1.4 Data Structures
1.5 ===============
1.6
1.7 -The fundamental "value type" is a pair of references: one pointing to the
1.8 -referenced object represented by the interchangeable value; one referring to
1.9 -the context of the referenced object, typically the object through which the
1.10 -referenced object was acquired as an attribute.
1.11 -
1.12 -Value Layout
1.13 -------------
1.14 -
1.15 - 0 1
1.16 - object context
1.17 - reference reference
1.18 -
1.19 -Such values are used as the stored representations of attributes (of classes,
1.20 -instances, modules, and other objects supporting attribute-like entities) as
1.21 -well as the stored values associated with names in functions and methods.
1.22 -
1.23 -Stored Values and Contexts
1.24 ---------------------------
1.25 -
1.26 -See assignment.txt for information about contexts and transformations.
1.27 -
1.28 -Acquiring Values
1.29 -----------------
1.30 -
1.31 -There are two classes of instructions which provide values:
1.32 -
1.33 - Instruction Purpose Context Operations
1.34 - ----------- ------- ------------------
1.35 -
1.36 - LoadConst Load class, function, Combine null context with
1.37 - module, constant loaded object
1.38 -
1.39 - LoadAddress Load attribute from Preserve or override stored
1.40 - LoadAddressContext class, module, context (as described in
1.41 - LoadAttr instance assignment.txt)
1.42 - LoadAttrIndex
1.43 -
1.44 -Storing Values
1.45 ---------------
1.46 -
1.47 -There is only one class of instruction for storing values:
1.48 -
1.49 - Instruction Purpose Context Operations
1.50 - ----------- ------- ------------------
1.51 -
1.52 - StoreAddress Store attribute in a Preserve context; note that no
1.53 - known object test for class attribute
1.54 - assignment should be necessary
1.55 - since this instruction should only
1.56 - be generated for module globals
1.57 -
1.58 - StoreAttr Store attribute in an Preserve context; note that no
1.59 - instance test for class attribute
1.60 - assignment should be necessary
1.61 - since this instruction should only
1.62 - be generated for self accesses
1.63 -
1.64 - StoreAttrIndex Store attribute in an Preserve context; since the index
1.65 - unknown object lookup could yield a class
1.66 - attribute, a test of the nature of
1.67 - the nature of the structure is
1.68 - necessary in order to prevent
1.69 - assignments to classes
1.70 -
1.71 -Note that contexts are never changed in the stored value: they are preserved.
1.72 -See assignment.txt for more information.
1.73 -
1.74 -Objects
1.75 --------
1.76 -
1.77 -Since classes, functions and instances are all "objects", each must support
1.78 -certain features and operations in the same way.
1.79 -
1.80 The __class__ Attribute
1.81 -----------------------
1.82
1.83 @@ -95,36 +22,6 @@
1.84 Structure Layout
1.85 ----------------
1.86
1.87 -A suitable structure layout might be something like this:
1.88 -
1.89 - Identifier Identifier Address Details Type Object ...
1.90 -
1.91 - 0 1 2 3 4 5 6
1.92 - classcode attrcode invocation invocation __class__ attribute ...
1.93 - reference #args, reference reference
1.94 - defaults
1.95 - reference
1.96 -
1.97 -Here, the classcode refers to the attribute lookup table for the object. Since
1.98 -classes and instances share the same classcode, they might resemble the
1.99 -following:
1.100 -
1.101 -Class C:
1.102 -
1.103 - 0 1 2 3 4 5 6
1.104 - code for C attrcode __new__ __new__ class type attribute ...
1.105 - for C reference #args, reference reference
1.106 - defaults
1.107 - reference
1.108 -
1.109 -Instance of C:
1.110 -
1.111 - 0 1 2 3 4 5 6
1.112 - code for C attrcode C.__call__ C.__call__ class C attribute ...
1.113 - for C reference #args, reference reference
1.114 - (if exists) defaults
1.115 - reference
1.116 -
1.117 The __new__ reference would lead to code consisting of the following
1.118 instructions:
1.119