Author: Ronan Lamy <ronan.l...@gmail.com> Branch: translation-cleanup Changeset: r57630:41fac9129f86 Date: 2012-09-27 07:07 +0100 http://bitbucket.org/pypy/pypy/changeset/41fac9129f86/
Log: Fix PRINT_ITEM and PRINT_NEWLINE diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py --- a/pypy/objspace/flow/flowcontext.py +++ b/pypy/objspace/flow/flowcontext.py @@ -10,6 +10,7 @@ from pypy.objspace.flow.framestate import (FrameState, recursively_unflatten, recursively_flatten) from pypy.objspace.flow.bytecode import HostCode +from pypy.objspace.flow.specialcase import sc_applevel class FlowingError(Exception): """ Signals invalid RPython in the function being analysed""" @@ -574,6 +575,36 @@ # isn't popped straightaway. self.pushvalue(None) + def PRINT_EXPR(self, oparg, next_instr): + w_expr = self.popvalue() + print_expr(self.space, w_expr) + + def PRINT_ITEM_TO(self, oparg, next_instr): + w_stream = self.popvalue() + w_item = self.popvalue() + if self.space.is_w(w_stream, self.space.w_None): + w_stream = sys_stdout(self.space) # grumble grumble special cases + print_item_to(self.space, w_item, w_stream) + + def PRINT_ITEM(self, oparg, next_instr): + w_item = self.popvalue() + self.print_item(w_item) + + def print_item(self, *args): + return sc_applevel(self.space, 'print_item', args) + + def PRINT_NEWLINE_TO(self, oparg, next_instr): + w_stream = self.popvalue() + if self.space.is_w(w_stream, self.space.w_None): + w_stream = sys_stdout(self.space) # grumble grumble special cases + print_newline_to(self.space, w_stream) + + def PRINT_NEWLINE(self, oparg, next_instr): + self.print_newline() + + def print_newline(self): + return sc_applevel(self.space, 'print_newline', []) + def FOR_ITER(self, jumpby, next_instr): w_iterator = self.peekvalue() 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 @@ -51,12 +51,12 @@ import os os.write(1, s) -def sc_applevel(space, app, name, args_w): +def sc_applevel(space, name, args_w): # special case only for print_item and print_newline - if 'pyopcode' in app.filename and name == 'print_item': + if name == 'print_item': w_s = space.do_operation('str', *args_w) args_w = (w_s,) - elif 'pyopcode' in app.filename and name == 'print_newline': + elif name == 'print_newline': pass else: raise Exception("not RPython: calling %r from %r" % (name, app)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit