From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../src/compiler/translator/tree_util/NodeType.h | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 gfx/angle/checkout/src/compiler/translator/tree_util/NodeType.h (limited to 'gfx/angle/checkout/src/compiler/translator/tree_util/NodeType.h') diff --git a/gfx/angle/checkout/src/compiler/translator/tree_util/NodeType.h b/gfx/angle/checkout/src/compiler/translator/tree_util/NodeType.h new file mode 100644 index 0000000000..4ab63dbebb --- /dev/null +++ b/gfx/angle/checkout/src/compiler/translator/tree_util/NodeType.h @@ -0,0 +1,155 @@ +// +// 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_TRANSLATORMETALDIRECT_NODETYPE_H_ +#define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_NODETYPE_H_ + +#include "compiler/translator/tree_util/IntermTraverse.h" + +namespace sh +{ + +enum class NodeType +{ + Unknown, + Symbol, + ConstantUnion, + FunctionPrototype, + PreprocessorDirective, + Unary, + Binary, + Ternary, + Swizzle, + IfElse, + Switch, + Case, + FunctionDefinition, + Aggregate, + Block, + GlobalQualifierDeclaration, + Declaration, + Loop, + Branch, +}; + +// This is a function like object instead of a function that stack allocates this because +// TIntermTraverser is a heavy object to construct. +class GetNodeType : private TIntermTraverser +{ + NodeType nodeType; + + public: + GetNodeType() : TIntermTraverser(true, false, false) {} + + NodeType operator()(TIntermNode &node) + { + node.visit(Visit::PreVisit, this); + return nodeType; + } + + private: + void visitSymbol(TIntermSymbol *) override { nodeType = NodeType::Symbol; } + + void visitConstantUnion(TIntermConstantUnion *) override { nodeType = NodeType::ConstantUnion; } + + void visitFunctionPrototype(TIntermFunctionPrototype *) override + { + nodeType = NodeType::FunctionPrototype; + } + + void visitPreprocessorDirective(TIntermPreprocessorDirective *) override + { + nodeType = NodeType::PreprocessorDirective; + } + + bool visitSwizzle(Visit, TIntermSwizzle *) override + { + nodeType = NodeType::Swizzle; + return false; + } + + bool visitBinary(Visit, TIntermBinary *) override + { + nodeType = NodeType::Binary; + return false; + } + + bool visitUnary(Visit, TIntermUnary *) override + { + nodeType = NodeType::Unary; + return false; + } + + bool visitTernary(Visit, TIntermTernary *) override + { + nodeType = NodeType::Ternary; + return false; + } + + bool visitIfElse(Visit, TIntermIfElse *) override + { + nodeType = NodeType::IfElse; + return false; + } + + bool visitSwitch(Visit, TIntermSwitch *) override + { + nodeType = NodeType::Switch; + return false; + } + + bool visitCase(Visit, TIntermCase *) override + { + nodeType = NodeType::Case; + return false; + } + + bool visitFunctionDefinition(Visit, TIntermFunctionDefinition *) override + { + nodeType = NodeType::FunctionDefinition; + return false; + } + + bool visitAggregate(Visit, TIntermAggregate *) override + { + nodeType = NodeType::Aggregate; + return false; + } + + bool visitBlock(Visit, TIntermBlock *) override + { + nodeType = NodeType::Block; + return false; + } + + bool visitGlobalQualifierDeclaration(Visit, TIntermGlobalQualifierDeclaration *) override + { + nodeType = NodeType::GlobalQualifierDeclaration; + return false; + } + + bool visitDeclaration(Visit, TIntermDeclaration *) override + { + nodeType = NodeType::Declaration; + return false; + } + + bool visitLoop(Visit, TIntermLoop *) override + { + nodeType = NodeType::Loop; + return false; + } + + bool visitBranch(Visit, TIntermBranch *) override + { + nodeType = NodeType::Branch; + return false; + } +}; + +} // namespace sh + +#endif // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_NODETYPE_H_ -- cgit v1.2.3