glsl: Populate built-in types correctly for GLSL 3.00 ES.
[mesa.git] / src / glsl / glsl_symbol_table.cpp
index 3dcd928016ac1b1c5c7af45d4a6e5e8b0ac26e63..f934ea8657063a5175d0ef6a367fcfff03b89c4d 100644 (file)
 
 class symbol_table_entry {
 public:
-   /* Callers of this talloc-based new need not call delete. It's
-    * easier to just talloc_free 'ctx' (or any of its ancestors). */
+   /* Callers of this ralloc-based new need not call delete. It's
+    * easier to just ralloc_free 'ctx' (or any of its ancestors). */
    static void* operator new(size_t size, void *ctx)
    {
-      void *entry = talloc_size(ctx, size);
+      void *entry = ralloc_size(ctx, size);
       assert(entry != NULL);
       return entry;
    }
 
-   /* If the user *does* call delete, that's OK, we will just
-    * talloc_free in that case. Here, C++ will have already called the
-    * destructor so tell talloc not to do that again. */
-   static void operator delete(void *table)
+   /* If the user *does* call delete, that's OK, we will just ralloc_free. */
+   static void operator delete(void *entry)
    {
-      talloc_set_destructor(table, NULL);
-      talloc_free(table);
+      ralloc_free(entry);
    }
 
    symbol_table_entry(ir_variable *v)                     : v(v), f(0), t(0) {}
@@ -55,15 +52,15 @@ 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 = talloc_init("symbol table entries");
+   this->mem_ctx = ralloc_context(NULL);
 }
 
 glsl_symbol_table::~glsl_symbol_table()
 {
    _mesa_symbol_table_dtor(table);
-   talloc_free(mem_ctx);
+   ralloc_free(mem_ctx);
 }
 
 void glsl_symbol_table::push_scope()
@@ -83,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)) {
@@ -123,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)) {
@@ -140,6 +137,7 @@ void glsl_symbol_table::add_global_function(ir_function *f)
    symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f);
    int added = _mesa_symbol_table_add_global_symbol(table, -1, f->name, entry);
    assert(added == 0);
+   (void)added;
 }
 
 ir_variable *glsl_symbol_table::get_variable(const char *name)