Hash :
beb6dc74
Author :
Date :
2017-12-14T16:03:03
Always use TFunction instead of TFunctionSymbolInfo This reduces unnecessary memory allocations and conversions between different objects containing the same data. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I87316509ab1cd6d36756ff6af7fa2b5c5a76a8ea Reviewed-on: https://chromium-review.googlesource.com/827134 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
//
// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FindMain.cpp: Find the main() function definition in a given AST.
#include "compiler/translator/FindMain.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/Symbol.h"
namespace sh
{
TIntermFunctionDefinition *FindMain(TIntermBlock *root)
{
for (TIntermNode *node : *root->getSequence())
{
TIntermFunctionDefinition *nodeFunction = node->getAsFunctionDefinition();
if (nodeFunction != nullptr && nodeFunction->getFunction()->isMain())
{
return nodeFunction;
}
}
return nullptr;
}
TIntermBlock *FindMainBody(TIntermBlock *root)
{
TIntermFunctionDefinition *main = FindMain(root);
ASSERT(main != nullptr);
TIntermBlock *mainBody = main->getBody();
ASSERT(mainBody != nullptr);
return mainBody;
}
} // namespace sh