[pypy-commit] pypy less-stringly-ops: Use operator in FSFrame.do_operation_with...; shorten its name
rlamy
noreply at buildbot.pypy.org
Mon Aug 19 23:15:00 CEST 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: less-stringly-ops
Changeset: r66229:a3a24731c83d
Date: 2013-08-09 02:06 +0100
http://bitbucket.org/pypy/pypy/changeset/a3a24731c83d/
Log: Use operator in FSFrame.do_operation_with...; shorten its name
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -14,7 +14,6 @@
recursively_flatten)
from rpython.flowspace.specialcase import (rpython_print_item,
rpython_print_newline)
-from rpython.flowspace.operation import op
class FlowingError(Exception):
@@ -449,10 +448,9 @@
recorder.append(spaceop)
return spaceop.result
- def do_operation_with_implicit_exceptions(self, name, *args_w):
- w_result = self.do_operation(name, *args_w)
- oper = getattr(op, name)
- self.handle_implicit_exceptions(oper.canraise)
+ def do_op(self, operator, *args_w):
+ w_result = self.do_operation(operator.name, *args_w)
+ self.handle_implicit_exceptions(operator.canraise)
return w_result
def handle_implicit_exceptions(self, exceptions):
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -11,7 +11,7 @@
from rpython.flowspace.model import (Constant, Variable, WrapException,
UnwrapException, checkgraph, const)
from rpython.flowspace.bytecode import HostCode
-from rpython.flowspace import operation
+from rpython.flowspace.operation import op
from rpython.flowspace.flowcontext import (FlowSpaceFrame, fixeggblocks,
FSException, FlowingError)
from rpython.flowspace.generator import (tweak_generator_graph,
@@ -275,8 +275,7 @@
if w_obj in self.not_really_const:
const_w = self.not_really_const[w_obj]
if w_name not in const_w:
- return self.frame.do_operation_with_implicit_exceptions('getattr',
- w_obj, w_name)
+ return self.frame.do_op(op.getattr, w_obj, w_name)
if w_obj.foldable() and w_name.foldable():
obj, name = w_obj.value, w_name.value
try:
@@ -290,8 +289,7 @@
return const(result)
except WrapException:
pass
- return self.frame.do_operation_with_implicit_exceptions('getattr',
- w_obj, w_name)
+ return self.frame.do_op(op.getattr, w_obj, w_name)
def isinstance_w(self, w_obj, w_type):
return self.is_true(self.isinstance(w_obj, w_type))
@@ -310,8 +308,7 @@
if w_module in self.not_really_const:
const_w = self.not_really_const[w_module]
if w_name not in const_w:
- return self.frame.do_operation_with_implicit_exceptions('getattr',
- w_module, w_name)
+ return self.frame.do_op(op.getattr, w_module, w_name)
try:
return const(getattr(w_module.value, w_name.value))
except AttributeError:
@@ -391,7 +388,7 @@
return oper.eval(self.frame, *args)
return generic_operator
-for oper in operation.op.__dict__.values():
+for oper in op.__dict__.values():
if getattr(FlowObjSpace, oper.name, None) is None:
setattr(FlowObjSpace, oper.name, make_op(oper))
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -43,8 +43,7 @@
def eval(self, frame, *args_w):
if len(args_w) != self.arity:
raise TypeError(self.name + " got the wrong number of arguments")
- w_result = frame.do_operation_with_implicit_exceptions(self.name, *args_w)
- return w_result
+ return frame.do_op(self, *args_w)
class PureOperator(SpaceOperator):
pure = True
@@ -81,8 +80,7 @@
# type cannot sanely appear in flow graph,
# store operation with variable result instead
pass
- w_result = frame.do_operation_with_implicit_exceptions(self.name, *args_w)
- return w_result
+ return frame.do_op(self, *args_w)
def add_operator(name, arity, symbol, pyfunc=None, pure=False, ovf=False):
More information about the pypy-commit
mailing list