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


Python L.rewrite_comp方法代码示例

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


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

示例1: flatten_memberships

# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import rewrite_comp [as 别名]
def flatten_memberships(comp):
    """Transform the comprehension to rewrite set memberships (Member
    nodes) as MMember clauses. Return an ObjRelations indicating whether
    an M set is needed.
    """
    M = False
    def process(clause):
        nonlocal M
        if isinstance(clause, L.Member):
            # MMember.
            if (isinstance(clause.target, L.Name) and
                isinstance(clause.iter, L.Name)):
                set_ = clause.iter.id
                elem = clause.target.id
                M = True
                clause = L.MMember(set_, elem)
            
            # Subquery clause, leave as Member for now.
            elif (isinstance(clause.target, L.Name) and
                  isinstance(clause.iter, L.Unwrap)):
                pass
            
            else:
                raise L.ProgramError('Cannot flatten Member clause: {}'
                                     .format(clause))
            
        
        return clause, [], []
    
    tree = L.rewrite_comp(comp, process)
    objrels = ObjRelations(M, [], False, [])
    return tree, objrels
开发者ID:jieaozhu,项目名称:dist_lang_reviews,代码行数:34,代码来源:comp.py

示例2: flatten_replaceables

# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import rewrite_comp [as 别名]
def flatten_replaceables(comp):
    """Transform the comprehension to rewrite replaceables and add new
    clauses for them. Also return an ObjRelations indicating what object
    relations are needed.
    """
    field_namer = lambda obj, attr: obj + '_' + attr
    map_namer = lambda map, key: map + '_' + key
    tuple_namer = lambda elts: 't_' + '_'.join(elts)
    
    rewriter = ReplaceableRewriter(field_namer, map_namer, tuple_namer)
    tree = L.rewrite_comp(comp, rewriter.process)
    
    # Go from MutableObjRelations to an immutable one.
    objrels = ObjRelations(*rewriter.objrels)
    
    return tree, objrels
开发者ID:jieaozhu,项目名称:dist_lang_reviews,代码行数:18,代码来源:comp.py

示例3: rewrite_comp

# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import rewrite_comp [as 别名]
 def rewrite_comp(self, symbol, name, comp):
     rewriter = AggrMapReplacer(self.symtab.fresh_names.vars)
     comp = L.rewrite_comp(comp, rewriter.process)
     self.sfm_invs.update(rewriter.sfm_invs)
     return comp
开发者ID:jieaozhu,项目名称:dist_lang_reviews,代码行数:7,代码来源:comp.py


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