mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07: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:
committed by
Alexandre Julliard
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>[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;}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
if (ctx->expansion_count)
|
||||
@@ -375,6 +389,14 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
|
||||
switch (func_state->state)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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_UNDEF "#undef"
|
||||
|
||||
%token T_CONCAT "##"
|
||||
|
||||
%type <integer> expr
|
||||
%type <string> body_token
|
||||
%type <const_string> body_token_const
|
||||
@@ -419,6 +421,10 @@ body_token_const
|
||||
{
|
||||
$$ = ",";
|
||||
}
|
||||
| T_CONCAT
|
||||
{
|
||||
$$ = "##";
|
||||
}
|
||||
|
||||
directive
|
||||
: T_DEFINE T_IDENTIFIER body_text T_NEWLINE
|
||||
|
Reference in New Issue
Block a user