Record whether a file contains a main entry point in the serialized module.

This isn't being used for much yet, but it will allow us to tell whether
something is an app target even at the module-merging stage, which is a
better way to tell if something is an app than whether it has a bridging
header.

We'll also need this if we ever take advantage of reusing "partial modules"
(serialized ASTs for other parts of the module that aren't affected by the
current source file) for compiling source files in incremental builds;
unfortunately that's unlikely given our dependency model.

Swift SVN r24531
This commit is contained in:
Jordan Rose
2015-01-19 23:08:57 +00:00
parent 3e61956a81
commit 6de91151e2
10 changed files with 105 additions and 14 deletions

View File

@@ -338,6 +338,7 @@ void Serializer::writeBlockInfoBlock() {
BLOCK_RECORD(index_block, CLASS_MEMBERS);
BLOCK_RECORD(index_block, OPERATOR_METHODS);
BLOCK_RECORD(index_block, OBJC_METHODS);
BLOCK_RECORD(index_block, ENTRY_POINT);
BLOCK(SIL_BLOCK);
BLOCK_RECORD(sil_block, SIL_FUNCTION);
@@ -3078,8 +3079,13 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
DeclTable topLevelDecls, extensionDecls, operatorDecls, operatorMethodDecls;
ObjCMethodTable objcMethods;
Optional<DeclID> entryPointClassID;
ArrayRef<const FileUnit *> files = SF ? SF : M->getFiles();
for (auto nextFile : files) {
if (nextFile->hasEntryPoint())
entryPointClassID = addDeclRef(nextFile->getMainClass());
// FIXME: Switch to a visitor interface?
SmallVector<Decl *, 32> fileDecls;
nextFile->getTopLevelDecls(fileDecls);
@@ -3140,6 +3146,11 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
index_block::ObjCMethodTableLayout ObjCMethodTable(Out);
writeObjCMethodTable(ObjCMethodTable, objcMethods);
if (entryPointClassID.hasValue()) {
index_block::EntryPointLayout EntryPoint(Out);
EntryPoint.emit(ScratchRecord, entryPointClassID.getValue());
}
}
}