1.1 --- a/rsvp.py Fri Aug 22 00:50:59 2008 +0200
1.2 +++ b/rsvp.py Sat Aug 23 02:41:55 2008 +0200
1.3 @@ -246,6 +246,7 @@
1.4
1.5 def StoreAttr(self):
1.6 context, ref = self.value
1.7 + # Target should already be an instance.
1.8 self.save(ref + self.operand, self.source)
1.9
1.10 def LoadAttrIndex(self):
1.11 @@ -264,9 +265,23 @@
1.12 self.value = self.load(ref + offset)
1.13 else:
1.14 # NOTE: This should cause an attribute error.
1.15 - self.value = None
1.16 + raise Exception, "LoadAttrIndex % r" % element
1.17
1.18 - def StoreAttrIndex(self): pass
1.19 + def StoreAttrIndex(self):
1.20 + context, ref = self.value
1.21 + code = self.load(ref) # + 0 (the classcode)
1.22 + element = self.objtable[code + self.operand]
1.23 + found_code, class_attr, replace_context, offset = element
1.24 + if found_code == code:
1.25 + if class_attr:
1.26 + # NOTE: This should cause an attribute or type error.
1.27 + # Class attributes cannot be changed at run-time.
1.28 + raise Exception, "StoreAttrIndex % r" % element
1.29 + else:
1.30 + self.save(ref + offset, self.source)
1.31 + else:
1.32 + # NOTE: This should cause an attribute error.
1.33 + raise Exception, "StoreAttrIndex % r" % element
1.34
1.35 # NOTE: LoadAttrIndexContext is a possibility if a particular attribute can always be overridden.
1.36
1.37 @@ -285,6 +300,21 @@
1.38 frame = self.invocation_sp_stack.pop()
1.39 self.frame_stack = self.frame_stack[:frame] # reset stack before call
1.40
1.41 + def StoreFrame(self):
1.42 + frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.43 + self.frame_stack[frame + self.operand] = self.value
1.44 +
1.45 + def StoreFrameIndex(self):
1.46 + frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.47 + code = self.load(ref) # + 0 (the functioncode)
1.48 + element = self.objtable[code + self.operand]
1.49 + found_code, offset = element
1.50 + if found_code == code:
1.51 + self.frame_stack[frame + offset] = self.value
1.52 + else:
1.53 + # NOTE: This should cause an argument error.
1.54 + raise Exception, "StoreFrameIndex % r" % element
1.55 +
1.56 def CheckFrame(self): pass
1.57
1.58 def CheckSelf(self): pass
1.59 @@ -304,15 +334,6 @@
1.60 def StoreResult(self):
1.61 self.result = self.value
1.62
1.63 - def LoadException(self):
1.64 - self.value = self.exception
1.65 -
1.66 - def StoreException(self):
1.67 - self.exception = self.value
1.68 -
1.69 - def LoadBoolean(self):
1.70 - self.value = self.status
1.71 -
1.72 def Jump(self):
1.73 return self.operand
1.74
1.75 @@ -324,8 +345,31 @@
1.76 if not self.status:
1.77 return self.operand
1.78
1.79 - def StoreFrame(self):
1.80 - frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.81 - self.frame_stack[frame + self.operand] = self.value
1.82 + def LoadException(self):
1.83 + self.value = self.exception
1.84 +
1.85 + def StoreException(self):
1.86 + self.exception = self.value
1.87 +
1.88 + def RaiseException(self):
1.89 + return self.handler_stack.pop()
1.90 +
1.91 + def PushHandler(self):
1.92 + self.handler_stack.append(self.operand)
1.93 +
1.94 + def PopHandler(self):
1.95 + self.handler_stack.pop()
1.96 +
1.97 + def CheckException(self):
1.98 + self.status = self.value[1] == self.exception
1.99 +
1.100 + def TestIdentity(self):
1.101 + self.status = self.value[1] == self.source
1.102 +
1.103 + def TestIdentityAddress(self):
1.104 + self.status = self.value[1] == self.operand
1.105 +
1.106 + # LoadBoolean is implemented in the generated code.
1.107 + # StoreBoolean is implemented by testing against the True value.
1.108
1.109 # vim: tabstop=4 expandtab shiftwidth=4