当前位置: 首页>>代码示例>>Python>>正文


Python Translation.view方法代码示例

本文整理汇总了Python中pypy.translator.interactive.Translation.view方法的典型用法代码示例。如果您正苦于以下问题:Python Translation.view方法的具体用法?Python Translation.view怎么用?Python Translation.view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.translator.interactive.Translation的用法示例。


在下文中一共展示了Translation.view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compile

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def compile(fn, argtypes, view=False, gcpolicy="ref", backendopt=True,
            annotatorpolicy=None):
    t = Translation(fn, argtypes, gc=gcpolicy, backend="c",
                    policy=annotatorpolicy)
    if not backendopt:
        t.disable(["backendopt_lltype"])
    t.annotate()
    # XXX fish
    t.driver.config.translation.countmallocs = True
    compiled_fn = t.compile_c()
    if getattr(py.test.config.option, 'view', False):
        t.view()
    malloc_counters = t.driver.cbuilder.get_malloc_counters()
    def checking_fn(*args, **kwds):
        if 'expected_extra_mallocs' in kwds:
            expected_extra_mallocs = kwds.pop('expected_extra_mallocs')
        else:
            expected_extra_mallocs = 0
        res = compiled_fn(*args, **kwds)
        mallocs, frees = malloc_counters()
        if isinstance(expected_extra_mallocs, int):
            assert mallocs - frees == expected_extra_mallocs
        else:
            assert mallocs - frees in expected_extra_mallocs
        return res
    return checking_fn
开发者ID:alkorzt,项目名称:pypy,代码行数:28,代码来源:test_genc.py

示例2: compile

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def compile(fn, argtypes, view=False, gcpolicy="ref", backendopt=True,
            annotatorpolicy=None):
    if argtypes is not None and "__pypy__" in sys.builtin_module_names:
        py.test.skip("requires building cpython extension modules")
    t = Translation(fn, argtypes, gc=gcpolicy, backend="c",
                    policy=annotatorpolicy)
    if not backendopt:
        t.disable(["backendopt_lltype"])
    t.annotate()
    # XXX fish
    t.driver.config.translation.countmallocs = True
    compiled_fn = t.compile_c()
    try:
        if py.test.config.option.view:
            t.view()
    except AttributeError:
        pass
    malloc_counters = t.driver.cbuilder.get_malloc_counters()
    def checking_fn(*args, **kwds):
        if 'expected_extra_mallocs' in kwds:
            expected_extra_mallocs = kwds.pop('expected_extra_mallocs')
        else:
            expected_extra_mallocs = 0
        res = compiled_fn(*args, **kwds)
        mallocs, frees = malloc_counters()
        if isinstance(expected_extra_mallocs, int):
            assert mallocs - frees == expected_extra_mallocs
        else:
            assert mallocs - frees in expected_extra_mallocs
        return res
    return checking_fn
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:33,代码来源:test_genc.py

示例3: build_adi

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def build_adi(function, types):
    t = Translation(function)
    t.rtype(types)
    if conftest.option.view:
        t.view()
    adi = AbstractDataFlowInterpreter(t.context)
    graph = graphof(t.context, function)
    adi.schedule_function(graph)
    adi.complete()
    return t.context, adi, graph
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:test_escape.py

示例4: test_tagged_boehm

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_tagged_boehm():
    t = Translation(entry_point, standalone=True, gc='boehm', taggedpointers=True)
    try:
        exename = str(t.compile_c())
    finally:
        if conftest.option.view:
            t.view()
    g = os.popen(exename, 'r')
    data = g.read()
    g.close()
    assert data.rstrip().endswith('ALL OK')
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:13,代码来源:test_rtagged.py

示例5: test_tagged_boehm

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_tagged_boehm():
    py.test.skip("broken as test need rffi")
    t = Translation(entry_point, standalone=True, gc='boehm')
    try:
        exename = t.compile_llvm()
    finally:
        if conftest.option.view:
            t.view()
    g = os.popen(exename, 'r')
    data = g.read()
    g.close()
    assert data.rstrip().endswith('ALL OK')
开发者ID:antoine1fr,项目名称:pygirl,代码行数:14,代码来源:test_rtagged.py

示例6: test_name

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_name():
    def f():
        return 3

    f.c_name = 'pypy_xyz_f'

    t = Translation(f, [], backend="c")
    t.annotate()
    compiled_fn = t.compile_c()
    if py.test.config.option.view:
        t.view()
    assert 'pypy_xyz_f' in t.driver.cbuilder.c_source_filename.read()
开发者ID:alkorzt,项目名称:pypy,代码行数:14,代码来源:test_genc.py

示例7: test_tagged_boehm

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_tagged_boehm():
    runtest.llvm_test()
    runtest.gcc3_test()
    t = Translation(entry_point, standalone=True, gc='boehm')
    try:
        exename = t.compile_llvm()
    finally:
        if conftest.option.view:
            t.view()
    g = os.popen(exename, 'r')
    data = g.read()
    g.close()
    assert data.rstrip().endswith('ALL OK')
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:15,代码来源:test_rtagged.py

示例8: compile_rex

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def compile_rex(rex):
    try:
        from pypy.translator.interactive import Translation
    except ImportError:
        py.test.skip("pypy not found")
    fda = rex.make_automaton().make_deterministic()
    fda.optimize()
    fn = fda.make_code()
    t = Translation(fn)
    t.backendopt([str], backend="c")
    if py.test.config.option.view:
        t.view()
    return t.compile_c()
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:15,代码来源:test_regex.py

示例9: test_exportstruct

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_exportstruct():
    from pypy.rlib.exports import export_struct
    def f():
        return 42
    FOO = Struct("FOO", ("field1", Signed))
    foo = malloc(FOO, flavor="raw")
    foo.field1 = 43
    export_struct("BarStruct", foo._obj)
    t = Translation(f, [], backend="c")
    t.annotate()
    compiled_fn = t.compile_c()
    if py.test.config.option.view:
        t.view()
    assert ' BarStruct ' in t.driver.cbuilder.c_source_filename.read()
    free(foo, flavor="raw")
开发者ID:ieure,项目名称:pypy,代码行数:17,代码来源:test_genc.py

示例10: test_entrypoints

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_entrypoints():
    def f():
        return 3

    key = "test_entrypoints42"
    @entrypoint(key, [int], "foobar")
    def g(x):
        return x + 42

    t = Translation(f, [], backend="c", secondaryentrypoints="test_entrypoints42")
    t.annotate()
    compiled_fn = t.compile_c()
    if py.test.config.option.view:
        t.view()
    assert 'foobar' in t.driver.cbuilder.c_source_filename.read()
开发者ID:ieure,项目名称:pypy,代码行数:17,代码来源:test_genc.py

示例11: test_computed_int_symbolic

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_computed_int_symbolic():
    too_early = True
    def compute_fn():
        assert not too_early
        return 7
    k = ComputedIntSymbolic(compute_fn)
    def f():
        return k*6

    t = Translation(f)
    t.rtype()
    if conftest.option.view:
        t.view()
    too_early = False
    fn = t.compile_c()
    res = fn()
    assert res == 42
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:19,代码来源:test_symbolic.py

示例12: compile

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def compile(fn, argtypes, view=False, gcpolicy="ref", backendopt=True,
            annotatorpolicy=None):
    t = Translation(fn, argtypes, gc=gcpolicy, backend="c",
                    policy=annotatorpolicy)
    if not backendopt:
        t.disable(["backendopt_lltype"])
    t.annotate()
    # XXX fish
    t.driver.config.translation.countmallocs = True
    compiled_fn = t.compile_c()
    if conftest.option.view:
        t.view()
    # XXX fish fish fish some more
    module = t.driver.cbuilder.c_ext_module
    def checking_fn(*args, **kwds):
        if 'expected_extra_mallocs' in kwds:
            expected_extra_mallocs = kwds.pop('expected_extra_mallocs')
        else:
            expected_extra_mallocs = 0
        res = compiled_fn(*args, **kwds)
        mallocs, frees = module.malloc_counters()
        assert mallocs - frees == expected_extra_mallocs
        return res
    return checking_fn
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:26,代码来源:test_genc.py

示例13: test_translate_pypackrat_regex

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_translate_pypackrat_regex():
    from pypy.rlib.parsing.pypackrat import PackratParser
    class parser(PackratParser):
        """
        num:
            `([1-9][0-9]*)|0`;
        """
    print parser._code
    def parse(s):
        p = parser(s)
        return p.num()
    res = parse("1234")
    assert res == '1234'
    t = Translation(parse)
    t.annotate([str])
    t.rtype()
    t.backendopt()
    if option.view:
        t.view()
    func = t.compile_c()
    res = func("12345")
    assert res == '12345'
    res = func("0")
    assert res == '0'
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:26,代码来源:test_translate.py

示例14: test_translate_pypackrat

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def test_translate_pypackrat():
    from pypy.rlib.parsing.pypackrat import PackratParser
    class parser(PackratParser):
        """
        expr:
            additive;
        additive:
            a = additive
            '-'
            b = multitive
            return {'(%s - %s)' % (a, b)}
          | multitive;
        multitive:
            a = multitive
            '*'
            b = simple
            return {'(%s * %s)' % (a, b)}
          | simple;
        simple:
            ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9');
        """
    print parser._code
    def parse(s):
        p = parser(s)
        return p.expr()
    res = parse("5-5-5")
    assert res == '((5 - 5) - 5)'
    t = Translation(parse)
    t.annotate([str])
    t.rtype()
    t.backendopt()
    if option.view:
        t.view()
    func = t.compile_c()
    res = func("5-5-5")
    assert res == '((5 - 5) - 5)'
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:38,代码来源:test_translate.py

示例15: getcompiled

# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import view [as 别名]
def getcompiled(f, args):
    t = Translation(f)
    fn = t.compile_c(args)
    if conftest.option.view:
        t.view()
    return fn, t
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:8,代码来源:test_symbolic.py


注:本文中的pypy.translator.interactive.Translation.view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。