1.1 --- a/rsvp.py Fri May 22 00:17:35 2009 +0200
1.2 +++ b/rsvp.py Sat May 23 01:46:46 2009 +0200
1.3 @@ -508,17 +508,40 @@
1.4 nlocals -= 1
1.5 else:
1.6 context_data = self.load(context_ref)
1.7 +
1.8 + # Classes are not themselves usable as the self argument.
1.9 + # NOTE: This may change at some point.
1.10 + # However, where classes appear as the context, instance
1.11 + # compatibility is required in the first argument.
1.12 +
1.13 if context_data.attrcode is None: # absent attrcode == class
1.14 +
1.15 + # Slide the frame to exclude the context.
1.16 +
1.17 self.local_sp_stack[-1] += 1
1.18 nlocals -= 1
1.19
1.20 - # NOTE: Should check the context here.
1.21 + # Check the context against the first argument.
1.22 + # NOTE: Raise a proper exception here.
1.23 +
1.24 + if nlocals > 0:
1.25 + self_context, self_ref = self.frame_stack[frame + 1]
1.26 + if not self._CheckInstance(self_ref, context_context):
1.27 + raise Exception, "CheckFrame %r (%r vs. %r)" % (self.operand, self.load(self_ref), self.load(context_context))
1.28 + #self.exception = self.type_error
1.29 + #return self.RaiseException()
1.30 + else:
1.31 + raise Exception, "CheckFrame %r (no self argument)" % self.operand
1.32 + #self.exception = self.type_error
1.33 + #return self.RaiseException()
1.34
1.35 # Test the frame size.
1.36 # NOTE: Raise a proper exception here.
1.37
1.38 if not ((nargs - ndefaults) <= nlocals and (nlocals <= nargs or has_star)):
1.39 raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, nlocals, nargs)
1.40 + #self.exception = self.type_error
1.41 + #return self.RaiseException()
1.42
1.43 def FillDefaults(self):
1.44 # NOTE: Make the get_operand method of the instruction provide the
1.45 @@ -637,8 +660,11 @@
1.46 # Find the table entry for the descendant.
1.47
1.48 element = self.objlist[target_data.classcode + data.attrcode]
1.49 - attr_index, class_attr, offset = element
1.50 - return attr_index == data.attrcode
1.51 + if element is not None:
1.52 + attr_index, class_attr, offset = element
1.53 + return attr_index == data.attrcode
1.54 + else:
1.55 + return 0
1.56
1.57 def _MakeObject(self, size, ref):
1.58 # Load the template.