Zebediah Figura : vkd3d-shader: Implement equality operators in #if directives.
Alexandre Julliard
julliard at winehq.org
Fri Jan 22 15:48:01 CST 2021
Module: vkd3d
Branch: master
Commit: 15bbaed9602cc0b9e87b98edda286fa28552fa6b
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=15bbaed9602cc0b9e87b98edda286fa28552fa6b
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu Jan 21 16:10:43 2021 -0600
vkd3d-shader: Implement equality operators in #if directives.
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>
---
Makefile.am | 1 -
libs/vkd3d-shader/preproc.l | 4 +++-
libs/vkd3d-shader/preproc.y | 26 ++++++++++++++++++++++++--
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 30bea62..76a2f31 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -243,7 +243,6 @@ XFAIL_TESTS = \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
- tests/preproc-ifdef.shader_test \
tests/preproc-if-expr.shader_test \
tests/preproc-macro.shader_test \
tests/swizzle-0.shader_test \
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index 6779a39..d21ddd1 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -80,6 +80,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>"<=" {return T_LE;}
<INITIAL>">=" {return T_GE;}
+<INITIAL>"==" {return T_EQ;}
+<INITIAL>"!=" {return T_NE;}
/* We have no use for floats, but shouldn't parse them as integers. */
@@ -99,7 +101,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>"--" {return T_TEXT;}
<INITIAL>"<<"=? {return T_TEXT;}
<INITIAL>">>"=? {return T_TEXT;}
-<INITIAL>[-+*/%&|^=!]= {return T_TEXT;}
+<INITIAL>[-+*/%&|^]= {return T_TEXT;}
<INCLUDE>\"[^"]*\" {return T_STRING;}
<INCLUDE>\<[^>]*\> {return T_STRING;}
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index 6d88419..089fd76 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -334,6 +334,8 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%token T_LE "<="
%token T_GE ">="
+%token T_EQ "=="
+%token T_NE "!="
%token T_DEFINED "defined"
%type <integer> primary_expr
@@ -341,6 +343,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%type <integer> mul_expr
%type <integer> add_expr
%type <integer> ineq_expr
+%type <integer> eq_expr
%type <string> body_token
%type <const_string> body_token_const
%type <string_buffer> body_text
@@ -473,6 +476,14 @@ body_token_const
{
$$ = ">=";
}
+ | T_EQ
+ {
+ $$ = "==";
+ }
+ | T_NE
+ {
+ $$ = "!=";
+ }
| T_DEFINED
{
$$ = "defined";
@@ -510,7 +521,7 @@ directive
}
vkd3d_free($2);
}
- | T_IF ineq_expr T_NEWLINE
+ | T_IF eq_expr T_NEWLINE
{
if (!preproc_push_if(ctx, !!$2))
YYABORT;
@@ -525,7 +536,7 @@ directive
preproc_push_if(ctx, !preproc_find_macro(ctx, $2));
vkd3d_free($2);
}
- | T_ELIF ineq_expr T_NEWLINE
+ | T_ELIF eq_expr T_NEWLINE
{
const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -707,3 +718,14 @@ ineq_expr
{
$$ = $1 >= $3;
}
+
+eq_expr
+ : ineq_expr
+ | eq_expr T_EQ ineq_expr
+ {
+ $$ = $1 == $3;
+ }
+ | eq_expr T_NE ineq_expr
+ {
+ $$ = $1 != $3;
+ }
More information about the wine-cvs
mailing list