本文整理汇总了Python中incoq.compiler.incast.L.mask_from_bounds方法的典型用法代码示例。如果您正苦于以下问题:Python L.mask_from_bounds方法的具体用法?Python L.mask_from_bounds怎么用?Python L.mask_from_bounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incoq.compiler.incast.L
的用法示例。
在下文中一共展示了L.mask_from_bounds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_code
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import mask_from_bounds [as 别名]
def get_code(self, cl, bindenv, body):
vars = self.lhs_vars(cl)
assert_unique(vars)
mask = L.mask_from_bounds(vars, bindenv)
comparison = L.Compare(L.Name(cl.tup), L.Eq(), L.tuplify(cl.elts))
if L.mask_is_allbound(mask):
code = (L.If(comparison, body, ()),)
needs_typecheck = True
elif mask.m.startswith('b'):
elts_mask = L.mask_from_bounds(cl.elts, bindenv)
code = L.bind_by_mask(elts_mask, cl.elts, L.Name(cl.tup))
if L.mask_is_allunbound(elts_mask):
code += body
else:
code += (L.If(comparison, body, ()),)
needs_typecheck = True
elif mask == L.mask('u' + 'b' * len(cl.elts)):
code = (L.Assign(cl.tup, L.tuplify(cl.elts)),)
code += body
needs_typecheck = False
else:
raise L.TransformationError('Cannot emit code for TUP clause '
'that would require an auxiliary '
'map; use demand filtering')
if needs_typecheck and self.use_typecheck:
code = (L.If(L.HasArity(L.Name(cl.tup), len(cl.elts)), code, ()),)
return code
示例2: get_priority
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import mask_from_bounds [as 别名]
def get_priority(self, cl, bindenv):
mask = L.mask_from_bounds(self.lhs_vars(cl), bindenv)
if mask == L.mask('bu'):
return Priority.Constant
else:
return super().get_priority(cl, bindenv)
示例3: functionally_determines
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import mask_from_bounds [as 别名]
def functionally_determines(self, cl, bindenv):
mask = L.mask_from_bounds(self.lhs_vars(cl), bindenv)
if mask == L.mask('bu'):
return True
else:
return super().functionally_determines(cl, bindenv)