Commit b779b12c by Jamie Madill Committed by Commit Bot

Add kEmptyImmutableString.

We can use this instead of ImmutableString(""). Bug: angleproject:2665 Change-Id: I8b3d5d3075838b9f2caa1627071202e48a5fdc83 Reviewed-on: https://chromium-review.googlesource.com/1108085 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent 0bb940a8
...@@ -81,7 +81,7 @@ ImmutableString HashName(const TSymbol *symbol, ShHashFunction64 hashFunction, N ...@@ -81,7 +81,7 @@ ImmutableString HashName(const TSymbol *symbol, ShHashFunction64 hashFunction, N
{ {
if (symbol->symbolType() == SymbolType::Empty) if (symbol->symbolType() == SymbolType::Empty)
{ {
return ImmutableString(""); return kEmptyImmutableString;
} }
if (symbol->symbolType() == SymbolType::AngleInternal || if (symbol->symbolType() == SymbolType::AngleInternal ||
symbol->symbolType() == SymbolType::BuiltIn) symbol->symbolType() == SymbolType::BuiltIn)
......
...@@ -138,6 +138,7 @@ class ImmutableString ...@@ -138,6 +138,7 @@ class ImmutableString
size_t mLength; size_t mLength;
}; };
constexpr ImmutableString kEmptyImmutableString("");
} // namespace sh } // namespace sh
std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str); std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str);
......
...@@ -1679,7 +1679,7 @@ ImmutableString OutputHLSL::samplerNamePrefixFromStruct(TIntermTyped *node) ...@@ -1679,7 +1679,7 @@ ImmutableString OutputHLSL::samplerNamePrefixFromStruct(TIntermTyped *node)
} }
default: default:
UNREACHABLE(); UNREACHABLE();
return ImmutableString(""); return kEmptyImmutableString;
} }
} }
......
...@@ -2448,7 +2448,7 @@ TIntermDeclaration *TParseContext::parseSingleDeclaration( ...@@ -2448,7 +2448,7 @@ TIntermDeclaration *TParseContext::parseSingleDeclaration(
if (type->getBasicType() == EbtStruct) if (type->getBasicType() == EbtStruct)
{ {
TVariable *emptyVariable = TVariable *emptyVariable =
new TVariable(&symbolTable, ImmutableString(""), type, SymbolType::Empty); new TVariable(&symbolTable, kEmptyImmutableString, type, SymbolType::Empty);
symbol = new TIntermSymbol(emptyVariable); symbol = new TIntermSymbol(emptyVariable);
} }
else if (IsAtomicCounter(publicType.getBasicType())) else if (IsAtomicCounter(publicType.getBasicType()))
......
...@@ -184,7 +184,7 @@ void TFunction::addParameter(const TVariable *p) ...@@ -184,7 +184,7 @@ void TFunction::addParameter(const TVariable *p)
mParametersVector->push_back(p); mParametersVector->push_back(p);
mParameters = mParametersVector->data(); mParameters = mParametersVector->data();
mParamCount = mParametersVector->size(); mParamCount = mParametersVector->size();
mMangledName = ImmutableString(""); mMangledName = kEmptyImmutableString;
} }
void TFunction::shareParameters(const TFunction &parametersSource) void TFunction::shareParameters(const TFunction &parametersSource)
......
...@@ -162,7 +162,7 @@ class RewriteStructSamplers final : public TIntermTraverser ...@@ -162,7 +162,7 @@ class RewriteStructSamplers final : public TIntermTraverser
new TStructure(mSymbolTable, structure->name(), newFieldList, structure->symbolType()); new TStructure(mSymbolTable, structure->name(), newFieldList, structure->symbolType());
TType *newStructType = new TType(newStruct, true); TType *newStructType = new TType(newStruct, true);
TVariable *newStructVar = TVariable *newStructVar =
new TVariable(mSymbolTable, ImmutableString(""), newStructType, SymbolType::Empty); new TVariable(mSymbolTable, kEmptyImmutableString, newStructType, SymbolType::Empty);
TIntermSymbol *newStructRef = new TIntermSymbol(newStructVar); TIntermSymbol *newStructRef = new TIntermSymbol(newStructVar);
TIntermDeclaration *structDecl = new TIntermDeclaration; TIntermDeclaration *structDecl = new TIntermDeclaration;
...@@ -329,13 +329,13 @@ class NameEmbeddedUniformStructsTraverser : public TIntermTraverser ...@@ -329,13 +329,13 @@ class NameEmbeddedUniformStructsTraverser : public TIntermTraverser
const TStructure *oldStructure) const TStructure *oldStructure)
{ {
// struct <structName> { ... }; // struct <structName> { ... };
TStructure *structure = new TStructure(mSymbolTable, ImmutableString(""), TStructure *structure = new TStructure(mSymbolTable, kEmptyImmutableString,
&oldStructure->fields(), SymbolType::AngleInternal); &oldStructure->fields(), SymbolType::AngleInternal);
TType *namedType = new TType(structure, true); TType *namedType = new TType(structure, true);
namedType->setQualifier(EvqGlobal); namedType->setQualifier(EvqGlobal);
TVariable *structVariable = TVariable *structVariable =
new TVariable(mSymbolTable, ImmutableString(""), namedType, SymbolType::Empty); new TVariable(mSymbolTable, kEmptyImmutableString, namedType, SymbolType::Empty);
TIntermSymbol *structDeclarator = new TIntermSymbol(structVariable); TIntermSymbol *structDeclarator = new TIntermSymbol(structVariable);
TIntermDeclaration *structDeclaration = new TIntermDeclaration; TIntermDeclaration *structDeclaration = new TIntermDeclaration;
structDeclaration->appendDeclarator(structDeclarator); structDeclaration->appendDeclarator(structDeclarator);
......
...@@ -607,7 +607,7 @@ declaration ...@@ -607,7 +607,7 @@ declaration
} }
| type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON { | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE SEMICOLON {
ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks"); ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks");
$$ = context->addInterfaceBlock(*$1, @2, ImmutableString($2.string), $3, ImmutableString(""), @$, NULL, @$); $$ = context->addInterfaceBlock(*$1, @2, ImmutableString($2.string), $3, kEmptyImmutableString, @$, NULL, @$);
} }
| type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON { | type_qualifier enter_struct struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON {
ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks"); ES3_OR_NEWER(ImmutableString($2.string), @1, "interface blocks");
...@@ -740,7 +740,7 @@ init_declarator_list ...@@ -740,7 +740,7 @@ init_declarator_list
single_declaration single_declaration
: fully_specified_type { : fully_specified_type {
$$.type = $1; $$.type = $1;
$$.intermDeclaration = context->parseSingleDeclaration($$.type, @1, ImmutableString("")); $$.intermDeclaration = context->parseSingleDeclaration($$.type, @1, kEmptyImmutableString);
} }
| fully_specified_type identifier { | fully_specified_type identifier {
$$.type = $1; $$.type = $1;
...@@ -1200,8 +1200,8 @@ struct_specifier ...@@ -1200,8 +1200,8 @@ struct_specifier
: STRUCT identifier LEFT_BRACE { context->enterStructDeclaration(@2, ImmutableString($2.string)); } struct_declaration_list RIGHT_BRACE { : STRUCT identifier LEFT_BRACE { context->enterStructDeclaration(@2, ImmutableString($2.string)); } struct_declaration_list RIGHT_BRACE {
$$ = context->addStructure(@1, @2, ImmutableString($2.string), $5); $$ = context->addStructure(@1, @2, ImmutableString($2.string), $5);
} }
| STRUCT LEFT_BRACE { context->enterStructDeclaration(@2, ImmutableString("")); } struct_declaration_list RIGHT_BRACE { | STRUCT LEFT_BRACE { context->enterStructDeclaration(@2, kEmptyImmutableString); } struct_declaration_list RIGHT_BRACE {
$$ = context->addStructure(@1, @$, ImmutableString(""), $4); $$ = context->addStructure(@1, @$, kEmptyImmutableString, $4);
} }
; ;
......
...@@ -3196,7 +3196,7 @@ yyreduce: ...@@ -3196,7 +3196,7 @@ yyreduce:
{ {
ES3_OR_NEWER(ImmutableString((yyvsp[-3].lex).string), (yylsp[-4]), "interface blocks"); ES3_OR_NEWER(ImmutableString((yyvsp[-3].lex).string), (yylsp[-4]), "interface blocks");
(yyval.interm.intermNode) = context->addInterfaceBlock(*(yyvsp[-4].interm.typeQualifierBuilder), (yylsp[-3]), ImmutableString((yyvsp[-3].lex).string), (yyvsp[-2].interm.fieldList), ImmutableString(""), (yyloc), NULL, (yyloc)); (yyval.interm.intermNode) = context->addInterfaceBlock(*(yyvsp[-4].interm.typeQualifierBuilder), (yylsp[-3]), ImmutableString((yyvsp[-3].lex).string), (yyvsp[-2].interm.fieldList), kEmptyImmutableString, (yyloc), NULL, (yyloc));
} }
break; break;
...@@ -3414,7 +3414,7 @@ yyreduce: ...@@ -3414,7 +3414,7 @@ yyreduce:
{ {
(yyval.interm).type = (yyvsp[0].interm.type); (yyval.interm).type = (yyvsp[0].interm.type);
(yyval.interm).intermDeclaration = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), ImmutableString("")); (yyval.interm).intermDeclaration = context->parseSingleDeclaration((yyval.interm).type, (yylsp[0]), kEmptyImmutableString);
} }
break; break;
...@@ -4398,14 +4398,14 @@ yyreduce: ...@@ -4398,14 +4398,14 @@ yyreduce:
case 229: case 229:
{ context->enterStructDeclaration((yylsp[0]), ImmutableString("")); } { context->enterStructDeclaration((yylsp[0]), kEmptyImmutableString); }
break; break;
case 230: case 230:
{ {
(yyval.interm.typeSpecifierNonArray) = context->addStructure((yylsp[-4]), (yyloc), ImmutableString(""), (yyvsp[-1].interm.fieldList)); (yyval.interm.typeSpecifierNonArray) = context->addStructure((yylsp[-4]), (yyloc), kEmptyImmutableString, (yyvsp[-1].interm.fieldList));
} }
break; break;
......
...@@ -115,7 +115,7 @@ bool PruneNoOpsTraverser::visitDeclaration(Visit, TIntermDeclaration *node) ...@@ -115,7 +115,7 @@ bool PruneNoOpsTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
type->setQualifier(EvqTemporary); type->setQualifier(EvqTemporary);
} }
TVariable *variable = TVariable *variable =
new TVariable(mSymbolTable, ImmutableString(""), type, SymbolType::Empty); new TVariable(mSymbolTable, kEmptyImmutableString, type, SymbolType::Empty);
queueReplacementWithParent(node, declaratorSymbol, new TIntermSymbol(variable), queueReplacementWithParent(node, declaratorSymbol, new TIntermSymbol(variable),
OriginalNode::IS_DROPPED); OriginalNode::IS_DROPPED);
} }
......
...@@ -207,7 +207,7 @@ void RemoveUnreferencedVariablesTraverser::removeVariableDeclaration(TIntermDecl ...@@ -207,7 +207,7 @@ void RemoveUnreferencedVariablesTraverser::removeVariableDeclaration(TIntermDecl
return; return;
} }
TVariable *emptyVariable = TVariable *emptyVariable =
new TVariable(mSymbolTable, ImmutableString(""), new TType(declarator->getType()), new TVariable(mSymbolTable, kEmptyImmutableString, new TType(declarator->getType()),
SymbolType::Empty); SymbolType::Empty);
queueReplacementWithParent(node, declarator, new TIntermSymbol(emptyVariable), queueReplacementWithParent(node, declarator, new TIntermSymbol(emptyVariable),
OriginalNode::IS_DROPPED); OriginalNode::IS_DROPPED);
......
...@@ -150,7 +150,7 @@ TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type) ...@@ -150,7 +150,7 @@ TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type)
ASSERT(symbolTable != nullptr); ASSERT(symbolTable != nullptr);
// TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created // TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created
// variable. This might need to be done in other places as well. // variable. This might need to be done in other places as well.
return new TVariable(symbolTable, ImmutableString(""), type, SymbolType::AngleInternal); return new TVariable(symbolTable, kEmptyImmutableString, type, SymbolType::AngleInternal);
} }
TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type, TQualifier qualifier) TVariable *CreateTempVariable(TSymbolTable *symbolTable, const TType *type, TQualifier qualifier)
......
...@@ -69,8 +69,9 @@ void WrapMainAndAppend(TIntermBlock *root, ...@@ -69,8 +69,9 @@ void WrapMainAndAppend(TIntermBlock *root,
TSymbolTable *symbolTable) TSymbolTable *symbolTable)
{ {
// Replace main() with main0() with the same body. // Replace main() with main0() with the same body.
TFunction *oldMain = new TFunction(symbolTable, ImmutableString(""), SymbolType::AngleInternal, TFunction *oldMain =
StaticType::GetBasic<EbtVoid>(), false); new TFunction(symbolTable, kEmptyImmutableString, SymbolType::AngleInternal,
StaticType::GetBasic<EbtVoid>(), false);
TIntermFunctionDefinition *oldMainDefinition = TIntermFunctionDefinition *oldMainDefinition =
CreateInternalFunctionDefinitionNode(*oldMain, main->getBody()); CreateInternalFunctionDefinitionNode(*oldMain, main->getBody());
......
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