Given a constant value constant, a type ty, a state index, and a vector of subfield
indices, serialize the constant into a vector of storage slots. The keys (slots) are
generated using the state index and the subfield indices which are recursively built. The
values are generated such that each subfield gets its own storage slot except for enums and
strings which are spread over successive storage slots (use serialize_to_words in this case).