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


Python TranslationContext.view方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
    def __init__(self, function, annotations, stackless=False, view=False, html=None, is_interactive=False, root = None, run_browser = True, policy = None):
        if not use_browsertest and not _CLI_is_on_path():
            py.test.skip('Javascript CLI (js) not found')

        self.html = html
        self.is_interactive = is_interactive
        t = TranslationContext()
        
        if policy is None:
            from pypy.annotation.policy import AnnotatorPolicy
            policy = AnnotatorPolicy()
            policy.allow_someobjects = False

        ann = t.buildannotator(policy=policy)
        ann.build_types(function, annotations)
        if view or option.view:
            t.view()
        t.buildrtyper(type_system="ootype").specialize()

        if view or option.view:
            t.view()
        #self.js = JS(t, [function, callback_function], stackless)
        self.js = JS(t, function, stackless)
        self.js.write_source()
        if root is None and use_tg:
            from pypy.translator.js.demo.jsdemo.controllers import Root
            self.root = Root
        else:
            self.root = root
        self.run_browser = run_browser
        self.function_calls = []
开发者ID:antoine1fr,项目名称:pygirl,代码行数:33,代码来源:runtest.py

示例2: _build_gen

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def _build_gen(func, annotation, graph=None, backendopt=True, exctrans=False,
               annotatorpolicy=None, nowrap=False):
    try: 
        func = func.im_func
    except AttributeError: 
        pass
    t = TranslationContext()
    if graph is not None:
        graph.func = func
        ann = t.buildannotator(policy=annotatorpolicy)
        inputcells = [ann.typeannotation(a) for a in annotation]
        ann.build_graph_types(graph, inputcells)
        t.graphs.insert(0, graph)
    else:
        ann = t.buildannotator(policy=annotatorpolicy)
        ann.build_types(func, annotation)

    if getoption('view'):
       t.view()

    t.buildrtyper(type_system="ootype").specialize()
    if backendopt:
        check_virtual_methods(ootype.ROOT)
        backend_optimizations(t)
    
    main_graph = t.graphs[0]

    if getoption('view'):
       t.view()
       
    return _build_gen_from_graph(main_graph, t, exctrans, nowrap)
开发者ID:ieure,项目名称:pypy,代码行数:33,代码来源:runtest.py

示例3: test_annotate_byval

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
 def test_annotate_byval(self):
     t = TranslationContext()
     a = t.buildannotator()
     s = a.build_types(test_testfunc_byval, [])
     if conftest.option.view:
         t.view()
     assert s.knowntype == int
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:test_rctypes.py

示例4: _build_gen

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def _build_gen(func, annotation, graph=None, backendopt=True):
    try: 
        func = func.im_func
    except AttributeError: 
        pass
    t = TranslationContext()
    if graph is not None:
        graph.func = func
        ann = t.buildannotator()
        inputcells = [ann.typeannotation(a) for a in annotation]
        ann.build_graph_types(graph, inputcells)
        t.graphs.insert(0, graph)
    else:
        ann = t.buildannotator()
        ann.build_types(func, annotation)

    if getoption('view'):
       t.view()

    t.buildrtyper(type_system="ootype").specialize()
    if backendopt:
        check_virtual_methods(ootype.ROOT)
        backend_optimizations(t)
    
    main_graph = t.graphs[0]

    if getoption('view'):
       t.view()

    if getoption('wd'):
        tmpdir = py.path.local('.')
    else:
        tmpdir = udir

    return GenCli(tmpdir, t, TestEntryPoint(main_graph, True))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:37,代码来源:runtest.py

示例5: hannotate

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def hannotate(func, argtypes, policy=P_DEFAULT, annotator=False, inline=None,
              backendoptimize=False):
    # build the normal ll graphs for ll_function
    t = TranslationContext()
    a = t.buildannotator()
    a.build_types(func, argtypes)
    rtyper = t.buildrtyper()
    rtyper.specialize()
    if inline:
        auto_inlining(t, threshold=inline)
    if backendoptimize:
        from pypy.translator.backendopt.all import backend_optimizations
        backend_optimizations(t)
    graph1 = graphof(t, func)

    # build hint annotator types
    hannotator = HintAnnotator(base_translator=t, policy=policy)
    hs = hannotator.build_types(graph1, [SomeLLAbstractConstant(v.concretetype,
                                                                {OriginFlags(): True})
                                         for v in graph1.getargs()])
    hannotator.simplify()
    t = hannotator.translator
    if conftest.option.view:
        t.view()
    if annotator:
        return hs, hannotator
    else:
        return hs
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:30,代码来源:test_annotator.py

示例6: check

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
 def check(self, fn, signature, args, expected_result,
           expected_mallocs=0, expected_calls=0):
     t = TranslationContext()
     self.translator = t
     t.buildannotator().build_types(fn, signature)
     t.buildrtyper(type_system=self.type_system).specialize()
     graph = graphof(t, fn)
     if option.view:
         t.view()
     self.original_graph_count = len(t.graphs)
     # to detect broken intermediate graphs,
     # we do the loop ourselves instead of calling remove_simple_mallocs()
     maxiter = 100
     mallocv = MallocVirtualizer(t.graphs, t.rtyper, verbose=True)
     while True:
         progress = mallocv.remove_mallocs_once()
         #simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()))
         if progress and option.view:
             t.view()
         t.checkgraphs()
         if expected_result is not DONT_CHECK_RESULT:
             interp = LLInterpreter(t.rtyper)
             if not isinstance(expected_result, CHECK_RAISES):
                 res = interp.eval_graph(graph, args)
                 assert res == expected_result
             else:
                 excinfo = py.test.raises(LLException,
                                          interp.eval_graph, graph, args)
                 assert expected_result.excname in str(excinfo.value)
         if not progress:
             break
         maxiter -= 1
         assert maxiter > 0, "infinite loop?"
     self.check_malloc_removed(graph, expected_mallocs, expected_calls)
     return graph
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:37,代码来源:test_mallocv.py

示例7: translate

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
 def translate(self, func, sig):
     t = TranslationContext()
     t.buildannotator().build_types(func, sig)
     t.buildrtyper(type_system=self.type_system).specialize()
     if option.view:
         t.view()
     return t, RaiseAnalyzer(t)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:test_canraise.py

示例8: gengraph

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def gengraph(func, argtypes=[], viewbefore='auto', policy=None,
             type_system="lltype", backendopt=False, config=None,
             **extraconfigopts):
    t = TranslationContext(config=config)
    t.config.set(**extraconfigopts)
    a = t.buildannotator(policy=policy)
    timelog("annotating", a.build_types, func, argtypes, main_entry_point=True)
    if viewbefore == 'auto':
        viewbefore = getattr(conftest.option, 'view', False)
    if viewbefore:
        a.simplify()
        t.view()
    global typer # we need it for find_exception
    typer = t.buildrtyper(type_system=type_system)
    timelog("rtyper-specializing", typer.specialize) 
    #t.view()
    timelog("checking graphs", t.checkgraphs) 
    if backendopt:
        from pypy.translator.backendopt.all import backend_optimizations
        backend_optimizations(t)
        timelog("checking graphs", t.checkgraphs)
        if viewbefore:
            t.view()
    desc = t.annotator.bookkeeper.getdesc(func)
    graph = desc.specialize(argtypes)
    return t, typer, graph
开发者ID:ieure,项目名称:pypy,代码行数:28,代码来源:test_llinterp.py

示例9: check

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
 def check(self, fn, signature, args, expected_result, must_be_removed=True,
           inline=None):
     remover = self.MallocRemover()
     t = TranslationContext()
     t.buildannotator().build_types(fn, signature)
     t.buildrtyper(type_system=self.type_system).specialize()
     graph = graphof(t, fn)
     if inline is not None:
         from pypy.translator.backendopt.inline import auto_inline_graphs
         auto_inline_graphs(t, t.graphs, inline)
     if option.view:
         t.view()
     # to detect missing keepalives and broken intermediate graphs,
     # we do the loop ourselves instead of calling remove_simple_mallocs()
     while True:
         progress = remover.remove_mallocs_once(graph)
         simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()))
         if progress and option.view:
             t.view()
         if expected_result is not Ellipsis:
             interp = LLInterpreter(t.rtyper)
             res = interp.eval_graph(graph, args)
             assert res == expected_result
         if not progress:
             break
     if must_be_removed:
         self.check_malloc_removed(graph)
     return graph
开发者ID:alkorzt,项目名称:pypy,代码行数:30,代码来源:test_malloc.py

示例10: rtype

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def rtype(func, inputtypes, specialize=True):
    t = TranslationContext()
    t.buildannotator().build_types(func, inputtypes)
    if specialize:
        t.buildrtyper().specialize()
    if conftest.option.view:
        t.view()
    return t    
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_transform.py

示例11: rtype

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def rtype(fn, signature):
    t = TranslationContext()
    t.buildannotator().build_types(fn, signature)
    t.buildrtyper().specialize()
    graph = graphof(t, fn)
    if option.view:
        t.view()
    return t, graph
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_mallocprediction.py

示例12: get_graph

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def get_graph(fn, signature):
    t = TranslationContext()
    t.buildannotator().build_types(fn, signature)
    t.buildrtyper().specialize()
    graph = graphof(t, fn)
    if conftest.option.view:
        t.view()
    return graph, t
开发者ID:antoine1fr,项目名称:pygirl,代码行数:10,代码来源:test_constfold.py

示例13: test_annotate_array_access_float

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
    def test_annotate_array_access_float(self):
        t = TranslationContext()
        a = t.buildannotator()
        s = a.build_types(access_array, [float])
        assert s.knowntype == float

        if conftest.option.view:
            t.view()
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:10,代码来源:test_array.py

示例14: translate

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
def translate(func, argtypes, backend_optimize=True):
    t = TranslationContext()
    t.buildannotator().build_types(func, argtypes)
    t.buildrtyper().specialize()
    if backend_optimize:
        backend_optimizations(t)
    if conftest.option.view:
        t.view()
    return graphof(t, func), t
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:test_simplify.py

示例15: translateopt

# 需要导入模块: from pypy.translator.translator import TranslationContext [as 别名]
# 或者: from pypy.translator.translator.TranslationContext import view [as 别名]
 def translateopt(self, func, sig, **optflags):
     t = TranslationContext()
     t.buildannotator().build_types(func, sig)
     t.buildrtyper(type_system=self.type_system).specialize()
     if conftest.option.view:
         t.view()
     backend_optimizations(t, **optflags)
     if conftest.option.view:
         t.view()
     return t
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:test_all.py


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