Module: vkd3d Branch: master Commit: 568983596e20b79aa3604404f36f3a0bc8a98edf URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=568983596e20b79aa3604404...
Author: Zebediah Figura zfigura@codeweavers.com Date: Thu Jan 7 11:48:08 2021 -0600
vkd3d-shader: Implement #ifndef.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
libs/vkd3d-shader/preproc.l | 4 ++++ libs/vkd3d-shader/preproc.y | 6 ++++++ tests/hlsl_d3d12.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 12a2e9d..8f54608 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -112,6 +112,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* return T_IF; if (!strcmp(p, "ifdef")) return T_IFDEF; + if (!strcmp(p, "ifndef")) + return T_IFNDEF;
preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE, "Ignoring unknown directive "%s".", yytext); @@ -202,6 +204,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner) case T_ENDIF: case T_IF: case T_IFDEF: + case T_IFNDEF: ctx->current_directive = token; break;
@@ -222,6 +225,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner) case T_ENDIF: case T_IF: case T_IFDEF: + case T_IFNDEF: break;
default: diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index c16f230..e1193fb 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -184,6 +184,7 @@ static uint32_t preproc_parse_integer(const char *s) %token T_ENDIF "#endif" %token T_IF "#if" %token T_IFDEF "#ifdef" +%token T_IFNDEF "#ifndef"
%type <integer> expr %type <string> body_token @@ -225,6 +226,11 @@ directive preproc_push_if(ctx, !!preproc_find_macro(ctx, $2)); vkd3d_free($2); } + | T_IFNDEF T_IDENTIFIER T_NEWLINE + { + preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); + vkd3d_free($2); + } | T_ELIF expr T_NEWLINE { if (ctx->if_count) diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 38c1ab2..8b8c302 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -349,7 +349,7 @@ static void test_preprocess(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i) { - if (i == 6) + if (i == 6 || i == 10 || i == 11) continue; vkd3d_test_set_context("Source "%s"", tests[i].source); todo_if (i <= 4 || (i >= 9 && i <= 14))