[pypy-svn] r30138 - in pypy/dist/pypy: module/_stackless objspace
auc at codespeak.net
auc at codespeak.net
Mon Jul 17 18:07:32 CEST 2006
Author: auc
Date: Mon Jul 17 18:07:26 2006
New Revision: 30138
Modified:
pypy/dist/pypy/module/_stackless/coroutine.py
pypy/dist/pypy/module/_stackless/interp_clonable.py
pypy/dist/pypy/objspace/logic.py
Log:
transl. fixes
Modified: pypy/dist/pypy/module/_stackless/coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/coroutine.py (original)
+++ pypy/dist/pypy/module/_stackless/coroutine.py Mon Jul 17 18:07:26 2006
@@ -247,19 +247,6 @@
space = module.space
AppCoroutine._get_state(space).post_install()
-
-from pypy.module._stackless.interp_clonable import InterpClonableCoroutine
-
-
-class ClonableCoroutine(AppCoroutine, InterpClonableCoroutine):
-
- def w_getcurrent(space):
- c = AppCoroutine._get_state(space).current
- assert c.frame is None
- return space.wrap(c)
- w_getcurrent = staticmethod(w_getcurrent)
-
-
# space.appexec("""() :
# maybe use __spacebind__ for postprocessing
Modified: pypy/dist/pypy/module/_stackless/interp_clonable.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/interp_clonable.py (original)
+++ pypy/dist/pypy/module/_stackless/interp_clonable.py Mon Jul 17 18:07:26 2006
@@ -1,8 +1,9 @@
from pypy.module._stackless.interp_coroutine import AbstractThunk
+from pypy.module._stackless.coroutine import AppCoroutine
from pypy.rpython.rgc import gc_swap_pool, gc_clone
from pypy.rpython.objectmodel import we_are_translated
-class InterpClonableCoroutine(object):
+class InterpClonableCoroutine(AppCoroutine):
local_pool = None
def hello(self):
@@ -17,6 +18,10 @@
else:
AppCoroutine.goodbye(self)
+ def w_getcurrent(space):
+ return space.wrap(InterpClonableCoroutine._get_state(space).current)
+ w_getcurrent = staticmethod(w_getcurrent)
+
def clone(self):
if not we_are_translated():
raise NotImplementedError
@@ -28,7 +33,7 @@
# cannot gc_clone() directly self, because it is not in its own
# local_pool. Moreover, it has a __del__, which cloning doesn't
# support properly at the moment.
- copy = ClonableCoroutine(self.costate)
+ copy = InterpClonableCoroutine(self.costate)
copy.parent = self.parent
copy.frame, copy.local_pool = gc_clone(self.frame, self.local_pool)
return copy
Modified: pypy/dist/pypy/objspace/logic.py
==============================================================================
--- pypy/dist/pypy/objspace/logic.py (original)
+++ pypy/dist/pypy/objspace/logic.py Mon Jul 17 18:07:26 2006
@@ -15,17 +15,18 @@
# misc
import os
-DEBUG = True
-def w(*msgs, **kwopt):
- if not DEBUG: return
+def w(*msgs):
+ """writeln"""
+ if we_are_translated(): return
+ v(*msgs)
+ os.write(1, ' \n')
+
+def v(*msgs):
+ """write"""
+ if we_are_translated(): return
for msg in msgs:
os.write(1, str(msg))
os.write(1, ' ')
- try:
- if kwopt['LF']:
- raise Exception
- except:
- os.write(1, ' \n')
#-- THE BUILTINS ----------------------------------------------------------------------
@@ -53,7 +54,9 @@
assert USE_COROUTINES # once & for all
-from pypy.module._stackless.coroutine import _AppThunk, AppCoState, Coroutine, ClonableCoroutine
+from pypy.module._stackless.coroutine import _AppThunk
+from pypy.module._stackless.coroutine import Coroutine
+from pypy.module._stackless.interp_clonable import InterpClonableCoroutine as ClonableCoroutine
def SETNEXT(obj, val):
obj.next = val
@@ -133,7 +136,7 @@
def schedule(self):
to_be_run = self._select_next(lambda coro: coro in self._blocked)
w(".. SWITCHING", id(ClonableCoroutine.w_getcurrent(self.space)), "=>", id(to_be_run))
- to_be_run.w_switch()
+ to_be_run.switch()
def _select_next(self, skip_condition):
"""skip_condition is a predicate for NOT selecting one thread"""
@@ -155,15 +158,16 @@
def display_head(self):
curr = self._head
- w("HEAD : [prev, curr, next]", LF=False)
- w([id(self._head.prev), id(self._head), id(self._head.next)], LF=False)
+ v("HEAD : [prev, curr, next]")
+ v([id(self._head.prev), id(self._head), id(self._head.next)])
while curr.next != self._head:
curr = curr.next
- w([id(curr.prev), id(curr), id(curr.next)], LF=False)
+ v([id(curr.prev), id(curr), id(curr.next)])
w()
def add_new_thread(self, thread):
"insert 'thread' at end of running queue"
+ assert isinstance(thread, ClonableCoroutine)
self._chain_insert(thread)
def add_to_blocked_on(self, w_var, uthread):
@@ -180,7 +184,7 @@
self._blocked[uthread] = True
def unblock_on(self, w_var):
- w(".. we UNBLOCK threads dependants of var", id(w_var), LF=False)
+ v(".. we UNBLOCK threads dependants of var", id(w_var))
assert isinstance(w_var, W_Var)
blocked = []
if w_var in self._blocked_on:
@@ -192,7 +196,7 @@
def add_to_blocked_byneed(self, w_var, uthread):
w(".. we BLOCK BYNEED thread", id(uthread), "on var", id(w_var))
assert isinstance(w_var, W_Var)
- assert isinstance(uthread, Coroutine)
+ assert isinstance(uthread, ClonableCoroutine)
if w_var in self._blocked_byneed:
blocked = self._blocked_byneed[w_var]
else:
@@ -202,7 +206,7 @@
self._blocked[uthread] = True
def unblock_byneed_on(self, space, w_var):
- w(".. we UNBLOCK BYNEED dependants of var", id(w_var), LF=False)
+ v(".. we UNBLOCK BYNEED dependants of var", id(w_var))
assert isinstance(w_var, W_Var)
blocked = []
for w_alias in aliases(space, w_var):
@@ -420,7 +424,8 @@
l = len(a_str) - 1
return a_str[l-3:l]
-def interp_id(w_obj):
+def interp_id(space, w_obj):
+ assert isinstance(w_obj, W_ObjectObject)
return space.newint(id(w_obj))
app_interp_id = gateway.interp2app(interp_id)
@@ -431,7 +436,7 @@
2. assign bound var to unbound var
3. assign value to unbound var
"""
- w(" :bind", LF=False)
+ v(" :bind")
assert isinstance(w_var, W_Var)
assert isinstance(w_obj, W_Root)
space.bind(w_var, w_obj)
More information about the Pypy-commit
mailing list