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_IC_PROTOTYPE_CHANGE_DETAILS_H
174514f5e3Sopenharmony_ci#define ECMASCRIPT_IC_PROTOTYPE_CHANGE_DETAILS_H
184514f5e3Sopenharmony_ci
194514f5e3Sopenharmony_ci#include "ecmascript/ecma_macros.h"
204514f5e3Sopenharmony_ci#include "ecmascript/js_handle.h"
214514f5e3Sopenharmony_ci#include "ecmascript/js_tagged_value.h"
224514f5e3Sopenharmony_ci#include "ecmascript/weak_vector.h"
234514f5e3Sopenharmony_ci
244514f5e3Sopenharmony_cinamespace panda {
254514f5e3Sopenharmony_cinamespace ecmascript {
264514f5e3Sopenharmony_ciclass ProtoChangeMarker : public TaggedObject {
274514f5e3Sopenharmony_cipublic:
284514f5e3Sopenharmony_ci    static ProtoChangeMarker *Cast(TaggedObject *object)
294514f5e3Sopenharmony_ci    {
304514f5e3Sopenharmony_ci        ASSERT(JSTaggedValue(object).IsProtoChangeMarker());
314514f5e3Sopenharmony_ci        return static_cast<ProtoChangeMarker *>(object);
324514f5e3Sopenharmony_ci    }
334514f5e3Sopenharmony_ci
344514f5e3Sopenharmony_ci    static constexpr size_t BIT_FIELD_OFFSET = TaggedObjectSize();
354514f5e3Sopenharmony_ci    ACCESSORS_BIT_FIELD(BitField, BIT_FIELD_OFFSET, LAST_OFFSET)
364514f5e3Sopenharmony_ci    DEFINE_ALIGN_SIZE(LAST_OFFSET);
374514f5e3Sopenharmony_ci    DECL_VISIT_PRIMITIVE_OBJECT()
384514f5e3Sopenharmony_ci
394514f5e3Sopenharmony_ci    // define BitField
404514f5e3Sopenharmony_ci    static constexpr size_t HAS_CHANGED_BITS = 1;
414514f5e3Sopenharmony_ci    static constexpr size_t ACCESSOR_HAS_CHANGED_BITS = 1;
424514f5e3Sopenharmony_ci    FIRST_BIT_FIELD(BitField, HasChanged, bool, HAS_CHANGED_BITS);
434514f5e3Sopenharmony_ci    NEXT_BIT_FIELD(BitField, AccessorHasChanged, bool, ACCESSOR_HAS_CHANGED_BITS, HasChanged);
444514f5e3Sopenharmony_ci
454514f5e3Sopenharmony_ci    DECL_DUMP()
464514f5e3Sopenharmony_ci};
474514f5e3Sopenharmony_ci
484514f5e3Sopenharmony_ciclass ProtoChangeDetails : public TaggedObject {
494514f5e3Sopenharmony_cipublic:
504514f5e3Sopenharmony_ci    static constexpr int UNREGISTERED = -1;
514514f5e3Sopenharmony_ci    static ProtoChangeDetails *Cast(TaggedObject *object)
524514f5e3Sopenharmony_ci    {
534514f5e3Sopenharmony_ci        ASSERT(JSTaggedValue(object).IsProtoChangeDetails());
544514f5e3Sopenharmony_ci        return static_cast<ProtoChangeDetails *>(object);
554514f5e3Sopenharmony_ci    }
564514f5e3Sopenharmony_ci
574514f5e3Sopenharmony_ci    static constexpr size_t CHANGE_LISTENER_OFFSET = TaggedObjectSize();
584514f5e3Sopenharmony_ci    ACCESSORS(ChangeListener, CHANGE_LISTENER_OFFSET, REGISTER_INDEX_OFFSET);
594514f5e3Sopenharmony_ci    ACCESSORS_PRIMITIVE_FIELD(RegisterIndex, uint32_t, REGISTER_INDEX_OFFSET, LAST_OFFSET);
604514f5e3Sopenharmony_ci    DEFINE_ALIGN_SIZE(LAST_OFFSET);
614514f5e3Sopenharmony_ci
624514f5e3Sopenharmony_ci    DECL_VISIT_OBJECT(CHANGE_LISTENER_OFFSET, REGISTER_INDEX_OFFSET)
634514f5e3Sopenharmony_ci    DECL_DUMP()
644514f5e3Sopenharmony_ci};
654514f5e3Sopenharmony_ci
664514f5e3Sopenharmony_ciclass ChangeListener : public WeakVector {
674514f5e3Sopenharmony_cipublic:
684514f5e3Sopenharmony_ci    static ChangeListener *Cast(TaggedObject *object)
694514f5e3Sopenharmony_ci    {
704514f5e3Sopenharmony_ci        return static_cast<ChangeListener *>(object);
714514f5e3Sopenharmony_ci    }
724514f5e3Sopenharmony_ci
734514f5e3Sopenharmony_ci    static JSHandle<ChangeListener> Add(const JSThread *thread, const JSHandle<ChangeListener> &array,
744514f5e3Sopenharmony_ci                                        const JSHandle<JSHClass> &value, uint32_t *index);
754514f5e3Sopenharmony_ci
764514f5e3Sopenharmony_ci    static uint32_t CheckHole(const JSHandle<ChangeListener> &array);
774514f5e3Sopenharmony_ci
784514f5e3Sopenharmony_ci    JSTaggedValue Get(uint32_t index);
794514f5e3Sopenharmony_ci};
804514f5e3Sopenharmony_ci}  // namespace ecmascript
814514f5e3Sopenharmony_ci}  // namespace panda
824514f5e3Sopenharmony_ci
834514f5e3Sopenharmony_ci#endif  // ECMASCRIPT_IC_PROTOTYPE_CHANGE_DETAILS_H
84