[pypy-commit] lang-smalltalk default: move logic to the image reader
cfbolz
noreply at buildbot.pypy.org
Fri Feb 22 11:51:44 CET 2013
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r85:19453007f92c
Date: 2013-02-21 17:07 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/19453007f92c/
Log: move logic to the image reader
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -223,6 +223,25 @@
for name, idx in constants.objects_in_special_object_table.items():
space.objtable["w_" + name] = self.special_objects[idx]
+ self.w_asSymbol = self.find_asSymbol(space, reader)
+
+ def find_asSymbol(self, space, reader):
+ w_dnu = self.special(constants.SO_DOES_NOT_UNDERSTAND)
+ assert w_dnu.as_string() == "doesNotUnderstand:"
+ w_Symbol = w_dnu.getclass(space)
+ w_obj = None
+ # bit annoying that we have to hunt through the image :-(
+ for chunk in reader.chunklist:
+ w_obj = chunk.g_object.w_object
+ if not isinstance(w_obj, model.W_BytesObject):
+ continue
+ if not w_obj.getclass(space).is_same_object(w_Symbol):
+ continue
+ if w_obj.as_string() == "asSymbol":
+ break
+ assert w_obj is not None
+ return w_obj
+
def special(self, index):
return self.special_objects[index]
diff --git a/spyvm/test/test_miniimage.py b/spyvm/test/test_miniimage.py
--- a/spyvm/test/test_miniimage.py
+++ b/spyvm/test/test_miniimage.py
@@ -21,17 +21,8 @@
module.space = space
def find_symbol(name):
- w_dnu = image.special(constants.SO_DOES_NOT_UNDERSTAND)
- assert str(w_dnu) == "doesNotUnderstand:"
- w_Symbol = w_dnu.getclass(space)
- for chunk in reader.chunklist:
- w_obj = chunk.g_object.w_object
- if not isinstance(w_obj, model.W_BytesObject):
- continue
- if not w_obj.getclass(space).is_same_object(w_Symbol):
- continue
- if w_obj.as_string() == name:
- return w_obj
+ if name == "asSymbol":
+ return image.w_asSymbol
return perform(space.wrap_string(name), "asSymbol")
def open_miniimage(space):
@@ -298,6 +289,9 @@
assert space.unwrap_int(w_result) == 42
def perform(w_receiver, selector, *arguments_w):
+ return perform_with_space(space, w_receiver, selector, *arguments_w)
+
+def perform_with_space(space, w_receiver, selector, *arguments_w):
interp = interpreter.Interpreter(space)
s_class = w_receiver.shadow_of_my_class(space)
if isinstance(selector, str):
More information about the pypy-commit
mailing list