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:
Jon Ross-Perkins
2024-05-10 22:54:06 +00:00
committed by GitHub
parent c7e4cb2c76
commit a16842ab37
21 changed files with 1823 additions and 81 deletions
+7 -2
View File
@@ -44,6 +44,10 @@ auto AddImportIR(Context& context, SemIR::ImportIR import_ir)
if (!ir_id.is_valid()) {
// Note this updates check_ir_map.
ir_id = InternalAddImportIR(context, import_ir);
} else if (import_ir.is_export) {
// We're processing an `export import`. In case the IR was indirectly added
// as a non-export, mark it as an export.
context.import_irs().Get(ir_id).is_export = true;
}
return ir_id;
}
@@ -246,8 +250,9 @@ class ImportRefResolver {
cursor_ir_id = context_.check_ir_map()[cursor_ir->check_ir_id().index];
if (!cursor_ir_id.is_valid()) {
// TODO: Should we figure out a location to assign here?
cursor_ir_id = AddImportIR(
context_, {.node_id = Parse::NodeId::Invalid, .sem_ir = cursor_ir});
cursor_ir_id = AddImportIR(context_, {.node_id = Parse::NodeId::Invalid,
.sem_ir = cursor_ir,
.is_export = false});
}
cursor_inst_id = ir_inst.inst_id;