本文整理汇总了C++中ModuleDecl::getMainSourceFile方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleDecl::getMainSourceFile方法的具体用法?C++ ModuleDecl::getMainSourceFile怎么用?C++ ModuleDecl::getMainSourceFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleDecl
的用法示例。
在下文中一共展示了ModuleDecl::getMainSourceFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performParseOnly
void CompilerInstance::performParseOnly(bool EvaluateConditionals) {
const InputFileKind Kind = Invocation.getInputKind();
ModuleDecl *MainModule = getMainModule();
Context->LoadedModules[MainModule->getName()] = MainModule;
bool KeepTokens = Invocation.getLangOptions().KeepTokensInSourceFile;
assert((Kind == InputFileKind::IFK_Swift ||
Kind == InputFileKind::IFK_Swift_Library) &&
"only supports parsing .swift files");
(void)Kind;
auto implicitModuleImportKind = SourceFile::ImplicitModuleImportKind::None;
// Make sure the main file is the first file in the module but parse it last,
// to match the parsing logic used when performing Sema.
if (MainBufferID != NO_SUCH_BUFFER) {
assert(Kind == InputFileKind::IFK_Swift);
SourceMgr.setHashbangBufferID(MainBufferID);
auto *MainFile = new (*Context)
SourceFile(*MainModule, Invocation.getSourceFileKind(), MainBufferID,
implicitModuleImportKind, KeepTokens);
MainModule->addFile(*MainFile);
if (MainBufferID == PrimaryBufferID)
setPrimarySourceFile(MainFile);
}
PersistentParserState PersistentState;
PersistentState.PerformConditionEvaluation = EvaluateConditionals;
// Parse all the library files.
for (auto BufferID : InputSourceCodeBufferIDs) {
if (BufferID == MainBufferID)
continue;
auto *NextInput = new (*Context)
SourceFile(*MainModule, SourceFileKind::Library, BufferID,
implicitModuleImportKind, KeepTokens);
MainModule->addFile(*NextInput);
if (BufferID == PrimaryBufferID)
setPrimarySourceFile(NextInput);
bool Done;
do {
// Parser may stop at some erroneous constructions like #else, #endif
// or '}' in some cases, continue parsing until we are done
parseIntoSourceFile(*NextInput, BufferID, &Done, nullptr,
&PersistentState, nullptr);
} while (!Done);
}
// Now parse the main file.
if (MainBufferID != NO_SUCH_BUFFER) {
SourceFile &MainFile =
MainModule->getMainSourceFile(Invocation.getSourceFileKind());
bool Done;
do {
parseIntoSourceFile(MainFile, MainFile.getBufferID().getValue(), &Done,
nullptr, &PersistentState, nullptr);
} while (!Done);
}
assert(Context->LoadedModules.size() == 1 &&
"Loaded a module during parse-only");
}