diff --git a/src/tinySelf/vm/primitives/os/primitive_files.py b/src/tinySelf/vm/primitives/os/primitive_files.py index 98ece65..7e6e41a 100644 --- a/src/tinySelf/vm/primitives/os/primitive_files.py +++ b/src/tinySelf/vm/primitives/os/primitive_files.py @@ -97,8 +97,8 @@ def __init__(self, value, obj_map=None, path=""): self.value = value self.path = path - if PrimitiveFileObject._OBJ_CACHE.map is not None: - self._slot_values = PrimitiveFileObject._OBJ_CACHE.slots + if PrimitiveFileObject._OBJ_CACHE.is_set: + PrimitiveFileObject._OBJ_CACHE.restore(self) return add_primitive_fn(self, "close", close_file, []) @@ -110,8 +110,7 @@ def __init__(self, value, obj_map=None, path=""): add_primitive_fn(self, "seek:", seek_to, ["pos"]) add_primitive_fn(self, "closed?", is_closed, []) - if PrimitiveFileObject._OBJ_CACHE.map is None: - PrimitiveFileObject._OBJ_CACHE.store(self) + PrimitiveFileObject._OBJ_CACHE.store(self) def __str__(self): status = ", closed" if self.value.closed else "" diff --git a/src/tinySelf/vm/primitives/os/primitive_socket.py b/src/tinySelf/vm/primitives/os/primitive_socket.py index 9dbcbb7..08043ac 100644 --- a/src/tinySelf/vm/primitives/os/primitive_socket.py +++ b/src/tinySelf/vm/primitives/os/primitive_socket.py @@ -50,16 +50,15 @@ def __init__(self, value, obj_map=None): assert isinstance(value, RSocket) self.value = value - if PrimitiveSocketObject._OBJ_CACHE.map is not None: - self._slot_values = PrimitiveSocketObject._OBJ_CACHE.slots + if PrimitiveSocketObject._OBJ_CACHE.is_set: + PrimitiveSocketObject._OBJ_CACHE.restore(self) return add_primitive_fn(self, "recv:", socket_recv, ["size"]) add_primitive_fn(self, "sendAll:", socket_sendall, ["data"]) add_primitive_fn(self, "close", socket_close, []) - if PrimitiveSocketObject._OBJ_CACHE.map is None: - PrimitiveSocketObject._OBJ_CACHE.store(self) + PrimitiveSocketObject._OBJ_CACHE.store(self) def __str__(self): return "PrimitiveSocket()" diff --git a/src/tinySelf/vm/primitives/primitive_dict.py b/src/tinySelf/vm/primitives/primitive_dict.py index 3a6123c..0ca19e4 100644 --- a/src/tinySelf/vm/primitives/primitive_dict.py +++ b/src/tinySelf/vm/primitives/primitive_dict.py @@ -140,8 +140,8 @@ def __init__(self, value, obj_map=None): self.value = value - if PrimitiveDictObject._OBJ_CACHE.map is not None: - self._slot_values = PrimitiveDictObject._OBJ_CACHE.slots + if PrimitiveDictObject._OBJ_CACHE.is_set: + PrimitiveDictObject._OBJ_CACHE.restore(self) return add_primitive_fn(self, "at:", dict_at, ["index"]) @@ -149,8 +149,7 @@ def __init__(self, value, obj_map=None): add_primitive_fn(self, "length", dict_length, []) add_primitive_fn(self, "at:Put:", dict_at_key_put_obj, ["key", "obj"]) - if PrimitiveDictObject._OBJ_CACHE.map is None: - PrimitiveDictObject._OBJ_CACHE.store(self) + PrimitiveDictObject._OBJ_CACHE.store(self) def __str__(self): return "dict()" diff --git a/src/tinySelf/vm/primitives/primitive_list.py b/src/tinySelf/vm/primitives/primitive_list.py index 6100004..c5ae753 100644 --- a/src/tinySelf/vm/primitives/primitive_list.py +++ b/src/tinySelf/vm/primitives/primitive_list.py @@ -84,8 +84,8 @@ def __init__(self, value, obj_map=None): assert isinstance(value, list) self.value = value - if PrimitiveListObject._OBJ_CACHE.map is not None: - self._slot_values = PrimitiveListObject._OBJ_CACHE.slots + if PrimitiveListObject._OBJ_CACHE.is_set: + PrimitiveListObject._OBJ_CACHE.restore(self) return add_primitive_fn(self, "at:", list_at, ["index"])