summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index c316974f1..ec90ee418 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -410,6 +410,11 @@ const char* getBuiltinModuleNameStr(slang::BuiltinModuleName name)
return result;
}
+TypeCheckingCache* Session::getTypeCheckingCache()
+{
+ return static_cast<TypeCheckingCache*>(m_typeCheckingCache.get());
+}
+
Session::BuiltinModuleInfo Session::getBuiltinModuleInfo(slang::BuiltinModuleName name)
{
Session::BuiltinModuleInfo result;
@@ -700,6 +705,7 @@ SlangResult Session::_readBuiltinModule(
module->setModuleDecl(moduleDecl);
}
+ srcModule.irModule->setName(module->getNameObj());
module->setIRModule(srcModule.irModule);
// Put in the loaded module map
@@ -803,6 +809,10 @@ Session::createSession(slang::SessionDesc const& inDesc, slang::ISession** outSe
RefPtr<Linkage> linkage = new Linkage(this, astBuilder, getBuiltinLinkage());
+ if (m_typeCheckingCache)
+ linkage->m_typeCheckingCache =
+ new TypeCheckingCache(*static_cast<TypeCheckingCache*>(m_typeCheckingCache.get()));
+
linkage->setMatrixLayoutMode(desc.defaultMatrixLayoutMode);
Int searchPathCount = desc.searchPathCount;
@@ -1263,9 +1273,6 @@ Linkage::Linkage(Session* session, ASTBuilder* astBuilder, Linkage* builtinLinka
, m_astBuilder(astBuilder)
, m_cmdLineContext(new CommandLineContext())
{
- if (builtinLinkage)
- m_astBuilder->m_cachedNodes = builtinLinkage->getASTBuilder()->m_cachedNodes;
-
getNamePool()->setRootNamePool(session->getRootNamePool());
m_defaultSourceManager.initialize(session->getBuiltinSourceManager(), nullptr);
@@ -1297,6 +1304,17 @@ ISlangUnknown* Linkage::getInterface(const Guid& guid)
Linkage::~Linkage()
{
+ // Upstream type checking cache.
+ if (m_typeCheckingCache)
+ {
+ auto globalSession = getSessionImpl();
+ if (!globalSession->m_typeCheckingCache ||
+ globalSession->getTypeCheckingCache()->resolvedOperatorOverloadCache.getCount() <
+ getTypeCheckingCache()->resolvedOperatorOverloadCache.getCount())
+ {
+ globalSession->m_typeCheckingCache = m_typeCheckingCache;
+ }
+ }
destroyTypeCheckingCache();
}
@@ -1318,12 +1336,11 @@ TypeCheckingCache* Linkage::getTypeCheckingCache()
{
m_typeCheckingCache = new TypeCheckingCache();
}
- return m_typeCheckingCache;
+ return static_cast<TypeCheckingCache*>(m_typeCheckingCache.get());
}
void Linkage::destroyTypeCheckingCache()
{
- delete m_typeCheckingCache;
m_typeCheckingCache = nullptr;
}
@@ -4080,6 +4097,8 @@ RefPtr<Module> Linkage::loadModuleFromIRBlobImpl(
loadedModulesList.add(resultModule);
resultModule->setPathInfo(filePathInfo);
+ resultModule->getIRModule()->setName(resultModule->getNameObj());
+
return resultModule;
}