More enhanced constant folding of format()

Instead of a small number of specific cased ("%s", "%s%d", etc.), now
we loop over the arguments, back to front, peeling each one off and
formatting it into the format string itself, until there are no more
constant-valued arguments at the end. If we've exhaused all arguments by
the time we're done, the format goes away entirely and we just have a
string assignment.

To illustrate,
    format ("%s %g (%g)", "blah", 42.0, point(1,2,3))
turns into the constant string "blah 42 (1 2 3)", and
    format ("%s %g (%g)", "blah", u, point(1,2,3))
would at least simplify to
    format ("%s %g (1 2 3)", "blah", u)

Most of the interesting cases are the first category (complete formatting),
but at least in the partial-formatting case it's a little bit simpler.