1 // 2 // Copyright 2002 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 7 #ifndef COMPILER_TRANSLATOR_TREEOPS_SEPARATEDECLARATIONS_H_ 8 #define COMPILER_TRANSLATOR_TREEOPS_SEPARATEDECLARATIONS_H_ 9 10 #include "common/angleutils.h" 11 12 namespace sh 13 { 14 class TCompiler; 15 class TIntermBlock; 16 17 // Transforms declarations so that in the end each declaration contains only one declarator. 18 // This is useful as an intermediate step when initialization needs to be separated from 19 // declaration, or when things need to be unfolded out of the initializer. 20 // Examples: 21 // Input: 22 // int a[1] = int[1](1), b[1] = int[1](2); 23 // Output: 24 // int a[1] = int[1](1); 25 // int b[1] = int[1](2); 26 // Input: 27 // struct S { vec3 d; } a, b; 28 // Output: 29 // struct S { vec3 d; } a; 30 // S b; 31 // Input: 32 // struct { vec3 d; } a; 33 // Output (note: no change): 34 // struct { vec3 d; } a; 35 // Input: 36 // struct { vec3 d; } a, b; 37 // Output: 38 // struct s1234 { vec3 d; } a; 39 // s1234 b; 40 // Input: 41 // struct Foo { int a; } foo(); 42 // Output: 43 // struct Foo { int a; }; 44 // Foo foo(); 45 // Input with separateCompoundStructDeclarations=true: 46 // struct S { vec3 d; } a; 47 // Output: 48 // struct S { vec3 d; }; 49 // S a; 50 // Input with separateCompoundStructDeclarations=true: 51 // struct S { vec3 d; } a, b; 52 // Output: 53 // struct S { vec3 d; }; 54 // S a; 55 // S b; 56 // Input with separateCompoundStructDeclarations=true: 57 // struct { vec3 d; } a, b; 58 // Output: 59 // struct s1234 { vec3 d; }; 60 // s1234 a; 61 // s1234 b; 62 // Input with separateCompoundStructDeclarations=true: 63 // struct { vec3 d; } a; 64 // Output (note: now, changes): 65 // struct s1234 { vec3 d; }; 66 // s1234 a; 67 68 [[nodiscard]] bool SeparateDeclarations(TCompiler &compiler, 69 TIntermBlock &root, 70 bool separateCompoundStructDeclarations); 71 72 } // namespace sh 73 74 #endif // COMPILER_TRANSLATOR_TREEOPS_SEPARATEDECLARATIONS_H_ 75