1.1 --- a/rsvp.py Sat May 23 02:46:04 2009 +0200
1.2 +++ b/rsvp.py Sun May 24 00:21:41 2009 +0200
1.3 @@ -256,9 +256,10 @@
1.4
1.5 print "Execution terminated",
1.6 if self.exception is not None:
1.7 - context, ref = self.exception
1.8 + ref = self.exception
1.9 + addr = self.load(ref + 1)
1.10 print "with exception:", self.load(ref)
1.11 - print "at address:", self.load(ref + 1)
1.12 + print "At address %d: %r" % (addr, self.load(addr))
1.13 else:
1.14 print "successfully."
1.15
1.16 @@ -412,8 +413,7 @@
1.17 else:
1.18 self.value = self.load(ref + offset)
1.19 else:
1.20 - exc = self._MakeObject(2, self.attr_error_instance)
1.21 - self.exception = exc, exc
1.22 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.23 return self.RaiseException()
1.24
1.25 def LoadAttrIndexContext(self):
1.26 @@ -425,8 +425,7 @@
1.27 loaded_context, loaded_ref = self.load(offset) # offset is address of class attribute
1.28 self.value = ref, loaded_ref
1.29 else:
1.30 - exc = self._MakeObject(2, self.attr_error_instance)
1.31 - self.exception = exc, exc
1.32 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.33 return self.RaiseException()
1.34
1.35 def LoadAttrIndexContextCond(self):
1.36 @@ -441,8 +440,7 @@
1.37 else:
1.38 self.value = self.load(ref + offset)
1.39 else:
1.40 - exc = self._MakeObject(2, self.attr_error_instance)
1.41 - self.exception = exc, exc
1.42 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.43 return self.RaiseException()
1.44
1.45 def StoreAttrIndex(self):
1.46 @@ -452,14 +450,12 @@
1.47 attr_index, class_attr, offset = element
1.48 if attr_index == self.operand:
1.49 if class_attr:
1.50 - exc = self._MakeObject(2, self.type_error_instance)
1.51 - self.exception = exc, exc
1.52 + self.exception = self._MakeObject(2, self.type_error_instance)
1.53 return self.RaiseException()
1.54 else:
1.55 self.save(ref + offset, self.source)
1.56 else:
1.57 - exc = self._MakeObject(2, self.attr_error_instance)
1.58 - self.exception = exc, exc
1.59 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.60 return self.RaiseException()
1.61
1.62 # NOTE: LoadAttrIndexContext is a possibility if a particular attribute can always be overridden.
1.63 @@ -490,8 +486,7 @@
1.64 if param_index == self.operand:
1.65 self.frame_stack[frame + offset + 1] = self.source # add 1 to skip the context always generated
1.66 else:
1.67 - exc = self._MakeObject(2, self.type_error_instance)
1.68 - self.exception = exc, exc
1.69 + self.exception = self._MakeObject(2, self.type_error_instance)
1.70 return self.RaiseException()
1.71
1.72 def LoadCallable(self):
1.73 @@ -511,6 +506,20 @@
1.74 # NOTE: self() inside methods impossible.
1.75 self.value = context, context
1.76
1.77 + def CheckContext(self):
1.78 + self.status = self.value[1] is not None
1.79 +
1.80 + def CheckClassContext(self):
1.81 + context_context, context_ref = self.value
1.82 + context_data = self.load(context_ref)
1.83 +
1.84 + # Classes are not themselves usable as the self argument.
1.85 + # NOTE: This may change at some point.
1.86 + # However, where classes appear as the context, instance
1.87 + # compatibility is required in the first argument.
1.88 +
1.89 + self.status = context_data.attrcode is None # absent attrcode == class
1.90 +
1.91 def CheckFrame(self):
1.92 (nargs, ndefaults, has_star) = self.operand
1.93
1.94 @@ -551,13 +560,11 @@
1.95 self_context, self_ref = self.frame_stack[frame + 1]
1.96 if not self._CheckInstance(self_ref, context_context):
1.97 #raise Exception, "CheckFrame %r (%r vs. %r)" % (self.operand, self.load(self_ref), self.load(context_context))
1.98 - exc = self._MakeObject(2, self.type_error_instance)
1.99 - self.exception = exc, exc
1.100 + self.exception = self._MakeObject(2, self.type_error_instance)
1.101 return self.RaiseException()
1.102 else:
1.103 #raise Exception, "CheckFrame %r (no self argument)" % self.operand
1.104 - exc = self._MakeObject(2, self.type_error_instance)
1.105 - self.exception = exc, exc
1.106 + self.exception = self._MakeObject(2, self.type_error_instance)
1.107 return self.RaiseException()
1.108
1.109 # Test the frame size.
1.110 @@ -565,8 +572,7 @@
1.111
1.112 if not ((nargs - ndefaults) <= nlocals and (nlocals <= nargs or has_star)):
1.113 #raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, nlocals, nargs)
1.114 - exc = self._MakeObject(2, self.type_error_instance)
1.115 - self.exception = exc, exc
1.116 + self.exception = self._MakeObject(2, self.type_error_instance)
1.117 return self.RaiseException()
1.118
1.119 def FillDefaults(self):
1.120 @@ -644,7 +650,7 @@
1.121
1.122 def RaiseException(self):
1.123 # NOTE: Adding the program counter as the first attribute.
1.124 - self.save(self.exception[1] + 1, self.pc)
1.125 + self.save(self.exception + 1, self.pc)
1.126 # Jumping to the current handler.
1.127 return self.handler_stack[-1]
1.128
1.129 @@ -726,8 +732,7 @@
1.130 # Test operand suitability.
1.131
1.132 if not self._CheckInstance(left, self.int_class) and self._CheckInstance(right, self.int_class):
1.133 - exc = self._MakeObject(2, self.type_error_instance)
1.134 - self.exception = exc, exc
1.135 + self.exception = self._MakeObject(2, self.type_error_instance)
1.136 return self.RaiseException()
1.137
1.138 # NOTE: Assume single location for data.
1.139 @@ -759,8 +764,7 @@
1.140 # Test operand suitability.
1.141
1.142 if not self._CheckInstance(left, self.int_class):
1.143 - exc = self._MakeObject(2, self.type_error_instance)
1.144 - self.exception = exc, exc
1.145 + self.exception = self._MakeObject(2, self.type_error_instance)
1.146 return self.RaiseException()
1.147
1.148 # NOTE: Assume single location for data.
1.149 @@ -785,8 +789,7 @@
1.150 # Test operand suitability.
1.151
1.152 if not self._CheckInstance(left, self.int_class):
1.153 - exc = self._MakeObject(2, self.type_error_instance)
1.154 - self.exception = exc, exc
1.155 + self.exception = self._MakeObject(2, self.type_error_instance)
1.156 return self.RaiseException()
1.157
1.158 # NOTE: Assume single location for data.
1.159 @@ -848,8 +851,7 @@
1.160 elif item_pos < 0 and item_pos >= -nelements:
1.161 item_pos = nelements + item_pos
1.162 else:
1.163 - exc = self._MakeObject(2, self.index_error_instance)
1.164 - self.exception = exc, exc
1.165 + self.exception = self._MakeObject(2, self.index_error_instance)
1.166 return self.RaiseException()
1.167
1.168 self.result = self.load(obj + 1 + item_pos)