[PATCH vkd3d 1/5] vkd3d-shader: Implement __LINE__.
Zebediah Figura
zfigura at codeweavers.com
Thu Jan 14 14:47:47 CST 2021
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
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 388b77f6..c5c49251 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 9d8d16d9..03169716 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);
--
2.30.0
More information about the wine-devel
mailing list