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

Split deferred node traversal out from check.cpp #4559

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Nov 20, 2024

I'm looking at adding more significant logic to checking, particularly for interop. But check.cpp is getting large, and I think just adding more logic will make it harder to reason about, so I'm looking at splitting it up. This moves out NodeIdTraversal and DeferredDefinitionWorklist because they're already independent from the other code, and are reasonably sized to have their own files.

Context& context, Parse::DeferredDefinitionIndex index,
Parse::FunctionDefinitionStartId node_id) -> void {
worklist_.push_back(CheckSkippedDefinition{
index, HandleFunctionDefinitionSuspend(context, node_id)});
Copy link
Contributor

Choose a reason for hiding this comment

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

This call to HandleFunctionDefinitionSuspend is really breaking the abstraction that these two factored out classes are trying to provide -- this isn't a reusable traversal because it also has this weird side-effect of calling a Handle function.

Please can you add a TODO to move this call out of the worklist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +105 to +117
// When we reach the start of a deferred definition scope, add a task to the
// worklist to check future skipped definitions in the new context.
if (IsStartOfDeferredDefinitionScope(parse_kind)) {
worklist_.PushEnterDeferredDefinitionScope(context_);
}

// When we reach the end of a deferred definition scope, add a task to the
// worklist to leave the scope. If this is not a nested scope, start
// checking the deferred definitions now.
if (IsEndOfDeferredDefinitionScope(parse_kind)) {
chunks_.back().checking_deferred_definitions =
worklist_.SuspendFinishedScopeAndPush(context_);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These calls make me sad for the same reason as the one in the worklist. Can you add a TODO for these also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jonmeow jonmeow added this pull request to the merge queue Nov 20, 2024
Merged via the queue into carbon-language:trunk with commit 16bf3f7 Nov 20, 2024
8 checks passed
@jonmeow jonmeow deleted the split-check branch November 20, 2024 21:17
bricknerb pushed a commit to bricknerb/carbon-lang that referenced this pull request Nov 28, 2024
I'm looking at adding more significant logic to checking, particularly
for interop. But check.cpp is getting large, and I think just adding
more logic will make it harder to reason about, so I'm looking at
splitting it up. This moves out NodeIdTraversal and
DeferredDefinitionWorklist because they're already independent from the
other code, and are reasonably sized to have their own files.
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