summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_symbol_table.cpp
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2015-02-26 12:15:16 +0100
committerTapani Pälli <[email protected]>2015-11-12 09:50:13 +0200
commitd6a61673543deeebac773801cbd717b7a342626e (patch)
tree80d598774300083bff3ae2f9fe384c49ab9ffb09 /src/glsl/glsl_symbol_table.cpp
parentd4fdb84f80dd3dbad2b71ea6e877f24dc625aa2a (diff)
glsl: Add API to put default precision qualifiers in the symbol table
These have scoping rules that match the ones defined for other things such as variables, so we want them in the symbol table. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src/glsl/glsl_symbol_table.cpp')
-rw-r--r--src/glsl/glsl_symbol_table.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 536f0a3a8c2..6c682acf560 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -23,6 +23,7 @@
*/
#include "glsl_symbol_table.h"
+#include "ast.h"
class symbol_table_entry {
public:
@@ -201,6 +202,20 @@ bool glsl_symbol_table::add_function(ir_function *f)
return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0;
}
+bool glsl_symbol_table::add_default_precision_qualifier(const char *type_name,
+ int precision)
+{
+ char *name = ralloc_asprintf(mem_ctx, "#default_precision_%s", type_name);
+
+ ast_type_specifier *default_specifier = new(mem_ctx) ast_type_specifier(name);
+ default_specifier->default_precision = precision;
+
+ symbol_table_entry *entry =
+ new(mem_ctx) symbol_table_entry(default_specifier);
+
+ return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0;
+}
+
void glsl_symbol_table::add_global_function(ir_function *f)
{
symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f);
@@ -234,6 +249,15 @@ ir_function *glsl_symbol_table::get_function(const char *name)
return entry != NULL ? entry->f : NULL;
}
+int glsl_symbol_table::get_default_precision_qualifier(const char *type_name)
+{
+ char *name = ralloc_asprintf(mem_ctx, "#default_precision_%s", type_name);
+ symbol_table_entry *entry = get_entry(name);
+ if (!entry)
+ return ast_precision_none;
+ return entry->a->default_precision;
+}
+
symbol_table_entry *glsl_symbol_table::get_entry(const char *name)
{
return (symbol_table_entry *)