def update_rdict_annotations(self, s_eqfn, s_hashfn, other=None):
     assert self.custom_eq_hash
     s_eqfn = union(s_eqfn, self.s_rdict_eqfn)
     s_hashfn = union(s_hashfn, self.s_rdict_hashfn)
     self.s_rdict_eqfn = s_eqfn
     self.s_rdict_hashfn = s_hashfn
     self.emulate_rdict_calls(other=other)
Exemple #2
0
 def update_rdict_annotations(self, s_eqfn, s_hashfn, other=None):
     assert self.custom_eq_hash
     s_eqfn = union(s_eqfn, self.s_rdict_eqfn)
     s_hashfn = union(s_hashfn, self.s_rdict_hashfn)
     self.s_rdict_eqfn = s_eqfn
     self.s_rdict_hashfn = s_hashfn
     self.emulate_rdict_calls(other=other)
Exemple #3
0
 def setbinding(self, arg, s_value):
     s_old = arg.annotation
     if s_old is not None:
         if not s_value.contains(s_old):
             log.WARNING("%s does not contain %s" % (s_value, s_old))
             log.WARNING("%s" % annmodel.union(s_value, s_old))
             assert False
     arg.annotation = s_value
Exemple #4
0
 def setbinding(self, arg, s_value):
     s_old = arg.annotation
     if s_old is not None:
         if not s_value.contains(s_old):
             log.WARNING("%s does not contain %s" % (s_value, s_old))
             log.WARNING("%s" % annmodel.union(s_value, s_old))
             assert False
     arg.annotation = s_value
Exemple #5
0
def builtin_max(*s_values):
    if len(s_values) == 1: # xxx do we support this?
        s_iter = s_values[0].iter()
        return s_iter.next()
    else:
        s = union(*s_values)
        if type(s) is SomeInteger and not s.nonneg:
            nonneg = False
            for s1 in s_values:
                nonneg |= s1.nonneg
            if nonneg:
                s = SomeInteger(nonneg=True, knowntype=s.knowntype)
        return s
Exemple #6
0
def builtin_max(*s_values):
    if len(s_values) == 1:  # xxx do we support this?
        s_iter = s_values[0].iter()
        return s_iter.next()
    else:
        s = union(*s_values)
        if type(s) is SomeInteger and not s.nonneg:
            nonneg = False
            for s1 in s_values:
                nonneg |= s1.nonneg
            if nonneg:
                s = SomeInteger(nonneg=True, knowntype=s.knowntype)
        return s
Exemple #7
0
 def union((s_inst, s_exc)):
     return union(s_exc.as_SomeInstance(), s_inst)
Exemple #8
0
def builtin_min(*s_values):
    if len(s_values) == 1: # xxx do we support this?
        s_iter = s_values[0].iter()
        return s_iter.next()
    else:
        return union(*s_values)
Exemple #9
0
 def union((s_inst, s_exc)):
     return union(s_exc.as_SomeInstance(), s_inst)
Exemple #10
0
def test_ll_union():
    PS1 = lltype.Ptr(lltype.GcStruct('s'))
    PS2 = lltype.Ptr(lltype.GcStruct('s'))
    PS3 = lltype.Ptr(lltype.GcStruct('s3'))
    PA1 = lltype.Ptr(lltype.GcArray())
    PA2 = lltype.Ptr(lltype.GcArray())

    assert union(SomePtr(PS1), SomePtr(PS1)) == SomePtr(PS1)
    assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS2)
    assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS1)

    assert union(SomePtr(PA1), SomePtr(PA1)) == SomePtr(PA1)
    assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA2)
    assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA1)

    assert union(SomePtr(PS1), SomeImpossibleValue()) == SomePtr(PS1)
    assert union(SomeImpossibleValue(), SomePtr(PS1)) == SomePtr(PS1)

    with py.test.raises(UnionError):
        union(SomePtr(PA1), SomePtr(PS1))
    with py.test.raises(UnionError):
        union(SomePtr(PS1), SomePtr(PS3))
    with py.test.raises(UnionError):
        union(SomePtr(PS1), SomeInteger())
    with py.test.raises(UnionError):
        union(SomeInteger(), SomePtr(PS1))
Exemple #11
0
def test_ll_union():
    PS1 = lltype.Ptr(lltype.GcStruct('s'))
    PS2 = lltype.Ptr(lltype.GcStruct('s'))
    PS3 = lltype.Ptr(lltype.GcStruct('s3'))
    PA1 = lltype.Ptr(lltype.GcArray())
    PA2 = lltype.Ptr(lltype.GcArray())

    assert union(SomePtr(PS1), SomePtr(PS1)) == SomePtr(PS1)
    assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS2)
    assert union(SomePtr(PS1), SomePtr(PS2)) == SomePtr(PS1)

    assert union(SomePtr(PA1), SomePtr(PA1)) == SomePtr(PA1)
    assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA2)
    assert union(SomePtr(PA1), SomePtr(PA2)) == SomePtr(PA1)

    assert union(SomePtr(PS1), SomeImpossibleValue()) == SomePtr(PS1)
    assert union(SomeImpossibleValue(), SomePtr(PS1)) == SomePtr(PS1)

    with py.test.raises(UnionError):
        union(SomePtr(PA1), SomePtr(PS1))
    with py.test.raises(UnionError):
        union(SomePtr(PS1), SomePtr(PS3))
    with py.test.raises(UnionError):
        union(SomePtr(PS1), SomeInteger())
    with py.test.raises(UnionError):
        union(SomeInteger(), SomePtr(PS1))
Exemple #12
0
def builtin_min(*s_values):
    if len(s_values) == 1:  # xxx do we support this?
        s_iter = s_values[0].iter()
        return s_iter.next()
    else:
        return union(*s_values)