summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-preprocessor.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-06 01:03:42 -0800
committerGitHub <noreply@github.com>2024-02-06 01:03:42 -0800
commitb301c93753eaddb4571999f209cb8c1faa2fe205 (patch)
tree72fef2e499abecad0dda5ba2347e5890346ac173 /source/slang/slang-preprocessor.cpp
parent23c65b873f8002b74d60f61cacb3614da60e078d (diff)
Unify GLSL and HLSL buffer block parsing. (#3552)
* Unify GLSL and HLSL buffer block parsing. Automatic GLSL module recognition. * Fix.
Diffstat (limited to 'source/slang/slang-preprocessor.cpp')
-rw-r--r--source/slang/slang-preprocessor.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index 02f46103b..9586088a1 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -1015,6 +1015,9 @@ struct Preprocessor
/// Stores the initiating macro source location.
SourceLoc initiatingMacroSourceLoc;
+ /// Detected source language.
+ SourceLanguage language = SourceLanguage::Unknown;
+
/// Stores macro definition and invocation info for language server.
PreprocessorContentAssistInfo* contentAssistInfo = nullptr;
@@ -3655,6 +3658,7 @@ static void HandleVersionDirective(PreprocessorDirectiveContext* context)
}
SkipToEndOfLine(context);
+ context->m_preprocessor->language = SourceLanguage::GLSL;
// TODO, just skip the version for now
}
@@ -4022,6 +4026,7 @@ TokenList preprocessSource(
IncludeSystem* includeSystem,
Dictionary<String, String> const& defines,
Linkage* linkage,
+ SourceLanguage& outDetectedLanguage,
PreprocessorHandler* handler)
{
PreprocessorDesc desc;
@@ -4040,12 +4045,13 @@ TokenList preprocessSource(
{
desc.contentAssistInfo = &linkage->contentAssistInfo.preprocessorInfo;
}
- return preprocessSource(file, desc);
+ return preprocessSource(file, desc, outDetectedLanguage);
}
TokenList preprocessSource(
SourceFile* file,
- PreprocessorDesc const& desc)
+ PreprocessorDesc const& desc,
+ SourceLanguage &outDetectedLanguage)
{
using namespace preprocessor;
@@ -4132,6 +4138,8 @@ TokenList preprocessSource(
String s = sb.produceString();
#endif
+ outDetectedLanguage = preprocessor.language;
+
return tokens;
}