本文整理汇总了Python中pypy.translator.interactive.Translation.source_c方法的典型用法代码示例。如果您正苦于以下问题:Python Translation.source_c方法的具体用法?Python Translation.source_c怎么用?Python Translation.source_c使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.translator.interactive.Translation
的用法示例。
在下文中一共展示了Translation.source_c方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_source
# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import source_c [as 别名]
def test_simple_source():
def f(x, y):
return x,y
t = Translation(f, backend='c')
t.annotate([int, int])
t.source()
assert 'source_c' in t.driver.done
t = Translation(f, [int, int])
t.source_c()
assert 'source_c' in t.driver.done
t = Translation(f, [int, int])
py.test.raises(Exception, "t.source()")
示例2: test_inhibit_tail_call
# 需要导入模块: from pypy.translator.interactive import Translation [as 别名]
# 或者: from pypy.translator.interactive.Translation import source_c [as 别名]
def test_inhibit_tail_call():
from pypy.rpython.lltypesystem import lltype
def foobar_fn(n):
return 42
foobar_fn._dont_inline_ = True
def main(n):
return foobar_fn(n)
#
t = Translation(main, [int], backend="c")
t.rtype()
t.context._graphof(foobar_fn).inhibit_tail_call = True
t.source_c()
lines = t.driver.cbuilder.c_source_filename.readlines()
for i, line in enumerate(lines):
if '= pypy_g_foobar_fn' in line:
break
else:
assert 0, "the call was not found in the C source"
assert 'PYPY_INHIBIT_TAIL_CALL();' in lines[i+1]