diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/runtime/JSPromise.h | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSPromise.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSPromise.h | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/Source/JavaScriptCore/runtime/JSPromise.h b/Source/JavaScriptCore/runtime/JSPromise.h index 662b1cdf6..d1d1854d9 100644 --- a/Source/JavaScriptCore/runtime/JSPromise.h +++ b/Source/JavaScriptCore/runtime/JSPromise.h @@ -26,37 +26,68 @@ #ifndef JSPromise_h #define JSPromise_h -#include "JSObject.h" +#if ENABLE(PROMISES) + +#include "JSDestructibleObject.h" namespace JSC { -class JSPromise : public JSNonFinalObject { +class JSPromiseReaction; +class JSPromiseConstructor; + +class JSPromise : public JSDestructibleObject { public: - typedef JSNonFinalObject Base; + typedef JSDestructibleObject Base; - static JSPromise* create(VM&, Structure*); + static JSPromise* create(VM&, JSGlobalObject*, JSPromiseConstructor*); static Structure* createStructure(VM&, JSGlobalObject*, JSValue); - DECLARE_EXPORT_INFO; + DECLARE_INFO; - enum class Status : unsigned { - Pending = 1, - Fulfilled, - Rejected + enum class Status { + Unresolved, + HasResolution, + HasRejection }; - Status status(VM&) const; - JSValue result(VM&) const; + Status status() const + { + return m_status; + } + + JSValue result() const + { + ASSERT(m_status != Status::Unresolved); + return m_result.get(); + } + + JSPromiseConstructor* constructor() const + { + return m_constructor.get(); + } - // Initialize the promise with the executor. - // This may raise a JS exception. - void initialize(ExecState*, JSGlobalObject*, JSValue executor); + void reject(VM&, JSValue); + void resolve(VM&, JSValue); -protected: + void appendResolveReaction(VM&, JSPromiseReaction*); + void appendRejectReaction(VM&, JSPromiseReaction*); + +private: JSPromise(VM&, Structure*); - void finishCreation(VM&); + void finishCreation(VM&, JSPromiseConstructor*); + static const unsigned StructureFlags = OverridesVisitChildren | JSObject::StructureFlags; + static void destroy(JSCell*); + static void visitChildren(JSCell*, SlotVisitor&); + + Status m_status; + WriteBarrier<Unknown> m_result; + WriteBarrier<JSPromiseConstructor> m_constructor; + Vector<WriteBarrier<JSPromiseReaction>> m_resolveReactions; + Vector<WriteBarrier<JSPromiseReaction>> m_rejectReactions; }; } // namespace JSC +#endif // ENABLE(PROMISES) + #endif // JSPromise_h |