From: Marek Olšák <marek.ol...@amd.com> --- src/compiler/glsl/glsl_lexer.ll | 16 ++++++++-------- src/compiler/glsl/glsl_parser_extras.cpp | 2 ++ src/compiler/glsl/glsl_parser_extras.h | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll index d5e5d4c..b473af7 100644 --- a/src/compiler/glsl/glsl_lexer.ll +++ b/src/compiler/glsl/glsl_lexer.ll @@ -73,22 +73,22 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); do { \ if (yyextra->is_version(allowed_glsl, allowed_glsl_es) \ || (alt_expr)) { \ return token; \ } else if (yyextra->is_version(reserved_glsl, \ reserved_glsl_es)) { \ _mesa_glsl_error(yylloc, yyextra, \ "illegal use of reserved word `%s'", yytext); \ return ERROR_TOK; \ } else { \ - void *mem_ctx = yyextra; \ - yylval->identifier = ralloc_strdup(mem_ctx, yytext); \ + void *mem_ctx = yyextra->linalloc; \ + yylval->identifier = linear_strdup(mem_ctx, yytext); \ return classify_identifier(yyextra, yytext); \ } \ } while (0) /** * A macro for handling keywords that have been present in GLSL since * its origin, but were changed into reserved words in GLSL 3.00 ES. */ #define DEPRECATED_ES_KEYWORD(token) \ do { \ @@ -238,22 +238,22 @@ HASH ^{SPC}#{SPC} } ^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } <PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; } <PRAGMA>. { } <PP>\/\/[^\n]* { } <PP>[ \t\r]* { } <PP>: return COLON; <PP>[_a-zA-Z][_a-zA-Z0-9]* { - void *mem_ctx = yyextra; - yylval->identifier = ralloc_strdup(mem_ctx, yytext); + void *mem_ctx = yyextra->linalloc; + yylval->identifier = linear_strdup(mem_ctx, yytext); return IDENTIFIER; } <PP>[1-9][0-9]* { yylval->n = strtol(yytext, NULL, 10); return INTCONSTANT; } <PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } <PP>. { return yytext[0]; } \n { yylineno++; yycolumn = 0; } @@ -422,22 +422,22 @@ layout { || yyextra->ARB_explicit_attrib_location_enable || yyextra->ARB_explicit_uniform_location_enable || yyextra->has_separate_shader_objects() || yyextra->ARB_uniform_buffer_object_enable || yyextra->ARB_fragment_coord_conventions_enable || yyextra->ARB_shading_language_420pack_enable || yyextra->ARB_compute_shader_enable || yyextra->ARB_tessellation_shader_enable) { return LAYOUT_TOK; } else { - void *mem_ctx = yyextra; - yylval->identifier = ralloc_strdup(mem_ctx, yytext); + void *mem_ctx = yyextra->linalloc; + yylval->identifier = linear_strdup(mem_ctx, yytext); return classify_identifier(yyextra, yytext); } } \+\+ return INC_OP; -- return DEC_OP; \<= return LE_OP; >= return GE_OP; == return EQ_OP; != return NE_OP; @@ -583,27 +583,27 @@ isamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_ usamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, USAMPLERBUFFER); /* Additional reserved words in GLSL ES 3.00 */ resource KEYWORD(420, 300, 0, 0, RESOURCE); sample KEYWORD_WITH_ALT(400, 300, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->OES_shader_multisample_interpolation_enable, SAMPLE); subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_enable, SUBROUTINE); [_a-zA-Z][_a-zA-Z0-9]* { struct _mesa_glsl_parse_state *state = yyextra; - void *ctx = state; + void *ctx = state->linalloc; if (state->es_shader && strlen(yytext) > 1024) { _mesa_glsl_error(yylloc, state, "Identifier `%s' exceeds 1024 characters", yytext); } else { - yylval->identifier = ralloc_strdup(ctx, yytext); + yylval->identifier = linear_strdup(ctx, yytext); } return classify_identifier(state, yytext); } \. { struct _mesa_glsl_parse_state *state = yyextra; state->is_field = true; return DOT_TOK; } . { return yytext[0]; } diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 5f3474e..d649695 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -60,20 +60,22 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, : ctx(_ctx), cs_input_local_size_specified(false), cs_input_local_size(), switch_state() { assert(stage < MESA_SHADER_STAGES); this->stage = stage; this->scanner = NULL; this->translation_unit.make_empty(); this->symbols = new(mem_ctx) glsl_symbol_table; + this->linalloc = linear_alloc_parent(this, 0); + this->info_log = ralloc_strdup(mem_ctx, ""); this->error = false; this->loop_nesting_ast = NULL; this->uses_builtin_functions = false; /* Set default language version and extensions */ this->language_version = 110; this->forced_language_version = ctx->Const.ForceGLSLVersion; this->zero_init = ctx->Const.GLSLZeroInit; diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index c0a5704..cd9fa59 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -326,20 +326,22 @@ struct _mesa_glsl_parse_state { } void process_version_directive(YYLTYPE *locp, int version, const char *ident); struct gl_context *const ctx; void *scanner; exec_list translation_unit; glsl_symbol_table *symbols; + void *linalloc; + unsigned num_supported_versions; struct { unsigned ver; uint8_t gl_ver; bool es; } supported_versions[16]; bool es_shader; unsigned language_version; unsigned forced_language_version; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev