[Mesa-dev] [PATCH 1/2] mesa/program: Add _mesa_symbol_table_replace_symbol()
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Thu Oct 20 10:39:58 UTC 2016
This function allows to modify an existing symbol.
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/mesa/program/symbol_table.c | 35 +++++++++++++++++++++++++++++++++++
src/mesa/program/symbol_table.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c
index 3e58432..4f6ccf4 100644
--- a/src/mesa/program/symbol_table.c
+++ b/src/mesa/program/symbol_table.c
@@ -313,6 +313,41 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
return 0;
}
+int
+_mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table,
+ int name_space, const char *name,
+ void *declaration)
+{
+ struct symbol_header *hdr;
+ struct symbol *tmp;
+ struct symbol *sym = NULL;
+
+ check_symbol_table(table);
+
+ hdr = find_symbol(table, name);
+
+ check_symbol_table(table);
+
+ if (hdr == NULL)
+ return -1;
+
+ /* If the symbol doesn't exist in this namespace at this scope, it cannot
+ * be replaced.
+ */
+ for (tmp = hdr->symbols ; tmp != NULL ; tmp = tmp->next_with_same_name) {
+ if (tmp->name_space == name_space) {
+ sym = tmp;
+ break;
+ }
+ }
+
+ if (sym == NULL)
+ return -1;
+
+ sym->data = declaration;
+ check_symbol_table(table);
+ return 0;
+}
int
_mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *table,
diff --git a/src/mesa/program/symbol_table.h b/src/mesa/program/symbol_table.h
index 1027f47..33a5bab 100644
--- a/src/mesa/program/symbol_table.h
+++ b/src/mesa/program/symbol_table.h
@@ -32,6 +32,9 @@ extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table);
extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab,
int name_space, const char *name, void *declaration);
+extern int _mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table,
+ int name_space, const char *name, void *declaration);
+
extern int _mesa_symbol_table_add_global_symbol(
struct _mesa_symbol_table *symtab, int name_space, const char *name,
void *declaration);
--
2.7.4
More information about the mesa-dev
mailing list