[pypy-svn] r30398 - in pypy/dist/pypy: annotation rpython translator/c

arigo at codespeak.net arigo at codespeak.net
Sun Jul 23 15:08:53 CEST 2006


Author: arigo
Date: Sun Jul 23 15:08:50 2006
New Revision: 30398

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/translator/c/extfunc.py
Log:
More pypy-c compatibility fixes.


Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Sun Jul 23 15:08:50 2006
@@ -390,7 +390,14 @@
                 result = s_self.find_method(x.__name__)
                 if result is None:
                     result = SomeObject()
+            elif hasattr(x, 'im_self') and hasattr(x, 'im_func'):
+                # on top of PyPy, for cases like 'l.append' where 'l' is a
+                # global constant list, the find_method() returns non-None
+                s_self = self.immutablevalue(x.im_self)
+                result = s_self.find_method(x.im_func.__name__)
             else:
+                result = None
+            if result is None:
                 if (self.annotator.policy.allow_someobjects
                     and getattr(x, '__module__', None) == '__builtin__'
                     # XXX note that the print support functions are __builtin__

Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Sun Jul 23 15:08:50 2006
@@ -145,7 +145,11 @@
         assert hop2.args_r[0] is self
         if isinstance(hop2.args_v[0], Constant):
             c = hop2.args_v[0].value    # get object from bound method
-            hop2.args_v[0] = Constant(c.__self__)
+            if hasattr(c, '__self__'):
+                c = c.__self__    # on top of CPython
+            else:
+                c = c.im_self     # on top of PyPy
+            hop2.args_v[0] = Constant(c)
         hop2.args_s[0] = self.s_self
         hop2.args_r[0] = self.self_repr
         return bltintyper(hop2)

Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/extfunc.py	Sun Jul 23 15:08:50 2006
@@ -10,7 +10,11 @@
 from pypy.rpython.lltypesystem.module.ll_os import STAT_RESULT, Implementation as impl
 from pypy.rpython.lltypesystem.module import ll_math as ll_math2
 from pypy.rpython.lltypesystem.module import ll_strtod as ll_strtod2
-from pypy.module.thread.rpython import ll_thread
+
+try:
+    from pypy.module.thread.rpython import ll_thread
+except ImportError:
+    ll_thread = None
 
 # table of functions hand-written in src/ll_*.h
 # Note about *.im_func: The annotator and the rtyper expect direct
@@ -54,17 +58,20 @@
         'LL_strtod_parts_to_float',
     ll_strtod2.Implementation.ll_strtod_formatd:
         'LL_strtod_formatd',
+    ll_stackless.ll_stackless_switch:             'LL_stackless_switch',
+    ll_stackless.ll_stackless_stack_frames_depth: 'LL_stackless_stack_frames_depth',
+    ll_stack.ll_stack_unwind: 'LL_stack_unwind',
+    ll_stack.ll_stack_too_big: 'LL_stack_too_big',
+    }
+
+if ll_thread: EXTERNALS.update({
     ll_thread.ll_newlock:            'LL_thread_newlock',
     ll_thread.ll_acquirelock:        'LL_thread_acquirelock',
     ll_thread.ll_releaselock:        'LL_thread_releaselock',
     ll_thread.ll_fused_releaseacquirelock: 'LL_thread_fused_releaseacquirelock',
     ll_thread.ll_thread_start:     'LL_thread_start',
     ll_thread.ll_thread_get_ident: 'LL_thread_get_ident',
-    ll_stackless.ll_stackless_switch:             'LL_stackless_switch',
-    ll_stackless.ll_stackless_stack_frames_depth: 'LL_stackless_stack_frames_depth',
-    ll_stack.ll_stack_unwind: 'LL_stack_unwind',
-    ll_stack.ll_stack_too_big: 'LL_stack_too_big',
-    }
+    })
 
 #______________________________________________________
 # insert 'simple' math functions into EXTERNALs table:



More information about the Pypy-commit mailing list