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 #include "compiler/translator/Operator_autogen.h" 8 9 #include "common/debug.h" 10 11 namespace sh 12 { 13 GetOperatorString(TOperator op)14const char *GetOperatorString(TOperator op) 15 { 16 switch (op) 17 { 18 // Note: EOpNull and EOpCall* can't be handled here. 19 20 case EOpNegative: 21 return "-"; 22 case EOpPositive: 23 return "+"; 24 case EOpLogicalNot: 25 return "!"; 26 case EOpBitwiseNot: 27 return "~"; 28 29 case EOpPostIncrement: 30 return "++"; 31 case EOpPostDecrement: 32 return "--"; 33 case EOpPreIncrement: 34 return "++"; 35 case EOpPreDecrement: 36 return "--"; 37 38 case EOpArrayLength: 39 return ".length()"; 40 41 case EOpAdd: 42 return "+"; 43 case EOpSub: 44 return "-"; 45 case EOpMul: 46 return "*"; 47 case EOpDiv: 48 return "/"; 49 case EOpIMod: 50 return "%"; 51 52 case EOpEqual: 53 return "=="; 54 case EOpNotEqual: 55 return "!="; 56 case EOpLessThan: 57 return "<"; 58 case EOpGreaterThan: 59 return ">"; 60 case EOpLessThanEqual: 61 return "<="; 62 case EOpGreaterThanEqual: 63 return ">="; 64 65 case EOpComma: 66 return ","; 67 68 // Fall-through. 69 case EOpVectorTimesScalar: 70 case EOpVectorTimesMatrix: 71 case EOpMatrixTimesVector: 72 case EOpMatrixTimesScalar: 73 case EOpMatrixTimesMatrix: 74 return "*"; 75 76 case EOpLogicalOr: 77 return "||"; 78 case EOpLogicalXor: 79 return "^^"; 80 case EOpLogicalAnd: 81 return "&&"; 82 83 case EOpBitShiftLeft: 84 return "<<"; 85 case EOpBitShiftRight: 86 return ">>"; 87 88 case EOpBitwiseAnd: 89 return "&"; 90 case EOpBitwiseXor: 91 return "^"; 92 case EOpBitwiseOr: 93 return "|"; 94 95 // Fall-through. 96 case EOpIndexDirect: 97 case EOpIndexIndirect: 98 return "[]"; 99 100 case EOpIndexDirectStruct: 101 case EOpIndexDirectInterfaceBlock: 102 return "."; 103 104 case EOpAssign: 105 case EOpInitialize: 106 return "="; 107 case EOpAddAssign: 108 return "+="; 109 case EOpSubAssign: 110 return "-="; 111 112 // Fall-through. 113 case EOpMulAssign: 114 case EOpVectorTimesMatrixAssign: 115 case EOpVectorTimesScalarAssign: 116 case EOpMatrixTimesScalarAssign: 117 case EOpMatrixTimesMatrixAssign: 118 return "*="; 119 120 case EOpDivAssign: 121 return "/="; 122 case EOpIModAssign: 123 return "%="; 124 case EOpBitShiftLeftAssign: 125 return "<<="; 126 case EOpBitShiftRightAssign: 127 return ">>="; 128 case EOpBitwiseAndAssign: 129 return "&="; 130 case EOpBitwiseXorAssign: 131 return "^="; 132 case EOpBitwiseOrAssign: 133 return "|="; 134 135 default: 136 UNREACHABLE(); 137 break; 138 } 139 return ""; 140 } 141 IsAssignment(TOperator op)142bool IsAssignment(TOperator op) 143 { 144 switch (op) 145 { 146 case EOpPostIncrement: 147 case EOpPostDecrement: 148 case EOpPreIncrement: 149 case EOpPreDecrement: 150 case EOpAssign: 151 case EOpAddAssign: 152 case EOpSubAssign: 153 case EOpMulAssign: 154 case EOpVectorTimesMatrixAssign: 155 case EOpVectorTimesScalarAssign: 156 case EOpMatrixTimesScalarAssign: 157 case EOpMatrixTimesMatrixAssign: 158 case EOpDivAssign: 159 case EOpIModAssign: 160 case EOpBitShiftLeftAssign: 161 case EOpBitShiftRightAssign: 162 case EOpBitwiseAndAssign: 163 case EOpBitwiseXorAssign: 164 case EOpBitwiseOrAssign: 165 return true; 166 default: 167 return false; 168 } 169 } 170 171 } // namespace sh 172