[PATCH vkd3d 4/5] vkd3d-shader: Implement #include.

Matteo Bruni matteo.mystral at gmail.com
Thu Jan 7 06:49:19 CST 2021


On Tue, Jan 5, 2021 at 5:18 PM Zebediah Figura <zfigura at codeweavers.com> wrote:
>
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
>  libs/vkd3d-shader/preproc.h              |  44 +++++--
>  libs/vkd3d-shader/preproc.l              | 129 +++++++++++++++----
>  libs/vkd3d-shader/preproc.y              | 155 +++++++++++++++++++++--
>  libs/vkd3d-shader/vkd3d_shader_private.h |   1 +
>  tests/hlsl_d3d12.c                       |  16 +--
>  5 files changed, 292 insertions(+), 53 deletions(-)
>
> @@ -60,8 +76,16 @@ struct preproc_ctx
>      bool error;
>  };
>
> +void preproc_close_include(struct preproc_ctx *ctx, const struct vkd3d_shader_code *code) DECLSPEC_HIDDEN;
>  void preproc_free_macro(struct preproc_macro *macro) DECLSPEC_HIDDEN;
> +bool preproc_push_include(struct preproc_ctx *ctx, char *filename, const struct vkd3d_shader_code *code) DECLSPEC_HIDDEN;
>  void preproc_warning(struct preproc_ctx *ctx, const struct vkd3d_shader_location *loc,
>          enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
>
> +static struct preproc_file *preproc_get_top_file(struct preproc_ctx *ctx)
> +{
> +    assert(ctx->file_count);
> +    return &ctx->file_stack[ctx->file_count - 1];
> +}

There are a couple of places in preproc.l (e.g. in update_location(),
preproc_pop_buffer()) where this helper can be used, in particular one
with the same assert too. It's a stylistic choice so not using it is
also fine.
You probably want to make the function inline though.

I like the patch overall.



More information about the wine-devel mailing list