// // 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. // #ifndef COMPILER_TRANSLATOR_INTERMREBUILD_H_ #define COMPILER_TRANSLATOR_INTERMREBUILD_H_ #include "compiler/translator/NodeType.h" #include "compiler/translator/tree_util/IntermTraverse.h" namespace sh { // Walks the tree to rebuild nodes. // This class is intended to be derived with overridden visitXXX functions. // // Each visitXXX function that does not have a Visit parameter simply has the visitor called // exactly once, regardless of (preVisit) or (postVisit) values. // Each visitXXX function that has a Visit parameter behaves as follows: // * If (preVisit): // - The node is visited before children are traversed. // - The returned value is used to replace the visited node. The returned value may be the same // as the original node. // - If multiple nodes are returned, children and post visits of the returned nodes are not // preformed, even if it is a singleton collection. // * If (childVisit) // - If any new children are returned, the node is automatically rebuilt with the new children // before post visit. // - Depending on the type of the node, null children may be discarded. // - Ill-typed children cause rebuild errors. Ill-typed means the node to automatically rebuild // cannot accept a child of a certain type as input to its constructor. // - Only instances of TIntermAggregateBase can accept Multi results for any of its children. // If supplied, the nodes are spliced children at the spot of the original child. // * If (postVisit) // - The node is visited after any children are traversed. // - Only after such a rebuild (or lack thereof), the post-visit is performed. // // Nodes in visit functions are allowed to be modified in place, including TIntermAggregateBase // child sequences. // // The default implementations of all the visitXXX functions support full pre and post traversal // without modifying the visited nodes. // class TIntermRebuild : angle::NonCopyable { … }; } // namespace sh #endif // COMPILER_TRANSLATOR_INTERMREBUILD_H_