For now, just enough for lowering.
Perhaps we should have a way to always just get this information
from metadata instead, since protocol metadata is always static
and not instantiated.
This would require the static "object file" interface used by
swift-reflection-dump to take a callback for symbol lookup.
For convenience when reading looking at heap closure metadata.
Also move the capture typerefs above the metadata sources, since
they're more likely to be accessed than generic metadata sources.
In order to perform layout, the remote mirrors library needs to know
about the size, alignment and extra inhabitants of builtin types.
Ideally we would emit a reflection info section in libswiftRuntime.o,
but in the meantime just duplicate builtin type metadata for all
builtin types referenced from the current module instead.
In practice only the stdlib and a handful of overlays like the SIMD
overlay use builtin types, and only a few at a time.
Tested manually by running swift-reflection-tool on the standard
library -- I'll add automated tests by using -parse-stdlib to
reference Builtin types in a subsequent patch that adds more layout
logic.
NFC if -enable-reflection-metadata is off.
Once an unsubstituted typeref for a field is built, we substitute
`GenericTypeParameterTypeRef`s with concrete ones built from the generic
arguments of concrete bound generic metadata.
During that process, if we run into a `DependentMemberTypeRef` (e.g.
something of type T.Index), we substitute the base (T) using the current
list of substitutions, and then resolve what `Index` is for the base
using the associated type metadata in the 'assocty' data section.
These likely don't have Swift type metadata but might be useful to
record or instantiate based on what kind of metadata is encountered for
the sake of memory tools.