[pypy-commit] pypy less-stringly-ops: Add HLOperation.constfold()
rlamy
noreply at buildbot.pypy.org
Mon Aug 19 23:15:15 CEST 2013
Author: Ronan Lamy <ronan.lamy at 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):
More information about the pypy-commit
mailing list