Beispiel #1
0
 def visit_AttrDelete(self, node):
     if node.attr not in self.objrels.Fs:
         return
     
     lookup = L.Attribute(node.obj, node.attr)
     pair = L.Tuple([node.obj, lookup])
     var = next(self.fresh_vars)
     return (L.Assign(var, pair),
             L.RelUpdate(N.F(node.attr), L.SetRemove(), var))
Beispiel #2
0
    def get_code(self, cl, bindenv, body):
        vars = self.lhs_vars(cl)
        assert_unique(vars)
        mask = L.mask_from_bounds(vars, bindenv)

        if L.mask_is_allbound(mask):
            comparison = L.Compare(L.Name(cl.value), L.Eq(),
                                   L.Attribute(L.Name(cl.obj), cl.attr))
            code = (L.If(comparison, body, ()), )
            needs_typecheck = True

        elif mask == L.mask('bu'):
            code = (L.Assign(cl.value, L.Attribute(L.Name(cl.obj), cl.attr)), )
            code += body
            needs_typecheck = True

        else:
            code = super().get_code(cl, bindenv, body)
            needs_typecheck = False

        if needs_typecheck and self.use_typecheck:
            code = (L.If(L.HasField(L.Name(cl.obj), cl.attr), code, ()), )

        return code