[pypy-svn] r20171 - in pypy/branch/somepbc-refactoring/pypy: objspace/flow rpython

pedronis at codespeak.net pedronis at codespeak.net
Tue Nov 22 20:49:38 CET 2005


Author: pedronis
Date: Tue Nov 22 20:49:36 2005
New Revision: 20171

Modified:
   pypy/branch/somepbc-refactoring/pypy/objspace/flow/objspace.py
   pypy/branch/somepbc-refactoring/pypy/rpython/callparse.py
   pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
Log:
Use callparse again in the simple simple_call case. Now it takes a graph. 

Graphs now have attached a signature and defaults to be more
interchangeable with functions.



Modified: pypy/branch/somepbc-refactoring/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/objspace/flow/objspace.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/objspace/flow/objspace.py	Tue Nov 22 20:49:36 2005
@@ -1,7 +1,7 @@
 # ______________________________________________________________________
 import sys, operator, types
 from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
-from pypy.interpreter.pycode import PyCode
+from pypy.interpreter.pycode import PyCode, cpython_code_signature
 from pypy.interpreter.module import Module
 from pypy.interpreter.error import OperationError
 from pypy.objspace.flow.model import *
@@ -239,11 +239,17 @@
             name = name.replace(c, '_')
         ec = flowcontext.FlowExecutionContext(self, code, func.func_globals,
                                               constargs, closure, name)
-        ec.graph.func = func
+        graph = ec.graph
+        graph.func = func
+        # attach a signature and defaults to the graph
+        # so that it becomes even more interchangeable with the function
+        # itself
+        graph.signature = cpython_code_signature(code)
+        graph.defaults = func.func_defaults
         self.setup_executioncontext(ec)
         ec.build_flow()
-        checkgraph(ec.graph)
-        return ec.graph
+        checkgraph(graph)
+        return graph
 
     def unpacktuple(self, w_tuple, expected_length=None):
 ##        # special case to accept either Constant tuples

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/callparse.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/callparse.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/callparse.py	Tue Nov 22 20:49:36 2005
@@ -1,4 +1,3 @@
-from pypy.interpreter.pycode import cpython_code_signature
 from pypy.interpreter.argument import Arguments, ArgErr
 from pypy.annotation import model as annmodel
 from pypy.rpython import rtuple
@@ -30,7 +29,7 @@
         raise CallPatternTooComplex, "'*' argument must be a tuple"
 
 
-def callparse(op, func, rinputs, hop):
+def callparse(op, graph, rinputs, hop):
     space = RPythonCallsSpace()
     def args_h(start):
         return [VarHolder(i, hop.args_s[i]) for i in range(start, hop.nb_args)]
@@ -40,15 +39,15 @@
         arguments = Arguments.fromshape(space, hop.args_s[1].const, # shape
                                         args_h(2))
     # parse the arguments according to the function we are calling
-    signature = cpython_code_signature(func.func_code)
+    signature = graph.signature
     defs_h = []
-    if func.func_defaults:
-        for x in func.func_defaults:
+    if graph.defaults:
+        for x in graph.defaults:
             defs_h.append(ConstHolder(x))
     try:
         holders = arguments.match_signature(signature, defs_h)
     except ArgErr, e:
-        raise TyperError, "signature mismatch: %s" % e.getmsg(arguments, func.__name__)
+        raise TyperError, "signature mismatch: %s" % e.getmsg(arguments, graph.name)
 
     assert len(holders) == len(rinputs), "argument parsing mismatch"
     vlist = []

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py	Tue Nov 22 20:49:36 2005
@@ -135,8 +135,9 @@
         llfnobj = self.rtyper.getcallable(graph)
         vlist = [hop.inputconst(typeOf(llfnobj), llfnobj)]
         # XXX use callparse again here
-        vlist += [hop.inputarg(self.rtyper.bindingrepr(graph.getargs()[i]), arg=i+1)
-                  for i in range(len(graph.getargs()))]
+        rinputs = [self.rtyper.bindingrepr(graph.getargs()[i])
+                   for i in range(len(graph.getargs()))]
+        vlist += callparse.callparse('simple_call', graph, rinputs, hop)
         rresult = self.rtyper.bindingrepr(graph.getreturnvar())
         hop.exception_is_here()
         v = hop.genop('direct_call', vlist, resulttype = rresult)



More information about the Pypy-commit mailing list