diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-19 15:34:13 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-19 15:34:13 -0700 |
commit | 38395c1aad82abdeecbd66bca8daaa6f431c920c (patch) | |
tree | 93f83b8840114b352fb70efd2f43dacb77217d9f | |
parent | 95517faf6931765408c697e3d60e4469616ad1d3 (diff) |
Use separate namespaces for types, variables, and functions
This will allow types and their constructors to be easily stored in
the same symbol table. This does add a potential problem that a
shader could declare a variable and a function with the same name.
This appears to be forbidden by the GLSL spec.
-rw-r--r-- | glsl_symbol_table.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/glsl_symbol_table.h b/glsl_symbol_table.h index 482507cf67..ad3ccf06ef 100644 --- a/glsl_symbol_table.h +++ b/glsl_symbol_table.h @@ -37,6 +37,13 @@ * type safe and some symbol table invariants. */ class glsl_symbol_table { +private: + enum glsl_symbol_name_space { + glsl_variable_name_space = 0, + glsl_type_name_space = 1, + glsl_function_name_space = 2 + }; + public: glsl_symbol_table() { @@ -68,17 +75,20 @@ public: /*@{*/ bool add_variable(const char *name, ir_variable *v) { - return _mesa_symbol_table_add_symbol(table, 0, name, v) == 0; + 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, 0, name, (void *) t) == 0; + 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, 0, name, f) == 0; + return _mesa_symbol_table_add_symbol(table, glsl_function_name_space, + name, f) == 0; } /*@}*/ @@ -88,17 +98,20 @@ public: /*@{*/ ir_variable *get_variable(const char *name) { - return (ir_variable *) _mesa_symbol_table_find_symbol(table, 0, 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, 0, 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, 0, name); + return (ir_function *) + _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name); } /*@}*/ |