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.cpp60
1 files changed, 47 insertions, 13 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 9379f3b03..7602096d4 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -509,6 +509,8 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::createSession(
targetDescPtr += targetDesc.structureSize;
}
+ linkage->setFlags(desc.flags);
+
if(desc.flags & slang::kSessionFlag_FalcorCustomSharedKeywordSemantics)
{
linkage->m_useFalcorCustomSharedKeywordSemantics = true;
@@ -529,6 +531,10 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::createSession(
linkage->addPreprocessorDefine(macro.name, macro.value);
}
+ if (desc.fileSystem)
+ {
+ linkage->setFileSystem(desc.fileSystem);
+ }
*outSession = asExternal(linkage.detach());
return SLANG_OK;
}
@@ -926,6 +932,12 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModule(
slang::IBlob** outDiagnostics)
{
DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer);
+
+ if (m_flag & slang::kSessionFlag_LanguageServer)
+ {
+ sink.setFlags(DiagnosticSink::Flag::HumaneLoc | DiagnosticSink::Flag::LanguageServer);
+ }
+
try
{
auto name = getNamePool()->getName(moduleName);
@@ -945,9 +957,16 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModule(
SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModuleFromSource(
const char* moduleName,
+ const char* path,
slang::IBlob* source,
slang::IBlob** outDiagnostics)
{
+ DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer);
+ if (m_flag & slang::kSessionFlag_LanguageServer)
+ {
+ sink.setFlags(DiagnosticSink::Flag::HumaneLoc | DiagnosticSink::Flag::LanguageServer);
+ }
+
try
{
auto name = getNamePool()->getName(moduleName);
@@ -956,10 +975,9 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModuleFromSource(
{
return loadedModule;
}
- DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer);
auto module = loadModule(
name,
- PathInfo::makeFromString(moduleName),
+ PathInfo::makeFromString(path),
source,
SourceLoc(),
&sink,
@@ -970,6 +988,7 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModuleFromSource(
}
catch (const AbortCompilationException&)
{
+ sink.getBlobIfNeeded(outDiagnostics);
return nullptr;
}
}
@@ -2567,17 +2586,29 @@ void Linkage::loadParsedModule(
int errorCountBefore = sink->getErrorCount();
compileRequest->checkAllTranslationUnits();
int errorCountAfter = sink->getErrorCount();
-
- if (errorCountAfter != errorCountBefore)
+ if (isInLanguageServer())
{
- // There must have been an error in the loaded module.
+ // Don't generate IR as language server.
+ // This means that we currently cannot report errors that are detected during IR passes.
+ // Ideally we want to run those passes, but that is too risky for what it is worth right
+ // now.
}
else
{
- // If we didn't run into any errors, then try to generate
- // IR code for the imported module.
- SLANG_ASSERT(errorCountAfter == 0);
- loadedModule->setIRModule(generateIRForTranslationUnit(getASTBuilder(), translationUnit));
+ if (errorCountAfter != errorCountBefore)
+ {
+ // There must have been an error in the loaded module.
+ }
+ else
+ {
+ // If we didn't run into any errors, then try to generate
+ // IR code for the imported module.
+ if (errorCountAfter == 0)
+ {
+ loadedModule->setIRModule(
+ generateIRForTranslationUnit(getASTBuilder(), translationUnit));
+ }
+ }
}
loadedModulesList.add(loadedModule);
}
@@ -2602,7 +2633,10 @@ void Linkage::_diagnoseErrorInImportedModule(
{
sink->diagnose(info->importLoc, Diagnostics::errorInImportedModule, info->name);
}
- sink->diagnose(SourceLoc(), Diagnostics::complationCeased);
+ if ((m_flag & slang::kSessionFlag_LanguageServer) == 0)
+ {
+ sink->diagnose(SourceLoc(), Diagnostics::complationCeased);
+ }
}
RefPtr<Module> Linkage::loadModule(
@@ -2641,11 +2675,11 @@ RefPtr<Module> Linkage::loadModule(
frontEndReq->parseTranslationUnit(translationUnit);
int errorCountAfter = sink->getErrorCount();
- if( errorCountAfter != errorCountBefore )
+ if (errorCountAfter != errorCountBefore && !isInLanguageServer())
{
_diagnoseErrorInImportedModule(sink);
}
- if (errorCountAfter)
+ if (errorCountAfter && !isInLanguageServer())
{
// Something went wrong during the parsing, so we should bail out.
return nullptr;
@@ -2659,7 +2693,7 @@ RefPtr<Module> Linkage::loadModule(
errorCountAfter = sink->getErrorCount();
- if (errorCountAfter != errorCountBefore)
+ if (errorCountAfter != errorCountBefore && !isInLanguageServer())
{
_diagnoseErrorInImportedModule(sink);
// Something went wrong during the parsing, so we should bail out.