本文整理汇总了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 = []
示例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)
示例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
示例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))
示例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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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
示例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()
示例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
示例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