Assign unique id's to symbols inserted directly into a symbol table level.
TRAC #23359
Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
Author: Nicolas Capens
diff --git a/src/compiler/SymbolTable.cpp b/src/compiler/SymbolTable.cpp
index c9c6291..d225b39 100644
--- a/src/compiler/SymbolTable.cpp
+++ b/src/compiler/SymbolTable.cpp
@@ -20,6 +20,8 @@
#include "common/angleutils.h"
+int TSymbolTableLevel::uniqueId = 0;
+
TType::TType(const TPublicType &p) :
type(p.type), precision(p.precision), qualifier(p.qualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), layoutQualifier(p.layoutQualifier), arraySize(p.arraySize),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
diff --git a/src/compiler/SymbolTable.h b/src/compiler/SymbolTable.h
index 8365df3..caf2e05 100644
--- a/src/compiler/SymbolTable.h
+++ b/src/compiler/SymbolTable.h
@@ -113,7 +113,7 @@
//
struct TParameter {
TString *name;
- TType* type;
+ TType *type;
};
//
@@ -196,8 +196,10 @@
TSymbolTableLevel() { }
~TSymbolTableLevel();
- bool insert(TSymbol& symbol)
+ bool insert(TSymbol &symbol)
{
+ symbol.setUniqueId(++uniqueId);
+
//
// returning true means symbol was added to the table
//
@@ -216,21 +218,12 @@
return (*it).second;
}
- const_iterator begin() const
- {
- return level.begin();
- }
-
- const_iterator end() const
- {
- return level.end();
- }
-
void relateToOperator(const char* name, TOperator op);
void relateToExtension(const char* name, const TString& ext);
protected:
tLevel level;
+ static int uniqueId; // for unique identification in code generation
};
enum ESymbolLevel
@@ -244,7 +237,7 @@
class TSymbolTable {
public:
- TSymbolTable() : uniqueId(0)
+ TSymbolTable()
{
//
// The symbol table cannot be used until push() is called, but
@@ -280,14 +273,13 @@
precisionStack.pop_back();
}
- bool declare(TSymbol& symbol)
+ bool declare(TSymbol &symbol)
{
return insert(currentLevel(), symbol);
}
- bool insert(ESymbolLevel level, TSymbol& symbol)
+ bool insert(ESymbolLevel level, TSymbol &symbol)
{
- symbol.setUniqueId(++uniqueId);
return table[level]->insert(symbol);
}
@@ -305,7 +297,6 @@
void relateToExtension(ESymbolLevel level, const char* name, const TString& ext) {
table[level]->relateToExtension(name, ext);
}
- int getMaxSymbolId() { return uniqueId; }
bool setDefaultPrecision( const TPublicType& type, TPrecision prec ){
if (IsSampler(type.type))
@@ -347,7 +338,6 @@
std::vector<TSymbolTableLevel*> table;
typedef std::map< TBasicType, TPrecision > PrecisionStackLevel;
std::vector< PrecisionStackLevel > precisionStack;
- int uniqueId; // for unique identification in code generation
};
#endif // _SYMBOL_TABLE_INCLUDED_