mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader: Implement concatenation.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e1a956f8f2
commit
33df515f10
@ -83,6 +83,8 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
|
|||||||
<INITIAL>0[0-7]*[ul]{0,2} {return T_INTEGER;}
|
<INITIAL>0[0-7]*[ul]{0,2} {return T_INTEGER;}
|
||||||
<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
|
<INITIAL>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
|
||||||
|
|
||||||
|
<INITIAL>## {return T_CONCAT;}
|
||||||
|
|
||||||
<INITIAL>"&&" {return T_TEXT;}
|
<INITIAL>"&&" {return T_TEXT;}
|
||||||
<INITIAL>"||" {return T_TEXT;}
|
<INITIAL>"||" {return T_TEXT;}
|
||||||
<INITIAL>"++" {return T_TEXT;}
|
<INITIAL>"++" {return T_TEXT;}
|
||||||
@ -189,6 +191,18 @@ static struct preproc_macro *preproc_get_top_macro(struct preproc_ctx *ctx)
|
|||||||
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
|
return ctx->expansion_stack[ctx->expansion_count - 1].macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Concatenation is not done for object-like macros, but is done for both
|
||||||
|
* function-like macro bodies and their arguments. */
|
||||||
|
static bool should_concat(struct preproc_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct preproc_macro *macro;
|
||||||
|
|
||||||
|
if (!ctx->expansion_count)
|
||||||
|
return false;
|
||||||
|
macro = ctx->expansion_stack[ctx->expansion_count - 1].macro;
|
||||||
|
return !macro || macro->arg_count;
|
||||||
|
}
|
||||||
|
|
||||||
static void preproc_pop_buffer(struct preproc_ctx *ctx)
|
static void preproc_pop_buffer(struct preproc_ctx *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->expansion_count)
|
if (ctx->expansion_count)
|
||||||
@ -375,6 +389,14 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
|
|||||||
switch (func_state->state)
|
switch (func_state->state)
|
||||||
{
|
{
|
||||||
case STATE_NONE:
|
case STATE_NONE:
|
||||||
|
if (token == T_CONCAT && should_concat(ctx))
|
||||||
|
{
|
||||||
|
while (ctx->buffer.content_size
|
||||||
|
&& strchr(" \t\r\n", ctx->buffer.buffer[ctx->buffer.content_size - 1]))
|
||||||
|
--ctx->buffer.content_size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (token == T_IDENTIFIER || token == T_IDENTIFIER_PAREN)
|
if (token == T_IDENTIFIER || token == T_IDENTIFIER_PAREN)
|
||||||
{
|
{
|
||||||
const struct preproc_text *expansion;
|
const struct preproc_text *expansion;
|
||||||
|
@ -327,6 +327,8 @@ static void free_parse_arg_names(struct parse_arg_names *args)
|
|||||||
%token T_INCLUDE "#include"
|
%token T_INCLUDE "#include"
|
||||||
%token T_UNDEF "#undef"
|
%token T_UNDEF "#undef"
|
||||||
|
|
||||||
|
%token T_CONCAT "##"
|
||||||
|
|
||||||
%type <integer> expr
|
%type <integer> expr
|
||||||
%type <string> body_token
|
%type <string> body_token
|
||||||
%type <const_string> body_token_const
|
%type <const_string> body_token_const
|
||||||
@ -419,6 +421,10 @@ body_token_const
|
|||||||
{
|
{
|
||||||
$$ = ",";
|
$$ = ",";
|
||||||
}
|
}
|
||||||
|
| T_CONCAT
|
||||||
|
{
|
||||||
|
$$ = "##";
|
||||||
|
}
|
||||||
|
|
||||||
directive
|
directive
|
||||||
: T_DEFINE T_IDENTIFIER body_text T_NEWLINE
|
: T_DEFINE T_IDENTIFIER body_text T_NEWLINE
|
||||||
|
@ -349,10 +349,8 @@ static void test_preprocess(void)
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tests); ++i)
|
for (i = 0; i < ARRAY_SIZE(tests); ++i)
|
||||||
{
|
{
|
||||||
if (i == 10 || i == 11)
|
|
||||||
continue;
|
|
||||||
vkd3d_test_set_context("Source \"%s\"", tests[i].source);
|
vkd3d_test_set_context("Source \"%s\"", tests[i].source);
|
||||||
todo_if (i <= 4 || (i >= 9 && i <= 14))
|
todo_if (i <= 4 || i == 9 || (i >= 12 && i <= 14))
|
||||||
check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
|
check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
|
||||||
}
|
}
|
||||||
vkd3d_test_set_context(NULL);
|
vkd3d_test_set_context(NULL);
|
||||||
@ -407,8 +405,7 @@ static void test_preprocess(void)
|
|||||||
ok(include_count_file2 == 2, "file2 was included %u times.\n", include_count_file2);
|
ok(include_count_file2 == 2, "file2 was included %u times.\n", include_count_file2);
|
||||||
|
|
||||||
/* Macro invocation spread across multiple files. */
|
/* Macro invocation spread across multiple files. */
|
||||||
if (0)
|
check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL);
|
||||||
todo check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL);
|
|
||||||
|
|
||||||
blob = errors = (ID3D10Blob *)0xdeadbeef;
|
blob = errors = (ID3D10Blob *)0xdeadbeef;
|
||||||
hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors);
|
hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user