Commit Graph

67 Commits

Author SHA1 Message Date
David Farler
88fde5050d SwiftRemoteMirror: Fix missing ReaderContext in creation API
swift_reflection_createReflectionContext was defaulting to C++ mangling
because the declaration under extern C in the header didn't match
its signature.
2016-04-27 12:53:39 -07:00
Slava Pestov
729428b4b1 Reflection: Type lowering for metatypes
The thin vs thick distinction is handled a little awkwardly. Instead of
passing around abstraction patterns, we add a "must be thick" bit to
MetatypeTypeRef, and thicken substitutions (to handle T; T := C.Type)
and the result of a subtitution (to handle T.Type; T := C).

With the exception of enums this completes <rdar://problem/25738849>.
2016-04-25 21:22:20 -07:00
Slava Pestov
996a859235 Reflection: Add basic type lowering for existentials
This approach doesn't work for imported Objective-C protocols yet.
2016-04-25 20:08:49 -07:00
David Farler
90f1523c4c Add opaque context pointer to SwiftRemoteMirror C API Reader API
Memory readers on the C-side of the API may actually have an object-
oriented design, so they may want to pass an instance to revive
when callbacks make it to the other side of the API boundary.
2016-04-25 00:00:27 -07:00
Slava Pestov
936d4e5e23 Reflection: Flesh out SwiftRemoteMirror C API
- Add swift_reflection_genericArgumentCountOfTypeRef()
- Flesh out swift_reflection_infoForTypeRef()
- Flesh out swift_reflection_infoForChild()
2016-04-24 23:36:31 -07:00
Slava Pestov
15d2149d78 Reflection: Should not depend on header file from SwiftRemoteMirror, NFC 2016-04-22 19:03:14 -07:00
David Farler
f5583c8295 Restore const-ness of TypeRefs
We got rid of the last mutating methods on TypeRefs, so let's
make these all const again.
2016-04-15 13:13:34 -07:00
Slava Pestov
824bd7544d IRGen: Emit typerefs for all builtin types referenced from reflection metadata sections
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.
2016-04-15 00:12:11 -07:00
John McCall
7ff15dd075 Progress towards marking ReflectionContext templated over the builder. 2016-04-14 13:39:35 -07:00
David Farler
cf97a12109 Tie lifetime of typerefs to the ReflectionContext
We will be handing pointers to typerefs over the SwiftRemoteMirrors C
API boundary, at which point it is unclear who will hold onto a shared
pointer. The useful lifetime of a typeref is tied to the
ReflectionContext for which they were created anyway so, when it goes
away, all of those typerefs can go away anyway.

We can't use LLVM's bump-pointer allocator here because we only build
the Support library for the host. As a compromise, stuff new typeref
pointers into a vector pool, where they will be taken down during
ReflectionContext's destructor.
2016-04-13 13:58:35 -07:00
David Farler
20f5304b90 Revised SwiftRemoteMirror C API
Some minor changes to the SwiftRemoteMirror C API, NFC yet.
2016-04-13 13:09:27 -07:00
John McCall
91f02848df Organize the MemoryReader interface headers to better support
multiple clients.
2016-04-12 16:05:29 -07:00
David Farler
0b04b90895 SwiftRemoteMirrors: Stub implementations for infoFor{TypeRef,Field}
These are just some dummy implementations to temporarily appease
the linker.
2016-04-11 20:03:45 -07:00
David Farler
67943c437b SwiftRemoteMirrors: Implementationsfor typeRefForMetadata/genericArgumentOfTypeRef
Implement the C wrappers for the corresponding C++ methods in
ReflectionContext.
2016-04-11 19:42:47 -07:00
David Farler
ec4f1fd22b Use external but native runtime target template for SwiftRemoteMirror
Although the SwiftRemoteMirror library targets a specific architecture,
it's still an external runtime, so treat it as such. The InProcess template
argument is reserved for truly in-process reflection in the Runtime.
2016-04-11 19:41:23 -07:00
David Farler
9863e49968 Add SwiftRemoteMirror implementation for addReflectionInfo 2016-04-11 19:11:38 -07:00
David Farler
358a0fefe8 Add SwiftRemoteMirror library
This will wrap the ./lib/Reflection functionality in a C
interface.
2016-04-05 13:45:46 -07:00