[pypy-svn] r51838 - in pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk: . test

tverwaes at codespeak.net tverwaes at codespeak.net
Sun Feb 24 23:10:03 CET 2008


Author: tverwaes
Date: Sun Feb 24 23:10:02 2008
New Revision: 51838

Modified:
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
   pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/utility.py
Log:
using chartable from special objects array when available


Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/constants.py	Sun Feb 24 23:10:02 2008
@@ -149,6 +149,7 @@
     "nil": SO_NIL,
     "true": SO_TRUE,
     "false": SO_FALSE,
+    "charactertable": SO_CHARACTER_TABLE_ARRAY,
     "schedulerassociationpointer" : SO_SCHEDULERASSOCIATIONPOINTER,
 }
 

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/model.py	Sun Feb 24 23:10:02 2008
@@ -138,18 +138,7 @@
                 isinstance(self.w_class, W_PointersObject))
 
     def equals(self, w_other):
-        # Special case:
-        # Chars are not compared by pointer but by char-value.
-        # XXX Check comment at utility.unwrap_char ... is related.
-        from pypy.lang.smalltalk.classtable import w_Character
-        from pypy.lang.smalltalk import utility
-        if self.getclass() == w_Character:
-            if w_other.getclass() != w_Character:
-                return False
-            else:
-                return utility.unwrap_char(self) == utility.unwrap_char(w_other)
-        else:
-            return self.pointer_equals(w_other)
+        return self.pointer_equals(w_other)
 
     def become(self, w_old, w_new):
         if self.w_class == w_old:

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/squeakimage.py	Sun Feb 24 23:10:02 2008
@@ -207,6 +207,8 @@
         for name, idx in constants.objects_in_special_object_table.items():
             objtable.objtable["w_" + name] = self.special_objects[idx]
 
+        objtable.CharacterTable = objtable.objtable["w_charactertable"]
+
     def special(self, index):
         return self.special_objects[index]
 

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/test/test_miniimage.py	Sun Feb 24 23:10:02 2008
@@ -240,7 +240,6 @@
     interp.interpret()
     
 def test_compile_method():
-    #py.test.skip("Not working yet.")
     sourcecode = """fib 
                         ^self < 2 
                             ifTrue: [ 1 ] 

Modified: pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/utility.py
==============================================================================
--- pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/utility.py	(original)
+++ pypy/branch/smalltalk-shadow-changes/pypy/lang/smalltalk/utility.py	Sun Feb 24 23:10:02 2008
@@ -52,7 +52,11 @@
 
 def wrap_char(c):
     from pypy.lang.smalltalk.objtable import CharacterTable
-    return CharacterTable[ord(c)]
+    try:
+        return CharacterTable.fetch(ord(c))
+    except Exception:
+        # XXX For now fall back to old version of charactertable
+        return CharacterTable[ord(c)]
 
 def wrap_bool(bool):
     from pypy.lang.smalltalk import objtable



More information about the Pypy-commit mailing list