Zebediah Figura : vkd3d-shader: Use struct vkd3d_shader_location in struct hlsl_ctx.
Alexandre Julliard
julliard at winehq.org
Fri Feb 12 14:34:37 CST 2021
Module: vkd3d
Branch: master
Commit: 3bf0e40b9d8f185f6df8b087a7b5edd52a10cadf
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=3bf0e40b9d8f185f6df8b087a7b5edd52a10cadf
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Fri Feb 12 10:48:56 2021 -0600
vkd3d-shader: Use struct vkd3d_shader_location in struct hlsl_ctx.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.c | 10 +++++-----
libs/vkd3d-shader/hlsl.h | 4 +---
libs/vkd3d-shader/hlsl.l | 12 +++++-------
libs/vkd3d-shader/hlsl.y | 6 +++---
4 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 4597be1..a129e84 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -1482,16 +1482,16 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, struct vkd3d_shader_message_cont
ctx->message_context = message_context;
- ctx->line_no = ctx->column = 1;
- if (!(ctx->source_file = vkd3d_strdup("")))
- return false;
if (!(ctx->source_files = vkd3d_malloc(sizeof(*ctx->source_files))))
+ return false;
+ if (!(ctx->source_files[0] = vkd3d_strdup("")))
{
- vkd3d_free((void *)ctx->source_file);
+ vkd3d_free(ctx->source_files);
return false;
}
- ctx->source_files[0] = ctx->source_file;
ctx->source_files_count = 1;
+ ctx->location.source_name = ctx->source_files[0];
+ ctx->location.line = ctx->location.column = 1;
ctx->matrix_majority = HLSL_COLUMN_MAJOR;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 59bf314..067aae8 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -395,9 +395,7 @@ struct hlsl_ctx
{
const char **source_files;
unsigned int source_files_count;
- const char *source_file;
- unsigned int line_no;
- unsigned int column;
+ struct vkd3d_shader_location location;
enum parse_status status;
struct vkd3d_shader_message_context *message_context;
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
index 38b4bf1..a0e0bed 100644
--- a/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d-shader/hlsl.l
@@ -209,8 +209,8 @@ row_major {return KW_ROW_MAJOR; }
{NEWLINE} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- ctx->line_no++;
- ctx->column = 1;
+ ++ctx->location.line;
+ ctx->location.column = 1;
}
^# {
@@ -238,7 +238,7 @@ row_major {return KW_ROW_MAJOR; }
<pp_pragma>{NEWLINE} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- FIXME("Unsupported preprocessor #pragma directive at line %u.\n", ctx->line_no);
+ FIXME("Unsupported preprocessor #pragma directive at line %u.\n", ctx->location.line);
BEGIN(INITIAL);
}
<pp_pragma>{ANY} {}
@@ -279,10 +279,8 @@ row_major {return KW_ROW_MAJOR; }
static void update_location(struct hlsl_ctx *ctx, YYLTYPE *lloc)
{
- lloc->source_name = ctx->source_file;
- lloc->line = ctx->line_no;
- lloc->column = ctx->column;
- ctx->column += yyget_leng(ctx->scanner);
+ *lloc = ctx->location;
+ ctx->location.column += yyget_leng(ctx->scanner);
}
int hlsl_lexer_compile(struct hlsl_ctx *ctx, const char *text, const char *entrypoint)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 15c9c9c..d7201f5 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1762,8 +1762,8 @@ preproc_directive:
const char **new_array = NULL;
TRACE("Updating line information to file %s, line %u.\n", debugstr_a($2), $1);
- ctx->line_no = $1;
- if (strcmp($2, ctx->source_file))
+ ctx->location.line = $1;
+ if (strcmp($2, ctx->location.source_name))
new_array = vkd3d_realloc(ctx->source_files,
sizeof(*ctx->source_files) * (ctx->source_files_count + 1));
@@ -1771,7 +1771,7 @@ preproc_directive:
{
ctx->source_files = new_array;
ctx->source_files[ctx->source_files_count++] = $2;
- ctx->source_file = $2;
+ ctx->location.source_name = $2;
}
else
{
More information about the wine-cvs
mailing list