Commits

Alex Gaynor committed 76215c0 Draft

(alex, fijal) make getcompiled work

  • Participants
  • Parent commits 093ba82
  • Branches kill-someobject

Comments (0)

Files changed (2)

pypy/translator/c/test/test_genc.py

+import ctypes
+
 import py
-import ctypes
 
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.translator.translator import TranslationContext, graphof
 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))
     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:

pypy/translator/c/test/test_typed.py

 
 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
 
 
         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()