1 // 2 // Copyright (c) 2017 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // IntermNode_util.h: High-level utilities for creating AST nodes and node hierarchies. Mostly meant 7 // to be used in AST transforms. 8 9 #ifndef COMPILER_TRANSLATOR_INTERMNODEUTIL_H_ 10 #define COMPILER_TRANSLATOR_INTERMNODEUTIL_H_ 11 12 #include "compiler/translator/IntermNode.h" 13 14 namespace sh 15 { 16 17 TIntermFunctionPrototype *CreateInternalFunctionPrototypeNode(const TType &returnType, 18 const char *name, 19 const TSymbolUniqueId &functionId); 20 TIntermFunctionDefinition *CreateInternalFunctionDefinitionNode(const TType &returnType, 21 const char *name, 22 TIntermBlock *functionBody, 23 const TSymbolUniqueId &functionId); 24 TIntermAggregate *CreateInternalFunctionCallNode(const TType &returnType, 25 const char *name, 26 const TSymbolUniqueId &functionId, 27 TIntermSequence *arguments); 28 29 TIntermTyped *CreateZeroNode(const TType &type); 30 TIntermConstantUnion *CreateIndexNode(int index); 31 TIntermConstantUnion *CreateBoolNode(bool value); 32 33 TIntermSymbol *CreateTempSymbolNode(const TSymbolUniqueId &id, 34 const TType &type, 35 TQualifier qualifier); 36 TIntermDeclaration *CreateTempInitDeclarationNode(const TSymbolUniqueId &id, 37 TIntermTyped *initializer, 38 TQualifier qualifier); 39 40 // If the input node is nullptr, return nullptr. 41 // If the input node is a block node, return it. 42 // If the input node is not a block node, put it inside a block node and return that. 43 TIntermBlock *EnsureBlock(TIntermNode *node); 44 45 // Should be called from inside Compiler::compileTreeImpl() where the global level is in scope. 46 TIntermSymbol *ReferenceGlobalVariable(const TString &name, const TSymbolTable &symbolTable); 47 48 // Note: this can access desktop GLSL built-ins that are hidden from the parser. 49 TIntermSymbol *ReferenceBuiltInVariable(const TString &name, 50 const TSymbolTable &symbolTable, 51 int shaderVersion); 52 53 TIntermTyped *CreateBuiltInFunctionCallNode(const TString &name, 54 TIntermSequence *arguments, 55 const TSymbolTable &symbolTable, 56 int shaderVersion); 57 58 } // namespace sh 59 60 #endif // COMPILER_TRANSLATOR_INTERMNODEUTIL_H_