Author: Armin Rigo <ar...@tunes.org> Branch: kill-geninterp Changeset: r53589:4c689c1cdde2 Date: 2012-03-14 11:57 -0700 http://bitbucket.org/pypy/pypy/changeset/4c689c1cdde2/
Log: Redo the support for RPython-level print statements. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1431,11 +1431,9 @@ if lastchar.isspace() and lastchar != ' ': return file_softspace(stream, True) - print_item_to._annspecialcase_ = "specialize:argtype(0)" def print_item(x): print_item_to(x, sys_stdout()) - print_item._annspecialcase_ = "flowspace:print_item" def print_newline_to(stream): stream.write("\n") @@ -1443,7 +1441,6 @@ def print_newline(): print_newline_to(sys_stdout()) - print_newline._annspecialcase_ = "flowspace:print_newline" def file_softspace(file, newflag): try: diff --git a/pypy/objspace/flow/specialcase.py b/pypy/objspace/flow/specialcase.py --- a/pypy/objspace/flow/specialcase.py +++ b/pypy/objspace/flow/specialcase.py @@ -73,6 +73,19 @@ s = '\n' import os os.write(1, s) + +def sc_applevel(space, app, name, args_w): + # special case only for print_item and print_newline + if 'pyopcode' in app.filename and name == 'print_item': + w_s = space.do_operation('str', *args_w) + args_w = (w_s,) + elif 'pyopcode' in app.filename and name == 'print_newline': + pass + else: + raise Exception("not RPython: calling %r from %r" % (name, app)) + func = globals()['rpython_' + name] + return space.do_operation('simple_call', Constant(func), *args_w) + # _________________________________________________________________________ def sc_r_uint(space, r_uint, args): @@ -91,6 +104,8 @@ # this is now routed through the objspace, directly. # space.specialcases[fn] = sc_normalize_exception space.specialcases[__import__] = sc_import + # redirect ApplevelClass for print et al. + space.specialcases[ApplevelClass] = sc_applevel # turn calls to built-in functions to the corresponding operation, # if possible for fn in OperationName: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit