Hi friends,
I was playing with generated RPy functions, and just for fun,
I ran my generator over its output.
That should give an RPython interpreter for the whole
pypy implementation.
Not too useful, but nice to look at, better than disassembly :-)
Here *the problem*:
When I run flow space over my attached generated function,
it crashes with an UnboundLocalError: w_26.
This *is not* an error, because all the paths can only be
walked in the order enforced by the big goto loop.
But the flow space seems to step into a problem here.
Well, flow space tries every branch, and most probably
without looking at the data.
Question: Is it possible to change the flow space to just
ignore unbound variables?
Or is this kind of code to be defined as NOT_RPYTHON ?
The latter would be very bad, since I'm trying to create RPython,
so it should be.
An ugly solution would be to initialize all variables to
some default.
Please let me know ASAP -- ciao - chris
--
Christian Tismer :^) <mailto:[EMAIL PROTECTED]>
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
#!/bin/env python
# -*- coding: LATIN-1 -*-
##SECTION##
## filename 'genrpy.py'
## function 'ff'
## firstlineno 1062
##SECTION##
# global declarations
# global object gcls_SystemError
# global object gi_42
def f_ff(space, *args_w):
kwlist = ["a", "b", "c"]
w_1 = space.newtuple(list(args_w[3:]))
_args_w = args_w[:3]
defaults_w = (gi_3,)
# XXX should parse args here, but no keyword support in gateway
funcname = "ff"
w_2, w_4, w_6 = PyArg_ParseMini(space, funcname, 2, 3, _args_w, defaults_w)
return fastf_ff(space, w_2, w_4, w_6, w_1)
def fastf_ff(space, w_2, w_4, w_6, w_1):
goto = 1 # startblock
while True:
if goto == 1:
v0 = space.is_true(w_1)
if v0 == True:
w_3, w_5, w_7, w_8 = w_2, w_4, w_6, w_1
goto = 3
else:
assert v0 == False
w_9, w_10, w_11, w_12 = w_2, w_4, w_6, w_1
goto = 2
if goto == 2:
w_13 = space.add(w_9, w_10)
v14 = space.is_true(w_12)
if v14 == True:
(w_15, w_16, w_17, w_18, w_19, w_20) = (w_9, w_10, w_11, w_12,
w_13, v14)
goto = 5
else:
assert v14 == False
w_21 = w_13
goto = 6
if goto == 3:
v22 = space.is_true(w_8)
if v22 == True:
w_23, w_24, w_25, w_26, w_27 = w_3, w_5, w_7, w_8, v22
goto = 4
else:
assert v22 == False
w_28, w_29 = gcls_SystemError, gi_42
goto = 7
if goto == 4:
w_30 = space.len(w_26)
w_31 = space.newtuple([w_30, w_25])
w_21 = w_31
goto = 6
if goto == 5:
w_32 = space.len(w_18)
w_33 = space.newtuple([w_32, w_17])
w_21 = w_33
goto = 6
if goto == 6:
return w_21
if goto == 7:
raise OperationError(w_28, w_29)
##SECTION##
## filename 'genrpy.py'
## function '<lambda>'
## firstlineno 1142
##SECTION##
# global declarations
# global object gfunc__lambda_
# global object gfunc_ff
# global object gi_2
# global object gi_3
# global object gi_5
def f__lambda_(space, *args_w):
kwlist = []
_args_w = args_w
defaults_w = ()
# XXX should parse args here, but no keyword support in gateway
funcname = "<lambda>"
PyArg_ParseMini(space, funcname, 0, 0, _args_w, defaults_w)
return fastf__lambda_(space, )
def fastf__lambda_(space, ):
goto = 1 # startblock
while True:
if goto == 1:
_tup = space.newtuple([gi_2, gi_3, gi_5])
w_0 = space.call(gfunc_ff, _tup)
w_1 = w_0
goto = 2
if goto == 2:
return w_1
##SECTION##
#*************************************************************
def init_lambda__1(space):
"""NOT_RPYTHON"""
class m: pass # fake module
m.__dict__ = globals()
from pypy.interpreter.gateway import interp2app
m.gfunc__lambda_ = space.wrap(interp2app(f__lambda_))
m.gfunc_ff = space.wrap(interp2app(f_ff))
m.gi_2 = space.newint(2)
m.gi_3 = space.newint(3)
m.gi_5 = space.newint(5)
from pypy.translator.genrpy import PyArg_ParseMini
m.PyArg_ParseMini = PyArg_ParseMini
from pypy.interpreter.error import OperationError
m.OperationError = OperationError
m.gcls_SystemError = space.wrap(SystemError)
m.gi_42 = space.newint(42)
# entry point: _lambda_, gfunc__lambda_)
if __name__ == "__main__":
from pypy.objspace.std import StdObjSpace
space = StdObjSpace()
init_lambda__1(space)
print space.unwrap(space.call(
gfunc__lambda_, space.newtuple([])))
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev