vkd3d-shader: Implement #pragma.

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-14 14:47:49 -06:00 committed by Alexandre Julliard
parent 92877f7a43
commit ba32e91aca
3 changed files with 15 additions and 2 deletions

View File

@ -129,6 +129,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
return T_IFDEF;
if (!strcmp(p, "ifndef"))
return T_IFNDEF;
if (!strcmp(p, "pragma"))
return T_PRAGMA;
if (!strcmp(p, "undef"))
return T_UNDEF;
@ -352,6 +354,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
case T_IFDEF:
case T_IFNDEF:
case T_INCLUDE:
case T_PRAGMA:
case T_UNDEF:
ctx->current_directive = token;
break;
@ -387,6 +390,16 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
continue;
}
if (ctx->current_directive == T_PRAGMA)
{
/* Print all tokens verbatim. */
if (token == T_PRAGMA)
vkd3d_string_buffer_printf(&ctx->buffer, "#pragma ");
else
vkd3d_string_buffer_printf(&ctx->buffer, "%s", text);
continue;
}
switch (func_state->state)
{
case STATE_NONE:

View File

@ -326,6 +326,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%token T_IFDEF "#ifdef"
%token T_IFNDEF "#ifndef"
%token T_INCLUDE "#include"
%token T_PRAGMA "#pragma"
%token T_UNDEF "#undef"
%token T_CONCAT "##"

View File

@ -350,8 +350,7 @@ static void test_preprocess(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
vkd3d_test_set_context("Source \"%s\"", tests[i].source);
todo_if (i == 9)
check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
}
vkd3d_test_set_context(NULL);