vkd3d-shader/hlsl: Parse string constants.

This commit is contained in:
Francisco Casas
2024-06-14 19:59:21 -04:00
committed by Henri Verbeet
parent 4b2e847d11
commit 090df488ba
Notes: Henri Verbeet 2024-08-07 16:01:12 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/962
8 changed files with 116 additions and 20 deletions

View File

@@ -590,6 +590,7 @@ static union hlsl_constant_value_component evaluate_static_expression(struct hls
{
case HLSL_IR_CONSTANT:
case HLSL_IR_EXPR:
case HLSL_IR_STRING_CONSTANT:
case HLSL_IR_SWIZZLE:
case HLSL_IR_LOAD:
case HLSL_IR_INDEX:
@@ -633,6 +634,10 @@ static union hlsl_constant_value_component evaluate_static_expression(struct hls
constant = hlsl_ir_constant(node);
ret = constant->value.u[0];
}
else if (node->type == HLSL_IR_STRING_CONSTANT)
{
hlsl_fixme(ctx, &node->loc, "Evaluate string constants as static expressions.");
}
else
{
hlsl_error(ctx, &node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
@@ -8264,6 +8269,23 @@ primary_expr:
YYABORT;
}
}
| STRING
{
struct hlsl_ir_node *c;
if (!(c = hlsl_new_string_constant(ctx, $1, &@1)))
{
vkd3d_free($1);
YYABORT;
}
vkd3d_free($1);
if (!($$ = make_block(ctx, c)))
{
hlsl_free_instr(c);
YYABORT;
}
}
| VAR_IDENTIFIER
{
struct hlsl_ir_load *load;