[pypy-svn] r9867 - pypy/dist/pypy/translator

arigo at codespeak.net arigo at codespeak.net
Thu Mar 17 19:44:04 CET 2005


Author: arigo
Date: Thu Mar 17 19:44:03 2005
New Revision: 9867

Modified:
   pypy/dist/pypy/translator/genc.py
   pypy/dist/pypy/translator/genc_funcdef.py
Log:
Restored support for skipped (not R-Python) functions.


Modified: pypy/dist/pypy/translator/genc.py
==============================================================================
--- pypy/dist/pypy/translator/genc.py	(original)
+++ pypy/dist/pypy/translator/genc.py	Thu Mar 17 19:44:03 2005
@@ -171,6 +171,15 @@
     def skipped_function(self, func):
         # debugging only!  Generates a placeholder for missing functions
         # that raises an exception when called.
+        if self.translator.frozen:
+            warning = 'NOT GENERATING'
+        else:
+            warning = 'skipped'
+        printable_name = '(%s:%d) %s' % (
+            func.func_globals.get('__name__', '?'),
+            func.func_code.co_firstlineno,
+            func.__name__)
+        print warning, printable_name
         name = self.uniquename('gskippedfunc_' + func.__name__)
         self.initcode.append('def %s(*a,**k):' % name)
         self.initcode.append('  raise NotImplementedError')
@@ -178,6 +187,13 @@
 
     def getfuncdef(self, func):
         if func not in self.funcdefs:
+            if self.translator.frozen:
+                if func not in self.translator.flowgraphs:
+                    return None
+            else:
+                if (func.func_doc and
+                    func.func_doc.lstrip().startswith('NOT_RPYTHON')):
+                    return None
             funcdef = FunctionDef(func, self)
             self.funcdefs[func] = funcdef
             self.allfuncdefs.append(funcdef)
@@ -186,23 +202,13 @@
 
     def nameof_function(self, func, progress=['-\x08', '\\\x08',
                                               '|\x08', '/\x08']):
-        printable_name = '(%s:%d) %s' % (
-            func.func_globals.get('__name__', '?'),
-            func.func_code.co_firstlineno,
-            func.__name__)
-        if self.translator.frozen:
-            if func not in self.translator.flowgraphs:
-                print "NOT GENERATING", printable_name
-                return self.skipped_function(func)
-        else:
-            if (func.func_doc and
-                func.func_doc.lstrip().startswith('NOT_RPYTHON')):
-                print "skipped", printable_name
-                return self.skipped_function(func)
+        funcdef = self.getfuncdef(func)
+        if funcdef is None:
+            return self.skipped_function(func)
+        if not self.translator.frozen:
             p = progress.pop(0)
             sys.stderr.write(p)
             progress.append(p)
-        funcdef = self.getfuncdef(func)
         return funcdef.get_globalobject()
 
     def nameof_staticmethod(self, sm):

Modified: pypy/dist/pypy/translator/genc_funcdef.py
==============================================================================
--- pypy/dist/pypy/translator/genc_funcdef.py	(original)
+++ pypy/dist/pypy/translator/genc_funcdef.py	Thu Mar 17 19:44:03 2005
@@ -374,19 +374,31 @@
         args.insert(0, '%d' % len(args))
         return 'OP_NEWTUPLE((%s), %s, %s)' % (', '.join(args), r, err)
 
-    def OP_SIMPLE_CALL(self, target_args, r, err):
-        # try to use the shortcut: a direct call to
-        # the ff_xxx() function, using its C signature.
-        target = target_args[0].args[0]
-        args = [arg.compute() for arg in target_args[1:]]
-        if (isinstance(target, Constant) and
-            isinstance(target.value, FunctionType) and not USE_CALL_TRACE):
-            funcdef = self.genc.getfuncdef(target.value)
-            if len(funcdef.positional_args) == len(args) and not funcdef.vararg:
-                return 'if (!(%s=%s(%s))) FAIL(%s);' % (
-                    r, funcdef.fast_name, ', '.join(args), err)
+    def fast_simple_call(self, args, r, err):
+        # try to generate a SIMPLE_CALL using a shortcut:
+        # a direct call to the ff_xxx() function, using its C signature.
+        if USE_CALL_TRACE:
+            return None
+        target = args[0].args[0]
+        args = [arg.compute() for arg in args[1:]]
+        if not isinstance(target, Constant):
+            return None
+        if not isinstance(target.value, FunctionType):
+            return None
+        funcdef = self.genc.getfuncdef(target.value)
+        if funcdef is None:
+            return None
+        if len(funcdef.positional_args) != len(args) or funcdef.vararg:
+            return None
+        return 'if (!(%s=%s(%s))) FAIL(%s);' % (
+            r, funcdef.fast_name, ', '.join(args), err)
+
+    def OP_SIMPLE_CALL(self, args, r, err):
+        result = self.fast_simple_call(args, r, err)
+        if result is not None:
+            return result
         # fall-back
-        args.insert(0, target_args[0].compute())
+        args = [arg.compute() for arg in args]
         args.append('NULL')
         return 'OP_SIMPLE_CALL((%s), %s, %s)' % (', '.join(args), r, err)
 



More information about the Pypy-commit mailing list