Zebediah Figura : vkd3d-shader: Implement __LINE__.

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


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

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

vkd3d-shader: Implement __LINE__.

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 | 20 ++++++++++++++++++++
 tests/hlsl_d3d12.c          |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 388b77f..c5c4925 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -471,6 +471,26 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
                         }
                         continue;
                     }
+
+                    if (!strcmp(text, "__LINE__"))
+                    {
+                        const struct preproc_file *file = preproc_get_top_file(ctx);
+
+                        /* Not the current line number, but rather the line
+                         * number before invoking any macros. */
+
+                        if (ctx->current_directive)
+                        {
+                            char string[13];
+
+                            sprintf(string, "%d", file->buffer.location.line);
+                            return return_token(T_INTEGER, lval, string);
+                        }
+
+                        if (preproc_is_writing(ctx))
+                            vkd3d_string_buffer_printf(&ctx->buffer, "%d ", file->buffer.location.line);
+                        continue;
+                    }
                 }
 
                 if (ctx->current_directive)
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 9d8d16d..0316971 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -350,7 +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 || (i >= 12 && i <= 14))
+        todo_if (i == 9)
             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