[pypy-svn] r62162 - in pypy/branch/spy-graphic/pypy/lang/smalltalk: . test
witulski at codespeak.net
witulski at codespeak.net
Wed Feb 25 18:51:56 CET 2009
Author: witulski
Date: Wed Feb 25 18:51:56 2009
New Revision: 62162
Modified:
pypy/branch/spy-graphic/pypy/lang/smalltalk/conftest.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/interpreter.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/primitives.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/squeakimage.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_interpreter.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_wrapper.py
pypy/branch/spy-graphic/pypy/lang/smalltalk/wrapper.py
Log:
(cfbolz, witulski): the int getters and setters don't really need a space argument.
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/conftest.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/conftest.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/conftest.py Wed Feb 25 18:51:56 2009
@@ -7,4 +7,9 @@
dest="bc_trace",
default=False,
help="print bytecodes and stack during execution"),
- )
+ Option('--prim-trace',
+ action="store_true",
+ dest="prim_trace",
+ default=False,
+ help="print called primitives during execution"),
+)
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/interpreter.py Wed Feb 25 18:51:56 2009
@@ -42,8 +42,12 @@
except ReturnFromTopLevel, e:
return e.object
- def should_trace(self):
- return (not objectmodel.we_are_translated()) and option.bc_trace
+ def should_trace(self, primitives=False):
+ if objectmodel.we_are_translated():
+ return False
+ if not primitives:
+ return option.bc_trace
+ return option.prim_trace
def step(self):
next = self.s_active_context().getNextBytecode()
@@ -207,7 +211,7 @@
w_result = func(interp, argcount)
return
except primitives.PrimitiveFailedError:
- if interp.should_trace():
+ if interp.should_trace(True):
print "PRIMITIVE FAILED: %d %s" % (method.primitive, selector,)
pass # ignore this error and fall back to the Smalltalk version
arguments = self.pop_and_return_n(argcount)
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/primitives.py Wed Feb 25 18:51:56 2009
@@ -289,10 +289,10 @@
@expose_primitive(MAKE_POINT, unwrap_spec=[int, int])
def func(interp, x, y):
- w_res = interp.space.classtable['w_Point'].as_class_get_shadow(interp.space).new(2)
+ w_res = interp.space.w_Point.as_class_get_shadow(interp.space).new(2)
point = wrapper.PointWrapper(interp.space, w_res)
- point.store_x(interp.space, x)
- point.store_y(interp.space, y)
+ point.store_x(x)
+ point.store_y(y)
return w_res
@@ -455,6 +455,31 @@
return w_method
# ___________________________________________________________________________
+# I/O Primitives
+
+MOUSE_POINT = 90
+TEST_DISPLAY_DEPTH = 91
+SET_DISPLAY_MODE = 92
+INPUT_SEMAPHORE = 93
+GET_NEXT_EVENT = 94
+INPUT_WORD = 95
+OBSOLETE_INDEXED_PRIMITIVE = 96
+SNAPSHOT = 97
+STORE_IMAGE_SEGMENT = 98
+LOAD_IMAGE_SEGMENT = 99
+PERFORM_IN_SUPERCLASS = 100
+BE_CURSOR = 101
+BE_DISPLAY = 102
+SCAN_CHARACTERS = 103
+OBSOLETE_INDEXED_PRIMITIVE =104
+STRING_REPLACE = 105
+SCREEN_SIZE = 106
+MOUSE_BUTTONS = 107
+KBD_NEXT = 108
+KBD_PEEK = 109
+
+
+# ___________________________________________________________________________
# Control Primitives
EQUIVALENT = 110
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/squeakimage.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/squeakimage.py Wed Feb 25 18:51:56 2009
@@ -111,6 +111,7 @@
# 1 word last used hash
lasthash = self.stream.next()
savedwindowssize = self.stream.next()
+ print "savedwindowssize", savedwindowssize
fullscreenflag = self.stream.next()
extravmmemory = self.stream.next()
# we called 9 times next, 1 word = 4 byte
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_interpreter.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_interpreter.py Wed Feb 25 18:51:56 2009
@@ -464,8 +464,8 @@
w_point = interp.s_active_context().top()
from pypy.lang.smalltalk.wrapper import PointWrapper
point = PointWrapper(interp.space, w_point)
- assert point.x(interp.space) == 0
- assert point.y(interp.space) == 1
+ assert point.x() == 0
+ assert point.y() == 1
def test_longJumpIfTrue():
interp = new_interpreter(longJumpIfTrue(0) + chr(15) + longJumpIfTrue(0) + chr(15))
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_wrapper.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_wrapper.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/test/test_wrapper.py Wed Feb 25 18:51:56 2009
@@ -115,7 +115,7 @@
def new_semaphore(excess_signals=0):
w_semaphore = model.W_PointersObject(None, 3)
semaphore = wrapper.SemaphoreWrapper(space, w_semaphore)
- semaphore.store_excess_signals(space, excess_signals)
+ semaphore.store_excess_signals(excess_signals)
return semaphore
@@ -205,7 +205,7 @@
semaphore = new_semaphore()
self.space = space
semaphore.signal(self)
- assert semaphore.excess_signals(space) == 1
+ assert semaphore.excess_signals() == 1
def test_highest_priority(self):
py.test.raises(FatalError, wrapper.scheduler(space).highest_priority_process)
Modified: pypy/branch/spy-graphic/pypy/lang/smalltalk/wrapper.py
==============================================================================
--- pypy/branch/spy-graphic/pypy/lang/smalltalk/wrapper.py (original)
+++ pypy/branch/spy-graphic/pypy/lang/smalltalk/wrapper.py Wed Feb 25 18:51:56 2009
@@ -34,13 +34,13 @@
return make_getter(index0), make_setter(index0)
def make_int_getter(index0):
- def getter(self, space):
- return space.unwrap_int(self.read(index0))
+ def getter(self):
+ return self.space.unwrap_int(self.read(index0))
return getter
def make_int_setter(index0):
- def setter(self, space, new):
- return self.write(index0, space.wrap_int(new))
+ def setter(self, new):
+ return self.write(index0, self.space.wrap_int(new))
return setter
def make_int_getter_setter(index0):
@@ -186,17 +186,17 @@
def signal(self, interp):
if self.is_empty_list():
- value = self.excess_signals(interp.space)
- self.store_excess_signals(interp.space, value + 1)
+ value = self.excess_signals()
+ self.store_excess_signals(value + 1)
else:
process = self.remove_first_link_of_list()
ProcessWrapper(self.space, process).resume(interp)
def wait(self, interp):
- excess = self.excess_signals(interp.space)
+ excess = self.excess_signals()
w_process = scheduler(interp.space).active_process()
if excess > 0:
- self.store_excess_signals(interp.space, excess - 1)
+ self.store_excess_signals(excess - 1)
else:
self.add_last_link(w_process)
ProcessWrapper(self.space, w_process).suspend(interp)
@@ -219,6 +219,3 @@
class CursorWrapper(MaskWrapper):
offset = make_getter(4)
-class PointWrapper(Wrapper):
- x, store_x = make_int_getter_setter(0)
- y, store_y = make_int_getter_setter(1)
More information about the Pypy-commit
mailing list