Refactor checking flow to allow for ordering based on import/package. (#3379)

As I was working on this, I noticed `import` and `library` syntax needs
to be fixed for how it imports the current package, and for `Main`
libraries. This mostly reflects the current state in its testing.

Otherwise, this should handle most of the errors I could think of:
dependency cycles, redundant imports, etc.

It does not actually deal with the nuances of cross-IR references.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Jon Ross-Perkins
2023-11-14 22:24:03 +00:00
committed by GitHub
co-authored by Richard Smith
parent 09b5ab14d8
commit d024403dc4
16 changed files with 797 additions and 66 deletions
+13
View File
@@ -300,6 +300,19 @@ class Context {
auto RecoverFromDeclError(StateStackEntry state, NodeKind parse_node_kind,
bool skip_past_likely_end) -> void;
// Sets the package directive information. Called at most once.
auto set_packaging_directive(Tree::PackagingNames packaging_names,
Tree::ApiOrImpl api_or_impl) -> void {
CARBON_CHECK(!tree_->packaging_directive_);
tree_->packaging_directive_ = {.names = packaging_names,
.api_or_impl = api_or_impl};
}
// Adds an import.
auto AddImport(Tree::PackagingNames package) -> void {
tree_->imports_.push_back(package);
}
// Prints information for a stack dump.
auto PrintForStackDump(llvm::raw_ostream& output) const -> void;