本文整理汇总了Python中incoq.compiler.incast.L.rel_update方法的典型用法代码示例。如果您正苦于以下问题:Python L.rel_update方法的具体用法?Python L.rel_update怎么用?Python L.rel_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incoq.compiler.incast.L
的用法示例。
在下文中一共展示了L.rel_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_maint_code
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import rel_update [as 别名]
def get_maint_code(self, fresh_var_prefix, fresh_join_names,
comp, result_var, update, *,
selfjoin=SelfJoin.Without,
counted):
"""Given a comprehension (not necessarily a join) and an
update to a relation, return the maintenance code -- i.e.,
the update to the stored result variable looped for each
maintenance join.
If counted is False, generate non-counted set updates.
"""
assert isinstance(update, L.RelUpdate)
assert isinstance(update.op, (L.SetAdd, L.SetRemove))
result_elem_var = fresh_var_prefix + '_result'
# Prefix LHS vars in the comp to guarantee fresh names for their
# use in maintenance code.
renamer = lambda x: fresh_var_prefix + '_' + x
comp = self.comp_rename_lhs_vars(comp, renamer)
body = ()
body += (L.Assign(result_elem_var, comp.resexp),)
body += L.rel_update(result_var, update.op, result_elem_var,
counted=counted)
join = self.make_join_from_comp(comp)
maint_joins = self.get_maint_join_union(
join, update.rel, L.Name(update.elem),
selfjoin=selfjoin)
code = ()
for maint_join in maint_joins:
join_name = next(fresh_join_names)
code += self.get_loop_for_join(maint_join, body, join_name)
return code