[pypy-dev] Re: [pypy-svn] r20364 - in pypy/branch/somepbc-refactoring/pypy/translator/c: . test

Samuele Pedroni pedronis at strakt.com
Mon Nov 28 23:09:39 CET 2005


mwh at codespeak.net wrote:
> Author: mwh
> Date: Mon Nov 28 18:27:39 2005
> New Revision: 20364
> 
> Modified:
>    pypy/branch/somepbc-refactoring/pypy/translator/c/extfunc.py
>    pypy/branch/somepbc-refactoring/pypy/translator/c/genc.py
>    pypy/branch/somepbc-refactoring/pypy/translator/c/pyobj.py
>    pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py
>    pypy/branch/somepbc-refactoring/pypy/translator/c/wrapper.py
> Log:
> test_annotated passes again, though this is pretty much a 'hack-until-it-
> passes' approach.
> 
> 

I see,


> Modified: pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py
> ==============================================================================
> --- pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py	(original)
> +++ pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py	Mon Nov 28 18:27:39 2005
> @@ -1,7 +1,7 @@
>  import autopath
>  import py, sys
>  from pypy.translator.tool.cbuild import skip_missing_compiler
> -from pypy.translator.translator import Translator
> +from pypy.translator.translator import TranslationContext
>  
>  from pypy.translator.test import snippet 
>  
> @@ -12,7 +12,7 @@
>  class TestAnnotatedTestCase:
>  
>      def getcompiled(self, func):
> -        t = Translator(func, simplifying=True)
> +        t = TranslationContext(simplifying=True)
>          # builds starting-types from func_defs 
>          argstypelist = []
>          if func.func_defaults:
> @@ -20,9 +20,15 @@
>                  if isinstance(spec, tuple):
>                      spec = spec[0] # use the first type only for the tests
>                  argstypelist.append(spec)
> -        a = t.annotate(argstypelist)
> +        a = t.buildannotator()
> +        a.build_types(func, argstypelist)
>          a.simplify()
> -        return skip_missing_compiler(t.ccompile)
> +        from pypy.translator.c import genc
> +        builder = genc.CExtModuleBuilder(t, func)
> +        builder.generate_source()
> +        skip_missing_compiler(builder.compile)
> +        builder.import_module()
> +        return builder.get_entry_point()
>  
>      def test_set_attr(self):
>          set_attr = self.getcompiled(snippet.set_attr)
>

I missed this subtle point, indeed before going on writing more code 
like this, we need to think where and how much of translator.Translator
to keep working and where instead to switch using TranslationContext



More information about the Pypy-dev mailing list