Author: Ronan Lamy <[email protected]>
Branch: unify-call-ops
Changeset: r71724:9d5ad8746f40
Date: 2014-05-25 03:41 +0100
http://bitbucket.org/pypy/pypy/changeset/9d5ad8746f40/

Log:    kill bookkeeper.build_args

diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -18,7 +18,7 @@
 from rpython.annotator.dictdef import DictDef
 from rpython.annotator import description
 from rpython.annotator.signature import annotationoftype
-from rpython.annotator.argument import simple_args, complex_args
+from rpython.annotator.argument import simple_args
 from rpython.rlib.objectmodel import r_dict, Symbolic
 from rpython.tool.algo.unionfind import UnionFind
 from rpython.rtyper import extregistry
@@ -103,8 +103,9 @@
                 self.consider_call_site(call_op)
 
             for pbc, args_s in self.emulated_pbc_calls.itervalues():
-                self.consider_call_site_for_pbc(pbc, 'simple_call',
-                                                args_s, s_ImpossibleValue, 
None)
+                args = simple_args(args_s)
+                self.consider_call_site_for_pbc(pbc, args,
+                                                s_ImpossibleValue, None)
             self.emulated_pbc_calls = {}
         finally:
             self.leave()
@@ -152,16 +153,16 @@
             args_s = [lltype_to_annotation(adtmeth.ll_ptrtype)] + args_s
         if isinstance(s_callable, SomePBC):
             s_result = binding(call_op.result, s_ImpossibleValue)
-            self.consider_call_site_for_pbc(s_callable, call_op.opname, args_s,
+            args = call_op.build_args(args_s)
+            self.consider_call_site_for_pbc(s_callable, args,
                                             s_result, call_op)
 
-    def consider_call_site_for_pbc(self, s_callable, opname, args_s, s_result,
+    def consider_call_site_for_pbc(self, s_callable, args, s_result,
                                    call_op):
         descs = list(s_callable.descriptions)
         if not descs:
             return
         family = descs[0].getcallfamily()
-        args = self.build_args(opname, args_s)
         s_callable.getKind().consider_call_site(self, family, descs, args,
                                                 s_result, call_op)
 
@@ -562,12 +563,6 @@
             assert self.annotator.binding(op.args[pos]) == s_type
         return op
 
-    def build_args(self, op, args_s):
-        if op == "simple_call":
-            return simple_args(args_s)
-        elif op == "call_args":
-            return complex_args(args_s)
-
     def ondegenerated(self, what, s_value, where=None, called_from_graph=None):
         self.annotator.ondegenerated(what, s_value, where=where,
                                      called_from_graph=called_from_graph)
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -14,6 +14,7 @@
                                      SpaceOperation)
 from rpython.flowspace.specialcase import register_flow_sc
 from rpython.annotator.model import SomeTuple
+from rpython.annotator.argument import ArgumentsForTranslation
 from rpython.flowspace.specialcase import SPECIAL_CASES
 
 
@@ -511,6 +512,9 @@
                 return sc(ctx, *args_w)
         return ctx.do_op(self)
 
+    def build_args(self, args_s):
+        return ArgumentsForTranslation(list(args_s))
+
 
 class CallArgs(SingleDispatchMixin, CallOp):
     opname = 'call_args'
@@ -529,6 +533,10 @@
                     "should not call %r with keyword arguments" % (fn,))
         return ctx.do_op(self)
 
+    def build_args(self, args_s):
+        return ArgumentsForTranslation.fromshape(args_s[0].const,
+                                                list(args_s[1:]))
+
 
 # Other functions that get directly translated to SpaceOperators
 func2op[type] = op.type
diff --git a/rpython/rtyper/callparse.py b/rpython/rtyper/callparse.py
--- a/rpython/rtyper/callparse.py
+++ b/rpython/rtyper/callparse.py
@@ -31,7 +31,7 @@
             getrinputs(rtyper, graph),
             getrresult(rtyper, graph))
 
-def callparse(rtyper, graph, hop, opname, r_self=None):
+def callparse(rtyper, graph, hop, r_self=None):
     """Parse the arguments of 'hop' when calling the given 'graph'.
     """
     rinputs = getrinputs(rtyper, graph)
@@ -43,6 +43,7 @@
     else:
         start = 0
         rinputs[0] = r_self
+    opname = hop.spaceop.opname
     if opname == "simple_call":
         arguments =  ArgumentsForRtype(args_h(start))
     elif opname == "call_args":
diff --git a/rpython/rtyper/lltypesystem/rpbc.py 
b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -182,10 +182,10 @@
         return self.convert_desc(funcdesc)
 
     def rtype_simple_call(self, hop):
-        return self.call('simple_call', hop)
+        return self.call(hop)
 
     def rtype_call_args(self, hop):
-        return self.call('call_args', hop)
+        return self.call(hop)
 
     def dispatcher(self, shape, index, argtypes, resulttype):
         key = shape, index, tuple(argtypes), resulttype
@@ -223,9 +223,9 @@
         c_ret = self._dispatch_cache[key] = inputconst(typeOf(ll_ret), ll_ret)
         return c_ret
 
-    def call(self, opname, hop):
+    def call(self, hop):
         bk = self.rtyper.annotator.bookkeeper
-        args = bk.build_args(opname, hop.args_s[1:])
+        args = hop.spaceop.build_args(hop.args_s[1:])
         s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc
         descs = list(s_pbc.descriptions)
         vfcs = description.FunctionDesc.variant_for_call_site
@@ -233,7 +233,7 @@
         row_of_graphs = self.callfamily.calltables[shape][index]
         anygraph = row_of_graphs.itervalues().next()  # pick any witness
         vlist = [hop.inputarg(self, arg=0)]
-        vlist += callparse.callparse(self.rtyper, anygraph, hop, opname)
+        vlist += callparse.callparse(self.rtyper, anygraph, hop)
         rresult = callparse.getrresult(self.rtyper, anygraph)
         hop.exception_is_here()
         v_dispatcher = self.dispatcher(shape, index, [v.concretetype for v in 
vlist[1:]], rresult.lowleveltype)
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -300,14 +300,14 @@
         return inputconst(typeOf(llfn), llfn)
 
     def rtype_simple_call(self, hop):
-        return self.call('simple_call', hop)
+        return self.call(hop)
 
     def rtype_call_args(self, hop):
-        return self.call('call_args', hop)
+        return self.call(hop)
 
-    def call(self, opname, hop):
+    def call(self, hop):
         bk = self.rtyper.annotator.bookkeeper
-        args = bk.build_args(opname, hop.args_s[1:])
+        args = hop.spaceop.build_args(hop.args_s[1:])
         s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc
         descs = list(s_pbc.descriptions)
         vfcs = description.FunctionDesc.variant_for_call_site
@@ -317,7 +317,7 @@
         vfn = hop.inputarg(self, arg=0)
         vlist = [self.convert_to_concrete_llfn(vfn, shape, index,
                                                hop.llops)]
-        vlist += callparse.callparse(self.rtyper, anygraph, hop, opname)
+        vlist += callparse.callparse(self.rtyper, anygraph, hop)
         rresult = callparse.getrresult(self.rtyper, anygraph)
         hop.exception_is_here()
         if isinstance(vlist[0], Constant):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to