mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add export keyword handling. (#3944)
This provides `export import` logic in lex, parse, and check; `export name` logic is only in lex and parse, not check. I think with `export name` I'm going to need to modify import_ref and some consolidation logic, whereas `export import` seems feasible to keep as primarily import logic. Given the implementations were looking like they'd diverge more substantially, I thought it'd be helpful to cut the PR here.
This commit is contained in:
@@ -213,9 +213,11 @@ static auto CopyEnclosingNameScopesFromImportIR(
|
||||
auto ImportLibraryFromCurrentPackage(Context& context,
|
||||
SemIR::TypeId namespace_type_id,
|
||||
Parse::ImportDirectiveId node_id,
|
||||
const SemIR::File& import_sem_ir) -> void {
|
||||
auto ir_id =
|
||||
AddImportIR(context, {.node_id = node_id, .sem_ir = &import_sem_ir});
|
||||
const SemIR::File& import_sem_ir,
|
||||
bool is_export) -> void {
|
||||
auto ir_id = AddImportIR(
|
||||
context,
|
||||
{.node_id = node_id, .sem_ir = &import_sem_ir, .is_export = is_export});
|
||||
|
||||
context.import_ir_constant_values()[ir_id.index].Set(
|
||||
SemIR::InstId::PackageNamespace,
|
||||
@@ -257,6 +259,12 @@ auto ImportLibraryFromCurrentPackage(Context& context,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If an import of the current package caused an error for the imported
|
||||
// file, it transitively affects the current file too.
|
||||
if (import_sem_ir.name_scopes().Get(SemIR::NameScopeId::Package).has_error) {
|
||||
context.name_scopes().Get(SemIR::NameScopeId::Package).has_error = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto ImportLibrariesFromOtherPackage(Context& context,
|
||||
|
||||
Reference in New Issue
Block a user