[pypy-commit] lang-smalltalk default: added the space a w_object is created for to that object
lwassermann
noreply at buildbot.pypy.org
Wed Mar 20 14:53:28 CET 2013
Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch:
Changeset: r224:256cc8aa5d3f
Date: 2013-03-14 00:13 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/256cc8aa5d3f/
Log: added the space a w_object is created for to that object the only
exception is W_SmallInteger
diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -121,7 +121,7 @@
else:
w_selector = selector
- w_method = model.W_CompiledMethod()
+ w_method = model.W_CompiledMethod(self.space)
w_method.setbytes([chr(124)]) #returnTopFromMethod
s_method = w_method.as_compiledmethod_get_shadow(self.space)
s_frame = MethodContextShadow.make_context(
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -155,6 +155,7 @@
class W_Float(W_Object):
"""Boxed float value."""
_attrs_ = ['value']
+ _immutable_fields_ = ['space']
def fillin_fromwords(self, space, high, low):
from rpython.rlib.rstruct.ieee import float_unpack
@@ -162,7 +163,8 @@
r = (r_ulonglong(high) << 32) | low
self.value = float_unpack(r, 8)
- def __init__(self, value):
+ def __init__(self, space, value):
+ self.space = space
self.value = value
def getclass(self, space):
@@ -257,14 +259,16 @@
"""Objects with arbitrary class (ie not CompiledMethod, SmallInteger or
Float)."""
_attrs_ = ['w_class', 's_class']
+ _immutable_fields_ = ['space']
s_class = None
- def __init__(self, w_class):
+ def __init__(self, space, w_class):
if w_class is not None: # it's None only for testing and space generation
assert isinstance(w_class, W_PointersObject)
if w_class.has_shadow():
self.s_class = w_class.as_class_get_shadow(w_class._shadow.space)
self.w_class = w_class
+ self.space = space
def getclass(self, space):
assert self.w_class is not None
@@ -306,9 +310,9 @@
_shadow = None # Default value
@jit.unroll_safe
- def __init__(self, w_class, size):
+ def __init__(self, space, w_class, size):
"""Create new object with size = fixed + variable size."""
- W_AbstractObjectWithClassReference.__init__(self, w_class)
+ W_AbstractObjectWithClassReference.__init__(self, space, w_class)
vars = self._vars = [None] * size
for i in range(size): # do it by hand for the JIT's sake
vars[i] = w_nil
@@ -434,15 +438,15 @@
return True
def clone(self, space):
- w_result = W_PointersObject(self.w_class, len(self._vars))
+ w_result = W_PointersObject(self.space, self.w_class, len(self._vars))
w_result._vars = [self.fetch(space, i) for i in range(len(self._vars))]
return w_result
class W_BytesObject(W_AbstractObjectWithClassReference):
_attrs_ = ['bytes']
- def __init__(self, w_class, size):
- W_AbstractObjectWithClassReference.__init__(self, w_class)
+ def __init__(self, space, w_class, size):
+ W_AbstractObjectWithClassReference.__init__(self, space, w_class)
assert isinstance(size, int)
self.bytes = ['\x00'] * size
@@ -486,15 +490,15 @@
return self.bytes == other.bytes
def clone(self, space):
- w_result = W_BytesObject(self.w_class, len(self.bytes))
+ w_result = W_BytesObject(self.space, self.w_class, len(self.bytes))
w_result.bytes = list(self.bytes)
return w_result
class W_WordsObject(W_AbstractObjectWithClassReference):
_attrs_ = ['words']
- def __init__(self, w_class, size):
- W_AbstractObjectWithClassReference.__init__(self, w_class)
+ def __init__(self, space, w_class, size):
+ W_AbstractObjectWithClassReference.__init__(self, space, w_class)
self.words = [r_uint(0)] * size
def at0(self, space, index0):
@@ -519,7 +523,7 @@
isinstance(self.words, list))
def clone(self, space):
- w_result = W_WordsObject(self.w_class, len(self.words))
+ w_result = W_WordsObject(self.space, self.space, self.w_class, len(self.words))
w_result.words = list(self.words)
return w_result
@@ -549,7 +553,7 @@
_shadow = None # Default value
_likely_methodname = "<unknown>"
- def __init__(self, bytecount=0, header=0):
+ def __init__(self, space, bytecount=0, header=0):
self._shadow = None
self.setheader(header)
self.bytes = ["\x00"] * bytecount
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -123,7 +123,7 @@
w_cinst.store(self, constants.CHARACTER_VALUE_INDEX,
model.W_SmallInteger(i))
return w_cinst
- w_charactertable = model.W_PointersObject(
+ w_charactertable = model.W_PointersObject(self,
self.classtable['w_Array'], 256)
self.w_charactertable = w_charactertable
for i in range(256):
@@ -144,7 +144,7 @@
self.w_zero = model.W_SmallInteger(0)
self.w_one = model.W_SmallInteger(1)
self.w_two = model.W_SmallInteger(2)
- w_special_selectors = model.W_PointersObject(
+ w_special_selectors = model.W_PointersObject(self,
self.classtable['w_Array'], len(constants.SPECIAL_SELECTORS) * 2)
self.w_special_selectors = w_special_selectors
@@ -182,13 +182,13 @@
import math
bytes_len = int(math.log(val) / math.log(0xff)) + 1
bytes_len = 4 if 4 > bytes_len else bytes_len
- w_result = model.W_BytesObject(self.classtable['w_LargePositiveInteger'], bytes_len)
+ w_result = model.W_BytesObject(self, self.classtable['w_LargePositiveInteger'], bytes_len)
for i in range(bytes_len):
w_result.setchar(i, chr(intmask((val >> i*8) & 255)))
return w_result
def wrap_float(self, i):
- return model.W_Float(i)
+ return model.W_Float(self, i)
def wrap_string(self, string):
w_inst = self.w_String.as_class_get_shadow(self).new(len(string))
@@ -288,7 +288,7 @@
def bootstrap_class(space, instsize, w_superclass=None, w_metaclass=None,
name='?', format=shadow.POINTERS, varsized=False):
from spyvm import model
- w_class = model.W_PointersObject(w_metaclass, 0)
+ w_class = model.W_PointersObject(space, w_metaclass, 0)
# a dummy placeholder for testing
# XXX
s = instantiate(shadow.ClassShadow)
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -511,7 +511,7 @@
@expose_primitive(NEW_METHOD, unwrap_spec=[object, int, int])
def func(interp, s_frame, w_class, bytecount, header):
# We ignore w_class because W_CompiledMethod is special
- w_method = model.W_CompiledMethod(bytecount, header)
+ w_method = model.W_CompiledMethod(interp.space, bytecount, header)
return w_method
# ___________________________________________________________________________
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -194,13 +194,13 @@
def new(self, extrasize=0):
w_cls = self.w_self()
if self.instance_kind == POINTERS:
- w_new = model.W_PointersObject(w_cls, self.instsize()+extrasize)
+ w_new = model.W_PointersObject(self.space, w_cls, self.instsize()+extrasize)
elif self.instance_kind == WORDS:
- w_new = model.W_WordsObject(w_cls, extrasize)
+ w_new = model.W_WordsObject(self.space, w_cls, extrasize)
elif self.instance_kind == BYTES:
- w_new = model.W_BytesObject(w_cls, extrasize)
+ w_new = model.W_BytesObject(self.space, w_cls, extrasize)
elif self.instance_kind == COMPILED_METHOD:
- w_new = model.W_CompiledMethod(extrasize)
+ w_new = model.W_CompiledMethod(self.space, extrasize)
else:
raise NotImplementedError(self.instance_kind)
return w_new
@@ -307,8 +307,8 @@
def initialize_methoddict(self):
"NOT_RPYTHON" # this is only for testing.
if self._s_methoddict is None:
- w_methoddict = model.W_PointersObject(None, 2)
- w_methoddict._store(1, model.W_PointersObject(None, 0))
+ w_methoddict = model.W_PointersObject(self.space, None, 2)
+ w_methoddict._store(1, model.W_PointersObject(self.space, None, 0))
self._s_methoddict = w_methoddict.as_methoddict_get_shadow(self.space)
self.s_methoddict().sync_cache()
self.s_methoddict().invalid = False
@@ -696,7 +696,7 @@
# into the right places in the W_PointersObject
# XXX could hack some more to never have to create the _vars of w_result
contextsize = w_home.as_methodcontext_get_shadow(space).myblocksize()
- w_result = model.W_PointersObject(space.w_BlockContext, contextsize)
+ w_result = model.W_PointersObject(space, space.w_BlockContext, contextsize)
s_result = BlockContextShadow(space, w_result)
s_result_non_fresh = s_result # XXX: find a better solution to translation err
s_result = jit.hint(s_result, access_directly=True, fresh_virtualizable=True)
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -506,6 +506,7 @@
self.w_object = objectmodel.instantiate(model.W_CompiledMethod)
else:
assert 0, "not reachable"
+ self.w_object.space = self.space
return self.w_object
def fillin_w_object(self):
diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py
--- a/spyvm/test/test_interpreter.py
+++ b/spyvm/test/test_interpreter.py
@@ -40,7 +40,7 @@
# Install faked compiled methods that just invoke the primitive:
for (w_class, primnum, argsize, methname) in methods:
s_class = w_class.as_class_get_shadow(space)
- prim_meth = model.W_CompiledMethod(0)
+ prim_meth = model.W_CompiledMethod(space, 0)
prim_meth.primitive = primnum
prim_meth.argsize = argsize
symbol = fakesymbol(methname)
@@ -89,17 +89,17 @@
def new_frame(bytes, receiver=space.w_nil, space=space):
assert isinstance(bytes, str)
- w_method = model.W_CompiledMethod(len(bytes))
+ w_method = model.W_CompiledMethod(space, len(bytes))
w_method.islarge = 1
w_method.bytes = bytes
w_method.argsize=2
w_method.tempsize=8
- w_method.setliterals([model.W_PointersObject(None, 2)])
+ w_method.setliterals([model.W_PointersObject(space, None, 2)])
s_frame = w_method.as_compiledmethod_get_shadow(space).create_frame(space, receiver, ["foo", "bar"])
return s_frame.w_self(), s_frame
def test_create_frame():
- w_method = model.W_CompiledMethod(len("hello"))
+ w_method = model.W_CompiledMethod(space, len("hello"))
w_method.bytes="hello"
w_method.islarge = 1
w_method.argsize=2
@@ -415,7 +415,7 @@
(returnNil, space.w_nil),
(returnTopFromMethod, space.w_one) ]:
shadow = w_class.as_class_get_shadow(space)
- w_method = model.W_CompiledMethod(2)
+ w_method = model.W_CompiledMethod(space, 2)
w_method.bytes = pushConstantOneBytecode + bytecode
literals = fakeliterals(space, "foo")
w_foo = literals[0]
@@ -444,7 +444,7 @@
def test_fibWithArgument():
bytecode = ''.join(map(chr, [ 16, 119, 178, 154, 118, 164, 11, 112, 16, 118, 177, 224, 112, 16, 119, 177, 224, 176, 124 ]))
shadow = mockclass(space, 0).as_class_get_shadow(space)
- method = model.W_CompiledMethod(len(bytecode))
+ method = model.W_CompiledMethod(space, len(bytecode))
method.literalsize = 1
method.bytes = bytecode
method.argsize = 1
@@ -585,7 +585,7 @@
def test_callPrimitiveAndPush_fallback():
w_frame, s_frame = new_frame(bytecodePrimAdd)
shadow = mockclass(space, 0).as_class_get_shadow(space)
- w_method = model.W_CompiledMethod(0)
+ w_method = model.W_CompiledMethod(space, 0)
w_method.argsize = 1
w_method.tempsize = 1
w_method.literalsize = 1
@@ -632,18 +632,18 @@
# first call method installed in w_class
bytecodes = singleExtendedSendBytecode + chr(0)
# which does a call to its super
- meth1 = model.W_CompiledMethod(2)
+ meth1 = model.W_CompiledMethod(space, 2)
meth1.bytes = pushReceiverBytecode + bytecode
literals = fakeliterals(space, "foo")
foo = literals[0]
meth1.setliterals(literals)
w_class.as_class_get_shadow(space).installmethod(foo, meth1)
# and that one again to its super
- meth2 = model.W_CompiledMethod(2)
+ meth2 = model.W_CompiledMethod(space, 2)
meth2.bytes = pushReceiverBytecode + bytecode
meth2.setliterals(fakeliterals(space, foo))
w_super.as_class_get_shadow(space).installmethod(foo, meth2)
- meth3 = model.W_CompiledMethod(0)
+ meth3 = model.W_CompiledMethod(space, 0)
w_supersuper.as_class_get_shadow(space).installmethod(foo, meth3)
w_frame, s_frame = new_frame(bytecodes)
s_frame.w_method().setliterals(literals)
@@ -834,7 +834,7 @@
# ^ self objectAt: 2. yields the first literal (22)
# ^ self objectAt: 2 put: 3. changes the first literal to 3
# ^ self objectAt: 2. yields the new first literal (3)
- prim_meth = model.W_CompiledMethod(header=1024)
+ prim_meth = model.W_CompiledMethod(space, header=1024)
prim_meth.setliterals(fakeliterals(space, 22))
oal = fakeliterals(space, "objectAt:")
oalp = fakeliterals(space, "objectAt:put:", 3)
@@ -975,7 +975,7 @@
0x00, 0x11, 0x10, 0x75, 0xb6, 0x9a, 0x75, 0xa4, 0x09, 0x8c, 0x00, 0x01,
0x10, 0x76, 0xb1, 0xca, 0x10, 0xb0, 0x7d, 0x8e, 0x00, 0x00, 0x8c, 0x00,
0x00, 0x20, 0xca, 0x7c]))
- w_method = model.W_CompiledMethod(len(bytes))
+ w_method = model.W_CompiledMethod(space, len(bytes))
w_method.islarge = 1
w_method.bytes = bytes
w_method.argsize=0
@@ -1023,7 +1023,7 @@
0x10, 0x76, 0xb1, 0xca, 0x10, 0xb0, 0x7d, 0x8e, 0x00, 0x00, 0x8c, 0x00,
0x00, 0x20, 0xca, 0x7c]))
- w_method = model.W_CompiledMethod(len(bytes))
+ w_method = model.W_CompiledMethod(space, len(bytes))
w_method.islarge = 1
w_method.bytes = bytes
w_method.argsize=0
diff --git a/spyvm/test/test_model.py b/spyvm/test/test_model.py
--- a/spyvm/test/test_model.py
+++ b/spyvm/test/test_model.py
@@ -86,13 +86,13 @@
w_super = mockclass(space, 0)
w_class = mockclass(space, 0, w_superclass=w_super)
supershadow = w_super.as_class_get_shadow(space)
- supershadow.installmethod(w_foo, model.W_CompiledMethod(0))
+ supershadow.installmethod(w_foo, model.W_CompiledMethod(space, 0))
classshadow = w_class.as_class_get_shadow(space)
classshadow.initialize_methoddict()
assert classshadow.lookup(w_foo).w_compiledin is w_super
def test_compiledmethod_setchar():
- w_method = model.W_CompiledMethod(3)
+ w_method = model.W_CompiledMethod(space, 3)
w_method.setchar(0, "c")
assert w_method.bytes == list("c\x00\x00")
@@ -108,7 +108,7 @@
assert h1 == w_inst.hash
def test_compiledmethod_at0():
- w_method = model.W_CompiledMethod()
+ w_method = model.W_CompiledMethod(space)
w_method.bytes = list("abc")
w_method.header = 100
w_method.setliterals(['lit1', 'lit2'])
@@ -121,7 +121,7 @@
assert space.unwrap_int(w_method.at0(space, 14)) == ord('c')
def test_compiledmethod_atput0():
- w_method = model.W_CompiledMethod(3)
+ w_method = model.W_CompiledMethod(space, 3)
newheader = joinbits([0,2,0,0,0,0],[9,8,1,6,4,1])
assert w_method.getliteralsize() == 0
w_method.atput0(space, 0, space.wrap_int(newheader))
@@ -140,37 +140,37 @@
def test_compiledmethod_atput0_not_aligned():
header = joinbits([0,2,0,0,0,0],[9,8,1,6,4,1])
- w_method = model.W_CompiledMethod(3, header)
+ w_method = model.W_CompiledMethod(space, 3, header)
with py.test.raises(error.PrimitiveFailedError):
w_method.atput0(space, 7, 'lit1')
with py.test.raises(error.PrimitiveFailedError):
w_method.atput0(space, 9, space.wrap_int(5))
-def test_is_same_object(w_o1=model.W_PointersObject(None,0), w_o2=None):
+def test_is_same_object(w_o1=model.W_PointersObject(space, None,0), w_o2=None):
if w_o2 is None:
w_o2 = w_o1
assert w_o1.is_same_object(w_o2)
assert w_o2.is_same_object(w_o1)
-def test_not_is_same_object(w_o1=model.W_PointersObject(None,0),w_o2=model.W_PointersObject(None,0)):
+def test_not_is_same_object(w_o1=model.W_PointersObject(space, None,0),w_o2=model.W_PointersObject(space, None,0)):
assert not w_o1.is_same_object(w_o2)
assert not w_o2.is_same_object(w_o1)
w_o2 = model.W_SmallInteger(2)
assert not w_o1.is_same_object(w_o2)
assert not w_o2.is_same_object(w_o1)
- w_o2 = model.W_Float(5.5)
+ w_o2 = model.W_Float(space, 5.5)
assert not w_o1.is_same_object(w_o2)
assert not w_o2.is_same_object(w_o1)
def test_intfloat_is_same_object():
test_is_same_object(model.W_SmallInteger(1), model.W_SmallInteger(1))
test_is_same_object(model.W_SmallInteger(100), model.W_SmallInteger(100))
- test_is_same_object(model.W_Float(1.100), model.W_Float(1.100))
+ test_is_same_object(model.W_Float(space, 1.100), model.W_Float(space, 1.100))
def test_intfloat_notis_same_object():
- test_not_is_same_object(model.W_SmallInteger(1), model.W_Float(1))
- test_not_is_same_object(model.W_Float(100), model.W_SmallInteger(100))
- test_not_is_same_object(model.W_Float(1.100), model.W_Float(1.200))
+ test_not_is_same_object(model.W_SmallInteger(1), model.W_Float(space, 1))
+ test_not_is_same_object(model.W_Float(space, 100), model.W_SmallInteger(100))
+ test_not_is_same_object(model.W_Float(space, 1.100), model.W_Float(space, 1.200))
test_not_is_same_object(model.W_SmallInteger(101), model.W_SmallInteger(100))
def test_charis_same_object():
@@ -220,7 +220,7 @@
def test_word_atput():
i = model.W_SmallInteger(100)
- b = model.W_WordsObject(None, 1)
+ b = model.W_WordsObject(space, None, 1)
b.atput0(space, 0, i)
assert 100 == b.getword(0)
i = space.classtable['w_LargePositiveInteger'].as_class_get_shadow(space).new(4)
@@ -229,7 +229,7 @@
assert b.getword(0) == 3221225472
def test_word_at():
- b = model.W_WordsObject(None, 1)
+ b = model.W_WordsObject(space, None, 1)
b.setword(0, 100)
r = b.at0(space, 0)
assert isinstance(r, model.W_SmallInteger)
@@ -241,7 +241,7 @@
assert r.size() == 4
def test_float_at():
- b = model.W_Float(64.0)
+ b = model.W_Float(space, 64.0)
r = b.fetch(space, 0)
assert isinstance(r, model.W_BytesObject)
assert r.size() == 4
@@ -251,9 +251,9 @@
assert r.value == 0
def test_float_at_put():
- target = model.W_Float(1.0)
+ target = model.W_Float(space, 1.0)
for f in [1.0, -1.0, 1.1, 64.4, -0.0, float('nan'), float('inf')]:
- source = model.W_Float(f)
+ source = model.W_Float(space, f)
target.store(space, 0, source.fetch(space, 0))
target.store(space, 1, source.fetch(space, 1))
if math.isnan(f):
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -230,7 +230,7 @@
def test_size_of_compiled_method():
literalsize = 3
bytecount = 3
- w_cm = model.W_CompiledMethod(bytecount)
+ w_cm = model.W_CompiledMethod(space, bytecount)
w_cm.literalsize = literalsize
assert prim(primitives.SIZE, [w_cm]).value == (literalsize+1)*constants.BYTES_PER_WORD + bytecount
diff --git a/spyvm/test/test_shadow.py b/spyvm/test/test_shadow.py
--- a/spyvm/test/test_shadow.py
+++ b/spyvm/test/test_shadow.py
@@ -36,7 +36,7 @@
w_Metaclass)
w_methoddict = build_methoddict(methods)
size = constants.CLASS_NAME_INDEX + 1
- w_class = model.W_PointersObject(w_classofclass, size)
+ w_class = model.W_PointersObject(space, w_classofclass, size)
w_class.store(space, constants.CLASS_SUPERCLASS_INDEX, w_superclass)
w_class.store(space, constants.CLASS_METHODDICT_INDEX, w_methoddict)
w_class.store(space, constants.CLASS_FORMAT_INDEX, space.wrap_int(format))
@@ -66,8 +66,8 @@
yield basicshape, "CompiledMeth", 0xE02, shadow.COMPILED_METHOD, True, 0
def test_methoddict():
- methods = {'foo': model.W_CompiledMethod(0),
- 'bar': model.W_CompiledMethod(0)}
+ methods = {'foo': model.W_CompiledMethod(space, 0),
+ 'bar': model.W_CompiledMethod(space, 0)}
w_class = build_smalltalk_class("Demo", 0x90, methods=methods)
classshadow = w_class.as_class_get_shadow(space)
methoddict = classshadow.s_methoddict().methoddict
@@ -76,7 +76,7 @@
assert methods[w_key.as_string()].as_compiledmethod_get_shadow(space) is value
def method(tempsize=3,argsize=2, bytes="abcde"):
- w_m = model.W_CompiledMethod()
+ w_m = model.W_CompiledMethod(space)
w_m.bytes = bytes
w_m.tempsize = tempsize
w_m.argsize = argsize
@@ -85,7 +85,7 @@
def methodcontext(w_sender=space.w_nil, pc=1, stackpointer=0, stacksize=5,
method=method()):
- w_object = model.W_PointersObject(space.w_MethodContext, constants.MTHDCTX_TEMP_FRAME_START+method.tempsize+stacksize)
+ w_object = model.W_PointersObject(space, space.w_MethodContext, constants.MTHDCTX_TEMP_FRAME_START+method.tempsize+stacksize)
w_object.store(space, constants.CTXPART_SENDER_INDEX, w_sender)
w_object.store(space, constants.CTXPART_PC_INDEX, space.wrap_int(pc))
w_object.store(space, constants.CTXPART_STACKP_INDEX, space.wrap_int(method.tempsize+stackpointer))
@@ -99,7 +99,7 @@
def blockcontext(w_sender=space.w_nil, pc=1, stackpointer=1, stacksize=5,
home=methodcontext()):
- w_object = model.W_PointersObject(space.w_MethodContext, constants.MTHDCTX_TEMP_FRAME_START+stacksize)
+ w_object = model.W_PointersObject(space, space.w_MethodContext, constants.MTHDCTX_TEMP_FRAME_START+stacksize)
w_object.store(space, constants.CTXPART_SENDER_INDEX, w_sender)
w_object.store(space, constants.CTXPART_PC_INDEX, space.wrap_int(pc))
w_object.store(space, constants.CTXPART_STACKP_INDEX, space.wrap_int(stackpointer))
@@ -180,7 +180,7 @@
from test_model import joinbits
header = joinbits([0,2,0,1,0,0],[9,8,1,6,4,1])
- w_compiledmethod = model.W_CompiledMethod(3, header)
+ w_compiledmethod = model.W_CompiledMethod(space, 3, header)
w_compiledmethod.setbytes(list("abc"))
shadow = w_compiledmethod.as_compiledmethod_get_shadow(space)
assert shadow.bytecode == "abc"
@@ -229,9 +229,9 @@
def test_cached_methoddict():
# create a methoddict
- foo = model.W_CompiledMethod(0)
- bar = model.W_CompiledMethod(0)
- baz = model.W_CompiledMethod(0)
+ foo = model.W_CompiledMethod(space, 0)
+ bar = model.W_CompiledMethod(space, 0)
+ baz = model.W_CompiledMethod(space, 0)
methods = {'foo': foo,
'bar': bar}
w_class = build_smalltalk_class("Demo", 0x90, methods=methods)
@@ -241,8 +241,8 @@
i = 0
key = s_methoddict.w_self()._fetch(constants.METHODDICT_NAMES_INDEX+i)
while key is space.w_nil:
+ i = i + 1
key = s_methoddict.w_self()._fetch(constants.METHODDICT_NAMES_INDEX+i)
- i = i + 1
assert (s_class.lookup(key) is foo.as_compiledmethod_get_shadow(space)
or s_class.lookup(key) is bar.as_compiledmethod_get_shadow(space))
@@ -250,19 +250,18 @@
w_array = s_class.w_methoddict()._fetch(constants.METHODDICT_VALUES_INDEX)
version = s_class.version
w_array.atput0(space, i, baz)
-
assert s_class.lookup(key) is baz.as_compiledmethod_get_shadow(space)
assert version is not s_class.version
def test_updating_class_changes_subclasses():
w_parent = build_smalltalk_class("Demo", 0x90,
- methods={'bar': model.W_CompiledMethod(0)})
+ methods={'bar': model.W_CompiledMethod(space, 0)})
w_class = build_smalltalk_class("Demo", 0x90,
- methods={'foo': model.W_CompiledMethod(0)}, w_superclass=w_parent)
+ methods={'foo': model.W_CompiledMethod(space, 0)}, w_superclass=w_parent)
s_class = w_class.as_class_get_shadow(space)
version = s_class.version
- w_method = model.W_CompiledMethod(0)
+ w_method = model.W_CompiledMethod(space, 0)
key = space.wrap_string('foo')
s_md = w_parent.as_class_get_shadow(space).s_methoddict()
diff --git a/spyvm/test/test_wrapper.py b/spyvm/test/test_wrapper.py
--- a/spyvm/test/test_wrapper.py
+++ b/spyvm/test/test_wrapper.py
@@ -10,7 +10,7 @@
return new_frame_tuple("")[0]
def test_simpleread():
- w_o = model.W_PointersObject(None, 2)
+ w_o = model.W_PointersObject(space, None, 2)
w = wrapper.Wrapper(space, w_o)
w_o._vars[0] = "hello"
assert w.read(0) == "hello"
@@ -20,7 +20,7 @@
py.test.raises(WrapperException, "w.write(2, \"test\")")
def test_accessor_generators():
- w_o = model.W_PointersObject(None, 1)
+ w_o = model.W_PointersObject(space, None, 1)
w = wrapper.LinkWrapper(space, w_o)
w_o._vars[0] = "hello"
assert w.next_link() == "hello"
@@ -28,12 +28,12 @@
assert w.next_link() == "boe"
def link(w_next='foo'):
- w_object = model.W_PointersObject(None, 1)
+ w_object = model.W_PointersObject(space, None, 1)
wrapper.LinkWrapper(space, w_object).store_next_link(w_next)
return w_object
def test_linked_list():
- w_object = model.W_PointersObject(None,2)
+ w_object = model.W_PointersObject(space, None,2)
w_last = link(space.w_nil)
w_lb1 = link(w_last)
w_lb2 = link(w_lb1)
@@ -72,7 +72,7 @@
w_suspended_context=space.w_nil,
priority=0):
w_priority = space.wrap_int(priority)
- w_process = model.W_PointersObject(None, 4)
+ w_process = model.W_PointersObject(space, None, 4)
process = wrapper.ProcessWrapper(space, w_process)
process.store_next_link(w_next)
process.store_my_list(w_my_list)
@@ -81,7 +81,7 @@
return process
def new_processlist(processes_w=[]):
- w_processlist = model.W_PointersObject(None, 2)
+ w_processlist = model.W_PointersObject(space, None, 2)
w_first = space.w_nil
w_last = space.w_nil
for w_process in processes_w[::-1]:
@@ -99,7 +99,7 @@
else:
maxpriority = 5
prioritydict = {}
- w_prioritylist = model.W_PointersObject(None, maxpriority)
+ w_prioritylist = model.W_PointersObject(space, None, maxpriority)
prioritylist = wrapper.Wrapper(space, w_prioritylist)
for i in range(maxpriority):
prioritylist.write(i, new_processlist(prioritydict.get(i, []))._w_self)
@@ -108,14 +108,14 @@
def new_scheduler(w_process=space.w_nil, prioritydict=None):
priority_list = new_prioritylist(prioritydict)
- w_scheduler = model.W_PointersObject(None, 2)
+ w_scheduler = model.W_PointersObject(space, None, 2)
scheduler = wrapper.SchedulerWrapper(space, w_scheduler)
scheduler.store_active_process(w_process)
scheduler.write(0, priority_list._w_self)
return scheduler
def new_semaphore(excess_signals=0):
- w_semaphore = model.W_PointersObject(None, 3)
+ w_semaphore = model.W_PointersObject(space, None, 3)
semaphore = wrapper.SemaphoreWrapper(space, w_semaphore)
semaphore.store_excess_signals(excess_signals)
return semaphore
More information about the pypy-commit
mailing list