[DDMD] [refactor] Move member functions in cast.c into free functions