diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-09-21 09:14:51 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-22 18:29:25 +0200 |
commit | 0e7ddbd3d7e9439c67573b854c49cf82c398ae82 (patch) | |
tree | 2afe372acde921cb57ddb3444ff00c5adef8848c /deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp | |
parent | 13245dc50da4cb7443c39ef6c68d419d5e6336d4 (diff) | |
download | android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.gz android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.bz2 android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.zip |
deps: update V8 to 7.0.276.20
PR-URL: https://github.com/nodejs/node/pull/22754
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp')
-rw-r--r-- | deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp | 237 |
1 files changed, 0 insertions, 237 deletions
diff --git a/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp b/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp deleted file mode 100644 index 87c82a3b81..0000000000 --- a/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/support/CPPUtils.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -#include "support/CPPUtils.h" - -namespace antlrcpp { - -std::string join(std::vector<std::string> strings, - const std::string& separator) { - std::string str; - bool firstItem = true; - for (std::string s : strings) { - if (!firstItem) { - str.append(separator); - } - firstItem = false; - str.append(s); - } - return str; -} - -std::map<std::string, size_t> toMap(const std::vector<std::string>& keys) { - std::map<std::string, size_t> result; - for (size_t i = 0; i < keys.size(); ++i) { - result.insert({keys[i], i}); - } - return result; -} - -std::string escapeWhitespace(std::string str, bool escapeSpaces) { - std::string result; - for (auto c : str) { - switch (c) { - case '\n': - result += "\\n"; - break; - - case '\r': - result += "\\r"; - break; - - case '\t': - result += "\\t"; - break; - - case ' ': - if (escapeSpaces) { - result += "·"; - break; - } - result += c; - break; - - default: - result += c; - } - } - - return result; -} - -std::string toHexString(const int t) { - std::stringstream stream; - stream << std::uppercase << std::hex << t; - return stream.str(); -} - -std::string arrayToString(const std::vector<std::string>& data) { - std::string answer; - for (auto sub : data) { - answer += sub; - } - return answer; -} - -std::string replaceString(const std::string& s, const std::string& from, - const std::string& to) { - std::string::size_type p; - std::string ss, res; - - ss = s; - p = ss.find(from); - while (p != std::string::npos) { - if (p > 0) - res.append(ss.substr(0, p)).append(to); - else - res.append(to); - ss = ss.substr(p + from.size()); - p = ss.find(from); - } - res.append(ss); - - return res; -} - -std::vector<std::string> split(const std::string& s, const std::string& sep, - int count) { - std::vector<std::string> parts; - std::string ss = s; - - std::string::size_type p; - - if (s.empty()) return parts; - - if (count == 0) count = -1; - - p = ss.find(sep); - while (!ss.empty() && p != std::string::npos && (count < 0 || count > 0)) { - parts.push_back(ss.substr(0, p)); - ss = ss.substr(p + sep.size()); - - --count; - p = ss.find(sep); - } - parts.push_back(ss); - - return parts; -} - -//-------------------------------------------------------------------------------------------------- - -// Debugging helper. Adds indentation to all lines in the given string. -std::string indent(const std::string& s, const std::string& indentation, - bool includingFirst) { - std::vector<std::string> parts = split(s, "\n", -1); - for (size_t i = 0; i < parts.size(); ++i) { - if (i == 0 && !includingFirst) continue; - parts[i].insert(0, indentation); - } - - return join(parts, "\n"); -} - -//-------------------------------------------------------------------------------------------------- - -// Recursively get the error from a, possibly nested, exception. -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026 -// No nested exceptions before VS 2015. -template <typename T> -std::exception_ptr get_nested(const T& /*e*/) { - try { - return nullptr; - } catch (const std::bad_cast&) { - return nullptr; - } -} -#else -template <typename T> -std::exception_ptr get_nested(const T& e) { - try { - auto nested = dynamic_cast<const std::nested_exception&>(e); - return nested.nested_ptr(); - } catch (const std::bad_cast&) { - return nullptr; - } -} -#endif - -std::string what(std::exception_ptr eptr) { - if (!eptr) { - throw std::bad_exception(); - } - - std::string result; - std::size_t nestCount = 0; - -next : { - try { - std::exception_ptr yeptr; - std::swap(eptr, yeptr); - std::rethrow_exception(yeptr); - } catch (const std::exception& e) { - result += e.what(); - eptr = get_nested(e); - } catch (const std::string& e) { - result += e; - } catch (const char* e) { - result += e; - } catch (...) { - result += "cannot be determined"; - } - - if (eptr) { - result += " ("; - ++nestCount; - goto next; - } -} - - result += std::string(nestCount, ')'); - return result; -} - -//----------------- FinallyAction -//------------------------------------------------------------------------------------ - -FinalAction finally(std::function<void()> f) { return FinalAction(f); } - -//----------------- SingleWriteMultipleRead -//-------------------------------------------------------------------------- - -void SingleWriteMultipleReadLock::readLock() { - std::unique_lock<std::mutex> lock(_mutex); - while (_waitingWriters != 0) _readerGate.wait(lock); - ++_activeReaders; - lock.unlock(); -} - -void SingleWriteMultipleReadLock::readUnlock() { - std::unique_lock<std::mutex> lock(_mutex); - --_activeReaders; - lock.unlock(); - _writerGate.notify_one(); -} - -void SingleWriteMultipleReadLock::writeLock() { - std::unique_lock<std::mutex> lock(_mutex); - ++_waitingWriters; - while (_activeReaders != 0 || _activeWriters != 0) _writerGate.wait(lock); - ++_activeWriters; - lock.unlock(); -} - -void SingleWriteMultipleReadLock::writeUnlock() { - std::unique_lock<std::mutex> lock(_mutex); - --_waitingWriters; - --_activeWriters; - if (_waitingWriters > 0) - _writerGate.notify_one(); - else - _readerGate.notify_all(); - lock.unlock(); -} - -} // namespace antlrcpp |