1.1 --- a/docs/assignment.txt Sat Feb 28 01:49:33 2009 +0100
1.2 +++ b/docs/assignment.txt Sat Feb 28 19:40:15 2009 +0100
1.3 @@ -61,7 +61,8 @@
1.4 null context preserved
1.5 other context (instance) preserved
1.6
1.7 - LoadAttrIndex must therefore check whether the context must be overridden
1.8 + LoadAddressContext and LoadAttrIndex must therefore check whether the
1.9 + context must be overridden
1.10
1.11 Since the object table encodes sufficient information (an instance must be
1.12 compatible to access the class attribute, and compatibility information is
2.1 --- a/rsvp.py Sat Feb 28 01:49:33 2009 +0100
2.2 +++ b/rsvp.py Sat Feb 28 19:40:15 2009 +0100
2.3 @@ -320,9 +320,9 @@
2.4 self.value = self.load(self.operand)
2.5
2.6 def LoadAddressContext(self):
2.7 - value = self.load(self.operand)
2.8 - # Replace the context with the current value.
2.9 - self.value = self.value[1], value[1]
2.10 + context, ref = self.load(self.operand)
2.11 + inst_context, inst_ref = self.value
2.12 + self.value = self._LoadAddressContext(context, ref, inst_context, inst_ref)
2.13
2.14 def StoreAddress(self):
2.15 # Preserve context.
2.16 @@ -356,10 +356,7 @@
2.17 if attr_index == self.operand:
2.18 if class_attr:
2.19 loaded_context, loaded_ref = self.load(offset) # offset is address of class attribute
2.20 - if replace_context:
2.21 - self.value = ref, loaded_ref # classes can also replace the context if compatible
2.22 - return
2.23 - self.value = loaded_context, loaded_ref
2.24 + self.value = self._LoadAddressContext(loaded_context, loaded_ref, context, ref)
2.25 else:
2.26 self.value = self.load(ref + offset)
2.27 else:
2.28 @@ -549,6 +546,11 @@
2.29 data = self.load(ref)
2.30 target_data = self.load(cls)
2.31
2.32 + # Insist on a class.
2.33 +
2.34 + if target_data.instance:
2.35 + return 0
2.36 +
2.37 # Find the table entry for the descendant.
2.38
2.39 element = self.objlist[target_data.classcode + data.attrcode]
2.40 @@ -562,6 +564,16 @@
2.41 self.save(addr, data)
2.42 return addr
2.43
2.44 + def _LoadAddressContext(self, context, ref, inst_context, inst_ref):
2.45 +
2.46 + # Check the instance context against the target's context.
2.47 +
2.48 + if self._CheckInstance(inst_ref, context):
2.49 + # Replace the context with the instance.
2.50 + return inst_ref, ref
2.51 + else:
2.52 + return context, ref
2.53 +
2.54 # Native function implementations.
2.55
2.56 def builtins_object_init(self):