mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Implement multiplication and division in #if directives.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f8a8987737
commit
be7e06cd4a
@ -157,7 +157,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
|
||||
}
|
||||
|
||||
<INITIAL>{WS}+ {}
|
||||
<INITIAL>[-()\[\]{},+!] {return yytext[0];}
|
||||
<INITIAL>[-()\[\]{},+!*/] {return yytext[0];}
|
||||
<INITIAL>. {return T_TEXT;}
|
||||
|
||||
%%
|
||||
|
@ -335,6 +335,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
|
||||
|
||||
%type <integer> primary_expr
|
||||
%type <integer> unary_expr
|
||||
%type <integer> mul_expr
|
||||
%type <string> body_token
|
||||
%type <const_string> body_token_const
|
||||
%type <string_buffer> body_text
|
||||
@ -439,6 +440,14 @@ body_token_const
|
||||
{
|
||||
$$ = "!";
|
||||
}
|
||||
| '*'
|
||||
{
|
||||
$$ = "*";
|
||||
}
|
||||
| '/'
|
||||
{
|
||||
$$ = "/";
|
||||
}
|
||||
| T_CONCAT
|
||||
{
|
||||
$$ = "##";
|
||||
@ -480,7 +489,7 @@ directive
|
||||
}
|
||||
vkd3d_free($2);
|
||||
}
|
||||
| T_IF unary_expr T_NEWLINE
|
||||
| T_IF mul_expr T_NEWLINE
|
||||
{
|
||||
if (!preproc_push_if(ctx, !!$2))
|
||||
YYABORT;
|
||||
@ -495,7 +504,7 @@ directive
|
||||
preproc_push_if(ctx, !preproc_find_macro(ctx, $2));
|
||||
vkd3d_free($2);
|
||||
}
|
||||
| T_ELIF unary_expr T_NEWLINE
|
||||
| T_ELIF mul_expr T_NEWLINE
|
||||
{
|
||||
const struct preproc_file *file = preproc_get_top_file(ctx);
|
||||
|
||||
@ -631,3 +640,19 @@ unary_expr
|
||||
{
|
||||
$$ = !$2;
|
||||
}
|
||||
|
||||
mul_expr
|
||||
: unary_expr
|
||||
| mul_expr '*' unary_expr
|
||||
{
|
||||
$$ = $1 * $3;
|
||||
}
|
||||
| mul_expr '/' unary_expr
|
||||
{
|
||||
if (!$3)
|
||||
{
|
||||
preproc_warning(ctx, &@3, VKD3D_SHADER_WARNING_PP_DIV_BY_ZERO, "Division by zero.");
|
||||
$3 = 1;
|
||||
}
|
||||
$$ = $1 / $3;
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE = 4303,
|
||||
VKD3D_SHADER_WARNING_PP_UNTERMINATED_MACRO = 4304,
|
||||
VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF = 4305,
|
||||
VKD3D_SHADER_WARNING_PP_DIV_BY_ZERO = 4306,
|
||||
};
|
||||
|
||||
enum VKD3D_SHADER_INSTRUCTION_HANDLER
|
||||
|
Loading…
Reference in New Issue
Block a user