// // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2012-2016 LunarG, Inc. // Copyright (C) 2017, 2022-2024 Arm Limited. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // Neither the name of 3Dlabs Inc. Ltd. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #include "localintermediate.h" #include "../Include/InfoSink.h" #ifdef _MSC_VER #include <cfloat> #else #include <cmath> #endif #include <cstdint> namespace glslang { // // Two purposes: // 1. Show an example of how to iterate tree. Functions can // also directly call Traverse() on children themselves to // have finer grained control over the process than shown here. // See the last function for how to get started. // 2. Print out a text based description of the tree. // // // Use this class to carry along data from node to node in // the traversal // class TOutputTraverser : public TIntermTraverser { … }; // // Helper functions for printing, not part of traversing. // static void OutputTreeText(TInfoSink& infoSink, const TIntermNode* node, const int depth) { … } // // The rest of the file are the traversal functions. The last one // is the one that starts the traversal. // // Return true from interior nodes to have the external traversal // continue on to children. If you process children yourself, // return false. // bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node) { … } bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node) { … } bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node) { … } bool TOutputTraverser::visitSelection(TVisit /* visit */, TIntermSelection* node) { … } // Print infinities and NaNs, and numbers in a portable way. // Goals: // - portable (across IEEE 754 platforms) // - shows all possible IEEE values // - shows simple numbers in a simple way, e.g., no leading/trailing 0s // - shows all digits, no premature rounding static void OutputDouble(TInfoSink& out, double value, TOutputTraverser::EExtraOutput extra) { … } static void OutputConstantUnion(TInfoSink& out, const TIntermTyped* node, const TConstUnionArray& constUnion, TOutputTraverser::EExtraOutput extra, int depth) { … } void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node) { … } void TOutputTraverser::visitSymbol(TIntermSymbol* node) { … } bool TOutputTraverser::visitLoop(TVisit /* visit */, TIntermLoop* node) { … } bool TOutputTraverser::visitBranch(TVisit /* visit*/, TIntermBranch* node) { … } bool TOutputTraverser::visitSwitch(TVisit /* visit */, TIntermSwitch* node) { … } // // This function is the one to call externally to start the traversal. // Individual functions can be initialized to 0 to skip processing of that // type of node. It's children will still be processed. // void TIntermediate::output(TInfoSink& infoSink, bool tree) { … } } // end namespace glslang