vkd3d-shader: Introduce HLSL allocation helpers.

To automatically put the compilation context in a failed state.

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:
Zebediah Figura
2021-05-21 00:32:20 -05:00
committed by Alexandre Julliard
parent 3a9f547be3
commit 49726b0e64
5 changed files with 216 additions and 232 deletions

View File

@@ -170,7 +170,7 @@ row_major {return KW_ROW_MAJOR; }
{IDENTIFIER} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
yylval->name = vkd3d_strdup(yytext);
yylval->name = hlsl_strdup(ctx, yytext);
if (hlsl_get_var(ctx->cur_scope, yytext) || hlsl_get_function(ctx, yytext))
return VAR_IDENTIFIER;
else if (hlsl_get_type(ctx->cur_scope, yytext, true))
@@ -248,7 +248,8 @@ row_major {return KW_ROW_MAJOR; }
return PRE_LINE;
}
<pp_line>{STRING} {
char *string = vkd3d_strdup(yytext + 1);
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
char *string = hlsl_strdup(ctx, yytext + 1);
BEGIN(pp_ignore);
string[strlen(string) - 1] = 0;