Author: Ronan Lamy <[email protected]>
Branch: less-stringly-ops
Changeset: r67056:3ab58f53ee10
Date: 2013-09-22 02:40 +0100
http://bitbucket.org/pypy/pypy/changeset/3ab58f53ee10/
Log: Simplify creation of hlop proxy methods on FlowObjSpace
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -272,14 +272,9 @@
raise FlowingError("global name '%s' is not defined" % varname)
return const(value)
-def make_op(cls):
- def generic_operator(self, *args):
- return cls(*args).eval(self.frame)
- return generic_operator
-
for cls in op.__dict__.values():
if getattr(FlowObjSpace, cls.opname, None) is None:
- setattr(FlowObjSpace, cls.opname, make_op(cls))
+ setattr(FlowObjSpace, cls.opname, cls.make_sc())
def build_flow(func, space=FlowObjSpace()):
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -25,8 +25,8 @@
# this is an incomplete list of true constants.
# if we add much more, a dedicated class
# might be considered for special objects.
- }
}
+}
class _OpHolder(object): pass
@@ -36,6 +36,7 @@
class HLOperation(SpaceOperation):
pure = False
+
def __init__(self, *args):
if len(args) != self.arity:
raise TypeError(self.opname + " got the wrong number of arguments")
@@ -54,9 +55,7 @@
else:
raise Exception("should call %r with exactly %d arguments"
% (
cls.opname, cls.arity))
- # completely replace the call with the underlying
- # operation and its limited implicit exceptions semantic
- return getattr(space, cls.opname)(*args_w)
+ return cls(*args_w).eval(space.frame)
return sc_operator
def eval(self, frame):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit