1.1 --- a/rsvp.py Sat Feb 07 22:04:24 2009 +0100
1.2 +++ b/rsvp.py Sun Feb 08 23:48:47 2009 +0100
1.3 @@ -117,7 +117,7 @@
1.4 # Native class constants.
1.5
1.6 cls = objlist.access("__builtins__", "int")
1.7 - self.int_class = cls and cls.value.location
1.8 + self.int_instance_location = cls and cls.value.instance_template_location
1.9
1.10 # Debugging methods.
1.11
1.12 @@ -329,18 +329,21 @@
1.13 def MakeObject(self):
1.14 size = self.operand
1.15 context, ref = self.value
1.16 - addr = self._MakeObject(size, ref)
1.17 - # Introduce null context for new object.
1.18 + # NOTE: Referencing the instance template.
1.19 + addr = self._MakeObject(size, ref - 1)
1.20 + # Introduce object as context for the new object.
1.21 self.value = None, addr
1.22
1.23 def LoadAttr(self):
1.24 context, ref = self.value
1.25 # Retrieved context should already be appropriate for the instance.
1.26 + # NOTE: Adding 1 to skip any header.
1.27 self.value = self.load(ref + self.operand + 1)
1.28
1.29 def StoreAttr(self):
1.30 context, ref = self.value
1.31 # Target should already be an instance.
1.32 + # NOTE: Adding 1 to skip any header.
1.33 self.save(ref + self.operand + 1, self.source)
1.34
1.35 def LoadAttrIndex(self):
1.36 @@ -392,10 +395,11 @@
1.37 self.frame_stack[frame + self.operand] = self.value
1.38
1.39 def StoreFrameIndex(self):
1.40 + context, ref = self.value
1.41 frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.42 data = self.load(ref)
1.43 element = self.objlist[data.classcode + self.operand]
1.44 - attr_index, offset = element
1.45 + attr_index, class_attr, replace_context, offset = element
1.46 if attr_index == self.operand:
1.47 self.frame_stack[frame + offset] = self.value
1.48 else:
1.49 @@ -434,8 +438,8 @@
1.50 operand -= 1
1.51
1.52 nargs, ndefaults = data.codedetails
1.53 - if not (nargs - ndefaults <= operand <= nargs):
1.54 - raise Exception, "CheckFrame %r" % (nargs - ndefaults, self.operand, nargs)
1.55 + if not ((nargs - ndefaults) <= operand <= nargs):
1.56 + raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, operand, nargs)
1.57
1.58 # NOTE: Support population of defaults.
1.59
1.60 @@ -535,7 +539,7 @@
1.61 data = self.load(ref)
1.62 addr = self.new(size)
1.63 # Set the header to resemble the class.
1.64 - self.save(addr, DataObject(data.classcode, data.attrcode, None, None, 1, data.name)) # NOTE: __call__ method not yet provided.
1.65 + self.save(addr, data)
1.66 return addr
1.67
1.68 # Native function implementations.
1.69 @@ -567,7 +571,7 @@
1.70
1.71 # Make a new object.
1.72
1.73 - addr = self._MakeObject(2, self.int_class)
1.74 + addr = self._MakeObject(2, self.int_instance_location)
1.75 self.save(addr + 1, self.load(left_data) + self.load(right_data))
1.76
1.77 # Return the new object (with a null context).