| 110 | |
| 111 | |
| 112 | static BNOperatorPrecedence GetOperatorPrecedence(const InstructionTextToken& token, size_t* ternary = nullptr) |
| 113 | { |
| 114 | string trimmedText = TrimString(token.text); |
| 115 | auto i = g_operatorPrecedenceMap.find(trimmedText); |
| 116 | if (i != g_operatorPrecedenceMap.end()) |
| 117 | { |
| 118 | if (i->second == TernaryOperatorPrecedence && ternary) |
| 119 | { |
| 120 | // HLIL uses ':' in additional contexts, so look for active ternary operators before |
| 121 | // treating it as part of a ternary |
| 122 | if (trimmedText == "?") |
| 123 | { |
| 124 | (*ternary)++; |
| 125 | } |
| 126 | else if (trimmedText == ":") |
| 127 | { |
| 128 | if (*ternary) |
| 129 | (*ternary)--; |
| 130 | else |
| 131 | return MemberAndFunctionOperatorPrecedence; |
| 132 | } |
| 133 | } |
| 134 | return i->second; |
| 135 | } |
| 136 | return MemberAndFunctionOperatorPrecedence; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | struct Item |
no test coverage detected