-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-589] Plumbing for dynamic instantiation of generic types #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e60cde2
to
2c951d9
Compare
19417b8
to
2e51637
Compare
Thanks for the heads up @slavapestov, won’t be able to take a look until next week but I will do then. |
2e51637
to
aa4664f
Compare
Rebased and tests passing.
|
This extends <swiftlang@b5880f3> with the infrastructure necessary to dynamically instantiate generic types by name. In order to do so it extends GenericParameterDescriptor::Parameter with a list of ProtocolDescriptors containing associated type requirements. NB: no support for secondary archetypes yet. NB: this is "plumbing" as we have not defined a Swift API yet to lookup anything beyond a top-level non-generic class. The test suite uses private API taking a mangled type name in order to exercise this new code.
aa4664f
to
e6a154d
Compare
@swift-ci please test |
auto targetAddr = llvm::ConstantExpr::getPtrToInt(target.first, IGM.SizeTy); | ||
auto offset = llvm::ConstantInt::get(IGM.SizeTy, getNextOffset().getValue()); | ||
// This seems incredibly baroque, we should be creating an LLVM struct? | ||
// not sure how to define one with nested tail-emplaced values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would an anonymous LLVM struct type work?
Because there hasn't been action on this in quite some time, I'm going to close this pull request. @lhoward thank you for your work here. Please reopen this if you wish to continue it. |
With the new remote reflection stuff that went in, the correct way to implement this functionality is now to write a library function for constructing Metadata from a TypeRef. Then we can also use this to replace the field type vectors in IRGen. Unless @lhoward wants to take this on, I'll be working on it some time in the coming year. |
@slavapestov – I’ve not yet looked at the remote reflection stuff, but is this something the metadata lookup path for non-generic types (swift_getTypeByMangledName) should also be using? |
@lhoward Yes - the goal with the remote reflection stuff is to have one general mechanism for turning a mangled type string into a type. This should allow it to work for mangled function and tuple types, and so on, in full generality. |
Looks cool, I suspect you might get to it before I, but count me interested.
|
Clean up IRGen.cpp diff with upstream
This extends b5880f3 with the infrastructure necessary to dynamically instantiate generic types by name. In order to do so it extends GenericParameterDescriptor::Parameter with a list of ProtocolDescriptors for primary associated type requirements.
Some notes: