5#ifndef V8_COMPILER_TURBOSHAFT_TYPE_PARSER_H_
6#define V8_COMPILER_TURBOSHAFT_TYPE_PARSER_H_
29 if (
pos_ <
str_.length())
return std::nullopt;
40 if (!from)
return std::nullopt;
43 if (!to)
return std::nullopt;
45 if constexpr (!std::is_same_v<T, Word32Type> &&
46 !std::is_same_v<T, Word64Type>) {
49 return T::Range(*from, *to,
zone_);
56 if (!elements)
return std::nullopt;
59 CHECK_LE(elements->size(), T::kMaxSetSize);
60 return T::Set(*elements,
zone_);
65 std::vector<T> elements;
66 if (
IsNext(
"}"))
return elements;
69 if (!element_opt)
return std::nullopt;
70 elements.push_back(*element_opt);
76 elements.erase(std::unique(elements.begin(), elements.end()),
83 pos_ += prefix.length();
89 bool IsNext(
const std::string_view& prefix) {
92 if (
pos_ >=
str_.length())
return false;
93 size_t remaining_length =
str_.length() -
pos_;
94 if (prefix.length() > remaining_length)
return false;
95 return str_.compare(
pos_, prefix.length(), prefix, 0, prefix.length()) == 0;
105 if constexpr (std::is_same_v<T, uint32_t>) {
106 result =
static_cast<uint32_t
>(std::stoul(s, &read));
107 }
else if constexpr (std::is_same_v<T, uint64_t>) {
108 result = std::stoull(s, &read);
109 }
else if constexpr (std::is_same_v<T, float>) {
110 result = std::stof(s, &read);
111 }
else if constexpr (std::is_same_v<T, double>) {
112 result = std::stod(s, &read);
114 if (read == 0)
return std::nullopt;
std::optional< T > ParseSet()
std::optional< Type > Parse()
bool IsNext(const std::string_view &prefix)
std::optional< std::vector< T > > ParseSetElements()
std::optional< T > ReadValue()
bool ConsumeIf(const std::string_view &prefix)
std::optional< T > ParseRange()
TypeParser(const std::string_view &str, Zone *zone)
std::optional< Type > ParseType()
ZoneVector< RpoNumber > & result
#define CHECK_LT(lhs, rhs)
#define CHECK_LE(lhs, rhs)