Edit

kc3-lang/angle/src/compiler/translator/tree_util/ReplaceVariable.h

Branch :

  • Show log

    Commit

  • Author : Shahbaz Youssefi
    Date : 2021-01-17 14:24:53
    Hash : 2b242f53
    Message : Vulkan: Simplify RewriteCubeMapSamplersAs2DArray This change is mostly done to remove an unnecessary helper in ReplaceVariable.cpp. Tested locally, as the bots all support ES3.1+. There are a few failures, with or without this change. Bug: angleproject:5556 Change-Id: I7bd2d4294c9dc164146d713db6b45cbc73e59c16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633437 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>

  • src/compiler/translator/tree_util/ReplaceVariable.h
  • //
    // Copyright 2018 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.
    //
    // ReplaceVariable.h: Replace all references to a specific variable in the AST with references to
    // another variable.
    
    #ifndef COMPILER_TRANSLATOR_TREEUTIL_REPLACEVARIABLE_H_
    #define COMPILER_TRANSLATOR_TREEUTIL_REPLACEVARIABLE_H_
    
    #include "common/debug.h"
    
    #include <stack>
    #include <unordered_map>
    
    namespace sh
    {
    
    class TCompiler;
    class TFunction;
    class TIntermAggregate;
    class TIntermBlock;
    class TIntermFunctionPrototype;
    class TIntermNode;
    class TIntermTyped;
    class TSymbolTable;
    class TVariable;
    
    ANGLE_NO_DISCARD bool ReplaceVariable(TCompiler *compiler,
                                          TIntermBlock *root,
                                          const TVariable *toBeReplaced,
                                          const TVariable *replacement);
    ANGLE_NO_DISCARD bool ReplaceVariableWithTyped(TCompiler *compiler,
                                                   TIntermBlock *root,
                                                   const TVariable *toBeReplaced,
                                                   const TIntermTyped *replacement);
    
    using VariableReplacementMap = angle::HashMap<const TVariable *, const TIntermTyped *>;
    
    // Replace a set of variables with their corresponding expression.
    ANGLE_NO_DISCARD bool ReplaceVariables(TCompiler *compiler,
                                           TIntermBlock *root,
                                           const VariableReplacementMap &variableMap);
    
    // Find all declarators, and replace the TVariable they are declaring with a duplicate.  This is
    // used to support deepCopy of TIntermBlock and TIntermLoop nodes that include declarations.
    // Replacements already present in variableMap are preserved.
    void GetDeclaratorReplacements(TSymbolTable *symbolTable,
                                   TIntermBlock *root,
                                   VariableReplacementMap *variableMap);
    
    }  // namespace sh
    
    #endif  // COMPILER_TRANSLATOR_TREEUTIL_REPLACEVARIABLE_H_