v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
function-kind.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_OBJECTS_FUNCTION_KIND_H_
6#define V8_OBJECTS_FUNCTION_KIND_H_
7
8#include "src/base/bounds.h"
9#include "src/base/macros.h"
10
11namespace v8 {
12namespace internal {
13
14enum class FunctionKind : uint8_t {
15 // BEGIN constructable functions
17 kModule,
19 // BEGIN class constructors
20 // BEGIN base constructors
22 // BEGIN default constructors
24 // END base constructors
25 // BEGIN derived constructors
27 // END default constructors
29 // END derived constructors
30 // END class constructors
31 // END constructable functions.
32 // BEGIN accessors
37 // END accessors
38 // BEGIN arrow functions
40 // BEGIN async functions
42 // END arrow functions
44 // BEGIN concise methods 1
47 // BEGIN generators
50 // END concise methods 1
52 // END async functions
54 // BEGIN concise methods 2
57 // END generators
62 // END concise methods 2
64
66};
67
68constexpr int kFunctionKindBitSize = 5;
69static_assert(static_cast<int>(FunctionKind::kLastFunctionKind) <
71
76
81
85
90
95
100
104
111
120
125
130
135
140
145
150
155
160
165
180
185
187 switch (kind) {
189 return "NormalFunction";
191 return "ArrowFunction";
193 return "GeneratorFunction";
195 return "ConciseMethod";
197 return "StaticConciseMethod";
199 return "DerivedConstructor";
201 return "BaseConstructor";
203 return "GetterFunction";
205 return "StaticGetterFunction";
207 return "SetterFunction";
209 return "StaticSetterFunction";
211 return "AsyncFunction";
213 return "Module";
215 return "AsyncModule";
217 return "ClassMembersInitializerFunction";
219 return "ClassStaticInitializerFunction";
221 return "DefaultBaseConstructor";
223 return "DefaultDerivedConstructor";
225 return "AsyncArrowFunction";
227 return "AsyncConciseMethod";
229 return "StaticAsyncConciseMethod";
231 return "ConciseGeneratorMethod";
233 return "StaticConciseGeneratorMethod";
235 return "AsyncConciseGeneratorMethod";
237 return "StaticAsyncConciseGeneratorMethod";
239 return "AsyncGeneratorFunction";
241 return "Invalid";
242 }
243 UNREACHABLE();
244}
245
246inline std::ostream& operator<<(std::ostream& os, FunctionKind kind) {
247 return os << FunctionKind2String(kind);
248}
249
250} // namespace internal
251} // namespace v8
252
253#endif // V8_OBJECTS_FUNCTION_KIND_H_
Builtins::Kind kind
Definition builtins.cc:40
constexpr bool IsInRange(T value, U lower_limit, U higher_limit)
Definition bounds.h:20
bool IsArrowFunction(FunctionKind kind)
bool IsClassConstructor(FunctionKind kind)
bool IsGeneratorFunction(FunctionKind kind)
bool IsDerivedConstructor(FunctionKind kind)
bool IsResumableFunction(FunctionKind kind)
bool IsConciseMethod(FunctionKind kind)
bool IsAsyncFunction(FunctionKind kind)
bool IsModuleWithTopLevelAwait(FunctionKind kind)
constexpr int kFunctionKindBitSize
bool IsAccessorFunction(FunctionKind kind)
bool IsStatic(FunctionKind kind)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
bool IsBaseConstructor(FunctionKind kind)
bool IsAsyncGeneratorFunction(FunctionKind kind)
bool IsModule(FunctionKind kind)
bool BindsSuper(FunctionKind kind)
bool IsConstructable(FunctionKind kind)
bool IsStrictFunctionWithoutPrototype(FunctionKind kind)
bool IsClassMembersInitializerFunction(FunctionKind kind)
bool IsGetterFunction(FunctionKind kind)
bool IsDefaultConstructor(FunctionKind kind)
bool IsSetterFunction(FunctionKind kind)
const char * FunctionKind2String(FunctionKind kind)