1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef ECMASCRIPT_BUILTINS_BUILTINS_PROMISE_HANDLER_H 17#define ECMASCRIPT_BUILTINS_BUILTINS_PROMISE_HANDLER_H 18 19#include "ecmascript/base/builtins_base.h" 20 21namespace panda::ecmascript::builtins { 22class BuiltinsPromiseHandler : public base::BuiltinsBase { 23public: 24 // es6 26.6.1.3.1 Promise Resolve Functions 25 static JSTaggedValue Resolve(EcmaRuntimeCallInfo *argv); 26 27 // es6 26.6.1.3.2 Promise Reject Functions 28 static JSTaggedValue Reject(EcmaRuntimeCallInfo *argv); 29 30 // es6 26.6.1.5.1 GetCapabilitiesExecutor Functions 31 static JSTaggedValue Executor(EcmaRuntimeCallInfo *argv); 32 33 // es2017 25.5.5.4 AsyncFunction Awaited Fulfilled 34 static JSTaggedValue AsyncAwaitFulfilled(EcmaRuntimeCallInfo *argv); 35 36 // es2017 25.5.5.5 AsyncFunction Awaited Rejected 37 static JSTaggedValue AsyncAwaitRejected(EcmaRuntimeCallInfo *argv); 38 39 // es6 25.4.4.1.2 Promise.all Resolve Element Functions 40 static JSTaggedValue ResolveElementFunction(EcmaRuntimeCallInfo *argv); 41 42 static JSTaggedValue ThenFinally(EcmaRuntimeCallInfo *argv); 43 44 static JSTaggedValue CatchFinally(EcmaRuntimeCallInfo *argv); 45 46 static JSTaggedValue valueThunkFunction(EcmaRuntimeCallInfo *argv); 47 48 static JSTaggedValue throwerFunction(EcmaRuntimeCallInfo *argv); 49 50 static JSHandle<JSTaggedValue> PromiseResolve(JSThread *thread, const JSHandle<JSTaggedValue> &constructor, 51 const JSHandle<JSTaggedValue> &xValue); 52 53 static JSTaggedValue AllSettledResolveElementFunction(EcmaRuntimeCallInfo *argv); 54 55 static JSTaggedValue AllSettledRejectElementFunction(EcmaRuntimeCallInfo *argv); 56 57 static JSTaggedValue AnyRejectElementFunction(EcmaRuntimeCallInfo *argv); 58}; 59} // namespace panda::ecmascript::builtins 60 61#endif // ECMASCRIPT_BUILTINS_BUILTINS_PROMISE_HANDLER_H 62