[pypy-commit] pypy kill-someobject: (alex, fijal) make getcompiled work

alex_gaynor noreply at buildbot.pypy.org
Mon Oct 8 13:39:30 CEST 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: kill-someobject
Changeset: r57901:76215c02c5bf
Date: 2012-10-08 13:38 +0200
http://bitbucket.org/pypy/pypy/changeset/76215c02c5bf/

Log:	(alex, fijal) make getcompiled work

diff --git a/pypy/translator/c/test/test_genc.py b/pypy/translator/c/test/test_genc.py
--- a/pypy/translator/c/test/test_genc.py
+++ b/pypy/translator/c/test/test_genc.py
@@ -1,5 +1,6 @@
+import ctypes
+
 import py
-import ctypes
 
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.translator.translator import TranslationContext, graphof
@@ -9,6 +10,7 @@
 from pypy.tool.nullpath import NullPyPathLocal
 from pypy.rlib.unroll import unrolling_iterable
 
+
 def compile(fn, argtypes, view=False, gcpolicy="none", backendopt=True,
             annotatorpolicy=None):
     argtypes_unroll = unrolling_iterable(enumerate(argtypes))
@@ -16,26 +18,26 @@
     for argtype in argtypes:
         if argtype not in [int, float, str, bool]:
             raise Exception("Unsupported argtype, %r" % (argtype,))
-    
+
     def entry_point(argv):
         args = ()
         for i, argtype in argtypes_unroll:
             if argtype is int:
-                args = args + (int(argv[i + 1]),)
-            if argtype is bool:
+                args += (int(argv[i + 1]),)
+            elif argtype is bool:
                 if argv[i + 1] == 'True':
-                    args = args + (True,)
+                    args += (True,)
                 else:
                     assert argv[i + 1] == 'False'
-                    args = args + (False,)
+                    args += (False,)
             elif argtype is float:
-                args = args + (float(argv[i + 1]),)
+                args += (float(argv[i + 1]),)
             else:
-                args = args + (argv[i + 1],)
+                args += (argv[i + 1],)
         res = fn(*args)
         print "THE RESULT IS:", res, ";"
         return 0
-    
+
     t = Translation(entry_point, None, gc=gcpolicy, backend="c",
                     policy=annotatorpolicy)
     if not backendopt:
diff --git a/pypy/translator/c/test/test_typed.py b/pypy/translator/c/test/test_typed.py
--- a/pypy/translator/c/test/test_typed.py
+++ b/pypy/translator/c/test/test_typed.py
@@ -7,11 +7,11 @@
 
 from py.test import raises
 
-from pypy import conftest
 from pypy.rlib.objectmodel import compute_hash, current_object_addr_as_int
 from pypy.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, intmask, longlongmask
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.translator.test import snippet
+from pypy.translator.c.test.test_genc import compile
 from pypy.translator.translator import TranslationContext
 
 
@@ -39,15 +39,8 @@
         builder.compile()
         return builder.get_entry_point()
 
-    def getcompiled(self, func, argtypes=None, view=False):
-        from pypy.translator.transform import insert_ll_stackcheck
-        t = self.annotatefunc(func, argtypes)
-        self.process(t)
-        if view or conftest.option.view:
-            t.view()
-        t.checkgraphs()
-        insert_ll_stackcheck(t)
-        return self.compilefunc(t, func)
+    def getcompiled(self, func, argtypes=[], view=False):
+        return compile(func, argtypes, view=view)
 
     def process(self, t):
         t.buildrtyper().specialize()


More information about the pypy-commit mailing list