summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_symbol_table.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-08-21 20:23:18 -0700
committerIan Romanick <[email protected]>2010-08-26 09:19:48 -0700
commite9c7ceed27f6811ad1cae46c93ce9bc3fb3668d8 (patch)
treee66302bca944353decf9b78291effb9cee7a4982 /src/glsl/glsl_symbol_table.h
parent86ddb356e8278423ef41125be627e57e073471d1 (diff)
glsl: Use a single shared namespace in the symbol table.
As of 1.20, variable names, function names, and structure type names all share a single namespace, and should conflict with one another in the same scope, or hide each other in nested scopes. However, in 1.10, variables and functions can share the same name in the same scope. Structure types, however, conflict with/hide both. Fixes piglit tests redeclaration-06.vert, redeclaration-11.vert, redeclaration-19.vert, and struct-05.vert.
Diffstat (limited to 'src/glsl/glsl_symbol_table.h')
-rw-r--r--src/glsl/glsl_symbol_table.h85
1 files changed, 18 insertions, 67 deletions
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
index 4cb7559e9a0..d71be5578be 100644
--- a/src/glsl/glsl_symbol_table.h
+++ b/src/glsl/glsl_symbol_table.h
@@ -34,6 +34,8 @@ extern "C" {
#include "ir.h"
#include "glsl_types.h"
+class symbol_table_entry;
+
/**
* Facade class for _mesa_symbol_table
*
@@ -42,12 +44,6 @@ extern "C" {
*/
struct glsl_symbol_table {
private:
- enum glsl_symbol_name_space {
- glsl_variable_name_space = 0,
- glsl_type_name_space = 1,
- glsl_function_name_space = 2
- };
-
static int
_glsl_symbol_table_destructor (glsl_symbol_table *table)
{
@@ -80,33 +76,18 @@ public:
talloc_free(table);
}
- glsl_symbol_table()
- {
- table = _mesa_symbol_table_ctor();
- }
+ glsl_symbol_table();
+ ~glsl_symbol_table();
- ~glsl_symbol_table()
- {
- _mesa_symbol_table_dtor(table);
- }
+ unsigned int language_version;
- void push_scope()
- {
- _mesa_symbol_table_push_scope(table);
- }
-
- void pop_scope()
- {
- _mesa_symbol_table_pop_scope(table);
- }
+ void push_scope();
+ void pop_scope();
/**
* Determine whether a name was declared at the current scope
*/
- bool name_declared_this_scope(const char *name)
- {
- return _mesa_symbol_table_symbol_scope(table, -1, name) == 0;
- }
+ bool name_declared_this_scope(const char *name);
/**
* \name Methods to add symbols to the table
@@ -116,56 +97,26 @@ public:
* reduces the clarity of the intention of code that uses these methods.
*/
/*@{*/
- bool add_variable(const char *name, ir_variable *v)
- {
- return _mesa_symbol_table_add_symbol(table, glsl_variable_name_space,
- name, v) == 0;
- }
-
- bool add_type(const char *name, const glsl_type *t)
- {
- return _mesa_symbol_table_add_symbol(table, glsl_type_name_space,
- name, (void *) t) == 0;
- }
-
- bool add_function(const char *name, ir_function *f)
- {
- return _mesa_symbol_table_add_symbol(table, glsl_function_name_space,
- name, f) == 0;
- }
-
- bool remove_function(const char *name, ir_function *f)
- {
- return _mesa_symbol_table_add_symbol(table, glsl_function_name_space,
- name, f) == 0;
- }
+ bool add_variable(const char *name, ir_variable *v);
+ bool add_type(const char *name, const glsl_type *t,
+ ir_function *constructor = NULL);
+ bool add_function(const char *name, ir_function *f);
/*@}*/
/**
* \name Methods to get symbols from the table
*/
/*@{*/
- ir_variable *get_variable(const char *name)
- {
- return (ir_variable *)
- _mesa_symbol_table_find_symbol(table, glsl_variable_name_space, name);
- }
-
- glsl_type *get_type(const char *name)
- {
- return (glsl_type *)
- _mesa_symbol_table_find_symbol(table, glsl_type_name_space, name);
- }
-
- ir_function *get_function(const char *name)
- {
- return (ir_function *)
- _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name);
- }
+ ir_variable *get_variable(const char *name);
+ const glsl_type *get_type(const char *name);
+ ir_function *get_function(const char *name);
/*@}*/
private:
+ symbol_table_entry *get_entry(const char *name);
+
struct _mesa_symbol_table *table;
+ void *mem_ctx;
};
#endif /* GLSL_SYMBOL_TABLE */