Commit c9d9b30a by Nicolas Capens

Set symbol extension at insertion.

BUG=angle:926 Change-Id: I4c96ae89c79d720d99bde803541c3158ba4629ab Reviewed-on: https://chromium-review.googlesource.com/251662Tested-by: 's avatarNicolas Capens <capn@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 05ae50dc
...@@ -57,22 +57,6 @@ TSymbol *TSymbolTableLevel::find(const TString &name) const ...@@ -57,22 +57,6 @@ TSymbol *TSymbolTableLevel::find(const TString &name) const
return (*it).second; return (*it).second;
} }
//
// Change all function entries in the table with the non-mangled name
// to be related to the provided built-in extension. This is a low
// performance operation, and only intended for symbol tables that
// live across a large number of compiles.
//
void TSymbolTableLevel::relateToExtension(const char *name, const TString &ext)
{
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
{
TSymbol *symbol = it->second;
if (symbol->getName() == name)
symbol->relateToExtension(ext);
}
}
TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, TSymbol *TSymbolTable::find(const TString &name, int shaderVersion,
bool *builtIn, bool *sameScope) const bool *builtIn, bool *sameScope) const
{ {
...@@ -187,7 +171,8 @@ TType *VectorType(TType *type, int size) ...@@ -187,7 +171,8 @@ TType *VectorType(TType *type, int size)
} }
} }
void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue, const char *name, TType *ptype1, TType *ptype2, TType *ptype3, TType *ptype4, TType *ptype5) void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, TType *rvalue, const char *name,
TType *ptype1, TType *ptype2, TType *ptype3, TType *ptype4, TType *ptype5)
{ {
if (ptype1->getBasicType() == EbtGSampler2D) if (ptype1->getBasicType() == EbtGSampler2D)
{ {
...@@ -220,21 +205,21 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue ...@@ -220,21 +205,21 @@ void TSymbolTable::insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue
else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3)) else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3))
{ {
ASSERT(!ptype4 && !ptype5); ASSERT(!ptype4 && !ptype5);
insertBuiltIn(level, op, SpecificType(rvalue, 1), name, SpecificType(ptype1, 1), SpecificType(ptype2, 1), SpecificType(ptype3, 1)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 1), name, SpecificType(ptype1, 1), SpecificType(ptype2, 1), SpecificType(ptype3, 1));
insertBuiltIn(level, op, SpecificType(rvalue, 2), name, SpecificType(ptype1, 2), SpecificType(ptype2, 2), SpecificType(ptype3, 2)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 2), name, SpecificType(ptype1, 2), SpecificType(ptype2, 2), SpecificType(ptype3, 2));
insertBuiltIn(level, op, SpecificType(rvalue, 3), name, SpecificType(ptype1, 3), SpecificType(ptype2, 3), SpecificType(ptype3, 3)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 3), name, SpecificType(ptype1, 3), SpecificType(ptype2, 3), SpecificType(ptype3, 3));
insertBuiltIn(level, op, SpecificType(rvalue, 4), name, SpecificType(ptype1, 4), SpecificType(ptype2, 4), SpecificType(ptype3, 4)); insertBuiltIn(level, op, ext, SpecificType(rvalue, 4), name, SpecificType(ptype1, 4), SpecificType(ptype2, 4), SpecificType(ptype3, 4));
} }
else if (IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3)) else if (IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3))
{ {
ASSERT(!ptype4 && !ptype5); ASSERT(!ptype4 && !ptype5);
insertBuiltIn(level, op, VectorType(rvalue, 2), name, VectorType(ptype1, 2), VectorType(ptype2, 2), VectorType(ptype3, 2)); insertBuiltIn(level, op, ext, VectorType(rvalue, 2), name, VectorType(ptype1, 2), VectorType(ptype2, 2), VectorType(ptype3, 2));
insertBuiltIn(level, op, VectorType(rvalue, 3), name, VectorType(ptype1, 3), VectorType(ptype2, 3), VectorType(ptype3, 3)); insertBuiltIn(level, op, ext, VectorType(rvalue, 3), name, VectorType(ptype1, 3), VectorType(ptype2, 3), VectorType(ptype3, 3));
insertBuiltIn(level, op, VectorType(rvalue, 4), name, VectorType(ptype1, 4), VectorType(ptype2, 4), VectorType(ptype3, 4)); insertBuiltIn(level, op, ext, VectorType(rvalue, 4), name, VectorType(ptype1, 4), VectorType(ptype2, 4), VectorType(ptype3, 4));
} }
else else
{ {
TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op); TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op, ext);
TParameter param1 = {0, ptype1}; TParameter param1 = {0, ptype1};
function->addParameter(param1); function->addParameter(param1);
......
...@@ -186,13 +186,14 @@ class TFunction : public TSymbol ...@@ -186,13 +186,14 @@ class TFunction : public TSymbol
defined(false) defined(false)
{ {
} }
TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull) TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull, const char *ext = "")
: TSymbol(name), : TSymbol(name),
returnType(retType), returnType(retType),
mangledName(TFunction::mangleName(*name)), mangledName(TFunction::mangleName(*name)),
op(tOp), op(tOp),
defined(false) defined(false)
{ {
relateToExtension(ext);
} }
virtual ~TFunction(); virtual ~TFunction();
virtual bool isFunction() const virtual bool isFunction() const
...@@ -289,8 +290,6 @@ class TSymbolTableLevel ...@@ -289,8 +290,6 @@ class TSymbolTableLevel
TSymbol *find(const TString &name) const; TSymbol *find(const TString &name) const;
void relateToExtension(const char *name, const TString &ext);
protected: protected:
tLevel level; tLevel level;
}; };
...@@ -358,6 +357,12 @@ class TSymbolTable ...@@ -358,6 +357,12 @@ class TSymbolTable
return table[level]->insert(symbol); return table[level]->insert(symbol);
} }
bool insert(ESymbolLevel level, const char *ext, TSymbol *symbol)
{
symbol->relateToExtension(ext);
return table[level]->insert(symbol);
}
bool insertConstInt(ESymbolLevel level, const char *name, int value) bool insertConstInt(ESymbolLevel level, const char *name, int value)
{ {
TVariable *constant = new TVariable( TVariable *constant = new TVariable(
...@@ -366,13 +371,25 @@ class TSymbolTable ...@@ -366,13 +371,25 @@ class TSymbolTable
return insert(level, constant); return insert(level, constant);
} }
void insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue, const char *name, void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, TType *rvalue, const char *name,
TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0);
TType *ptype4 = 0, TType *ptype5 = 0);
void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0) void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name,
TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0)
{ {
insertBuiltIn(level, EOpNull, rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5); insertBuiltIn(level, EOpNull, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5);
}
void insertBuiltIn(ESymbolLevel level, const char *ext, TType *rvalue, const char *name,
TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0)
{
insertBuiltIn(level, EOpNull, ext, rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5);
}
void insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue, const char *name,
TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0)
{
insertBuiltIn(level, op, "", rvalue, name, ptype1, ptype2, ptype3, ptype4, ptype5);
} }
TSymbol *find(const TString &name, int shaderVersion, TSymbol *find(const TString &name, int shaderVersion,
...@@ -385,10 +402,6 @@ class TSymbolTable ...@@ -385,10 +402,6 @@ class TSymbolTable
return table[currentLevel() - 1]; return table[currentLevel() - 1];
} }
void relateToExtension(ESymbolLevel level, const char *name, const TString &ext)
{
table[level]->relateToExtension(name, ext);
}
void dump(TInfoSink &infoSink) const; void dump(TInfoSink &infoSink) const;
bool setDefaultPrecision(const TPublicType &type, TPrecision prec) bool setDefaultPrecision(const TPublicType &type, TPrecision prec)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment