5#ifndef V8_TORQUE_UTILS_H_
6#define V8_TORQUE_UTILS_H_
14#include <unordered_set>
28 const std::string& s);
40template <
class... Args>
42 std::stringstream stream;
43 USE((stream << std::forward<Args>(
args))...);
57 [[noreturn]]
void Throw()
const;
75template <
class... Args>
80template <
class... Args>
84template <
class... Args>
95template <
class... Args>
103std::string
DashifyString(
const std::string& underscore_string);
126 return std::forward<T>(
x);
129template <
class T,
class L>
137 for (
auto& e : l.list) {
151 using ElementType =
decltype(*list.begin());
152 auto id = [](ElementType el) {
return el; };
156template <
class T,
class L>
159 std::forward<L>(transformer)};
162template <
class C,
class T>
164 os <<
PrintList(list,
", ", std::forward<C>(transform));
176 this->offset = other_offset;
189 return offset < other.offset;
192 return offset <= other.offset;
195 return offset == other.offset;
198 return offset != other.offset;
203 return out <<
"BottomOffset{" << from_bottom.
offset <<
"}";
214 return begin_ == other.begin_ &&
end_ == other.end_;
232 return out <<
"StackRange{" << range.begin() <<
", " << range.end() <<
"}";
240 Stack(std::initializer_list<T> initializer)
241 :
Stack(
std::vector<T>(initializer)) {}
258 for (
const T&
x : v) {
274 result.push_back(std::move(*it));
284 if (range.Size() == 0)
return;
327template <
class Container,
class F>
329 for (
auto it = container->begin(); it != container->end();) {
331 it = container->erase(it);
342 return (c == traits_type::eof()) ?
'\0' : c;
358 if (s.size() < prefix.size())
return false;
359 return s.substr(0, prefix.size()) == prefix;
362 if (s.size() < suffix.size())
return false;
363 return s.substr(s.size() - suffix.size()) == suffix;
381 std::initializer_list<std::string> namespaces);
388 std::vector<std::string>
d_;
466 *
this = *
this + other;
471 *
this = *
this * other;
525template <
class T,
class U,
class F>
528 std::transform(v.begin(), v.end(), std::back_inserter(
result), f);
531template <
class T,
class U>
std::unordered_set< T, base::hash< T > > storage_
IfDefScope & operator=(const IfDefScope &)=delete
IfDefScope(const IfDefScope &)=delete
IncludeGuardScope(const IncludeGuardScope &)=delete
IncludeGuardScope & operator=(const IncludeGuardScope &)=delete
IncludeObjectMacrosScope & operator=(const IncludeObjectMacrosScope &)=delete
IncludeObjectMacrosScope(const IncludeObjectMacrosScope &)=delete
MessageBuilder & Position(SourcePosition position)
std::vector< TorqueMessage > extra_messages_
NamespaceScope(const NamespaceScope &)=delete
NamespaceScope & operator=(const NamespaceScope &)=delete
std::vector< std::string > d_
int overflow(int c) override
friend ResidueClass operator+(const ResidueClass &a, const ResidueClass &b)
ResidueClass & operator+=(const ResidueClass &other)
ResidueClass(size_t value, size_t modulus_log_2=kMaxModulusLog2)
ResidueClass & operator*=(const ResidueClass &other)
std::optional< size_t > SingleValue() const
static ResidueClass Unknown()
static const size_t kMaxModulusLog2
friend ResidueClass operator*(const ResidueClass &a, const ResidueClass &b)
friend std::ostream & operator<<(std::ostream &os, const ResidueClass &a)
size_t AlignmentLog2() const
void Extend(StackRange adjacent)
bool operator==(const StackRange &other) const
StackRange(BottomOffset begin, BottomOffset end)
BottomOffset begin() const
BottomOffset AboveTop() const
const T & Peek(BottomOffset from_bottom) const
std::vector< T > PopMany(size_t count)
StackRange TopRange(size_t slot_count) const
StackRange PushMany(const std::vector< T > &v)
bool operator==(const Stack &other) const
void DeleteRange(StackRange range)
Stack(std::vector< T > v)
void Poke(BottomOffset from_bottom, T x)
Stack(std::initializer_list< T > initializer)
std::vector< T > elements_
bool operator!=(const Stack &other) const
std::unordered_set< T > contained_
#define DECLARE_CONTEXTUAL_VARIABLE(VarName,...)
base::Vector< const DirectHandle< Object > > args
ZoneVector< RpoNumber > & result
bool StringEndsWith(const std::string &s, const std::string &suffix)
bool IsUpperCamelCase(const std::string &s)
std::string CapifyStringWithUnderscores(const std::string &camellified_string)
std::ostream & operator<<(std::ostream &os, Identifier *id)
void EraseIf(Container *container, F f)
std::string StringLiteralQuote(const std::string &s)
void ReportError(Args &&... args)
void ReplaceFileContentsIfDifferent(const std::string &file_path, const std::string &contents)
std::string ToString(Args &&... args)
static MessageBuilder Message(TorqueMessage::Kind kind, Args &&... args)
MessageBuilder Lint(Args &&... args)
std::string SnakeifyString(const std::string &camel_string)
bool IsValidTypeName(const std::string &s)
std::string DashifyString(const std::string &underscore_string)
bool StartsWithSingleUnderscore(const std::string &str)
T & DereferenceIfPointer(T *x)
bool IsSnakeCase(const std::string &s)
std::string CamelifyString(const std::string &underscore_string)
std::optional< std::string > FileUriDecode(const std::string &uri)
auto PrintList(const T &list, const std::string &separator=", ")
std::vector< T > TransformVector(const std::vector< U > &v, F f)
bool IsLowerCamelCase(const std::string &s)
bool StringStartsWith(const std::string &s, const std::string &prefix)
static const char *const kBaseNamespaceName
bool IsValidNamespaceConstName(const std::string &s)
void PrintCommaSeparatedList(std::ostream &os, const T &list, C &&transform)
std::string UnderlinifyPath(std::string path)
static const char *const kTestNamespaceName
MessageBuilder Error(Args &&... args)
std::string StringLiteralUnquote(const std::string &s)
base::Vector< const char > contents
#define DCHECK_LE(v1, v2)
#define CHECK_NOT_NULL(val)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
BottomOffset operator-(size_t x) const
BottomOffset operator+(size_t x) const
BottomOffset & operator=(std::size_t other_offset)
bool operator==(const BottomOffset &other) const
bool operator<(const BottomOffset &other) const
bool operator!=(const BottomOffset &other) const
BottomOffset & operator++()
bool operator<=(const BottomOffset &other) const
const std::string & separator
friend std::ostream & operator<<(std::ostream &os, const ListPrintAdaptor &l)
std::optional< SourcePosition > position