bool builtIn = false;
bool sameScope = false;
- TSymbol* symbol = symbolTable.find(identifier, &builtIn, &sameScope);
+ TSymbol* symbol = symbolTable.find(identifier, shaderVersion, &builtIn, &sameScope);
if (symbol == 0 || !sameScope) {
if (reservedErrorCheck(line, identifier))
return true;
bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, TSourceLoc line)
{
bool builtIn = false;
- TSymbol* symbol = symbolTable.find(node->getSymbol(), &builtIn);
+ TSymbol* symbol = symbolTable.find(node->getSymbol(), shaderVersion, &builtIn);
if (symbol == 0) {
error(line, " undeclared identifier", node->getSymbol().c_str());
return true;
// special casing to test index value of gl_FragData. If the accessed index is >= gl_MaxDrawBuffers
// its an error
if (node->getSymbol() == "gl_FragData") {
- TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", &builtIn);
+ TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", shaderVersion, &builtIn);
ASSERT(fragData);
int fragDataValue = static_cast<TVariable*>(fragData)->getConstPointer()[0].getIConst();
{
// First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename.
- const TSymbol* symbol = symbolTable.find(call->getName(), builtIn);
+ const TSymbol* symbol = symbolTable.find(call->getName(), shaderVersion, builtIn);
if (symbol == 0) {
- symbol = symbolTable.find(call->getMangledName(), builtIn);
+ symbol = symbolTable.find(call->getMangledName(), shaderVersion, builtIn);
}
if (symbol == 0) {
variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer());
}
} else if (initializer->getAsSymbolNode()) {
- const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol());
+ const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), shaderVersion);
const TVariable* tVar = static_cast<const TVariable*>(symbol);
ConstantUnion* constArray = tVar->getConstPointer();
//
// Symbol base class. (Can build functions or variables out of these...)
//
-class TSymbol {
+class TSymbol
+{
public:
POOL_ALLOCATOR_NEW_DELETE();
TSymbol(const TString *n) : name(n) { }
// different values for different types polymorphically, so this is
// just simple and pragmatic.
//
-class TVariable : public TSymbol {
+class TVariable : public TSymbol
+{
public:
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
virtual ~TVariable() { }
// The function sub-class of symbols and the parser will need to
// share this definition of a function parameter.
//
-struct TParameter {
+struct TParameter
+{
TString *name;
TType *type;
};
//
// The function sub-class of a symbol.
//
-class TFunction : public TSymbol {
+class TFunction : public TSymbol
+{
public:
TFunction(TOperator o) :
TSymbol(0),
}
void addParameter(TParameter& p)
- {
+ {
parameters.push_back(p);
mangledName = mangledName + p.type->getMangledName();
}
};
-class TSymbolTableLevel {
+class TSymbolTableLevel
+{
public:
typedef TMap<TString, TSymbol*> tLevel;
typedef tLevel::const_iterator const_iterator;
static int uniqueId; // for unique identification in code generation
};
-class TSymbolTable {
+class TSymbolTable
+{
public:
TSymbolTable()
{
}
void pop()
- {
- delete table[currentLevel()];
- table.pop_back();
+ {
+ delete table[currentLevel()];
+ table.pop_back();
precisionStack.pop_back();
}
- bool insert(TSymbol& symbol)
+ bool insert(TSymbol &symbol)
{
return table[currentLevel()]->insert(symbol);
}
return insert(*function);
}
- TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0)
+ TSymbol *find(const TString &name, int shaderVersion, bool *builtIn = false, bool *sameScope = false) const
{
int level = currentLevel();
TSymbol* symbol;
return symbol;
}
- TSymbol *findBuiltIn(const TString &name)
+ TSymbol *findBuiltIn(const TString &name, int shaderVersion) const
{
return table[0]->find(name);
}
- TSymbolTableLevel* getGlobalLevel() {
+ TSymbolTableLevel *getGlobalLevel() const
+ {
assert(table.size() >= 2);
return table[1];
}
- TSymbolTableLevel* getOuterLevel() {
+ TSymbolTableLevel *getOuterLevel() const
+ {
assert(table.size() >= 2);
return table[currentLevel() - 1];
}
- void relateToOperator(const char* name, TOperator op) {
+ void relateToOperator(const char* name, TOperator op)
+ {
table[0]->relateToOperator(name, op);
}
- void relateToExtension(const char* name, const TString& ext) {
+
+ void relateToExtension(const char* name, const TString& ext)
+ {
table[0]->relateToExtension(name, ext);
}
- bool setDefaultPrecision( const TPublicType& type, TPrecision prec ){
+ bool setDefaultPrecision(const TPublicType &type, TPrecision prec)
+ {
if (IsSampler(type.type))
return true; // Skip sampler types for the time being
if (type.type != EbtFloat && type.type != EbtInt)
return prec;
}
-protected:
- int currentLevel() const { return static_cast<int>(table.size()) - 1; }
+protected:
+ int currentLevel() const { return static_cast<int>(table.size() - 1); }
std::vector<TSymbolTableLevel*> table;
typedef std::map< TBasicType, TPrecision > PrecisionStackLevel;
bool valid = true;
TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable;
- TSymbol* symbol = symbolTable.find(node->getName());
+ TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->shaderVersion);
ASSERT(symbol && symbol->isFunction());
TFunction* function = static_cast<TFunction*>(symbol);
for (ParamIndex::const_iterator i = pIndex.begin();
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER;
- TSymbol* symbol = yyextra->symbolTable.find(yytext);
+ TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->shaderVersion);
if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName()));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName(), context->shaderVersion));
if (prevDec) {
if (prevDec->getReturnType() != $1->getReturnType()) {
context->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString());
: function_prototype {
TFunction* function = $1.function;
- const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName());
+ const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
if (builtIn)
{
context->recover();
}
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName()));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->shaderVersion));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER;
- TSymbol* symbol = yyextra->symbolTable.find(yytext);
+ TSymbol* symbol = yyextra->symbolTable.find(yytext, yyextra->shaderVersion);
if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getMangledName()));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getMangledName(), context->shaderVersion));
if (prevDec) {
if (prevDec->getReturnType() != (yyvsp[(1) - (2)].interm.function)->getReturnType()) {
context->error((yyvsp[(2) - (2)].lex).line, "overloaded functions must have the same return type", (yyvsp[(1) - (2)].interm.function)->getReturnType().getBasicString());
{
TFunction* function = (yyvsp[(1) - (1)].interm).function;
- const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName());
+ const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
if (builtIn)
{
context->recover();
}
- TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName()));
+ TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName(), context->shaderVersion));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
{\r
TRACE("(GLenum name = 0x%X)", name);\r
\r
- es2::Context *context = es2::getContext();\r
-\r
switch(name)\r
{\r
case GL_VENDOR:\r