Zebediah Figura : vkd3d-shader: Implement #undef.
Alexandre Julliard
julliard at winehq.org
Tue Jan 12 15:00:33 CST 2021
Module: vkd3d
Branch: master
Commit: 1fc8b85879cbc3189be8198711047ed131d4ae6f
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=1fc8b85879cbc3189be8198711047ed131d4ae6f
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu Jan 7 11:48:10 2021 -0600
vkd3d-shader: Implement #undef.
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/preproc.l | 3 +++
libs/vkd3d-shader/preproc.y | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index ad006fa..476c1e5 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -126,6 +126,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
return T_IFDEF;
if (!strcmp(p, "ifndef"))
return T_IFNDEF;
+ if (!strcmp(p, "undef"))
+ return T_UNDEF;
preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE,
"Ignoring unknown directive \"%s\".", yytext);
@@ -257,6 +259,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
case T_IFDEF:
case T_IFNDEF:
case T_INCLUDE:
+ case T_UNDEF:
ctx->current_directive = token;
break;
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index fd5d011..53ce3e5 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -282,6 +282,7 @@ static const void *get_parent_data(struct preproc_ctx *ctx)
%token T_IFDEF "#ifdef"
%token T_IFNDEF "#ifndef"
%token T_INCLUDE "#include"
+%token T_UNDEF "#undef"
%type <integer> expr
%type <string> body_token
@@ -313,6 +314,18 @@ directive
if (!preproc_add_macro(ctx, &@$, $2))
YYABORT;
}
+ | T_UNDEF T_IDENTIFIER T_NEWLINE
+ {
+ struct preproc_macro *macro;
+
+ if ((macro = preproc_find_macro(ctx, $2)))
+ {
+ TRACE("Removing macro definition %s.\n", debugstr_a($2));
+ rb_remove(&ctx->macros, ¯o->entry);
+ preproc_free_macro(macro);
+ }
+ vkd3d_free($2);
+ }
| T_IF expr T_NEWLINE
{
if (!preproc_push_if(ctx, !!$2))
More information about the wine-cvs
mailing list