v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-support.h
Go to the documentation of this file.
1
// Copyright 2019 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_TORQUE_RUNTIME_SUPPORT_H_
6
#define V8_TORQUE_RUNTIME_SUPPORT_H_
7
8
#include <type_traits>
9
10
template
<
class
T>
11
struct
Identity
{
12
using
type
=
T
;
13
};
14
15
template
<
class
T>
16
struct
UnderlyingTypeHelper
:
Identity
<typename std::underlying_type<T>::type> {
17
};
18
19
template
<
class
T>
20
using
UnderlyingTypeIfEnum
=
21
typename
std::conditional_t<std::is_enum<T>::value,
UnderlyingTypeHelper<T>
,
22
Identity<T>
>
::type
;
23
24
// Utility for extracting the underlying type of an enum, returns the type
25
// itself if not an enum.
26
template
<
class
T>
27
UnderlyingTypeIfEnum<T>
CastToUnderlyingTypeIfEnum
(T
x
) {
28
return
static_cast<
UnderlyingTypeIfEnum<T>
>
(
x
);
29
}
30
31
#endif
// V8_TORQUE_RUNTIME_SUPPORT_H_
T
#define T
x
int x
Definition
liveedit-diff.cc:60
UnderlyingTypeIfEnum
typename std::conditional_t< std::is_enum< T >::value, UnderlyingTypeHelper< T >, Identity< T > >::type UnderlyingTypeIfEnum
Definition
runtime-support.h:20
CastToUnderlyingTypeIfEnum
UnderlyingTypeIfEnum< T > CastToUnderlyingTypeIfEnum(T x)
Definition
runtime-support.h:27
Identity
Definition
runtime-support.h:11
Identity::type
T type
Definition
runtime-support.h:12
UnderlyingTypeHelper
Definition
runtime-support.h:16
type
wasm::ValueType type
Definition
wasm-inlining-into-js.cc:30
src
torque
runtime-support.h
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0