Ejemplo n.º 1
0
    def mkmasks(self, slices, base=None):
        #       print "mkmasks(%r, %r)"%(slices, base)
        my_bl = packer.slices_to_bitlist(self.__packer.slices())
        de_bl = packer.slices_to_bitlist(slices)
        assert set(de_bl) <= set(my_bl), ValueError(de_bl, my_bl)
        poss = [""]
        mask = ""
        if base == None:
            base = "X" * len(my_bl)
        for n, b in enumerate(my_bl):
            if b in de_bl:
                poss = map(lambda x:x+"0", poss) \
                       + map(lambda x:x+"1", poss)
                mask = "%s" + mask
            else:
                mask = base[-1 - n] + mask
        if len(poss) > 1:
            masks = []
            for x in poss:
                m = mask % tuple(list(x))
                masks.append(m)


#               print "  ", m
        else:
            masks = [mask]
        return sorted(masks)
Ejemplo n.º 2
0
    def mkmasks(self, slices, base = None):
#       print "mkmasks(%r, %r)"%(slices, base)
        my_bl = packer.slices_to_bitlist(self.__packer.slices())
        de_bl = packer.slices_to_bitlist(slices)
        assert set(de_bl) <= set(my_bl), ValueError(de_bl, my_bl)
        poss = [""]
        mask = ""
        if base == None:
            base = "X"*len(my_bl)
        for n, b in enumerate(my_bl):
            if b in de_bl:
                poss = map(lambda x:x+"0", poss) \
                       + map(lambda x:x+"1", poss)
                mask = "%s"+mask
            else:
                mask = base[-1-n]+mask
        if len(poss) > 1:
            masks = []
            for x in poss:
                m = mask%tuple(list(x))
                masks.append(m)
#               print "  ", m
        else:
            masks = [mask]
        return sorted(masks)
Ejemplo n.º 3
0
def get_useless_bits(slices, values):
    useful_bits = list(sorted(packer.slices_to_bitlist(slices)))
    useless_bits = []

    for n, bit in enumerate(useful_bits):
        idem = True
        for i in range(1 << len(useful_bits)):
            idem &= (values[i | (1 << n)] == values[i & ~(1 << n)])
        if idem:
            useless_bits.append((n, bit))
    return useless_bits
Ejemplo n.º 4
0
def get_useless_bits(slices, values):
    useful_bits = list(sorted(packer.slices_to_bitlist(slices)))
    useless_bits = []

    for n, bit in enumerate(useful_bits):
        idem = True
        for i in range(1<<len(useful_bits)):
            idem &= ( values[i | (1<<n)] == values[i & ~(1<<n)] )
        if idem:
            useless_bits.append((n,bit))
    return useless_bits