[pypy-svn] r28244 - in pypy/dist/pypy/translator: c stackless stackless/test
mwh at codespeak.net
mwh at codespeak.net
Sun Jun 4 13:10:44 CEST 2006
Author: mwh
Date: Sun Jun 4 13:10:43 2006
New Revision: 28244
Modified:
pypy/dist/pypy/translator/c/primitive.py
pypy/dist/pypy/translator/stackless/test/test_resume_point.py
pypy/dist/pypy/translator/stackless/transform.py
Log:
(mwh, pedronis)
Run the resume point tests after translation to C too.
Fix an argh thus revealed.
We think we're done for this subsubtask now.
Modified: pypy/dist/pypy/translator/c/primitive.py
==============================================================================
--- pypy/dist/pypy/translator/c/primitive.py (original)
+++ pypy/dist/pypy/translator/c/primitive.py Sun Jun 4 13:10:43 2006
@@ -45,6 +45,9 @@
value = value.compute_fn()
else:
raise Exception("unimplemented symbolic %r"%value)
+ if value is None:
+ assert not db.completed
+ return None
if value == -sys.maxint-1: # blame C
return '(-%dL-1L)' % sys.maxint
else:
Modified: pypy/dist/pypy/translator/stackless/test/test_resume_point.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_resume_point.py (original)
+++ pypy/dist/pypy/translator/stackless/test/test_resume_point.py Sun Jun 4 13:10:43 2006
@@ -56,6 +56,8 @@
return v1*100 + v2
res = llinterp_stackless_function(example)
assert res == 412
+ res = run_stackless_function(example)
+ assert res == 412
def test_returns_with_instance():
class C:
@@ -74,23 +76,8 @@
return v1*100 + v2
res = llinterp_stackless_function(example, assert_unwind=False)
assert res == 408
-
-def test_call_exception_handling():
- def g(x,y):
- if x == 0:
- raise KeyError
- return x*y
- def f(x, y):
- try:
- z = g(x,y)
- rstack.resume_point("rp1", y, returns=z)
- except KeyError:
- return 0
- return z+y
- def example():
- f(one(),one()+one())
- return 0
- transform_stackless_function(example)
+ res = run_stackless_function(example)
+ assert res == 408
def test_call_uncovered():
def g(x,y):
@@ -120,7 +107,9 @@
s2 = rstack.resume_state_create(None, "rp2", 2*one())
s1 = rstack.resume_state_create(s2, "rp1", 4*one(), 5*one())
return 100*v1 + rstack.resume_state_invoke(int, s1)
- res = llinterp_stackless_function(example, assert_unwind=False)
+ res = llinterp_stackless_function(example)
+ assert res == 811
+ res = run_stackless_function(example)
assert res == 811
def test_return_instance():
@@ -142,7 +131,9 @@
c.x = 4*one()
s1 = rstack.resume_state_create(s2, "rp1", c)
return v1*100 + rstack.resume_state_invoke(int, s1)
- res = llinterp_stackless_function(example, assert_unwind=False)
+ res = llinterp_stackless_function(example)
+ assert res == 406
+ res = run_stackless_function(example)
assert res == 406
def test_really_return_instance():
@@ -161,6 +152,8 @@
return v1*100 + rstack.resume_state_invoke(C, s1).x
res = llinterp_stackless_function(example)
assert res == 204
+ res = run_stackless_function(example)
+ assert res == 204
def test_resume_and_raise():
def g(x):
@@ -178,6 +171,8 @@
return v1*100 + v2
res = llinterp_stackless_function(example)
assert res == 242
+ res = run_stackless_function(example)
+ assert res == 242
def test_resume_and_raise_and_catch():
def g(x):
@@ -201,6 +196,8 @@
return v1*100 + v2
res = llinterp_stackless_function(example)
assert res == 141
+ res = run_stackless_function(example)
+ assert res == 141
def test_invoke_raising():
def g(x):
@@ -222,4 +219,6 @@
return v1*100 + v2
res = llinterp_stackless_function(example)
assert res == 141
+ res = run_stackless_function(example)
+ assert res == 141
Modified: pypy/dist/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/transform.py (original)
+++ pypy/dist/pypy/translator/stackless/transform.py Sun Jun 4 13:10:43 2006
@@ -56,12 +56,17 @@
# return retval + x + 1
class SymbolicRestartNumber(ComputedIntSymbolic):
- def __init__(self, value=None):
+ def __init__(self, label, value=None):
ComputedIntSymbolic.__init__(self, self._getvalue)
+ self.label = label
self.value = value
def _getvalue(self):
- assert self.value is not None
+ # argh, we'd like to assert-fail if value is None here, but we
+ # get called too early (during databasing) for this to be
+ # valid. so we might return None and rely on the database
+ # checking that this only happens before the database is
+ # complete.
return self.value
class ResumePoint:
@@ -499,7 +504,7 @@
assert symb.value is None
symb.value = restart_number
else:
- symb = SymbolicRestartNumber(restart_number)
+ symb = SymbolicRestartNumber(label, restart_number)
self.symbolic_restart_numbers[label] = symb
return link.target, i
@@ -528,7 +533,7 @@
if label in self.symbolic_restart_numbers:
symb = self.symbolic_restart_numbers[label]
else:
- symb = SymbolicRestartNumber()
+ symb = SymbolicRestartNumber(label)
self.symbolic_restart_numbers[label] = symb
llops.genop('setfield', [v_state,
More information about the Pypy-commit
mailing list