An...@Anton-Vaio  committed eb37fcf

Small changes + one fix in code order

  • Participants
  • Parent commits b6cf78e
  • Branches strategies

Comments (0)

Files changed (2)

File spyvm/

     unerase = staticmethod(unerase)
     strategy_tag = 'list'
+    def get_list(self, w_obj):
+        return self.unerase(w_obj.get_storage(self))
     def fetch(self, space, w_obj, n0):
-        return self.unerase(w_obj.get_storage(self))[n0]
+        return self.get_list(w_obj)[n0]
     def store(self, space, w_obj, n0, w_val):
         # TODO enable generalization by maintaining a counter of elements that are nil.
-        self.unerase(w_obj.get_storage(self))[n0] = w_val
+        self.get_list(w_obj)[n0] = w_val
     def fetch_all(self, space, w_obj):
-        return self.unerase(w_obj.get_storage(self))
+        return self.get_list(w_obj)
     def size_of(self, w_obj):
-        return len(self.unerase(w_obj.get_storage(self)))
+        return len(self.get_list(w_obj))
     def initial_storage(self, space, size):
         return self.erase([model.w_nil] * size)
     def storage_for_list(self, space, collection):

File spyvm/

         self.set_storage(self.strategy.storage_for_list(space, pointers), self.strategy)
     def switch_strategy(self, space, new_strategy):
-        old_strategy = self.strategy
+        new_storage = new_strategy.copy_storage_from(space, self, self.strategy, reuse_storage=True)
         self.strategy = new_strategy
-        self.set_storage(new_strategy.copy_storage_from(space, self, old_strategy, reuse_storage=True), new_strategy)
+        self.set_storage(new_storage, new_strategy)
     def store_with_new_strategy(self, space, new_strategy, n0, w_val):
         self.switch_strategy(space, new_strategy)
     def become(self, w_other):
         if not isinstance(w_other, W_PointersObject):
             return False
-        self.strategy, w_other.strategy = w_other.strategy, self.strategy
         self_storage = self._storage
         self.set_storage(w_other._storage, w_other.strategy)
         w_other.set_storage(self_storage, w_other.strategy)
+        self.strategy, w_other.strategy = w_other.strategy, self.strategy
         return W_AbstractPointersObject.become(self, w_other)