From b301c93753eaddb4571999f209cb8c1faa2fe205 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 6 Feb 2024 01:03:42 -0800 Subject: Unify GLSL and HLSL buffer block parsing. (#3552) * Unify GLSL and HLSL buffer block parsing. Automatic GLSL module recognition. * Fix. --- source/slang/slang-preprocessor.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-preprocessor.cpp') 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 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; } -- cgit v1.2.3