Refactored the way symbol tables are initialized and stored. This was done in response to the addition of EShSpec.
Symbol table entries depend on three things - language, spec (not now but may eventually), and built-in resources.
We used to build two global symbol-tables - one for each language. During each compile, one of the symbol table was
copied and resource-specific stuff was added. I have moved the symbol table to TCompiler that gets initilized when
compiler is created and reused for each compile. This makes it much cleaner and extensible in case a spec requires
special entries to be added to the symbol table.
PS: Sorry for the long CL, but all of it needed to be done in one CL. I have verified that everything still compiles
and passes all conformance tests.
Review URL: http://codereview.appspot.com/1864044
git-svn-id: https://angleproject.googlecode.com/svn/trunk@351 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/SymbolTable.h b/src/compiler/SymbolTable.h
index 87c6e8a..07c81d1 100644
--- a/src/compiler/SymbolTable.h
+++ b/src/compiler/SymbolTable.h
@@ -31,9 +31,9 @@
//
#include <assert.h>
-#include "compiler/Common.h"
-#include "compiler/intermediate.h"
+
#include "compiler/InfoSink.h"
+#include "compiler/intermediate.h"
//
// Symbol base class. (Can build functions or variables out of these...)
@@ -239,13 +239,6 @@
//
}
- TSymbolTable(TSymbolTable& symTable)
- {
- table.push_back(symTable.table[0]);
- precisionStack.push_back( symTable.precisionStack[0] );
- uniqueId = symTable.uniqueId;
- }
-
~TSymbolTable()
{
// level 0 is always built In symbols, so we never pop that out
@@ -259,11 +252,10 @@
// globals are at level 1.
//
bool isEmpty() { return table.size() == 0; }
- bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
- bool atSharedBuiltInLevel() { return table.size() == 1; }
- bool atGlobalLevel() { return table.size() <= 3; }
+ bool atBuiltInLevel() { return table.size() == 1; }
+ bool atGlobalLevel() { return table.size() <= 2; }
void push()
- {
+ {
table.push_back(new TSymbolTableLevel);
precisionStack.push_back( PrecisionStackLevel() );
}
@@ -297,7 +289,7 @@
return symbol;
}
- TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 3); return table[2]; }
+ TSymbolTableLevel* getGlobalLevel() { assert(table.size() >= 2); return table[1]; }
void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
int getMaxSymbolId() { return uniqueId; }
void dump(TInfoSink &infoSink) const;
@@ -329,7 +321,6 @@
protected:
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
- bool atDynamicBuiltInLevel() { return table.size() == 2; }
std::vector<TSymbolTableLevel*> table;
typedef std::map< TBasicType, TPrecision > PrecisionStackLevel;