Skip to content
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

Initialize Enums and Tuple #91

Closed
wants to merge 2 commits into from

Conversation

PSchmiedmayer
Copy link

This PR adds the functionality to initialize enums and tuples using the createInstance function that is currently missing in the runtime framework as documented in #90 .

Testing

Adds unit tests to create enums and tuples

@PSchmiedmayer
Copy link
Author

PSchmiedmayer commented Jun 15, 2021

As documented in the description this PR aims to address #90 in creating enums and tuples.

I am currently struggling with creating single-payload enums as well as multi-payload enums. I have taken a look at https://github.com/apple/swift/blob/main/docs/ABI/TypeLayout.rst#fragile-enum-layout as a reference for the enum layout in the Swift runtime and have tried to understand the concept of https://github.com/apple/swift/blob/main/stdlib/public/runtime/Enum.cpp but am still struggling with the fact that I can currently not determine the spare bits of a type to create single-payload enums. In addition I would need to get detailed type information about an enum and the extra inhabitants of an enum type.

@wickwirew I would be grateful if you can point me in some direction if and how I would be able to find that information in the Swift Runtime and how you approached these problems before. I was in contact with @varungandhi-apple who was very helpful and friendly and who pointed me towards https://github.com/apple/swift/tree/main/tools/swift-inspect but I think that I am a bit over my head here and am not sure how to approach this with my current knowledge about the Swift runtime.

@EricRabil
Copy link

EricRabil commented Aug 30, 2021

Just whipped up a very rough POC based on your work, the framework itself, and a lot of staring at the IRGen of enums. https://github.com/ericrabil/enummagic Feel free to adapt this as you'd like, or if you give me push access to your fork I could help finalize yours.

@PSchmiedmayer
Copy link
Author

@EricRabil Very cool, great news!
I will take a look at your implementation in the next days. In addition I have also invited you as a collaborator on my fork at https://github.com/PSchmiedmayer/Runtime, it would be wonderful if you can incorporate insights into my draft and we can work together to finalize the Runtime PR! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants