diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/SymbolTable.h')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/SymbolTable.h | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/SymbolTable.h b/src/3rdparty/angle/src/compiler/translator/SymbolTable.h index 9cd74218dc..dfc65cb957 100644 --- a/src/3rdparty/angle/src/compiler/translator/SymbolTable.h +++ b/src/3rdparty/angle/src/compiler/translator/SymbolTable.h @@ -4,8 +4,8 @@ // found in the LICENSE file. // -#ifndef _SYMBOL_TABLE_INCLUDED_ -#define _SYMBOL_TABLE_INCLUDED_ +#ifndef COMPILER_TRANSLATOR_SYMBOLTABLE_H_ +#define COMPILER_TRANSLATOR_SYMBOLTABLE_H_ // // Symbol table for parsing. Has these design characteristics: @@ -38,7 +38,7 @@ #include "compiler/translator/IntermNode.h" // Symbol base class. (Can build functions or variables out of these...) -class TSymbol +class TSymbol : angle::NonCopyable { public: POOL_ALLOCATOR_NEW_DELETE(); @@ -86,8 +86,6 @@ class TSymbol } private: - DISALLOW_COPY_AND_ASSIGN(TSymbol); - int uniqueId; // For real comparing during code generation const TString *name; TString extension; @@ -158,8 +156,6 @@ class TVariable : public TSymbol } private: - DISALLOW_COPY_AND_ASSIGN(TVariable); - TType type; bool userType; // we are assuming that Pool Allocator will free the memory @@ -186,13 +182,14 @@ class TFunction : public TSymbol 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), returnType(retType), mangledName(TFunction::mangleName(*name)), op(tOp), defined(false) { + relateToExtension(ext); } virtual ~TFunction(); virtual bool isFunction() const @@ -224,10 +221,6 @@ class TFunction : public TSymbol return returnType; } - void relateToOperator(TOperator o) - { - op = o; - } TOperator getBuiltInOp() const { return op; @@ -252,8 +245,6 @@ class TFunction : public TSymbol } private: - DISALLOW_COPY_AND_ASSIGN(TFunction); - typedef TVector<TParameter> TParamList; TParamList parameters; TType returnType; @@ -291,10 +282,10 @@ class TSymbolTableLevel bool insert(TSymbol *symbol); - TSymbol *find(const TString &name) const; + // Insert a function using its unmangled name as the key. + bool insertUnmangled(TFunction *function); - void relateToOperator(const char *name, TOperator op); - void relateToExtension(const char *name, const TString &ext); + TSymbol *find(const TString &name) const; protected: tLevel level; @@ -310,7 +301,7 @@ const int ESSL3_BUILTINS = 2; const int LAST_BUILTIN_LEVEL = ESSL3_BUILTINS; const int GLOBAL_LEVEL = 3; -class TSymbolTable +class TSymbolTable : angle::NonCopyable { public: TSymbolTable() @@ -363,6 +354,12 @@ class TSymbolTable 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) { TVariable *constant = new TVariable( @@ -371,9 +368,26 @@ class TSymbolTable return insert(level, constant); } + void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, 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); + TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0, TType *ptype5 = 0) + { + 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, bool *builtIn = NULL, bool *sameScope = NULL) const; @@ -385,14 +399,6 @@ class TSymbolTable return table[currentLevel() - 1]; } - void relateToOperator(ESymbolLevel level, const char *name, TOperator op) - { - table[level]->relateToOperator(name, op); - } - void relateToExtension(ESymbolLevel level, const char *name, const TString &ext) - { - table[level]->relateToExtension(name, ext); - } void dump(TInfoSink &infoSink) const; bool setDefaultPrecision(const TPublicType &type, TPrecision prec) @@ -413,7 +419,7 @@ class TSymbolTable // This records invariant varyings declared through // "invariant varying_name;". - void addInvariantVarying(const TString &originalName) + void addInvariantVarying(const std::string &originalName) { mInvariantVaryings.insert(originalName); } @@ -421,7 +427,7 @@ class TSymbolTable // if it is set as invariant during the varying variable // declaration - this piece of information is stored in the // variable's type, not here. - bool isVaryingInvariant(const TString &originalName) const + bool isVaryingInvariant(const std::string &originalName) const { return (mGlobalInvariant || mInvariantVaryings.count(originalName) > 0); @@ -445,10 +451,10 @@ class TSymbolTable typedef TMap<TBasicType, TPrecision> PrecisionStackLevel; std::vector< PrecisionStackLevel *> precisionStack; - std::set<TString> mInvariantVaryings; + std::set<std::string> mInvariantVaryings; bool mGlobalInvariant; static int uniqueIdCounter; }; -#endif // _SYMBOL_TABLE_INCLUDED_ +#endif // COMPILER_TRANSLATOR_SYMBOLTABLE_H_ |