Module: vkd3d Branch: master Commit: 4cd2dd50f94edb822012b254b4497decebac32ea URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/4cd2dd50f94edb822012b254b4497d...
Author: Elizabeth Figura zfigura@codeweavers.com Date: Tue Jun 11 22:17:51 2024 -0500
vkd3d-shader/hlsl: Separate an "array" rule.
---
libs/vkd3d-shader/hlsl.y | 49 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 28 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 9d1cce68..2dfb9f58 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5930,6 +5930,8 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h
%type <if_body> if_body
+%type <intval> array + %type <modifiers> var_modifiers
%type <name> any_identifier @@ -7385,52 +7387,43 @@ variable_def_typed: $$->modifiers_loc = @1; }
-arrays: - %empty +array: + '[' ']' { - $$.sizes = NULL; - $$.count = 0; + $$ = HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT; } - | '[' expr ']' arrays + | '[' expr ']' { - uint32_t *new_array; - unsigned int size; + $$ = evaluate_static_expression_as_uint(ctx, $2, &@2);
- size = evaluate_static_expression_as_uint(ctx, $2, &@2); - - destroy_block($2); - - $$ = $4; - - if (!size) + if (!$$) { hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, "Array size is not a positive integer constant."); - vkd3d_free($$.sizes); YYABORT; }
- if (size > 65536) + if ($$ > 65536) { hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE, - "Array size %u is not between 1 and 65536.", size); - vkd3d_free($$.sizes); + "Array size %u is not between 1 and 65536.", $$); YYABORT; }
- if (!(new_array = hlsl_realloc(ctx, $$.sizes, ($$.count + 1) * sizeof(*new_array)))) - { - vkd3d_free($$.sizes); - YYABORT; - } - $$.sizes = new_array; - $$.sizes[$$.count++] = size; + destroy_block($2); + } + +arrays: + %empty + { + $$.sizes = NULL; + $$.count = 0; } - | '[' ']' arrays + | array arrays { uint32_t *new_array;
- $$ = $3; + $$ = $2;
if (!(new_array = hlsl_realloc(ctx, $$.sizes, ($$.count + 1) * sizeof(*new_array)))) { @@ -7439,7 +7432,7 @@ arrays: }
$$.sizes = new_array; - $$.sizes[$$.count++] = HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT; + $$.sizes[$$.count++] = $1; }
var_modifiers: