glsl: Simplify symbol table version checking.

Previously, we stored the GLSL language version in the
glsl_symbol_table struct.  But this was unnecessary--all
glsl_symbol_table needs to know is whether functions and variables
have separate namespaces (they do in GLSL 1.10 only).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
This commit is contained in:
Paul Berry 2012-08-01 17:44:02 -07:00 committed by Ian Romanick
parent 9a93ba3068
commit 53e572f15c
5 changed files with 9 additions and 7 deletions

View File

@ -324,7 +324,8 @@ match_function_by_name(const char *name,
goto done; /* no match */
/* Is the function hidden by a variable (impossible in 1.10)? */
if (state->language_version != 110 && state->symbols->get_variable(name))
if (!state->symbols->separate_function_namespace
&& state->symbols->get_variable(name))
goto done; /* no match */
if (f != NULL) {

View File

@ -66,7 +66,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
{
_mesa_glsl_initialize_variables(instructions, state);
state->symbols->language_version = state->language_version;
state->symbols->separate_function_namespace = state->language_version == 110;
state->current_function = NULL;

View File

@ -183,7 +183,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne
new(sh) _mesa_glsl_parse_state(&fakeCtx, target, sh);
st->language_version = 140;
st->symbols->language_version = 140;
st->symbols->separate_function_namespace = false;
st->ARB_texture_rectangle_enable = true;
st->EXT_texture_array_enable = true;
st->OES_EGL_image_external_enable = true;

View File

@ -52,7 +52,7 @@ public:
glsl_symbol_table::glsl_symbol_table()
{
this->language_version = 120;
this->separate_function_namespace = false;
this->table = _mesa_symbol_table_ctor();
this->mem_ctx = ralloc_context(NULL);
}
@ -80,7 +80,7 @@ bool glsl_symbol_table::name_declared_this_scope(const char *name)
bool glsl_symbol_table::add_variable(ir_variable *v)
{
if (this->language_version == 110) {
if (this->separate_function_namespace) {
/* In 1.10, functions and variables have separate namespaces. */
symbol_table_entry *existing = get_entry(v->name);
if (name_declared_this_scope(v->name)) {
@ -120,7 +120,7 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
bool glsl_symbol_table::add_function(ir_function *f)
{
if (this->language_version == 110 && name_declared_this_scope(f->name)) {
if (this->separate_function_namespace && name_declared_this_scope(f->name)) {
/* In 1.10, functions and variables have separate namespaces. */
symbol_table_entry *existing = get_entry(f->name);
if ((existing->f == NULL) && (existing->t == NULL)) {

View File

@ -77,7 +77,8 @@ public:
glsl_symbol_table();
~glsl_symbol_table();
unsigned int language_version;
/* In 1.10, functions and variables have separate namespaces. */
bool separate_function_namespace;
void push_scope();
void pop_scope();