[pypy-svn] r28358 - pypy/dist/pypy/rpython/ootypesystem

antocuni at codespeak.net antocuni at codespeak.net
Tue Jun 6 12:41:56 CEST 2006


Author: antocuni
Date: Tue Jun  6 12:41:56 2006
New Revision: 28358

Modified:
   pypy/dist/pypy/rpython/ootypesystem/rpbc.py
Log:
Factored two helper functions out of MethodsPBCRepr.call.



Modified: pypy/dist/pypy/rpython/ootypesystem/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rpbc.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rpbc.py	Tue Jun  6 12:41:56 2006
@@ -111,28 +111,37 @@
         return self.call("call_args", hop)
 
     def call(self, opname, hop):
-        bk = self.rtyper.annotator.bookkeeper
-        args = bk.build_args(opname, hop.args_s[1:])
-        args = args.prepend(self.s_im_self)
-        s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc
-        descs = [desc.funcdesc for desc in s_pbc.descriptions]
-        callfamily = descs[0].getcallfamily()
-        shape, index = description.FunctionDesc.variant_for_call_site(
-                bk, callfamily, descs, args)
+        s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc        
+        args_s = hop.args_s[1:]
+        shape, index, callfamily = self._get_shape_index_callfamily(opname, s_pbc, args_s)
         row_of_graphs = callfamily.calltables[shape][index]
         anygraph = row_of_graphs.itervalues().next()  # pick any witness
         hop2 = self.add_instance_arg_to_hop(hop, opname == "call_args")
         vlist = callparse.callparse(self.rtyper, anygraph, hop2, opname,
                                     r_self = self.r_im_self)
         rresult = callparse.getrresult(self.rtyper, anygraph)
+        derived_mangled = self._get_method_name(opname, s_pbc, args_s)
+        cname = hop.inputconst(ootype.Void, derived_mangled)
         hop.exception_is_here()
+        v = hop.genop("oosend", [cname]+vlist, resulttype=rresult)
+        return hop.llops.convertvar(v, rresult, hop.r_result)
+
+    def _get_shape_index_callfamily(self, opname, s_pbc, args_s):
+        bk = self.rtyper.annotator.bookkeeper
+        args = bk.build_args(opname, args_s)
+        args = args.prepend(self.s_im_self)
+        descs = [desc.funcdesc for desc in s_pbc.descriptions]
+        callfamily = descs[0].getcallfamily()
+        shape, index = description.FunctionDesc.variant_for_call_site(
+                bk, callfamily, descs, args)
+        return shape, index, callfamily
+
+    def _get_method_name(self, opname, s_pbc, args_s):
+        shape, index, callfamily = self._get_shape_index_callfamily(opname, s_pbc, args_s)
         mangled = mangle(self.methodname)
         row = self.concretetable[shape, index]
         derived_mangled = row_method_name(mangled, row.attrname)
-        cname = hop.inputconst(ootype.Void, derived_mangled)
-        v = hop.genop("oosend", [cname]+vlist, resulttype=rresult)
-        return hop.llops.convertvar(v, rresult, hop.r_result)
-        
+        return derived_mangled
 
 class __extend__(pairtype(InstanceRepr, MethodsPBCRepr)):
 



More information about the Pypy-commit mailing list