[AST] Remove ModuleDecl::addFile

Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
This commit is contained in:
Hamish Knight
2024-11-17 14:17:20 +00:00
parent 309c02410b
commit 4946c799af
25 changed files with 252 additions and 183 deletions

View File

@@ -94,7 +94,7 @@ struct LibParseExecutor {
if (!opts.contains(ExecuteOptionFlag::SkipBodies))
parseOpts |= SourceFile::ParsingFlags::DisableDelayedBodies;
ModuleDecl *M = ModuleDecl::create(Identifier(), *ctx);
ModuleDecl *M = ModuleDecl::createEmpty(Identifier(), *ctx);
SourceFile *SF =
new (*ctx) SourceFile(*M, SourceFileKind::Library, bufferID, parseOpts);
@@ -170,7 +170,7 @@ struct ASTGenExecutor {
if (!opts.contains(ExecuteOptionFlag::SkipBodies))
parseOpts |= SourceFile::ParsingFlags::DisableDelayedBodies;
ModuleDecl *M = ModuleDecl::create(Identifier(), *ctx);
ModuleDecl *M = ModuleDecl::createEmpty(Identifier(), *ctx);
SourceFile *SF =
new (*ctx) SourceFile(*M, SourceFileKind::Library, bufferID, parseOpts);