Zebediah Figura : vkd3d-shader: Implement #pragma.

Alexandre Julliard julliard at winehq.org
Mon Jan 18 15:11:41 CST 2021


Module: vkd3d
Branch: master
Commit: ba32e91aca044141c6e26ee068ea7766054fe8a4
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=ba32e91aca044141c6e26ee068ea7766054fe8a4

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Jan 14 14:47:49 2021 -0600

vkd3d-shader: Implement #pragma.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/preproc.l | 13 +++++++++++++
 libs/vkd3d-shader/preproc.y |  1 +
 tests/hlsl_d3d12.c          |  3 +--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 80ac7d0..f7aee19 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -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:
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index 72d6486..4b276a9 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -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 "##"
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 0316971..837476d 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -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);
 




More information about the wine-cvs mailing list