1.1 --- a/rsvp.py Sat Feb 28 01:49:33 2009 +0100
1.2 +++ b/rsvp.py Sat Feb 28 19:40:15 2009 +0100
1.3 @@ -320,9 +320,9 @@
1.4 self.value = self.load(self.operand)
1.5
1.6 def LoadAddressContext(self):
1.7 - value = self.load(self.operand)
1.8 - # Replace the context with the current value.
1.9 - self.value = self.value[1], value[1]
1.10 + context, ref = self.load(self.operand)
1.11 + inst_context, inst_ref = self.value
1.12 + self.value = self._LoadAddressContext(context, ref, inst_context, inst_ref)
1.13
1.14 def StoreAddress(self):
1.15 # Preserve context.
1.16 @@ -356,10 +356,7 @@
1.17 if attr_index == self.operand:
1.18 if class_attr:
1.19 loaded_context, loaded_ref = self.load(offset) # offset is address of class attribute
1.20 - if replace_context:
1.21 - self.value = ref, loaded_ref # classes can also replace the context if compatible
1.22 - return
1.23 - self.value = loaded_context, loaded_ref
1.24 + self.value = self._LoadAddressContext(loaded_context, loaded_ref, context, ref)
1.25 else:
1.26 self.value = self.load(ref + offset)
1.27 else:
1.28 @@ -549,6 +546,11 @@
1.29 data = self.load(ref)
1.30 target_data = self.load(cls)
1.31
1.32 + # Insist on a class.
1.33 +
1.34 + if target_data.instance:
1.35 + return 0
1.36 +
1.37 # Find the table entry for the descendant.
1.38
1.39 element = self.objlist[target_data.classcode + data.attrcode]
1.40 @@ -562,6 +564,16 @@
1.41 self.save(addr, data)
1.42 return addr
1.43
1.44 + def _LoadAddressContext(self, context, ref, inst_context, inst_ref):
1.45 +
1.46 + # Check the instance context against the target's context.
1.47 +
1.48 + if self._CheckInstance(inst_ref, context):
1.49 + # Replace the context with the instance.
1.50 + return inst_ref, ref
1.51 + else:
1.52 + return context, ref
1.53 +
1.54 # Native function implementations.
1.55
1.56 def builtins_object_init(self):