1.1 --- a/rsvp.py Sun Feb 22 22:31:21 2009 +0100
1.2 +++ b/rsvp.py Sat Feb 28 01:49:33 2009 +0100
1.3 @@ -273,9 +273,11 @@
1.4 instructions would otherwise have.
1.5 """
1.6
1.7 + value = self.value
1.8 if self.instruction.source is not None:
1.9 self.perform(self.instruction.source)
1.10 self.source = self.value
1.11 + self.value = value
1.12 if self.instruction.input is not None:
1.13 self.perform(self.instruction.input)
1.14
1.15 @@ -324,7 +326,7 @@
1.16
1.17 def StoreAddress(self):
1.18 # Preserve context.
1.19 - self.save(self.operand, self.value)
1.20 + self.save(self.operand, self.source)
1.21
1.22 def MakeObject(self):
1.23 size = self.operand
1.24 @@ -362,6 +364,7 @@
1.25 self.value = self.load(ref + offset)
1.26 else:
1.27 self.exception = self.attr_error
1.28 + return self.RaiseException()
1.29
1.30 def StoreAttrIndex(self):
1.31 context, ref = self.value
1.32 @@ -371,10 +374,12 @@
1.33 if attr_index == self.operand:
1.34 if class_attr:
1.35 self.exception = self.type_error
1.36 + return self.RaiseException()
1.37 else:
1.38 self.save(ref + offset, self.source)
1.39 else:
1.40 self.exception = self.attr_error
1.41 + return self.RaiseException()
1.42
1.43 # NOTE: LoadAttrIndexContext is a possibility if a particular attribute can always be overridden.
1.44
1.45 @@ -398,12 +403,14 @@
1.46 context, ref = self.value
1.47 frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.48 data = self.load(ref)
1.49 - element = self.objlist[data.classcode + self.operand]
1.50 - attr_index, class_attr, replace_context, offset = element
1.51 - if attr_index == self.operand:
1.52 - self.frame_stack[frame + offset] = self.value
1.53 + element = self.paramlist[data.funccode + self.operand]
1.54 + # NOTE: Need to ensure correct positioning where a context has been generated.
1.55 + param_index, offset = element
1.56 + if param_index == self.operand:
1.57 + self.frame_stack[frame + offset + 1] = self.source # add 1 to skip the context always generated
1.58 else:
1.59 self.exception = self.type_error
1.60 + return self.RaiseException()
1.61
1.62 def LoadCallable(self):
1.63 context, ref = self.value
1.64 @@ -437,11 +444,24 @@
1.65 self.invocation_sp_stack[-1] += 1
1.66 operand -= 1
1.67
1.68 + # Test the frame size.
1.69 +
1.70 nargs, ndefaults = data.codedetails
1.71 if not ((nargs - ndefaults) <= operand <= nargs):
1.72 raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, operand, nargs)
1.73
1.74 - # NOTE: Support population of defaults.
1.75 + # Support population of defaults.
1.76 + # This involves copying the "attributes" of a function into the frame.
1.77 +
1.78 + default = operand - (nargs - ndefaults)
1.79 + self.frame_stack.extend([None] * (nargs - operand))
1.80 + pos = self.operand
1.81 +
1.82 + while operand < nargs:
1.83 + self.frame_stack[frame + pos] = self.load(ref + default + 1) # skip header
1.84 + default += 1
1.85 + pos += 1
1.86 + operand += 1
1.87
1.88 def CheckSelf(self):
1.89 context, ref = self.value