dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.36k stars 188 forks source link

Add basic support for frozen structs projections #2560

Closed kotlarmilos closed 1 month ago

kotlarmilos commented 2 months ago

Description

This PR implements basic support for frozen structs. It refactors the tooling, including the type database and declarations, to manage recursive dependencies. It introduces Swift metadata projections and type registrar system for mapping between Swift and C#. Additionally, it updates the parser and emitter to interact with the type database and registrar, and implement basic type filtering. Tests are added for non-generic nested frozen structs with primitive properties.

kotlarmilos commented 1 month ago

I've converted this PR to draft as we plan to have additional iterations before another review. @stephen-hawley thank you for your contribution. Here are some thoughts:

Let's integrate your changes and add comments, documentation, and more test cases.

kotlarmilos commented 1 month ago

I strongly recommend that you take TypeSpecParser, TypeSpecTokenizer, TypeSpecToken, and `TypeSpec (and its subclasses). This represents a very compact recursive descent parser than can handle whatever the swift compiler can generate.

Let's add them in a follow-up PR as this one is already ~+5k loc. What is the difference between TypeDecl and TypeSpec?

kotlarmilos commented 1 month ago

Merging this PR. Any additional feedback will be addressed in follow-up work.