| 112 | ignoreCase(ignoreCase) {} |
| 113 | |
| 114 | ConstantValue eval(EvalContext& context, const Args& args, SourceRange, |
| 115 | const CallExpression::SystemCallInfo&) const final { |
| 116 | auto lhsCv = args[0]->eval(context); |
| 117 | auto rhsCv = args[1]->eval(context); |
| 118 | if (!lhsCv || !rhsCv) |
| 119 | return nullptr; |
| 120 | |
| 121 | std::string& lhs = lhsCv.str(); |
| 122 | std::string& rhs = rhsCv.str(); |
| 123 | |
| 124 | int result; |
| 125 | if (ignoreCase) { |
| 126 | // No convenient way to do this with standard lib functions :( |
| 127 | const char* p1 = lhs.c_str(); |
| 128 | const char* p2 = rhs.c_str(); |
| 129 | while ((result = charToLower(*p1) - charToLower(*p2++)) == 0) { |
| 130 | if (*p1++ == '\0') |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | else { |
| 135 | result = lhs.compare(rhs); |
| 136 | if (result < 0) |
| 137 | result = -1; |
| 138 | else if (result > 0) |
| 139 | result = 1; |
| 140 | } |
| 141 | |
| 142 | return SVInt(32, uint64_t(result), true); |
| 143 | } |
| 144 | |
| 145 | private: |
| 146 | bool ignoreCase; |
nothing calls this directly
no test coverage detected