Author: Anton Gulenko <[email protected]>
Branch: storage
Changeset: r700:fac293b61449
Date: 2014-03-26 13:58 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/fac293b61449/

Log:    Removed hack for loading mini.image, replaced with clean
        distinguishing between modern and non-modern images.

diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -130,15 +130,6 @@
                 self._s_methoddict = w_val.as_methoddict_get_shadow(self.space)
                 self._s_methoddict.s_class = self
         elif n0 == constants.CLASS_FORMAT_INDEX:
-            if not isinstance(w_val, model.W_SmallInteger):
-                # TODO -- anton -- this happens with mini.image and other 
images (but not Squeak*.image)
-                # You can try something like the following after all g_objects 
have been initialized in the ImageReader:
-                # special_objects[11] == special_objects[36].g_class
-                # TODO -- fix images or think of a more appropriate hack.
-                self._instance_size = constants.BLKCLSR_SIZE
-                self.instance_varsized = True
-                return
-            
             # read and painfully decode the format
             classformat = self.space.unwrap_int(w_val)
             # The classformat in Squeak, as an integer value, is:
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -213,6 +213,7 @@
         self.space = space
         self.stream = stream
         self.version = version
+        self.is_modern = self.version.magic > 6502
         # dictionary mapping old address to chunk object
         self.chunks = {}
         self.chunklist = []
@@ -280,7 +281,15 @@
     def assign_prebuilt_constants(self):
         # Assign classes and objects that in special objects array that are 
already created.
         
self._assign_prebuilt_constants(constants.objects_in_special_object_table, 
self.space.objtable)
-        
self._assign_prebuilt_constants(constants.classes_in_special_object_table, 
self.space.classtable)
+        if not self.is_modern:
+            classtable = {}
+            for name, so_index in self.space.classtable.items():
+                # In non-modern images (pre 4.0), there was no BlockClosure 
class.
+                if not name == "BlockClosure":
+                    classtable[name] = so_index
+        else:
+            classtable = self.space.classtable
+        
self._assign_prebuilt_constants(constants.classes_in_special_object_table, 
classtable)
 
     def _assign_prebuilt_constants(self, names_and_indices, prebuilt_objects):
         for name, so_index in names_and_indices.items():
@@ -369,7 +378,7 @@
         self.w_simulateCopyBits = self.find_symbol(space, reader, 
"simulateCopyBits")
         self.lastWindowSize = reader.lastWindowSize
         self.version = reader.version
-        self.is_modern = reader.version.magic > 6502
+        self.is_modern = reader.is_modern
         self.run_spy_hacks(space)
         self.startup_time = time.time()
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to