1.1 --- a/rsvp.py Wed Jun 03 00:48:57 2009 +0200
1.2 +++ b/rsvp.py Sun Jun 07 20:04:16 2009 +0200
1.3 @@ -459,50 +459,59 @@
1.4 context, ref = self.value
1.5 data = self.load(ref)
1.6 element = self.objlist[data.classcode + self.operand]
1.7 - attr_index, class_attr, offset = element
1.8 - if attr_index == self.operand:
1.9 - if class_attr:
1.10 - self.value = self.load(offset) # offset is address of class attribute
1.11 - else:
1.12 - self.value = self.load(ref + offset)
1.13 - else:
1.14 - self.exception = self._MakeObject(2, self.attr_error_instance)
1.15 - return self.RaiseException()
1.16 +
1.17 + if element is not None:
1.18 + attr_index, class_attr, offset = element
1.19 + if attr_index == self.operand:
1.20 + if class_attr:
1.21 + self.value = self.load(offset) # offset is address of class attribute
1.22 + else:
1.23 + self.value = self.load(ref + offset)
1.24 + return
1.25 +
1.26 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.27 + return self.RaiseException()
1.28
1.29 # LoadAttrIndexContext not defined.
1.30
1.31 def LoadAttrIndexContextCond(self):
1.32 - context, ref = self.value
1.33 - data = self.load(ref)
1.34 + inst_context, inst_ref = self.value
1.35 + data = self.load(inst_ref)
1.36 element = self.objlist[data.classcode + self.operand]
1.37 - attr_index, class_attr, offset = element
1.38 - if attr_index == self.operand:
1.39 - if class_attr:
1.40 - loaded_context, loaded_ref = self.load(offset) # offset is address of class attribute
1.41 - if data.attrcode is None: # absent attrcode == class
1.42 - self.value = loaded_context, loaded_ref
1.43 +
1.44 + if element is not None:
1.45 + attr_index, class_attr, offset = element
1.46 + if attr_index == self.operand:
1.47 + if class_attr:
1.48 + loaded_context, loaded_ref = self.load(offset) # offset is address of class attribute
1.49 + if data.attrcode is None: # absent attrcode == class
1.50 + self.value = loaded_context, loaded_ref
1.51 + else:
1.52 + self.value = self._LoadAddressContextCond(loaded_context, loaded_ref, inst_ref)
1.53 else:
1.54 - self.value = self._LoadAddressContextCond(loaded_context, loaded_ref, ref)
1.55 - else:
1.56 - self.value = self.load(ref + offset)
1.57 - else:
1.58 - self.exception = self._MakeObject(2, self.attr_error_instance)
1.59 - return self.RaiseException()
1.60 + self.value = self.load(inst_ref + offset)
1.61 + return
1.62 +
1.63 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.64 + return self.RaiseException()
1.65
1.66 def StoreAttrIndex(self):
1.67 context, ref = self.value
1.68 data = self.load(ref)
1.69 element = self.objlist[data.classcode + self.operand]
1.70 - attr_index, class_attr, offset = element
1.71 - if attr_index == self.operand:
1.72 - if class_attr:
1.73 - self.exception = self._MakeObject(2, self.type_error_instance)
1.74 - return self.RaiseException()
1.75 - else:
1.76 - self.save(ref + offset, self.source)
1.77 - else:
1.78 - self.exception = self._MakeObject(2, self.attr_error_instance)
1.79 - return self.RaiseException()
1.80 +
1.81 + if element is not None:
1.82 + attr_index, class_attr, offset = element
1.83 + if attr_index == self.operand:
1.84 + if class_attr:
1.85 + self.exception = self._MakeObject(2, self.type_error_instance)
1.86 + return self.RaiseException()
1.87 + else:
1.88 + self.save(ref + offset, self.source)
1.89 + return
1.90 +
1.91 + self.exception = self._MakeObject(2, self.attr_error_instance)
1.92 + return self.RaiseException()
1.93
1.94 # NOTE: LoadAttrIndexContext is a possibility if a particular attribute can always be overridden.
1.95
1.96 @@ -524,13 +533,16 @@
1.97 frame = self.invocation_sp_stack[-1] # different from the current frame after MakeFrame
1.98 data = self.load(ref)
1.99 element = self.paramlist[data.funccode + self.operand]
1.100 - # NOTE: Need to ensure correct positioning where a context has been generated.
1.101 - param_index, offset = element
1.102 - if param_index == self.operand:
1.103 - self.frame_stack[frame + offset] = self.source
1.104 - else:
1.105 - self.exception = self._MakeObject(2, self.type_error_instance)
1.106 - return self.RaiseException()
1.107 +
1.108 + if element is not None:
1.109 + # NOTE: Need to ensure correct positioning where a context has been generated.
1.110 + param_index, offset = element
1.111 + if param_index == self.operand:
1.112 + self.frame_stack[frame + offset] = self.source
1.113 + return
1.114 +
1.115 + self.exception = self._MakeObject(2, self.type_error_instance)
1.116 + return self.RaiseException()
1.117
1.118 def LoadCallable(self):
1.119 context, ref = self.value
1.120 @@ -712,6 +724,7 @@
1.121 # Find the table entry for the descendant.
1.122
1.123 element = self.objlist[target_data.classcode + data.attrcode]
1.124 +
1.125 if element is not None:
1.126 attr_index, class_attr, offset = element
1.127 return attr_index == data.attrcode
1.128 @@ -729,7 +742,7 @@
1.129 def _LoadAddressContextCond(self, context, ref, inst_ref):
1.130 # Check the instance context against the target's context.
1.131 # This provides the context overriding for methods.
1.132 - if context is not ReplaceableContext and self._CheckInstance(inst_ref, context):
1.133 + if context is ReplaceableContext or context is not PlaceholderContext and self._CheckInstance(inst_ref, context):
1.134 # Replace the context with the instance.
1.135 return inst_ref, ref
1.136 else: