Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: src/globals.h

Issue 1841543003: [esnext] implement frontend changes for async/await proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix more problems Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index c7e59198b10f805765991ec5320adce8b792eda0..3d71934a5ca2360b3af76008009fc8a3e76eb5d0 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -963,11 +963,14 @@ enum FunctionKind {
kBaseConstructor = 1 << 5,
kGetterFunction = 1 << 6,
kSetterFunction = 1 << 7,
+ kAsyncFunction = 1 << 8,
kAccessorFunction = kGetterFunction | kSetterFunction,
kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor,
kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor,
kClassConstructor =
kBaseConstructor | kSubclassConstructor | kDefaultConstructor,
+ kAsyncArrowFunction = kArrowFunction | kAsyncFunction,
+ kAsyncConciseMethod = kAsyncFunction | kConciseMethod
};
inline bool IsValidFunctionKind(FunctionKind kind) {
@@ -982,7 +985,10 @@ inline bool IsValidFunctionKind(FunctionKind kind) {
kind == FunctionKind::kDefaultBaseConstructor ||
kind == FunctionKind::kDefaultSubclassConstructor ||
kind == FunctionKind::kBaseConstructor ||
- kind == FunctionKind::kSubclassConstructor;
+ kind == FunctionKind::kSubclassConstructor ||
+ kind == FunctionKind::kAsyncFunction ||
+ kind == FunctionKind::kAsyncArrowFunction ||
+ kind == FunctionKind::kAsyncConciseMethod;
}
@@ -997,6 +1003,10 @@ inline bool IsGeneratorFunction(FunctionKind kind) {
return kind & FunctionKind::kGeneratorFunction;
}
+inline bool IsAsyncFunction(FunctionKind kind) {
+ DCHECK(IsValidFunctionKind(kind));
+ return kind & FunctionKind::kAsyncFunction;
+}
inline bool IsConciseMethod(FunctionKind kind) {
DCHECK(IsValidFunctionKind(kind));
@@ -1059,6 +1069,49 @@ inline uint32_t ObjectHash(Address address) {
kPointerSizeLog2);
}
+enum class MethodKind {
+ None = 0,
+ Static = 1 << 0,
+ Generator = 1 << 1,
+ StaticGenerator = Static | Generator,
+ Async = 1 << 2,
+ StaticAsync = Static | Async,
+};
Dan Ehrenberg 2016/05/11 21:04:17 This seems to overlap a lot with ObjectLiteralProp
caitp (gmail) 2016/05/11 21:14:07 goal was to get rid of a boolean trap in CheckProp
+
+inline bool IsValidMethodKind(MethodKind kind) {
+ return kind == MethodKind::None || kind == MethodKind::Static ||
+ kind == MethodKind::Generator || kind == MethodKind::StaticGenerator ||
+ kind == MethodKind::Async || kind == MethodKind::StaticAsync;
+}
+
+static inline MethodKind operator|(MethodKind lhs, MethodKind rhs) {
+ typedef unsigned char T;
+ return static_cast<MethodKind>(static_cast<T>(lhs) | static_cast<T>(rhs));
+}
+
+static inline MethodKind& operator|=(MethodKind& lhs, const MethodKind& rhs) {
+ lhs = lhs | rhs;
+ DCHECK(IsValidMethodKind(lhs));
+ return lhs;
+}
+
+static inline bool operator&(MethodKind bitfield, MethodKind mask) {
+ typedef unsigned char T;
+ return static_cast<T>(bitfield) & static_cast<T>(mask);
+}
+
+inline bool IsMethod(MethodKind kind) { return kind != MethodKind::None; }
Dan Ehrenberg 2016/05/11 21:04:17 Huh? What about an ordinary non-static non-generat
caitp (gmail) 2016/05/11 21:14:07 good point, although it doesnt seem to actually ma
+
+inline bool IsStaticMethod(MethodKind kind) {
+ return kind & MethodKind::Static;
+}
+
+inline bool IsGeneratorMethod(MethodKind kind) {
+ return kind & MethodKind::Generator;
+}
+
+inline bool IsAsyncMethod(MethodKind kind) { return kind & MethodKind::Async; }
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/flag-definitions.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698