1.1 --- a/rsvp.py Sun May 24 00:21:41 2009 +0200
1.2 +++ b/rsvp.py Sun May 24 02:16:33 2009 +0200
1.3 @@ -348,6 +348,9 @@
1.4 # Instructions.
1.5
1.6 def LoadConst(self):
1.7 + self.value = self.operand, self.operand
1.8 +
1.9 + def LoadFunction(self):
1.10 self.value = None, self.operand # context of constant is not interesting
1.11
1.12 def LoadName(self):
1.13 @@ -376,12 +379,22 @@
1.14 def LoadAddressContextCond(self):
1.15 context, ref = self.load(self.operand)
1.16 inst_context, inst_ref = self.value
1.17 - self.value = self._LoadAddressContextCond(context, ref, inst_context, inst_ref)
1.18 + self.value = self._LoadAddressContextCond(context, ref, inst_ref)
1.19
1.20 def StoreAddress(self):
1.21 # Preserve context.
1.22 self.save(self.operand, self.source)
1.23
1.24 + def StoreAddressContext(self):
1.25 + # Overwrite context if null.
1.26 + context_context, context_ref = self.value
1.27 + source_context, source_ref = self.source
1.28 + if source_context is None:
1.29 + context = context_ref
1.30 + else:
1.31 + context = source_context
1.32 + self.save(self.operand, (context, source_ref))
1.33 +
1.34 def MakeObject(self):
1.35 size = self.operand
1.36 context, ref = self.value
1.37 @@ -436,7 +449,10 @@
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 - self.value = self._LoadAddressContextCond(loaded_context, loaded_ref, context, ref)
1.42 + if data.attrcode is None: # absent attrcode == class
1.43 + self.value = loaded_context, loaded_ref
1.44 + else:
1.45 + self.value = self._LoadAddressContextCond(loaded_context, loaded_ref, ref)
1.46 else:
1.47 self.value = self.load(ref + offset)
1.48 else:
1.49 @@ -687,7 +703,10 @@
1.50 data = self.load(ref)
1.51 target_data = self.load(cls)
1.52
1.53 - # Insist on a class.
1.54 + # Insist on instance vs. class.
1.55 +
1.56 + if data.attrcode is None: # absent attrcode == class
1.57 + return 0
1.58
1.59 if target_data.attrcode is not None: # present attrcode == instance
1.60 return 0
1.61 @@ -709,7 +728,7 @@
1.62 self.save(addr, data.with_size(size))
1.63 return addr
1.64
1.65 - def _LoadAddressContextCond(self, context, ref, inst_context, inst_ref):
1.66 + def _LoadAddressContextCond(self, context, ref, inst_ref):
1.67
1.68 # Check the instance context against the target's context.
1.69