* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H
#define ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H
#include "ecmascript/base/builtins_base.h"
#include "ecmascript/js_function.h"
#include "ecmascript/js_array.h"
#define CONDITION_BUILTIN_REFLECT_HAS_FUNCTION(V) V("set", ReflectSet, 3, ReflectSet)
#define BUILTIN_REFLECT_FUNCTIONS(V) \
\
V("apply", ReflectApply, 3, ReflectApply) \
\
V("construct", ReflectConstruct, 2, ReflectConstruct) \
\
V("defineProperty", ReflectDefineProperty, 3, INVALID) \
\
V("deleteProperty", ReflectDeleteProperty, 2, INVALID) \
\
V("get", ReflectGet, 2, ReflectGet) \
\
V("getOwnPropertyDescriptor", ReflectGetOwnPropertyDescriptor, 2, INVALID) \
\
V("getPrototypeOf", ReflectGetPrototypeOf, 1, ReflectGetPrototypeOf) \
\
V("has", ReflectHas, 2, ReflectHas) \
\
V("isExtensible", ReflectIsExtensible, 1, INVALID) \
\
V("ownKeys", ReflectOwnKeys, 1, INVALID) \
\
V("preventExtensions", ReflectPreventExtensions, 1, INVALID) \
\
CONDITION_BUILTIN_REFLECT_HAS_FUNCTION(V) \
\
V("setPrototypeOf", ReflectSetPrototypeOf, 2, INVALID)
namespace panda::ecmascript::builtins {
class BuiltinsReflect : public base::BuiltinsBase {
public:
static JSTaggedValue ReflectApply(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectApplyInternal(JSThread *thread, JSHandle<JSTaggedValue> target,
JSHandle<JSTaggedValue> thisArgument,
JSHandle<JSTaggedValue> argumentsList);
static JSTaggedValue ReflectConstruct(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectConstructInternal(JSThread *thread, JSHandle<JSTaggedValue> target,
JSHandle<TaggedArray> args, JSHandle<JSTaggedValue> newTarget);
static JSTaggedValue ReflectDefineProperty(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectDeleteProperty(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectGet(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectGetOwnPropertyDescriptor(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectGetPrototypeOf(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectHas(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectHasInternal(JSThread *thread, JSHandle<JSTaggedValue> target,
JSHandle<JSTaggedValue> key);
static JSTaggedValue ReflectIsExtensible(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectOwnKeys(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectPreventExtensions(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectSet(EcmaRuntimeCallInfo *argv);
static JSTaggedValue ReflectSetPrototypeOf(EcmaRuntimeCallInfo *argv);
static Span<const base::BuiltinFunctionEntry> GetReflectFunctions()
{
return Span<const base::BuiltinFunctionEntry>(REFLECT_FUNCTIONS);
}
private:
#define BUILTINS_REFLECT_FUNCTION_ENTRY(name, method, length, id) \
base::BuiltinFunctionEntry::Create(name, BuiltinsReflect::method, length, BUILTINS_STUB_ID(id)),
static constexpr std::array REFLECT_FUNCTIONS = {
BUILTIN_REFLECT_FUNCTIONS(BUILTINS_REFLECT_FUNCTION_ENTRY)
};
#undef BUILTINS_REFLECT_FUNCTION_ENTRY
};
}
#endif