From f175b4894ce712851d5deb7860291354d7d908e1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 2 Mar 2011 23:58:16 -0800 Subject: [PATCH] Make note of how many times a symbol is referenced. (Maybe for dead code stripping later on.) --- mojoshader_compiler.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mojoshader_compiler.c b/mojoshader_compiler.c index 9eaee6ab..3fc4e34a 100644 --- a/mojoshader_compiler.c +++ b/mojoshader_compiler.c @@ -69,6 +69,7 @@ typedef struct SymbolScope const char *symbol; const MOJOSHADER_astDataType *datatype; int index; // unique positive value within a function, negative if global. + int referenced; // non-zero if something looked for this symbol (so we know it's used). struct SymbolScope *next; } SymbolScope; @@ -351,6 +352,7 @@ static void push_symbol(Context *ctx, SymbolMap *map, const char *sym, item->symbol = sym; // cached strings, don't copy. item->index = index; item->datatype = dt; + item->referenced = 0; item->next = map->scope; map->scope = item; } // push_symbol @@ -471,8 +473,12 @@ static const MOJOSHADER_astDataType *find_symbol(Context *ctx, SymbolMap *map, c const void *_item = NULL; hash_find(map->hash, sym, &_item); SymbolScope *item = (SymbolScope *) _item; - if (item && _index) - *_index = item->index; + if (item != NULL) + { + item->referenced++; + if (_index != NULL) + *_index = item->index; + } // if return item ? item->datatype : NULL; } // find_symbol