Hash :
061188a7
        
        Author :
  
        
        Date :
2021-08-04T10:07:47
        
      
Translator: General clean up General clean up done as part of other changes, split to simplify review. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Iade9954d187a759be9edd0e3754be007f4133c56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3071598 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
//
// Copyright 2020 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.
//
// RunAtTheBeginningOfShader.cpp: Add code to be run at the beginning of the shader.
// void main() { body }
// =>
// void main()
// {
//     codeToRun
//     body
// }
//
#include "compiler/translator/tree_util/RunAtTheBeginningOfShader.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/SymbolTable.h"
#include "compiler/translator/tree_util/FindMain.h"
#include "compiler/translator/tree_util/IntermNode_util.h"
#include "compiler/translator/tree_util/IntermTraverse.h"
namespace sh
{
bool RunAtTheBeginningOfShader(TCompiler *compiler, TIntermBlock *root, TIntermNode *codeToRun)
{
    TIntermFunctionDefinition *main = FindMain(root);
    main->getBody()->insertStatement(0, codeToRun);
    return compiler->validateAST(root);
}
}  // namespace sh