[DDMD] [refactor] Move Expression::toDelegate into a free function