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>
This commit is contained in:
Zebediah Figura 2021-01-07 11:48:08 -06:00 committed by Alexandre Julliard
parent b0dbb35ec7
commit 568983596e
3 changed files with 11 additions and 1 deletions

View File

@ -112,6 +112,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
return T_IF; return T_IF;
if (!strcmp(p, "ifdef")) if (!strcmp(p, "ifdef"))
return T_IFDEF; return T_IFDEF;
if (!strcmp(p, "ifndef"))
return T_IFNDEF;
preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE, preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE,
"Ignoring unknown directive \"%s\".", yytext); "Ignoring unknown directive \"%s\".", yytext);
@ -202,6 +204,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
case T_ENDIF: case T_ENDIF:
case T_IF: case T_IF:
case T_IFDEF: case T_IFDEF:
case T_IFNDEF:
ctx->current_directive = token; ctx->current_directive = token;
break; break;
@ -222,6 +225,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
case T_ENDIF: case T_ENDIF:
case T_IF: case T_IF:
case T_IFDEF: case T_IFDEF:
case T_IFNDEF:
break; break;
default: default:

View File

@ -184,6 +184,7 @@ static uint32_t preproc_parse_integer(const char *s)
%token T_ENDIF "#endif" %token T_ENDIF "#endif"
%token T_IF "#if" %token T_IF "#if"
%token T_IFDEF "#ifdef" %token T_IFDEF "#ifdef"
%token T_IFNDEF "#ifndef"
%type <integer> expr %type <integer> expr
%type <string> body_token %type <string> body_token
@ -225,6 +226,11 @@ directive
preproc_push_if(ctx, !!preproc_find_macro(ctx, $2)); preproc_push_if(ctx, !!preproc_find_macro(ctx, $2));
vkd3d_free($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 | T_ELIF expr T_NEWLINE
{ {
if (ctx->if_count) if (ctx->if_count)

View File

@ -349,7 +349,7 @@ static void test_preprocess(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i) for (i = 0; i < ARRAY_SIZE(tests); ++i)
{ {
if (i == 6) if (i == 6 || i == 10 || i == 11)
continue; continue;
vkd3d_test_set_context("Source \"%s\"", tests[i].source); vkd3d_test_set_context("Source \"%s\"", tests[i].source);
todo_if (i <= 4 || (i >= 9 && i <= 14)) todo_if (i <= 4 || (i >= 9 && i <= 14))