Clean up TSymbol initialization
Now TSymbol objects always get their id when they are constructed. The
id cannot be changed after the TSymbol is created.
This makes it simpler to insert both mangled and unmangled versions of
a function to the symbol table. These can now both share the same
TSymbol object, unlike before, when inserting the same symbol twice
would have changed its symbol id.
This requires changes to function definition parsing: function
definition nodes now share any symbol created by previous prototype
declarations of the function. The parameters on the symbol get set to
the parameters in the function definition header.
BUG=angleproject:1490
TEST=angle_unittests
Change-Id: I8e600e9b5e5de27d64b85c5042cfd23ff02abe63
Reviewed-on: https://chromium-review.googlesource.com/396838
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index f092412..51a82f7 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -43,11 +43,8 @@
{
public:
POOL_ALLOCATOR_NEW_DELETE();
- TSymbol(const TString *n)
- : uniqueId(0),
- name(n)
- {
- }
+ TSymbol(const TString *n);
+
virtual ~TSymbol()
{
// don't delete name, it's from the pool
@@ -69,10 +66,6 @@
{
return false;
}
- void setUniqueId(int id)
- {
- uniqueId = id;
- }
int getUniqueId() const
{
return uniqueId;
@@ -87,7 +80,7 @@
}
private:
- int uniqueId; // For real comparing during code generation
+ const int uniqueId;
const TString *name;
TString extension;
};
@@ -229,6 +222,8 @@
mangledName = nullptr;
}
+ void swapParameters(const TFunction ¶metersSource);
+
const TString &getMangledName() const override
{
if (mangledName == nullptr)
@@ -262,6 +257,8 @@
}
private:
+ void clearParameters();
+
const TString *buildMangledName() const;
typedef TVector<TConstParameter> TParamList;