'Cast a value of type *fromty* to type *toty*.
This implements implicit conversions as can happen due to the
granularity of the Numba type system, or lax Python semantics.'

def cast(self, builder, val, fromty, toty):

    if ((fromty == toty) or (toty == types.Any)):
        return val
    try:
        impl = self._casts.find((fromty, toty))
        return impl(self, builder, fromty, toty, val)
    except NotImplementedError:
        raise NotImplementedError(('Cannot    cast    %s    to    %s:    %s' % (fromty, toty, val)))
