Memory management hygiene: Use compare() instead of substr(), and put a few more things intrinsically in the memory pool.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23467 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
3afe67dcc2
commit
4c70685382
10 changed files with 45 additions and 41 deletions
|
|
@ -1692,7 +1692,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||
if (version < FirstProfileVersion || profile == ECompatibilityProfile || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
|
||||
TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
|
||||
TType fragData(EbtFloat, EvqFragColor, pq, 4);
|
||||
TArraySizes* arraySizes = NewPoolTArraySizes();
|
||||
TArraySizes* arraySizes = new TArraySizes;
|
||||
arraySizes->setSize(resources.maxDrawBuffers);
|
||||
fragData.setArraySizes(arraySizes);
|
||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
||||
|
|
|
|||
|
|
@ -1204,7 +1204,7 @@ void TParseContext::globalCheck(TSourceLoc loc, bool global, const char* token)
|
|||
bool TParseContext::reservedErrorCheck(TSourceLoc loc, const TString& identifier)
|
||||
{
|
||||
if (! symbolTable.atBuiltInLevel()) {
|
||||
if (identifier.substr(0, 3) == TString("gl_")) {
|
||||
if (identifier.compare(0, 3, "gl_") == 0) {
|
||||
error(loc, "reserved built-in name", "gl_", "");
|
||||
|
||||
return true;
|
||||
|
|
@ -1826,7 +1826,7 @@ void TParseContext::nonInitConstCheck(TSourceLoc loc, TString& identifier, TType
|
|||
//
|
||||
TVariable* TParseContext::redeclareBuiltin(TSourceLoc loc, const TString& identifier, bool& newDeclaration)
|
||||
{
|
||||
if (profile == EEsProfile || identifier.substr(0, 3) != TString("gl_") || symbolTable.atBuiltInLevel())
|
||||
if (profile == EEsProfile || identifier.compare(0, 3, "gl_") != 0 || symbolTable.atBuiltInLevel())
|
||||
return 0;
|
||||
|
||||
// Potentially redeclaring a built-in variable...
|
||||
|
|
@ -2416,7 +2416,7 @@ void TParseContext::addBlock(TSourceLoc loc, TTypeList& typeList, const TString*
|
|||
|
||||
// make an anonymous variable if no name was provided
|
||||
if (! instanceName)
|
||||
instanceName = new TString("");
|
||||
instanceName = NewPoolTString("");
|
||||
|
||||
TVariable* variable = new TVariable(instanceName, blockType);
|
||||
if (! symbolTable.insert(*variable)) {
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
|
|||
while (candidate != level.end()) {
|
||||
const TString& candidateName = (*candidate).first;
|
||||
TString::size_type parenAt = candidateName.find_first_of('(');
|
||||
if (parenAt != candidateName.npos && candidateName.substr(0, parenAt) == name) {
|
||||
if (parenAt != candidateName.npos && candidateName.compare(0, parenAt, name) == 0) {
|
||||
TFunction* function = (*candidate).second->getAsFunction();
|
||||
function->relateToOperator(op);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
virtual ~TSymbol() { }
|
||||
|
||||
const TString& getName() const { return *name; }
|
||||
void changeName(const char* buf) { name = new TString(buf); }
|
||||
void changeName(const TString* newName) { name = newName; }
|
||||
virtual const TString& getMangledName() const { return getName(); }
|
||||
virtual TFunction* getAsFunction() { return 0; }
|
||||
virtual const TFunction* getAsFunction() const { return 0; }
|
||||
|
|
@ -257,7 +257,7 @@ public:
|
|||
// Give it a name and insert its members in the symbol table, pointing to the container.
|
||||
char buf[20];
|
||||
snprintf(buf, 20, "__anon__%d", anonId++);
|
||||
symbol.changeName(buf);
|
||||
symbol.changeName(NewPoolTString(buf));
|
||||
|
||||
bool isOkay = true;
|
||||
const TTypeList& types = *symbol.getAsVariable()->getType().getStruct();
|
||||
|
|
@ -307,7 +307,7 @@ public:
|
|||
if (candidate != level.end()) {
|
||||
const TString& candidateName = (*candidate).first;
|
||||
TString::size_type parenAt = candidateName.find_first_of('(');
|
||||
if (parenAt != candidateName.npos && candidateName.substr(0, parenAt) == name)
|
||||
if (parenAt != candidateName.npos && candidateName.compare(0, parenAt, name) == 0)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ block_structure
|
|||
|
||||
identifier_list
|
||||
: COMMA IDENTIFIER {
|
||||
$$ = NewPoolTIdentifierList();
|
||||
$$ = new TIdentifierList;
|
||||
$$->push_back($2.string);
|
||||
}
|
||||
| identifier_list COMMA IDENTIFIER {
|
||||
|
|
@ -1291,12 +1291,12 @@ type_specifier
|
|||
array_specifier
|
||||
: LEFT_BRACKET RIGHT_BRACKET {
|
||||
$$.loc = $1.loc;
|
||||
$$.arraySizes = NewPoolTArraySizes();
|
||||
$$.arraySizes = new TArraySizes;
|
||||
$$.arraySizes->setSize(0);
|
||||
}
|
||||
| LEFT_BRACKET constant_expression RIGHT_BRACKET {
|
||||
$$.loc = $1.loc;
|
||||
$$.arraySizes = NewPoolTArraySizes();
|
||||
$$.arraySizes = new TArraySizes;
|
||||
|
||||
int size;
|
||||
parseContext.arraySizeCheck($2->getLoc(), $2, size);
|
||||
|
|
@ -2051,7 +2051,7 @@ struct_declaration
|
|||
|
||||
struct_declarator_list
|
||||
: struct_declarator {
|
||||
$$ = NewPoolTTypeList();
|
||||
$$ = new TTypeList;
|
||||
$$->push_back($1);
|
||||
}
|
||||
| struct_declarator_list COMMA struct_declarator {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue