[pypy-svn] r52287 - pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk

tverwaes at codespeak.net tverwaes at codespeak.net
Sat Mar 8 05:24:16 CET 2008


Author: tverwaes
Date: Sat Mar  8 05:24:16 2008
New Revision: 52287

Modified:
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/interpreter.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/shadow.py
Log:
making method of version for composite shadows (ie, a class' methoddictionary
depends on the shadow of the methoddict which depends on the shadows of its
Arrays) Quick check if update is necessary could be by quickly running over
versionnumbers, halting and updating for any version mismatch.


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:24:16 2008
@@ -38,13 +38,15 @@
 
     def store_w_active_context(self, w_context):
         self._w_active_context = w_context
-        self._s_active_context = w_context.as_context_get_shadow()
-        self.s_version = self._s_active_context.version
+        self.store_s_active_context()
+
+    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 s_active_context(self):
-        if self._s_active_context.version != self.s_version:
-            self._s_active_context = self.w_active_context().as_context_get_shadow()
-            self.s_version = self._s_active_context.version
+        if self._s_active_context.version() != self.s_version:
+            self.store_s_active_context()
         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:24:16 2008
@@ -9,7 +9,7 @@
     
     def __init__(self, w_self, invalid):
         self._w_self = w_self
-        self.version = 0
+        self._version = 0
         self.invalid = invalid
         self.w_invalid = False
         if invalid:
@@ -21,9 +21,15 @@
     def invalidate(self):
         """XXX This should get called whenever the base Smalltalk
         object changes."""
-        self.version += 1
+        self._version += 1
         self.invalid = True
 
+    def version(self):
+        """ XXX If decoded shadows depends on more than just w_self,
+        this method should be overwritten to check the versions of the
+        shadows used to build up this shadow. """
+        return self._version
+
     def invalidate_w_self(self):
         """XXX This should get called whenever the shadow
         object changes.



More information about the Pypy-commit mailing list