1.1 --- a/rsvp.py Tue Jun 02 20:17:59 2009 +0200
1.2 +++ b/rsvp.py Wed Jun 03 00:48:57 2009 +0200
1.3 @@ -52,6 +52,7 @@
1.4 current callable
1.5 """
1.6
1.7 +from micropython.program import ReplaceableContext, PlaceholderContext
1.8 import operator
1.9
1.10 class IllegalInstruction(Exception):
1.11 @@ -386,8 +387,11 @@
1.12 def LoadConst(self):
1.13 self.value = self.operand, self.operand
1.14
1.15 + def LoadClass(self):
1.16 + self.value = PlaceholderContext, self.operand
1.17 +
1.18 def LoadFunction(self):
1.19 - self.value = None, self.operand
1.20 + self.value = ReplaceableContext, self.operand
1.21
1.22 def LoadName(self):
1.23 frame = self.local_sp_stack[-1]
1.24 @@ -425,7 +429,7 @@
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 + if source_context is ReplaceableContext:
1.30 context = context_ref
1.31 else:
1.32 context = source_context
1.33 @@ -546,10 +550,14 @@
1.34 self.value = context, context
1.35
1.36 def CheckContext(self):
1.37 - self.status = self.value[1] is not None
1.38 + self.status = self.value[1] is not ReplaceableContext
1.39
1.40 def CheckClass(self):
1.41 context, ref = self.value
1.42 + if ref in (ReplaceableContext, PlaceholderContext):
1.43 + self.status = 0
1.44 + return
1.45 +
1.46 data = self.load(ref)
1.47
1.48 # Classes are not themselves usable as the self argument.
1.49 @@ -721,7 +729,7 @@
1.50 def _LoadAddressContextCond(self, context, ref, inst_ref):
1.51 # Check the instance context against the target's context.
1.52 # This provides the context overriding for methods.
1.53 - if context is not None and self._CheckInstance(inst_ref, context):
1.54 + if context is not ReplaceableContext and self._CheckInstance(inst_ref, context):
1.55 # Replace the context with the instance.
1.56 return inst_ref, ref
1.57 else: