summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-preprocessor.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-21 21:10:48 -0700
committerGitHub <noreply@github.com>2024-03-21 21:10:48 -0700
commit00474731a90add7c0aaffc3a76d713ae2cecdbbe (patch)
treea99e6cd38901de6394c973992fc5ef6b600e3f2b /source/slang/slang-preprocessor.cpp
parent7a8ef896196ad0d7095412d8558dd9a2542874c8 (diff)
Partially implement vk_buffer_ref proposal. (#3814)
Diffstat (limited to 'source/slang/slang-preprocessor.cpp')
-rw-r--r--source/slang/slang-preprocessor.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index b0986f64c..702259381 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -2570,7 +2570,40 @@ static PreprocessorExpressionValue ParseAndEvaluateUnaryExpression(PreprocessorD
return LookupMacro(context, name) != NULL;
}
+ else if (token.getContent() == "__has_feature")
+ {
+ // handle `defined(someName)`
+
+ // Possibly parse a `(`
+ Token leftParen;
+ if (PeekRawTokenType(context) == TokenType::LParent)
+ {
+ leftParen = AdvanceRawToken(context);
+ }
+ // Expect an identifier
+ Token nameToken;
+ if (!ExpectRaw(context, TokenType::Identifier, Diagnostics::expectedTokenInDefinedExpression, &nameToken))
+ {
+ return 0;
+ }
+
+ // If we saw an opening `(`, then expect one to close
+ if (leftParen.type != TokenType::Unknown)
+ {
+ if (!ExpectRaw(context, TokenType::RParent, Diagnostics::expectedTokenInDefinedExpression))
+ {
+ GetSink(context)->diagnose(leftParen.loc, Diagnostics::seeOpeningToken, leftParen);
+ return 0;
+ }
+ }
+
+ if (nameToken.getContent() == "hlsl_vk_buffer_pointer")
+ {
+ return 1;
+ }
+ return 0;
+ }
// An identifier here means it was not defined as a macro (or
// it is defined, but as a function-like macro. These should
// just evaluate to zero (possibly with a warning)