diff options
Diffstat (limited to 'deps/v8/src/torque/utils.cc')
-rw-r--r-- | deps/v8/src/torque/utils.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/deps/v8/src/torque/utils.cc b/deps/v8/src/torque/utils.cc index 38862b31b0..4e757ac9e8 100644 --- a/deps/v8/src/torque/utils.cc +++ b/deps/v8/src/torque/utils.cc @@ -212,19 +212,25 @@ bool IsValidTypeName(const std::string& s) { } std::string CapifyStringWithUnderscores(const std::string& camellified_string) { + // Special case: JSAbc yields JS_ABC, not JSABC, for any Abc. + size_t js_position = camellified_string.find("JS"); + std::string result; - bool previousWasLower = false; - for (auto current : camellified_string) { - if (previousWasLower && isupper(current)) { + bool previousWasLowerOrDigit = false; + for (size_t index = 0; index < camellified_string.size(); ++index) { + char current = camellified_string[index]; + if ((previousWasLowerOrDigit && isupper(current)) || + (js_position != std::string::npos && + index == js_position + strlen("JS"))) { result += "_"; } if (current == '.' || current == '-') { result += "_"; - previousWasLower = false; + previousWasLowerOrDigit = false; continue; } result += toupper(current); - previousWasLower = (islower(current)); + previousWasLowerOrDigit = islower(current) || isdigit(current); } return result; } |