diff options
author | Ronan Lamy <ronan.lamy@gmail.com> | 2014-10-15 20:46:11 +0100 |
---|---|---|
committer | Ronan Lamy <ronan.lamy@gmail.com> | 2014-10-15 20:46:11 +0100 |
commit | 282fe6e1d94cb993735b33fee9fe98c6db03759b (patch) | |
tree | c38a231dd0aae6f8b74946166058b32499aecddd /rpython/flowspace | |
parent | fix (diff) | |
download | pypy-282fe6e1d94cb993735b33fee9fe98c6db03759b.tar.gz pypy-282fe6e1d94cb993735b33fee9fe98c6db03759b.tar.bz2 pypy-282fe6e1d94cb993735b33fee9fe98c6db03759b.zip |
Start work on performing annotation-dependent graph transformations
during the annotation phase.
Diffstat (limited to 'rpython/flowspace')
-rw-r--r-- | rpython/flowspace/operation.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py index b67194e744..5a7ea226ae 100644 --- a/rpython/flowspace/operation.py +++ b/rpython/flowspace/operation.py @@ -104,6 +104,9 @@ class HLOperation(SpaceOperation): def get_can_only_throw(self, annotator): return None + def transform(self, annotator): + pass + class PureOperation(HLOperation): pure = True @@ -606,6 +609,15 @@ class CallArgs(SingleDispatchMixin, CallOp): return ArgumentsForTranslation.fromshape(args_s[0].const, list(args_s[1:])) +def transform_len(hlop, annotator): + from rpython.annotator.model import SomeInstance + s_arg = annotator.annotation(hlop.args[0]) + if isinstance(s_arg, SomeInstance): + get_len = op.getattr(hlop.args[0], const('__len__')) + return [get_len, op.simple_call(get_len.result)] + +op.len.transform = transform_len + # Other functions that get directly translated to SpaceOperators func2op[type] = op.type |