Commit b50ccd36 by Martin Radev Committed by Commit Bot

Use FindMainBody to retrieve node of main()'s body

The patch addresses code duplication in cases in which main()'s body node has to be retrieved from the AST. TEST=angle_unittests Change-Id: I0ccee41821a5ecb2cdf09f5a928b178d6c037587 Reviewed-on: https://chromium-review.googlesource.com/561521Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 318f9aa5
...@@ -106,10 +106,7 @@ void InsertInitCodeToMain(TIntermBlock *root, TIntermSequence *deferredInitializ ...@@ -106,10 +106,7 @@ void InsertInitCodeToMain(TIntermBlock *root, TIntermSequence *deferredInitializ
TIntermBlock *initGlobalsBlock = new TIntermBlock(); TIntermBlock *initGlobalsBlock = new TIntermBlock();
initGlobalsBlock->getSequence()->swap(*deferredInitializers); initGlobalsBlock->getSequence()->swap(*deferredInitializers);
TIntermFunctionDefinition *main = FindMain(root); TIntermBlock *mainBody = FindMainBody(root);
ASSERT(main != nullptr);
TIntermBlock *mainBody = main->getBody();
ASSERT(mainBody != nullptr);
mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initGlobalsBlock); mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initGlobalsBlock);
} }
......
...@@ -84,7 +84,7 @@ void GLFragColorBroadcastTraverser::broadcastGLFragColor(TIntermBlock *root) ...@@ -84,7 +84,7 @@ void GLFragColorBroadcastTraverser::broadcastGLFragColor(TIntermBlock *root)
{ {
return; return;
} }
TIntermSequence *mainSequence = FindMain(root)->getBody()->getSequence(); TIntermSequence *mainSequence = FindMainBody(root)->getSequence();
// Now insert statements // Now insert statements
// gl_FragData[1] = gl_FragData[0]; // gl_FragData[1] = gl_FragData[0];
// ... // ...
......
...@@ -224,10 +224,7 @@ void InitializeVariables(TIntermBlock *root, ...@@ -224,10 +224,7 @@ void InitializeVariables(TIntermBlock *root,
ShShaderSpec shaderSpec, ShShaderSpec shaderSpec,
const TExtensionBehavior &extensionBehavior) const TExtensionBehavior &extensionBehavior)
{ {
TIntermBlock *body = FindMainBody(root);
TIntermFunctionDefinition *main = FindMain(root);
ASSERT(main != nullptr);
TIntermBlock *body = main->getBody();
InsertInitCode(body->getSequence(), vars, symbolTable, shaderVersion, shaderSpec, InsertInitCode(body->getSequence(), vars, symbolTable, shaderVersion, shaderSpec,
extensionBehavior); extensionBehavior);
} }
......
...@@ -100,9 +100,7 @@ void UseInterfaceBlockFields(TIntermBlock *root, ...@@ -100,9 +100,7 @@ void UseInterfaceBlockFields(TIntermBlock *root,
const InterfaceBlockList &blocks, const InterfaceBlockList &blocks,
const TSymbolTable &symbolTable) const TSymbolTable &symbolTable)
{ {
TIntermFunctionDefinition *main = FindMain(root); TIntermBlock *mainBody = FindMainBody(root);
TIntermBlock *mainBody = main->getBody();
ASSERT(mainBody);
InsertUseCode(mainBody->getSequence(), blocks, symbolTable); InsertUseCode(mainBody->getSequence(), blocks, symbolTable);
} }
......
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