Hash :
f128872e
Author :
Date :
2025-09-16T23:37:08
Translator: Compare variables by unique id instead of pointer Bug: angleproject:349994211 Change-Id: I32ab2ffe9a04e196330949484e704913d0f4e41d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6955119 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuxin Hu <yuxinhu@google.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 40 41 42 43 44 45 46 47 48 49 50
//
// 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/angleutils.h"
#include "common/hash_containers.h"
namespace sh
{
class TCompiler;
class TIntermBlock;
class TIntermTyped;
class TSymbolTable;
class TSymbolUniqueId;
class TVariable;
[[nodiscard]] bool ReplaceVariable(TCompiler *compiler,
TIntermBlock *root,
const TVariable *toBeReplaced,
const TVariable *replacement);
[[nodiscard]] bool ReplaceVariableWithTyped(TCompiler *compiler,
TIntermBlock *root,
const TVariable *toBeReplaced,
const TIntermTyped *replacement);
using VariableReplacementMap = angle::HashMap<TSymbolUniqueId, const TIntermTyped *>;
// Replace a set of variables with their corresponding expression.
[[nodiscard]] 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_