diff options
author | Samuel Iglesias Gonsálvez <siglesias@igalia.com> | 2016-10-20 09:04:59 +0200 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2016-10-27 19:12:06 +0100 |
commit | 95b5a69093ac6b3ea750567cc400696735ae07bc (patch) | |
tree | c919f9fdf0f7a5bd7d65789a8b4a8f7d5576a288 | |
parent | ea37a0603773467a567fbdf933104410ad8c3916 (diff) |
mesa/program: Add _mesa_symbol_table_replace_symbol()
This function allows to modify an existing symbol.
v2:
- Remove namespace usage now that it was deleted.
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit dfbdb2c0b3559c46d93f10d636a88b9541304fc7)
Nominated-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
-rw-r--r-- | src/mesa/program/symbol_table.c | 14 | ||||
-rw-r--r-- | src/mesa/program/symbol_table.h | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c index 23cb7ec26b..37066c904c 100644 --- a/src/mesa/program/symbol_table.c +++ b/src/mesa/program/symbol_table.c @@ -211,6 +211,20 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, return 0; } +int +_mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table, + const char *name, + void *declaration) +{ + struct symbol *sym = find_symbol(table, name); + + /* If the symbol doesn't exist, it cannot be replaced. */ + if (sym == NULL) + return -1; + + sym->data = declaration; + 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 ff1e6f2065..cba47143ef 100644 --- a/src/mesa/program/symbol_table.h +++ b/src/mesa/program/symbol_table.h @@ -32,6 +32,10 @@ extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, const char *name, void *declaration); +extern int _mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table, + const char *name, + void *declaration); + extern int _mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *symtab, const char *name, |