'Saturating add.'

@supports_vector
def _op_generic_QAdd(self, args):

    components = []
    for (a, b) in self.vector_args(args):
        top_a = a[(self._vector_size - 1)]
        top_b = b[(self._vector_size - 1)]
        res = (a + b)
        top_r = res[(self._vector_size - 1)]
        if self.is_signed:
            big_top_r = (~ top_r).zero_extend((self._vector_size - 1))
            cap = ((claripy.BVV((-1), self._vector_size) / 2) + big_top_r)
            cap_cond = (((~ (top_a ^ top_b)) & (top_a ^ top_r)) == 1)
        else:
            cap = claripy.BVV((-1), self._vector_size)
            cap_cond = claripy.ULT(res, a)
        components.append(claripy.If(cap_cond, cap, res))
    return claripy.Concat(*components)
