v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
type-parser.cc
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <optional>
8
10
11std::optional<Type> TypeParser::ParseType() {
12 if (ConsumeIf("Word32")) {
13 if (IsNext("{")) return ParseSet<Word32Type>();
14 if (IsNext("[")) return ParseRange<Word32Type>();
15 return Word32Type::Any();
16 } else if (ConsumeIf("Word64")) {
17 if (IsNext("{")) return ParseSet<Word64Type>();
18 if (IsNext("[")) return ParseRange<Word64Type>();
19 return Word64Type::Any();
20 } else if (ConsumeIf("Float32")) {
21 // TODO(nicohartmann@): Handle NaN.
22 if (IsNext("{")) return ParseSet<Float32Type>();
23 if (IsNext("[")) return ParseRange<Float32Type>();
24 return Float64Type::Any();
25 } else if (ConsumeIf("Float64")) {
26 // TODO(nicohartmann@): Handle NaN.
27 if (IsNext("{")) return ParseSet<Float64Type>();
28 if (IsNext("[")) return ParseRange<Float64Type>();
29 return Float64Type::Any();
30 } else {
31 return std::nullopt;
32 }
33}
34
35} // namespace v8::internal::compiler::turboshaft
bool IsNext(const std::string_view &prefix)
Definition type-parser.h:89
bool ConsumeIf(const std::string_view &prefix)
Definition type-parser.h:81