v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
integer-literal-inl.h
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
5#ifndef V8_NUMBERS_INTEGER_LITERAL_INL_H_
6#define V8_NUMBERS_INTEGER_LITERAL_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11namespace v8 {
12namespace internal {
13
14inline std::string IntegerLiteral::ToString() const {
15 if (negative_) return std::string("-") + std::to_string(absolute_value_);
16 return std::to_string(absolute_value_);
17}
18
20 const IntegerLiteral& y) {
21 DCHECK(!y.is_negative());
22 DCHECK_LT(y.absolute_value(), sizeof(uint64_t) * kBitsPerByte);
23 return IntegerLiteral(x.is_negative(), x.absolute_value()
24 << y.absolute_value());
25}
26
28 const IntegerLiteral& y) {
29 if (x.is_negative() == y.is_negative()) {
30 DCHECK_GE(x.absolute_value() + y.absolute_value(), x.absolute_value());
31 return IntegerLiteral(x.is_negative(),
32 x.absolute_value() + y.absolute_value());
33 }
34 if (x.absolute_value() >= y.absolute_value()) {
35 return IntegerLiteral(x.is_negative(),
36 x.absolute_value() - y.absolute_value());
37 }
38 return IntegerLiteral(!x.is_negative(),
39 y.absolute_value() - x.absolute_value());
40}
41
42} // namespace internal
43} // namespace v8
44#endif // V8_NUMBERS_INTEGER_LITERAL_INL_H_
int x
constexpr int kBitsPerByte
Definition globals.h:682
IntegerLiteral operator+(const IntegerLiteral &x, const IntegerLiteral &y)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_LT(v1, v2)
Definition logging.h:489