Author: Ronan Lamy <ronan.l...@gmail.com> Branch: less-stringly-ops Changeset: r66239:c97160d9f9cc Date: 2013-08-09 19:14 +0100 http://bitbucket.org/pypy/pypy/changeset/c97160d9f9cc/
Log: Add HLOperation.constfold() diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py --- a/rpython/flowspace/operation.py +++ b/rpython/flowspace/operation.py @@ -42,12 +42,18 @@ return sc_operator def eval(self, frame): + result = self.constfold() + if result is not None: + return result return frame.do_op(self) + def constfold(self): + return None + class PureOperation(HLOperation): pure = True - def eval(self, frame): + def constfold(self): args = [] if all(w_arg.foldable() for w_arg in self.args): args = [w_arg.value for w_arg in self.args] @@ -77,7 +83,6 @@ # type cannot sanely appear in flow graph, # store operation with variable result instead pass - return frame.do_op(self) def add_operator(name, arity, symbol, pyfunc=None, pure=False, ovf=False): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit