New code to probe the physical conditions of the Sun and the stars using spectral line polarization