[pypy-svn] r18410 - in pypy/dist/pypy/translator/c: . test
afa at codespeak.net
afa at codespeak.net
Tue Oct 11 16:54:36 CEST 2005
Author: afa
Date: Tue Oct 11 16:54:34 2005
New Revision: 18410
Modified:
pypy/dist/pypy/translator/c/stackless.py
pypy/dist/pypy/translator/c/test/test_standalone.py
Log:
(Valentino, afa): more stackless tests and bugfixes
Modified: pypy/dist/pypy/translator/c/stackless.py
==============================================================================
--- pypy/dist/pypy/translator/c/stackless.py (original)
+++ pypy/dist/pypy/translator/c/stackless.py Tue Oct 11 16:54:34 2005
@@ -166,6 +166,7 @@
argtypes = [erase_ptr_type(v.concretetype)
for v in self.graph.getargs()]
argtypes = [T for T in argtypes if T is not lltype.Void]
+ import sys
rettype = erase_ptr_type(self.graph.getreturnvar().concretetype)
FUNC = lltype.FuncType(argtypes, rettype)
slpdata.registerunwindable(self.functionname, FUNC,
@@ -180,24 +181,11 @@
curpos = block.operations.index(op)
# XXX obscure: find all variables that are produced before 'op'
- # and still used by or after 'op'.
- produced = {}
+ vars = []
for v in block.inputargs:
- produced[v] = True
+ vars.append(v)
for op1 in block.operations[:curpos]:
- produced[op1.result] = True
- consumed = {}
- for op1 in block.operations[curpos:]:
- for v in op1.args:
- if isinstance(v, Variable):
- consumed[v] = True
- if isinstance(block.exitswitch, Variable):
- consumed[block.exitswitch] = True
- for link in block.exits:
- for v in link.args:
- if isinstance(v, Variable):
- consumed[v] = True
- vars = [v for v in produced if v in consumed]
+ vars.append(op1.result)
# get the simplified frame struct that can store these vars
counts = {"long": [],
@@ -205,7 +193,7 @@
"void*": []}
variables_to_restore = []
for v in vars:
- st = simplified_type(v.concretetype)
+ st = simplified_type(erase_ptr_type(v.concretetype))
if st is not None: # ignore the Voids
varname = self.expr(v)
# XXX hackish: the name of the field in the structure is
@@ -250,7 +238,7 @@
varname, cdecl(vartype, ''), structname, fieldname))
retvarname = self.expr(op.result)
retvartype = self.lltypename(op.result)
- retvarst = simplified_type(op.result.concretetype)
+ retvarst = simplified_type(erase_ptr_type(op.result.concretetype))
if retvarst is not None:
globalretvalvarname = RETVALVARS[retvarst]
lines.append('%s = (%s) %s;' % (
@@ -283,10 +271,10 @@
return None
elif T is lltype.Float:
return "double"
+ elif T is Address:
+ return "void*"
elif isinstance(T, lltype.Primitive):
return "long" # large enough for all other primitives
- elif isinstance(T, lltype.Ptr):
- return "void*"
else:
raise Exception("don't know about %r" % (T,))
Modified: pypy/dist/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/dist/pypy/translator/c/test/test_standalone.py Tue Oct 11 16:54:34 2005
@@ -48,7 +48,7 @@
data = wrap_stackless_function(fn)
assert data.strip() == '10'
-def INPROGRESStest_stack_withptr():
+def test_stack_withptr():
def f(n):
if n > 0:
res = f(n-1)
More information about the Pypy-commit
mailing list