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


Python TranslationContext.viewcg方法代码示例

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


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

示例1: rtype

# 需要导入模块: from rpython.translator.translator import TranslationContext [as 别名]
# 或者: from rpython.translator.translator.TranslationContext import viewcg [as 别名]
def rtype(func, inputtypes, specialize=True, gcname='ref',
          backendopt=False, **extraconfigopts):
    from rpython.translator.translator import TranslationContext
    t = TranslationContext()
    # XXX XXX XXX mess
    t.config.translation.gc = gcname
    t.config.translation.gcremovetypeptr = True
    t.config.set(**extraconfigopts)
    ann = t.buildannotator()
    ann.build_types(func, inputtypes)

    if specialize:
        t.buildrtyper().specialize()
    if backendopt:
        from rpython.translator.backendopt.all import backend_optimizations
        backend_optimizations(t)
    if option.view:
        t.viewcg()
    return t
开发者ID:timfel,项目名称:thesis-data,代码行数:21,代码来源:test_transformed_gc.py

示例2: Translation

# 需要导入模块: from rpython.translator.translator import TranslationContext [as 别名]
# 或者: from rpython.translator.translator.TranslationContext import viewcg [as 别名]
class Translation(object):

    def __init__(self, entry_point, argtypes=None, **kwds):
        self.driver = driver.TranslationDriver(overrides=DEFAULTS)
        self.config = self.driver.config

        self.entry_point = export_symbol(entry_point)
        self.context = TranslationContext(config=self.config)

        policy = kwds.pop('policy', None)
        self.update_options(kwds)
        self.ensure_setup(argtypes, policy)
        # for t.view() to work just after construction
        graph = self.context.buildflowgraph(entry_point)
        self.context._prebuilt_graphs[entry_point] = graph

    def view(self):
        self.context.view()

    def viewcg(self):
        self.context.viewcg()

    def ensure_setup(self, argtypes=None, policy=None):
        standalone = argtypes is None
        if standalone:
            assert argtypes is None
        else:
            if argtypes is None:
                argtypes = []
        self.driver.setup(self.entry_point, argtypes, policy,
                          empty_translator=self.context)
        self.ann_argtypes = argtypes
        self.ann_policy = policy

    def update_options(self, kwds):
        gc = kwds.pop('gc', None)
        if gc:
            self.config.translation.gc = gc
        self.config.translation.set(**kwds)

    def ensure_opt(self, name, value=None, fallback=None):
        if value is not None:
            self.update_options({name: value})
            return value
        val = getattr(self.config.translation, name, None)
        if fallback is not None and val is None:
            self.update_options({name: fallback})
            return fallback
        if val is not None:
            return val
        raise Exception(
                    "the %r option should have been specified at this point" % name)

    def ensure_type_system(self, type_system=None):
        if self.config.translation.backend is not None:
            return self.ensure_opt('type_system')
        return self.ensure_opt('type_system', type_system, 'lltype')

    def ensure_backend(self, backend=None):
        backend = self.ensure_opt('backend', backend)
        self.ensure_type_system()
        return backend

    # disable some goals (steps)
    def disable(self, to_disable):
        self.driver.disable(to_disable)

    def set_backend_extra_options(self, **extra_options):
        for name in extra_options:
            backend, option = name.split('_', 1)
            self.ensure_backend(backend)
        self.driver.set_backend_extra_options(extra_options)

    # backend independent

    def annotate(self, **kwds):
        self.update_options(kwds)
        return self.driver.annotate()

    # type system dependent

    def rtype(self, **kwds):
        self.update_options(kwds)
        ts = self.ensure_type_system()
        return getattr(self.driver, 'rtype_' + ts)()

    def backendopt(self, **kwds):
        self.update_options(kwds)
        ts = self.ensure_type_system('lltype')
        return getattr(self.driver, 'backendopt_' + ts)()

    # backend depedent

    def source(self, **kwds):
        self.update_options(kwds)
        backend = self.ensure_backend()
        getattr(self.driver, 'source_' + backend)()

    def source_c(self, **kwds):
        self.update_options(kwds)
#.........这里部分代码省略.........
开发者ID:Darriall,项目名称:pypy,代码行数:103,代码来源:interactive.py


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