diff options
Diffstat (limited to 'source/slang/slang-module-library.cpp')
| -rw-r--r-- | source/slang/slang-module-library.cpp | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp index 060c9007c..c03d5c2dd 100644 --- a/source/slang/slang-module-library.cpp +++ b/source/slang/slang-module-library.cpp @@ -45,6 +45,8 @@ SlangResult loadModuleLibrary( EndToEndCompileRequest* req, ComPtr<IModuleLibrary>& outLibrary) { + SLANG_UNUSED(path); + auto library = new ModuleLibrary; ComPtr<IModuleLibrary> scopeLibrary(library); @@ -55,54 +57,28 @@ SlangResult loadModuleLibrary( SLANG_RETURN_ON_FAIL(RiffUtil::read(&memoryStream, riffContainer)); auto linkage = req->getLinkage(); + auto sink = req->getSink(); + auto namePool = req->getNamePool(); + + auto container = ContainerChunkRef::find(&riffContainer); + + for (auto moduleChunk : container.getModules()) + { + auto loadedModule = linkage->findOrLoadSerializedModuleForModuleLibrary(moduleChunk, sink); + if (!loadedModule) + return SLANG_FAIL; + + library->m_modules.add(loadedModule); + } + + for (auto entryPointChunk : container.getEntryPoints()) { - SerialContainerData containerData; - - SerialContainerUtil::ReadOptions options; - options.namePool = req->getNamePool(); - options.session = req->getSession(); - options.sharedASTBuilder = linkage->getASTBuilder()->getSharedASTBuilder(); - options.sourceManager = linkage->getSourceManager(); - options.linkage = req->getLinkage(); - options.sink = req->getSink(); - options.astBuilder = linkage->getASTBuilder(); - options.modulePath = path; - SLANG_RETURN_ON_FAIL( - SerialContainerUtil::read(&riffContainer, options, nullptr, containerData)); - DiagnosticSink sink; - - // Modules in the container should be serialized in its depedency order, - // so that we always load the dependencies before the consuming module. - for (auto& module : containerData.modules) - { - // If the irModule is set, add it - if (module.irModule) - { - if (module.dependentFiles.getCount() == 0) - return SLANG_FAIL; - if (!module.astRootNode) - return SLANG_FAIL; - auto loadedModule = linkage->loadDeserializedModule( - as<ModuleDecl>(module.astRootNode)->getName(), - PathInfo::makePath(module.dependentFiles.getFirst()), - module, - &sink); - if (!loadedModule) - return SLANG_FAIL; - library->m_modules.add(loadedModule); - } - } - - for (const auto& entryPoint : containerData.entryPoints) - { - FrontEndCompileRequest::ExtraEntryPointInfo dst; - dst.mangledName = entryPoint.mangledName; - dst.name = entryPoint.name; - dst.profile = entryPoint.profile; - - // Add entry point - library->m_entryPoints.add(dst); - } + FrontEndCompileRequest::ExtraEntryPointInfo entryPointInfo; + entryPointInfo.mangledName = entryPointChunk.getMangledName(); + entryPointInfo.name = namePool->getName(entryPointChunk.getName()); + entryPointInfo.profile = entryPointChunk.getProfile(); + + library->m_entryPoints.add(entryPointInfo); } outLibrary.swap(scopeLibrary); |
