[pypy-svn] r14460 - pypy/dist/pypy/rpython

pedronis at codespeak.net pedronis at codespeak.net
Sun Jul 10 01:56:14 CEST 2005


Author: pedronis
Date: Sun Jul 10 01:56:13 2005
New Revision: 14460

Modified:
   pypy/dist/pypy/rpython/extfunctable.py
   pypy/dist/pypy/rpython/llinterp.py
Log:
going in the direction of having llannotatable True by default (with appropriately written  testing implementations
for the ll_* defs for external functions this should work "out-of-the-box"). Flag suggested_primitive to avoid infinite
interpretation in llinterp. 



Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Sun Jul 10 01:56:13 2005
@@ -34,11 +34,12 @@
     return p
 
 def from_rstr(rs):
-    return ''.join(rs.chars)
+    return ''.join([rs.chars[i] for i in range(len(rs.chars))])
 
 # dummy low-level implementations for the external functions
 def ll_os_open(fname, flag, mode):
     return os.open(from_rstr(fname), flag, mode)
+ll_os_open.suggested_primitive=True
 
 def ll_os_read(fd, n):
     return to_rstr(os.read(fd, n))
@@ -68,7 +69,7 @@
 nonefactory = lambda *args: None
 
 # external function declarations
-declare(os.open   , int        , ll_os_open)
+declare(os.open   , int        , ll_os_open, True)
 declare(os.read   , str        , ll_os_read)
 declare(os.write  , int        , ll_os_write)
 declare(os.close  , nonefactory, ll_os_close)

Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Sun Jul 10 01:56:13 2005
@@ -166,13 +166,16 @@
         array[index] = item
 
     def op_direct_call(self, f, *args):
+        has_callable = hasattr(f._obj, '_callable')
+        if has_callable and getattr(f._obj._callable, 'suggested_primitive', False):
+            return f._obj._callable(*args)
         if hasattr(f._obj, 'graph'):
             graph = f._obj.graph
         else:
             try:
                 graph = self.llinterpreter.getgraph(f._obj._callable)
             except KeyError:
-                assert hasattr(f._obj, '_callable'), "don't know how to execute %r" % f
+                assert has_callable, "don't know how to execute %r" % f
                 return f._obj._callable(*args)
         frame = self.__class__(graph, args, self.llinterpreter)
         return frame.eval()



More information about the Pypy-commit mailing list