1 // 2 // Copyright 2020 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_TRANSLATORMETALDIRECT_SEPARATECOMPOUNDEXPRESSIONS_H_ 8 #define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_SEPARATECOMPOUNDEXPRESSIONS_H_ 9 10 #include "common/angleutils.h" 11 #include "compiler/translator/Compiler.h" 12 #include "compiler/translator/TranslatorMetalDirect/IdGen.h" 13 #include "compiler/translator/TranslatorMetalDirect/SymbolEnv.h" 14 15 namespace sh 16 { 17 18 // Transforms code to (usually) have most one non-terminal expression per statement. 19 // This also rewrites (&&), (||), and (?:) into raw if/if-not/if-else statements, respectively. 20 // 21 // e.g. 22 // int x = 6 + foo(y, bar()); 23 // becomes 24 // auto _1 = bar(); 25 // auto _2 = foo(y, _1); 26 // auto _3 = 6 + _2; 27 // int x = _3; 28 // 29 // WARNING: 30 // - This does not rewrite object indexing operators as a whole (e.g. foo.x, foo[x]), but will 31 // rewrite the arguments to the operator (when applicable). 32 // e.g. 33 // foo(getVec()[i + 2] + 1); 34 // becomes 35 // auto _1 = getVec(); 36 // auto _2 = i + 2; 37 // auto _3 = _1[_2] + 1; // Index operator remains in (+) expr here. 38 // foo(_3); 39 // 40 ANGLE_NO_DISCARD bool SeparateCompoundExpressions(TCompiler &compiler, 41 SymbolEnv &symbolEnv, 42 IdGen &idGen, 43 TIntermBlock &root); 44 45 } // namespace sh 46 47 #endif // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_SEPARATECOMPOUNDEXPRESSIONS_H_ 48