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

Add GenericInstance type to represent instances of generics. #4085

Merged
merged 10 commits into from
Jun 26, 2024

Conversation

zygoloid
Copy link
Contributor

Also add a corresponding value store and YAML output.

We don't create any generic instances in this change; this is just adding infrastructure for future changes.


// Context for hashing keys.
struct KeyContext {
llvm::ArrayRef<GenericInstance> instances;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be private? It doesn't seem like it's part of the public API, so it strikes me as odd to put it first. hashtable_key_context.h's example provides the interface as a class, so would similar work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a struct; given the limited scope I don't think it makes sense to add encapsulation here.

Copy link
Contributor Author

@zygoloid zygoloid Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said... looking at this again, I don't think this needs to be in the header file. Moved to the .cpp file. Maybe that provides the level of privateness you're looking for?

// entity, this contains the corresponding non-generic value. This includes
// values for the compile-time parameters themselves.
struct GenericInstance : Printable<GenericInstance> {
// Values corresponding to a region of a generic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a region of a generic? I don't see the term used in the design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'd incompletely removed this. Will be introduced in a future PR, gone for now :)

@zygoloid zygoloid requested a review from jonmeow June 26, 2024 22:17
@zygoloid zygoloid added this pull request to the merge queue Jun 26, 2024
Merged via the queue into carbon-language:trunk with commit a0d7672 Jun 26, 2024
7 checks passed
@zygoloid zygoloid deleted the toolchain-generic-2 branch June 26, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants