mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -355,6 +355,7 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
|
||||
case llvm::BitstreamEntry::Record:
|
||||
scratch.clear();
|
||||
blobData = {};
|
||||
unsigned kind = cursor.readRecord(next.ID, scratch, &blobData);
|
||||
|
||||
switch (kind) {
|
||||
@@ -388,6 +389,10 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
case index_block::OBJC_METHODS:
|
||||
ObjCMethods = readObjCMethodTable(scratch, blobData);
|
||||
break;
|
||||
case index_block::ENTRY_POINT:
|
||||
assert(blobData.empty());
|
||||
setEntryPointClassID(scratch.front());
|
||||
break;
|
||||
default:
|
||||
// Unknown index kind, which this version of the compiler won't use.
|
||||
break;
|
||||
@@ -940,6 +945,12 @@ ModuleStatus ModuleFile::associateWithFileContext(FileUnit *file,
|
||||
if (Bits.HasUnderlyingModule)
|
||||
(void)getModule(FileContext->getParentModule()->Name);
|
||||
|
||||
if (Bits.HasEntryPoint) {
|
||||
FileContext->getParentModule()->registerEntryPointFile(FileContext,
|
||||
SourceLoc(),
|
||||
None);
|
||||
}
|
||||
|
||||
return getStatus();
|
||||
}
|
||||
|
||||
@@ -1340,3 +1351,12 @@ void ModuleFile::verify() const {
|
||||
swift::verify(next);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SerializedASTFile::hasEntryPoint() const {
|
||||
return File.Bits.HasEntryPoint;
|
||||
}
|
||||
|
||||
ClassDecl *SerializedASTFile::getMainClass() const {
|
||||
assert(hasEntryPoint());
|
||||
return cast_or_null<ClassDecl>(File.getDecl(File.Bits.EntryPointDeclID));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user