本文整理汇总了Python中rpython.translator.translator.TranslationContext.platform方法的典型用法代码示例。如果您正苦于以下问题:Python TranslationContext.platform方法的具体用法?Python TranslationContext.platform怎么用?Python TranslationContext.platform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rpython.translator.translator.TranslationContext
的用法示例。
在下文中一共展示了TranslationContext.platform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile
# 需要导入模块: from rpython.translator.translator import TranslationContext [as 别名]
# 或者: from rpython.translator.translator.TranslationContext import platform [as 别名]
def compile(f, gc, **kwds):
from rpython.annotator.listdef import s_list_of_strings
from rpython.translator.translator import TranslationContext
from rpython.jit.metainterp.warmspot import apply_jit
from rpython.translator.platform import platform, is_host_build
from rpython.translator.c import genc
#
t = TranslationContext()
t.config.translation.gc = gc
if not is_host_build():
t.platform = platform
if gc != 'boehm':
t.config.translation.gcremovetypeptr = True
for name, value in kwds.items():
setattr(t.config.translation, name, value)
ann = t.buildannotator()
ann.build_types(f, [s_list_of_strings], main_entry_point=True)
t.buildrtyper().specialize()
if kwds['jit']:
patch = get_functions_to_patch()
old_value = {}
try:
for (obj, attr), value in patch.items():
old_value[obj, attr] = getattr(obj, attr)
setattr(obj, attr, value)
#
apply_jit(t)
#
finally:
for (obj, attr), oldvalue in old_value.items():
setattr(obj, attr, oldvalue)
cbuilder = genc.CStandaloneBuilder(t, f, t.config)
cbuilder.generate_source(defines=cbuilder.DEBUG_DEFINES)
cbuilder.compile()
return cbuilder