mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
glsl: Track structs' ast_type_specifiers in symbol table.
Will be used in a future commit. An ast_type_specifier is stored (rather than an ast_struct_specifier) with the idea that we may have more general uses for this in the future. struct names are prefixed with '#ast.' to avoid collisions with the glsl_types in the symbol table. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
e641b5fbee
commit
5df807b06f
2 changed files with 27 additions and 4 deletions
|
|
@ -84,17 +84,19 @@ public:
|
|||
}
|
||||
|
||||
symbol_table_entry(ir_variable *v) :
|
||||
v(v), f(0), t(0), ibu(0), ibi(0), ibo(0) {}
|
||||
v(v), f(0), t(0), ibu(0), ibi(0), ibo(0), a(0) {}
|
||||
symbol_table_entry(ir_function *f) :
|
||||
v(0), f(f), t(0), ibu(0), ibi(0), ibo(0) {}
|
||||
v(0), f(f), t(0), ibu(0), ibi(0), ibo(0), a(0) {}
|
||||
symbol_table_entry(const glsl_type *t) :
|
||||
v(0), f(0), t(t), ibu(0), ibi(0), ibo(0) {}
|
||||
v(0), f(0), t(t), ibu(0), ibi(0), ibo(0), a(0) {}
|
||||
symbol_table_entry(const glsl_type *t, enum ir_variable_mode mode) :
|
||||
v(0), f(0), t(0), ibu(0), ibi(0), ibo(0)
|
||||
v(0), f(0), t(0), ibu(0), ibi(0), ibo(0), a(0)
|
||||
{
|
||||
assert(t->is_interface());
|
||||
add_interface(t, mode);
|
||||
}
|
||||
symbol_table_entry(const class ast_type_specifier *a):
|
||||
v(0), f(0), t(0), ibu(0), ibi(0), ibo(0), a(a) {}
|
||||
|
||||
ir_variable *v;
|
||||
ir_function *f;
|
||||
|
|
@ -102,6 +104,7 @@ public:
|
|||
const glsl_type *ibu;
|
||||
const glsl_type *ibi;
|
||||
const glsl_type *ibo;
|
||||
const class ast_type_specifier *a;
|
||||
};
|
||||
|
||||
glsl_symbol_table::glsl_symbol_table()
|
||||
|
|
@ -172,6 +175,15 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
|
|||
return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0;
|
||||
}
|
||||
|
||||
bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a)
|
||||
{
|
||||
symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a);
|
||||
char ast_name[strlen("#ast.") + strlen(name) + 1];
|
||||
strcpy(ast_name, "#ast.");
|
||||
strcat(ast_name + strlen("#ast."), name);
|
||||
return _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0;
|
||||
}
|
||||
|
||||
bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i,
|
||||
enum ir_variable_mode mode)
|
||||
{
|
||||
|
|
@ -223,6 +235,15 @@ const glsl_type *glsl_symbol_table::get_type(const char *name)
|
|||
return entry != NULL ? entry->t : NULL;
|
||||
}
|
||||
|
||||
const class ast_type_specifier *glsl_symbol_table::get_type_ast(const char *name)
|
||||
{
|
||||
char ast_name[strlen("#ast.") + strlen(name) + 1];
|
||||
strcpy(ast_name, "#ast.");
|
||||
strcat(ast_name + strlen("#ast."), name);
|
||||
symbol_table_entry *entry = get_entry(ast_name);
|
||||
return entry != NULL ? entry->a : NULL;
|
||||
}
|
||||
|
||||
const glsl_type *glsl_symbol_table::get_interface(const char *name,
|
||||
enum ir_variable_mode mode)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public:
|
|||
/*@{*/
|
||||
bool add_variable(ir_variable *v);
|
||||
bool add_type(const char *name, const glsl_type *t);
|
||||
bool add_type_ast(const char *name, const class ast_type_specifier *t);
|
||||
bool add_function(ir_function *f);
|
||||
bool add_interface(const char *name, const glsl_type *i,
|
||||
enum ir_variable_mode mode);
|
||||
|
|
@ -114,6 +115,7 @@ public:
|
|||
/*@{*/
|
||||
ir_variable *get_variable(const char *name);
|
||||
const glsl_type *get_type(const char *name);
|
||||
const class ast_type_specifier *get_type_ast(const char *name);
|
||||
ir_function *get_function(const char *name);
|
||||
const glsl_type *get_interface(const char *name,
|
||||
enum ir_variable_mode mode);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue