14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/base/builtins_base.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_function.h" 214514f5e3Sopenharmony_ci#include "ecmascript/js_array.h" 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_ci// List of functions in Reflect, excluding the '@@' properties. 244514f5e3Sopenharmony_ci// V(name, func, length, stubIndex) 254514f5e3Sopenharmony_ci// where BuiltinsRefject::func refers to the native implementation of Reflect[name]. 264514f5e3Sopenharmony_ci// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available. 274514f5e3Sopenharmony_ci#define BUILTIN_REFLECT_FUNCTIONS(V) \ 284514f5e3Sopenharmony_ci /* Reflect.apply ( target, thisArgument, argumentsList ) */ \ 294514f5e3Sopenharmony_ci V("apply", ReflectApply, 3, ReflectApply) \ 304514f5e3Sopenharmony_ci /* Reflect.construct ( target, argumentsList [ , newTarget ] ) */ \ 314514f5e3Sopenharmony_ci V("construct", ReflectConstruct, 2, ReflectConstruct) \ 324514f5e3Sopenharmony_ci /* Reflect.defineProperty ( target, propertyKey, attributes ) */ \ 334514f5e3Sopenharmony_ci V("defineProperty", ReflectDefineProperty, 3, INVALID) \ 344514f5e3Sopenharmony_ci /* Reflect.deleteProperty ( target, propertyKey ) */ \ 354514f5e3Sopenharmony_ci V("deleteProperty", ReflectDeleteProperty, 2, INVALID) \ 364514f5e3Sopenharmony_ci /* Reflect.get ( target, propertyKey [ , receiver ] ) */ \ 374514f5e3Sopenharmony_ci V("get", ReflectGet, 2, ReflectGet) \ 384514f5e3Sopenharmony_ci /* Reflect.getOwnPropertyDescriptor ( target, propertyKey ) */ \ 394514f5e3Sopenharmony_ci V("getOwnPropertyDescriptor", ReflectGetOwnPropertyDescriptor, 2, INVALID) \ 404514f5e3Sopenharmony_ci /* Reflect.getPrototypeOf ( target ) */ \ 414514f5e3Sopenharmony_ci V("getPrototypeOf", ReflectGetPrototypeOf, 1, ReflectGetPrototypeOf) \ 424514f5e3Sopenharmony_ci /* Reflect.has ( target, propertyKey ) */ \ 434514f5e3Sopenharmony_ci V("has", ReflectHas, 2, ReflectHas) \ 444514f5e3Sopenharmony_ci /* Reflect.isExtensible ( target ) */ \ 454514f5e3Sopenharmony_ci V("isExtensible", ReflectIsExtensible, 1, INVALID) \ 464514f5e3Sopenharmony_ci /* Reflect.ownKeys ( target ) */ \ 474514f5e3Sopenharmony_ci V("ownKeys", ReflectOwnKeys, 1, INVALID) \ 484514f5e3Sopenharmony_ci /* Reflect.preventExtensions ( target ) */ \ 494514f5e3Sopenharmony_ci V("preventExtensions", ReflectPreventExtensions, 1, INVALID) \ 504514f5e3Sopenharmony_ci /* Reflect.set ( target, propertyKey, V [ , receiver ] ) */ \ 514514f5e3Sopenharmony_ci V("set", ReflectSet, 3, INVALID) \ 524514f5e3Sopenharmony_ci /* Reflect.setPrototypeOf ( target, proto ) */ \ 534514f5e3Sopenharmony_ci V("setPrototypeOf", ReflectSetPrototypeOf, 2, INVALID) 544514f5e3Sopenharmony_ci 554514f5e3Sopenharmony_cinamespace panda::ecmascript::builtins { 564514f5e3Sopenharmony_ciclass BuiltinsReflect : public base::BuiltinsBase { 574514f5e3Sopenharmony_cipublic: 584514f5e3Sopenharmony_ci // ecma 26.1.1 594514f5e3Sopenharmony_ci static JSTaggedValue ReflectApply(EcmaRuntimeCallInfo *argv); 604514f5e3Sopenharmony_ci static JSTaggedValue ReflectApplyInternal(JSThread *thread, JSHandle<JSTaggedValue> target, 614514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> thisArgument, 624514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> argumentsList); 634514f5e3Sopenharmony_ci 644514f5e3Sopenharmony_ci // ecma 26.1.2 654514f5e3Sopenharmony_ci static JSTaggedValue ReflectConstruct(EcmaRuntimeCallInfo *argv); 664514f5e3Sopenharmony_ci static JSTaggedValue ReflectConstructInternal(JSThread *thread, JSHandle<JSTaggedValue> target, 674514f5e3Sopenharmony_ci JSHandle<TaggedArray> args, JSHandle<JSTaggedValue> newTarget); 684514f5e3Sopenharmony_ci 694514f5e3Sopenharmony_ci // ecma 26.1.3 704514f5e3Sopenharmony_ci static JSTaggedValue ReflectDefineProperty(EcmaRuntimeCallInfo *argv); 714514f5e3Sopenharmony_ci 724514f5e3Sopenharmony_ci // ecma 26.1.4 734514f5e3Sopenharmony_ci static JSTaggedValue ReflectDeleteProperty(EcmaRuntimeCallInfo *argv); 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_ci // ecma 26.1.5 764514f5e3Sopenharmony_ci static JSTaggedValue ReflectGet(EcmaRuntimeCallInfo *argv); 774514f5e3Sopenharmony_ci 784514f5e3Sopenharmony_ci // ecma 26.1.6 794514f5e3Sopenharmony_ci static JSTaggedValue ReflectGetOwnPropertyDescriptor(EcmaRuntimeCallInfo *argv); 804514f5e3Sopenharmony_ci 814514f5e3Sopenharmony_ci // ecma 26.1.7 824514f5e3Sopenharmony_ci static JSTaggedValue ReflectGetPrototypeOf(EcmaRuntimeCallInfo *argv); 834514f5e3Sopenharmony_ci 844514f5e3Sopenharmony_ci // ecma 26.1.8 854514f5e3Sopenharmony_ci static JSTaggedValue ReflectHas(EcmaRuntimeCallInfo *argv); 864514f5e3Sopenharmony_ci static JSTaggedValue ReflectHasInternal(JSThread *thread, JSHandle<JSTaggedValue> target, 874514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> key); 884514f5e3Sopenharmony_ci 894514f5e3Sopenharmony_ci // ecma 26.1.9 904514f5e3Sopenharmony_ci static JSTaggedValue ReflectIsExtensible(EcmaRuntimeCallInfo *argv); 914514f5e3Sopenharmony_ci 924514f5e3Sopenharmony_ci // ecma 26.1.10 934514f5e3Sopenharmony_ci static JSTaggedValue ReflectOwnKeys(EcmaRuntimeCallInfo *argv); 944514f5e3Sopenharmony_ci 954514f5e3Sopenharmony_ci // ecma 26.1.11 964514f5e3Sopenharmony_ci static JSTaggedValue ReflectPreventExtensions(EcmaRuntimeCallInfo *argv); 974514f5e3Sopenharmony_ci 984514f5e3Sopenharmony_ci // ecma 26.1.12 994514f5e3Sopenharmony_ci static JSTaggedValue ReflectSet(EcmaRuntimeCallInfo *argv); 1004514f5e3Sopenharmony_ci 1014514f5e3Sopenharmony_ci // ecma 26.1.13 1024514f5e3Sopenharmony_ci static JSTaggedValue ReflectSetPrototypeOf(EcmaRuntimeCallInfo *argv); 1034514f5e3Sopenharmony_ci 1044514f5e3Sopenharmony_ci // Excluding the '@@' internal properties. 1054514f5e3Sopenharmony_ci static Span<const base::BuiltinFunctionEntry> GetReflectFunctions() 1064514f5e3Sopenharmony_ci { 1074514f5e3Sopenharmony_ci return Span<const base::BuiltinFunctionEntry>(REFLECT_FUNCTIONS); 1084514f5e3Sopenharmony_ci } 1094514f5e3Sopenharmony_ci 1104514f5e3Sopenharmony_ciprivate: 1114514f5e3Sopenharmony_ci#define BUILTINS_REFLECT_FUNCTION_ENTRY(name, method, length, id) \ 1124514f5e3Sopenharmony_ci base::BuiltinFunctionEntry::Create(name, BuiltinsReflect::method, length, kungfu::BuiltinsStubCSigns::id), 1134514f5e3Sopenharmony_ci 1144514f5e3Sopenharmony_ci static constexpr std::array REFLECT_FUNCTIONS = { 1154514f5e3Sopenharmony_ci BUILTIN_REFLECT_FUNCTIONS(BUILTINS_REFLECT_FUNCTION_ENTRY) 1164514f5e3Sopenharmony_ci }; 1174514f5e3Sopenharmony_ci#undef BUILTINS_REFLECT_FUNCTION_ENTRY 1184514f5e3Sopenharmony_ci}; 1194514f5e3Sopenharmony_ci} // namespace panda::ecmascript::builtins 1204514f5e3Sopenharmony_ci#endif // ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H 121