[pypy-svn] r52288 - pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk
tverwaes at codespeak.net
tverwaes at codespeak.net
Sat Mar 8 05:48:05 CET 2008
Author: tverwaes
Date: Sat Mar 8 05:48:04 2008
New Revision: 52288
Modified:
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
Log:
removed versioning system, replaced by invalidation notification system. Only
notifies first time the shadow becomes invalid.
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py Sat Mar 8 05:48:04 2008
@@ -30,7 +30,6 @@
def __init__(self):
self._w_active_context = None
self._s_active_context = None
- self.s_version = None
self.cnt = 0
def w_active_context(self):
@@ -38,15 +37,14 @@
def store_w_active_context(self, w_context):
self._w_active_context = w_context
- self.store_s_active_context()
+ self._s_active_context = None
- def store_s_active_context(self):
- self._s_active_context = self.w_active_context().as_context_get_shadow()
- self.s_version = self._s_active_context.version()
+ def invalidate(self):
+ self._s_active_context = None
def s_active_context(self):
- if self._s_active_context.version() != self.s_version:
- self.store_s_active_context()
+ if self._s_active_context is None:
+ self._s_active_context = self.w_active_context().as_context_get_shadow()
return self._s_active_context
def interpret(self):
Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py (original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py Sat Mar 8 05:48:04 2008
@@ -9,20 +9,26 @@
def __init__(self, w_self, invalid):
self._w_self = w_self
- self._version = 0
+ self._invalidnotify = []
self.invalid = invalid
self.w_invalid = False
if invalid:
self.invalidate()
+ def invalidnotify(self, other):
+ if other not in self._invalidnotify:
+ self._invalidnotify += [other]
+
def getname(self):
return repr(self)
def invalidate(self):
"""XXX This should get called whenever the base Smalltalk
object changes."""
- self._version += 1
- self.invalid = True
+ if not self.invalid:
+ self.invalid = True
+ for listener in self._invalidnotify:
+ listener.invalidate()
def version(self):
""" XXX If decoded shadows depends on more than just w_self,
More information about the Pypy-commit
mailing list