[pypy-svn] r47901 - in pypy/dist/pypy/lang/smalltalk: . test
niko at codespeak.net
niko at codespeak.net
Thu Oct 25 11:33:21 CEST 2007
Author: niko
Date: Thu Oct 25 11:33:20 2007
New Revision: 47901
Added:
pypy/dist/pypy/lang/smalltalk/objtable.py
- copied unchanged from r47900, pypy/dist/pypy/lang/smalltalk/fakeimage.py
Removed:
pypy/dist/pypy/lang/smalltalk/fakeimage.py
Modified:
pypy/dist/pypy/lang/smalltalk/interpreter.py
pypy/dist/pypy/lang/smalltalk/primitives.py
pypy/dist/pypy/lang/smalltalk/squeakimage.py
pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
Log:
rename fakeimage to objtable
Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py Thu Oct 25 11:33:20 2007
@@ -1,6 +1,6 @@
import py
from pypy.lang.smalltalk import model, constants, primitives
-from pypy.lang.smalltalk import fakeimage
+from pypy.lang.smalltalk import objtable
class MissingBytecode(NotImplementedError):
@@ -399,13 +399,13 @@
class Interpreter:
- TRUE = fakeimage.w_true
- FALSE = fakeimage.w_false
- NIL = fakeimage.w_nil
- MONE = fakeimage.w_mone
- ZERO = fakeimage.w_zero
- ONE = fakeimage.w_one
- TWO = fakeimage.w_two
+ TRUE = objtable.w_true
+ FALSE = objtable.w_false
+ NIL = objtable.w_nil
+ MONE = objtable.w_mone
+ ZERO = objtable.w_zero
+ ONE = objtable.w_one
+ TWO = objtable.w_two
def __init__(self):
self.activeContext = None
Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py Thu Oct 25 11:33:20 2007
@@ -1,7 +1,7 @@
import operator
from pypy.lang.smalltalk import model, mirror
from pypy.lang.smalltalk import classtable
-from pypy.lang.smalltalk import fakeimage
+from pypy.lang.smalltalk import objtable
from pypy.rlib import rarithmetic
class PrimitiveFailedError(Exception):
@@ -19,9 +19,9 @@
if isinstance(w_obj, model.W_PointersObject):
return w_obj.getindexedvar(idx)
elif isinstance(w_obj, model.W_WordsObject):
- return fakeimage.wrap_int(w_obj.getword(idx))
+ return objtable.wrap_int(w_obj.getword(idx))
elif isinstance(w_obj, model.W_BytesObject):
- return fakeimage.wrap_int(w_obj.getbyte(idx))
+ return objtable.wrap_int(w_obj.getbyte(idx))
raise PrimitiveFailedError()
def assert_bounds(idx, minb, maxb):
@@ -68,7 +68,7 @@
raise PrimitiveFailedError()
if value < -1073741824:
raise PrimitiveFailedError()
- return fakeimage.wrap_int(value)
+ return objtable.wrap_int(value)
ADD = 1
SUBTRACT = 2
@@ -189,7 +189,7 @@
[w_v1, w_v2] = res
v1 = unwrap_float(w_v1)
v2 = unwrap_float(w_v2)
- w_res = fakeimage.wrap_float(op(v1, v2))
+ w_res = objtable.wrap_float(op(v1, v2))
return w_res
prim_table[code] = func
@@ -242,7 +242,7 @@
def func(stack):
w_obj, idx = common_at(stack)
byte = w_obj.getbyte(idx)
- return fakeimage.CharacterTable[byte]
+ return objtable.CharacterTable[byte]
@primitive(STRING_AT_PUT)
@stack(3)
@@ -250,7 +250,7 @@
w_obj, idx, w_val = common_at_put(stack)
if w_val.getclassmirror() is not classtable.m_Character:
raise PrimitiveFailedError()
- w_obj.setbyte(idx, fakeimage.ord_w_char(w_val))
+ w_obj.setbyte(idx, objtable.ord_w_char(w_val))
return w_val
# ___________________________________________________________________________
@@ -464,7 +464,7 @@
v1 = unwrap_int(w_v1)
v2 = unwrap_int(w_v2)
res = op(v1, v2)
- w_res = fakeimage.wrap_bool(res)
+ w_res = objtable.wrap_bool(res)
return w_res
for (code,op) in bool_ops.items():
@@ -475,7 +475,7 @@
v1 = unwrap_float(w_v1)
v2 = unwrap_float(w_v2)
res = op(v1, v2)
- w_res = fakeimage.wrap_bool(res)
+ w_res = objtable.wrap_bool(res)
return w_res
# ___________________________________________________________________________
@@ -498,13 +498,13 @@
def define_const_primitives():
for (code, const) in [
- (PUSH_TRUE, fakeimage.w_true),
- (PUSH_FALSE, fakeimage.w_false),
- (PUSH_NIL, fakeimage.w_nil),
- (PUSH_MINUS_ONE, fakeimage.w_mone),
- (PUSH_ZERO, fakeimage.w_zero),
- (PUSH_ONE, fakeimage.w_one),
- (PUSH_TWO, fakeimage.w_two),
+ (PUSH_TRUE, objtable.w_true),
+ (PUSH_FALSE, objtable.w_false),
+ (PUSH_NIL, objtable.w_nil),
+ (PUSH_MINUS_ONE, objtable.w_mone),
+ (PUSH_ZERO, objtable.w_zero),
+ (PUSH_ONE, objtable.w_one),
+ (PUSH_TWO, objtable.w_two),
]:
@primitive(code)
@stack(1)
Modified: pypy/dist/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/squeakimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/squeakimage.py Thu Oct 25 11:33:20 2007
@@ -1,6 +1,6 @@
import py
from pypy.lang.smalltalk import model
-from pypy.lang.smalltalk import fakeimage
+from pypy.lang.smalltalk import objtable
from pypy.lang.smalltalk.mirror import mirrorcache
from pypy.rlib import objectmodel
@@ -222,7 +222,7 @@
self.owner = reader
self.value = value
self.size = -1
- self.w_object = fakeimage.wrap_int(value)
+ self.w_object = objtable.wrap_int(value)
def initialize(self, chunk, reader):
self.owner = reader
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 Thu Oct 25 11:33:20 2007
@@ -1,6 +1,6 @@
import py
from pypy.lang.smalltalk import model, interpreter, primitives, mirror
-from pypy.lang.smalltalk.fakeimage import wrap_int
+from pypy.lang.smalltalk.objtable import wrap_int
import pypy.lang.smalltalk.classtable as ct
mockclassmirror = ct.bootstrap_classmirror
Modified: pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_primitives.py (original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_primitives.py Thu Oct 25 11:33:20 2007
@@ -3,7 +3,7 @@
from pypy.lang.smalltalk import model, mirror
from pypy.lang.smalltalk import interpreter
from pypy.lang.smalltalk import classtable
-from pypy.lang.smalltalk import fakeimage
+from pypy.lang.smalltalk import objtable
# Violates the guideline, but we use it A LOT to reference the primitive codes:
import pypy.lang.smalltalk.primitives as p
@@ -15,11 +15,11 @@
self.stack = stack
def wrap(x):
- if isinstance(x, int): return fakeimage.wrap_int(x)
- if isinstance(x, float): return fakeimage.wrap_float(x)
+ if isinstance(x, int): return objtable.wrap_int(x)
+ if isinstance(x, float): return objtable.wrap_float(x)
if isinstance(x, model.W_Object): return x
- if isinstance(x, str) and len(x) == 1: return fakeimage.wrap_char(x)
- if isinstance(x, str): return fakeimage.wrap_string(x)
+ if isinstance(x, str) and len(x) == 1: return objtable.wrap_char(x)
+ if isinstance(x, str): return objtable.wrap_string(x)
if isinstance(x, mirror.ClassMirror): return x.w_self
raise NotImplementedError
@@ -170,11 +170,11 @@
assert prim(p.STRING_AT, [test_str, i]) == wrap(exp[i])
def test_object_at():
- w_v = prim(p.OBJECT_AT, ["q", fakeimage.CHARACTER_VALUE_INDEX])
+ w_v = prim(p.OBJECT_AT, ["q", objtable.CHARACTER_VALUE_INDEX])
assert w_v.value == ord("q")
def test_invalid_object_at():
- prim_fails(p.OBJECT_AT, ["q", fakeimage.CHARACTER_VALUE_INDEX+1])
+ prim_fails(p.OBJECT_AT, ["q", objtable.CHARACTER_VALUE_INDEX+1])
def test_object_at_put():
w_obj = mockclassmirror(1).new()
@@ -210,7 +210,7 @@
def test_inst_var_at():
# I am not entirely sure if this is what this primitive is
# supposed to do, so the test may be bogus:
- w_v = prim(p.INST_VAR_AT, ["q", fakeimage.CHARACTER_VALUE_INDEX])
+ w_v = prim(p.INST_VAR_AT, ["q", objtable.CHARACTER_VALUE_INDEX])
assert w_v.value == ord("q")
w_v = prim(p.INST_VAR_AT, ["abc", 1])
assert w_v.value == ord("b")
@@ -225,30 +225,30 @@
def test_const_primitives():
for (code, const) in [
- (p.PUSH_TRUE, fakeimage.w_true),
- (p.PUSH_FALSE, fakeimage.w_false),
- (p.PUSH_NIL, fakeimage.w_nil),
- (p.PUSH_MINUS_ONE, fakeimage.w_mone),
- (p.PUSH_ZERO, fakeimage.w_zero),
- (p.PUSH_ONE, fakeimage.w_one),
- (p.PUSH_TWO, fakeimage.w_two),
+ (p.PUSH_TRUE, objtable.w_true),
+ (p.PUSH_FALSE, objtable.w_false),
+ (p.PUSH_NIL, objtable.w_nil),
+ (p.PUSH_MINUS_ONE, objtable.w_mone),
+ (p.PUSH_ZERO, objtable.w_zero),
+ (p.PUSH_ONE, objtable.w_one),
+ (p.PUSH_TWO, objtable.w_two),
]:
- assert prim(code, [fakeimage.w_nil]) is const
- assert prim(p.PUSH_SELF, [fakeimage.w_nil]) is fakeimage.w_nil
+ assert prim(code, [objtable.w_nil]) is const
+ assert prim(p.PUSH_SELF, [objtable.w_nil]) is objtable.w_nil
assert prim(p.PUSH_SELF, ["a"]) is wrap("a")
def test_boolean():
- assert prim(p.LESSTHAN, [1,2]) == fakeimage.w_true
- assert prim(p.GREATERTHAN, [3,4]) == fakeimage.w_false
- assert prim(p.LESSOREQUAL, [1,2]) == fakeimage.w_true
- assert prim(p.GREATEROREQUAL, [3,4]) == fakeimage.w_false
- assert prim(p.EQUAL, [2,2]) == fakeimage.w_true
- assert prim(p.NOTEQUAL, [2,2]) == fakeimage.w_false
+ assert prim(p.LESSTHAN, [1,2]) == objtable.w_true
+ assert prim(p.GREATERTHAN, [3,4]) == objtable.w_false
+ assert prim(p.LESSOREQUAL, [1,2]) == objtable.w_true
+ assert prim(p.GREATEROREQUAL, [3,4]) == objtable.w_false
+ assert prim(p.EQUAL, [2,2]) == objtable.w_true
+ assert prim(p.NOTEQUAL, [2,2]) == objtable.w_false
def test_float_boolean():
- assert prim(p.FLOAT_LESSTHAN, [1.0,2.0]) == fakeimage.w_true
- assert prim(p.FLOAT_GREATERTHAN, [3.0,4.0]) == fakeimage.w_false
- assert prim(p.FLOAT_LESSOREQUAL, [1.3,2.6]) == fakeimage.w_true
- assert prim(p.FLOAT_GREATEROREQUAL, [3.5,4.9]) == fakeimage.w_false
- assert prim(p.FLOAT_EQUAL, [2.2,2.2]) == fakeimage.w_true
- assert prim(p.FLOAT_NOTEQUAL, [2.2,2.2]) == fakeimage.w_false
+ assert prim(p.FLOAT_LESSTHAN, [1.0,2.0]) == objtable.w_true
+ assert prim(p.FLOAT_GREATERTHAN, [3.0,4.0]) == objtable.w_false
+ assert prim(p.FLOAT_LESSOREQUAL, [1.3,2.6]) == objtable.w_true
+ assert prim(p.FLOAT_GREATEROREQUAL, [3.5,4.9]) == objtable.w_false
+ assert prim(p.FLOAT_EQUAL, [2.2,2.2]) == objtable.w_true
+ assert prim(p.FLOAT_NOTEQUAL, [2.2,2.2]) == objtable.w_false
More information about the Pypy-commit
mailing list