Files
carbon-lang/toolchain/check/handle_import_and_package.cpp
T
Jon Ross-PerkinsandRichard Smith d024403dc4 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>
2023-11-14 22:24:03 +00:00

53 lines
1.4 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/check/context.h"
namespace Carbon::Check {
// `import` and `package` are structured by parsing. As a consequence, no
// checking logic is needed here.
auto HandleImportIntroducer(Context& /*context*/, Parse::Node /*parse_node*/)
-> bool {
return true;
}
auto HandlePackageIntroducer(Context& /*context*/, Parse::Node /*parse_node*/)
-> bool {
return true;
}
auto HandleLibrary(Context& context, Parse::Node /*parse_node*/) -> bool {
// Pop and discard the library name from the node stack.
context.node_stack().Pop<Parse::NodeKind::Literal>();
return true;
}
auto HandlePackageApi(Context& /*context*/, Parse::Node /*parse_node*/)
-> bool {
return true;
}
auto HandlePackageImpl(Context& /*context*/, Parse::Node /*parse_node*/)
-> bool {
return true;
}
auto HandleImportDirective(Context& context, Parse::Node /*parse_node*/)
-> bool {
// Pop and discard the identifier from the node stack.
context.node_stack().Pop<Parse::NodeKind::Name>();
return true;
}
auto HandlePackageDirective(Context& context, Parse::Node /*parse_node*/)
-> bool {
// Pop and discard the identifier from the node stack.
context.node_stack().Pop<Parse::NodeKind::Name>();
return true;
}
} // namespace Carbon::Check