[pypy-svn] r20262 - in pypy/branch/somepbc-refactoring/pypy: annotation interpreter

pedronis at codespeak.net pedronis at codespeak.net
Sat Nov 26 00:36:37 CET 2005


Author: pedronis
Date: Sat Nov 26 00:36:36 2005
New Revision: 20262

Modified:
   pypy/branch/somepbc-refactoring/pypy/annotation/description.py
   pypy/branch/somepbc-refactoring/pypy/interpreter/argument.py
Log:
Arguments class is mutable, rawshape has a method ended being called to late.

Now all uses of .rawshape are in descriptions.py. Use a function rawshape() instead
which should be knowingly called on a fresh constructed Arguments instance before
any manipulations.

test_call_star_method etc now passes.



Modified: pypy/branch/somepbc-refactoring/pypy/annotation/description.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/description.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/description.py	Sat Nov 26 00:36:36 2005
@@ -1,6 +1,7 @@
 import types
 from pypy.objspace.flow.model import Constant, FunctionGraph
 from pypy.interpreter.pycode import cpython_code_signature
+from pypy.interpreter.argument import rawshape
 from pypy.interpreter.argument import ArgErr
 
 
@@ -216,17 +217,18 @@
                                              name)
 
     def consider_call_site(bookkeeper, family, descs, args, s_result):
+        shape = rawshape(args)
         row = FunctionDesc.row_to_consider(descs, args)
-        family.calltable_add_row(args.rawshape(), row)
+        family.calltable_add_row(shape, row)
     consider_call_site = staticmethod(consider_call_site)
 
     def variant_for_call_site(bookkeeper, family, descs, args):
+        shape = rawshape(args)
         bookkeeper.enter(None)
         try:
             row = FunctionDesc.row_to_consider(descs, args)
         finally:
             bookkeeper.leave()
-        shape = args.rawshape() 
         index = family.calltable_lookup_row(shape, row)
         return shape, index
     variant_for_call_site = staticmethod(variant_for_call_site)
@@ -514,10 +516,9 @@
                                              self.name)
     
     def consider_call_site(bookkeeper, family, descs, args, s_result):
+        shape = rawshape(args, nextra=1)     # account for the extra 'self'
         funcdescs = [methoddesc.funcdesc for methoddesc in descs]
         row = FunctionDesc.row_to_consider(descs, args)
-        shape = args.rawshape()
-        shape = (shape[0]+1,) + shape[1:]    # account for the extra 'self'
         family.calltable_add_row(shape, row)
     consider_call_site = staticmethod(consider_call_site)
 
@@ -609,10 +610,9 @@
         return self.funcdesc.pycall(schedule, args, s_previous_result)
     
     def consider_call_site(bookkeeper, family, descs, args, s_result):
+        shape = rawshape(args, nextra=1)    # account for the extra 'self'
         funcdescs = [mofdesc.funcdesc for mofdesc in descs]
         row = FunctionDesc.row_to_consider(descs, args)
-        shape = args.rawshape()
-        shape = (shape[0]+1,) + shape[1:]    # account for the extra 'self'
         family.calltable_add_row(shape, row)
     consider_call_site = staticmethod(consider_call_site)
 

Modified: pypy/branch/somepbc-refactoring/pypy/interpreter/argument.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/interpreter/argument.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/interpreter/argument.py	Sat Nov 26 00:36:36 2005
@@ -233,8 +233,8 @@
 
     ### Argument <-> list of w_objects together with "shape" information
 
-    def rawshape(self):
-        shape_cnt  = len(self.arguments_w)        # Number of positional args
+    def _rawshape(self, nextra=0):
+        shape_cnt  = len(self.arguments_w)+nextra        # Number of positional args
         if self.kwds_w:
             shape_keys = self.kwds_w.keys()           # List of keywords (strings)
         else:
@@ -245,7 +245,7 @@
         return shape_cnt, tuple(shape_keys), shape_star, shape_stst # shape_keys are sorted
 
     def flatten(self):
-        shape_cnt, shape_keys, shape_star, shape_stst = self.rawshape()
+        shape_cnt, shape_keys, shape_star, shape_stst = self._rawshape()
         data_w = self.arguments_w + [self.kwds_w[key] for key in shape_keys]
         if shape_star:
             data_w.append(self.w_stararg)
@@ -273,6 +273,9 @@
         return Arguments(space, args_w, kwds_w, w_star, w_starstar)
     fromshape = staticmethod(fromshape)
 
+def rawshape(args, nextra=0):
+    return args._rawshape(nextra)
+
 
 #
 # ArgErr family of exceptions raised in case of argument mismatch.



More information about the Pypy-commit mailing list