glsl/lexer: use the linear allocator
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
@@ -80,8 +80,8 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
|
|||||||
"illegal use of reserved word `%s'", yytext); \
|
"illegal use of reserved word `%s'", yytext); \
|
||||||
return ERROR_TOK; \
|
return ERROR_TOK; \
|
||||||
} else { \
|
} else { \
|
||||||
void *mem_ctx = yyextra; \
|
void *mem_ctx = yyextra->linalloc; \
|
||||||
yylval->identifier = ralloc_strdup(mem_ctx, yytext); \
|
yylval->identifier = linear_strdup(mem_ctx, yytext); \
|
||||||
return classify_identifier(yyextra, yytext); \
|
return classify_identifier(yyextra, yytext); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -245,8 +245,8 @@ HASH ^{SPC}#{SPC}
|
|||||||
<PP>[ \t\r]* { }
|
<PP>[ \t\r]* { }
|
||||||
<PP>: return COLON;
|
<PP>: return COLON;
|
||||||
<PP>[_a-zA-Z][_a-zA-Z0-9]* {
|
<PP>[_a-zA-Z][_a-zA-Z0-9]* {
|
||||||
void *mem_ctx = yyextra;
|
void *mem_ctx = yyextra->linalloc;
|
||||||
yylval->identifier = ralloc_strdup(mem_ctx, yytext);
|
yylval->identifier = linear_strdup(mem_ctx, yytext);
|
||||||
return IDENTIFIER;
|
return IDENTIFIER;
|
||||||
}
|
}
|
||||||
<PP>[1-9][0-9]* {
|
<PP>[1-9][0-9]* {
|
||||||
@@ -429,8 +429,8 @@ layout {
|
|||||||
|| yyextra->ARB_tessellation_shader_enable) {
|
|| yyextra->ARB_tessellation_shader_enable) {
|
||||||
return LAYOUT_TOK;
|
return LAYOUT_TOK;
|
||||||
} else {
|
} else {
|
||||||
void *mem_ctx = yyextra;
|
void *mem_ctx = yyextra->linalloc;
|
||||||
yylval->identifier = ralloc_strdup(mem_ctx, yytext);
|
yylval->identifier = linear_strdup(mem_ctx, yytext);
|
||||||
return classify_identifier(yyextra, yytext);
|
return classify_identifier(yyextra, yytext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -590,13 +590,13 @@ subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_ena
|
|||||||
|
|
||||||
[_a-zA-Z][_a-zA-Z0-9]* {
|
[_a-zA-Z][_a-zA-Z0-9]* {
|
||||||
struct _mesa_glsl_parse_state *state = yyextra;
|
struct _mesa_glsl_parse_state *state = yyextra;
|
||||||
void *ctx = state;
|
void *ctx = state->linalloc;
|
||||||
if (state->es_shader && strlen(yytext) > 1024) {
|
if (state->es_shader && strlen(yytext) > 1024) {
|
||||||
_mesa_glsl_error(yylloc, state,
|
_mesa_glsl_error(yylloc, state,
|
||||||
"Identifier `%s' exceeds 1024 characters",
|
"Identifier `%s' exceeds 1024 characters",
|
||||||
yytext);
|
yytext);
|
||||||
} else {
|
} else {
|
||||||
yylval->identifier = ralloc_strdup(ctx, yytext);
|
yylval->identifier = linear_strdup(ctx, yytext);
|
||||||
}
|
}
|
||||||
return classify_identifier(state, yytext);
|
return classify_identifier(state, yytext);
|
||||||
}
|
}
|
||||||
|
@@ -67,6 +67,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
|
|||||||
this->translation_unit.make_empty();
|
this->translation_unit.make_empty();
|
||||||
this->symbols = new(mem_ctx) glsl_symbol_table;
|
this->symbols = new(mem_ctx) glsl_symbol_table;
|
||||||
|
|
||||||
|
this->linalloc = linear_alloc_parent(this, 0);
|
||||||
|
|
||||||
this->info_log = ralloc_strdup(mem_ctx, "");
|
this->info_log = ralloc_strdup(mem_ctx, "");
|
||||||
this->error = false;
|
this->error = false;
|
||||||
this->loop_nesting_ast = NULL;
|
this->loop_nesting_ast = NULL;
|
||||||
|
@@ -333,6 +333,8 @@ struct _mesa_glsl_parse_state {
|
|||||||
exec_list translation_unit;
|
exec_list translation_unit;
|
||||||
glsl_symbol_table *symbols;
|
glsl_symbol_table *symbols;
|
||||||
|
|
||||||
|
void *linalloc;
|
||||||
|
|
||||||
unsigned num_supported_versions;
|
unsigned num_supported_versions;
|
||||||
struct {
|
struct {
|
||||||
unsigned ver;
|
unsigned ver;
|
||||||
|
Reference in New Issue
Block a user