// // 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_TREEUTIL_INTERMASNODE_H_ #define COMPILER_TRANSLATOR_TREEUTIL_INTERMASNODE_H_ #include "common/angleutils.h" #include "compiler/translator/IntermNode.h" #include namespace sh { namespace priv { template struct AsNode {}; template <> struct AsNode { static ANGLE_INLINE TIntermNode *exec(TIntermNode *node) { return node; } }; template <> struct AsNode { static ANGLE_INLINE TIntermTyped *exec(TIntermNode *node) { return node ? node->getAsTyped() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermSymbol *exec(TIntermNode *node) { return node ? node->getAsSymbolNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermConstantUnion *exec(TIntermNode *node) { return node ? node->getAsConstantUnion() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermFunctionPrototype *exec(TIntermNode *node) { return node ? node->getAsFunctionPrototypeNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermPreprocessorDirective *exec(TIntermNode *node) { return node ? node->getAsPreprocessorDirective() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermSwizzle *exec(TIntermNode *node) { return node ? node->getAsSwizzleNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermBinary *exec(TIntermNode *node) { return node ? node->getAsBinaryNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermUnary *exec(TIntermNode *node) { return node ? node->getAsUnaryNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermTernary *exec(TIntermNode *node) { return node ? node->getAsTernaryNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermIfElse *exec(TIntermNode *node) { return node ? node->getAsIfElseNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermSwitch *exec(TIntermNode *node) { return node ? node->getAsSwitchNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermCase *exec(TIntermNode *node) { return node ? node->getAsCaseNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermFunctionDefinition *exec(TIntermNode *node) { return node ? node->getAsFunctionDefinition() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermAggregate *exec(TIntermNode *node) { return node ? node->getAsAggregate() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermBlock *exec(TIntermNode *node) { return node ? node->getAsBlock() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermGlobalQualifierDeclaration *exec(TIntermNode *node) { return node ? node->getAsGlobalQualifierDeclarationNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermDeclaration *exec(TIntermNode *node) { return node ? node->getAsDeclarationNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermLoop *exec(TIntermNode *node) { return node ? node->getAsLoopNode() : nullptr; } }; template <> struct AsNode { static ANGLE_INLINE TIntermBranch *exec(TIntermNode *node) { return node ? node->getAsBranchNode() : nullptr; } }; } // namespace priv template ANGLE_INLINE T *asNode(TIntermNode *node) { return priv::AsNode::exec(node); } } // namespace sh #endif // COMPILER_TRANSLATOR_TREEUTIL_INTERMASNODE_H_