[pypy-svn] r47824 - in pypy/dist/pypy/lang/smalltalk: . test
akuhn at codespeak.net
akuhn at codespeak.net
Wed Oct 24 14:55:49 CEST 2007
Author: akuhn
Date: Wed Oct 24 14:55:48 2007
New Revision: 47824
Modified:
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
Log:
(cfbolz, akuhn)
changed internal representation of W_PointersObject to use one list only, as on image loading there is no clue about instVarSize (the file just specifies the total size)
Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py (original)
+++ pypy/dist/pypy/lang/smalltalk/model.py Wed Oct 24 14:55:48 2007
@@ -23,23 +23,25 @@
""" The normal object """
def __init__(self, w_class, size=0):
W_Object.__init__(self, w_class)
- self.named_vars = [None] * w_class.instvarsize
- self.indexed_vars = [None] * size
+ self.vars = [None] * (w_class.instvarsize + size)
def getnamedvar(self, index):
- return self.named_vars[index]
+ if not index < self.w_class.instvarsize: raise IndexError
+ return self.vars[index]
def setnamedvar(self, index, w_value):
- self.named_vars[index] = w_value
+ if not index < self.w_class.instvarsize: raise IndexError
+ self.vars[index] = w_value
def size(self):
- return len(self.indexed_vars)
+ return len(self.vars) - self.w_class.instvarsize
def getindexedvar(self, index):
- return self.indexed_vars[index]
+ return self.vars[index + self.w_class.instvarsize]
def setindexedvar(self, index, w_value):
- self.indexed_vars[index] = w_value
+ self.vars[index + self.w_class.instvarsize] = w_value
+
class W_BytesObject(W_Object):
def __init__(self, w_class, size):
@@ -72,7 +74,6 @@
class W_CompiledMethod(W_Object):
"""My instances are methods suitable for interpretation by the virtual machine. This is the only class in the system whose instances intermix both indexable pointer fields and indexable integer fields.
-
The current format of a CompiledMethod is as follows:
header (4 bytes)
@@ -90,7 +91,6 @@
(index 28) 1 bit: high-bit of primitive number (#primitive)
(index 29) 1 bit: flag bit, ignored by the VM (#flag)
-
The trailer has two variant formats. In the first variant, the last byte is at least 252 and the last four bytes represent a source pointer into one of the sources files (see #sourcePointer). In the second variant, the last byte is less than 252, and the last several bytes are a compressed version of the names of the method's temporary variables. The number of bytes used for this purpose is the value of the last byte in the method.
"""
def __init__(self, w_class, size, bytes="", argsize=0,
Modified: pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py (original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py Wed Oct 24 14:55:48 2007
@@ -126,9 +126,9 @@
assert interp.activeContext.stack == []
for test_index in range(8):
if test_index == index:
- assert w_object.named_vars[test_index] == interp.TRUE
+ assert w_object.getnamedvar(test_index) == interp.TRUE
else:
- assert w_object.named_vars[test_index] == None
+ assert w_object.getnamedvar(test_index) == None
def test_storeAndPopTemporaryVariableBytecode():
for index in range(8):
@@ -367,9 +367,9 @@
assert interp.activeContext.stack == []
for test_index in range(8):
if test_index == index:
- assert w_object.named_vars[test_index] == interp.TRUE
+ assert w_object.getnamedvar(test_index) == interp.TRUE
else:
- assert w_object.named_vars[test_index] == None
+ assert w_object.getnamedvar(test_index) == None
def test_extendedStoreAndPopBytecode1():
for index in range(8):
More information about the Pypy-commit
mailing list