/*
 * 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_JSREGEXP_H
#define ECMASCRIPT_JSREGEXP_H

#include "ecmascript/ecma_macros.h"
#include "ecmascript/js_object.h"
#include "ecmascript/js_hclass.h"
#include "ecmascript/js_tagged_value_wrapper-inl.h"

namespace panda::ecmascript {
class JSRegExp : public JSObject {
public:
    static constexpr int EXEC_INLINE_PROPERTY_INDEX = 1;
    static constexpr int SPLIT_INLINE_PROPERTY_INDEX = 13;
    static constexpr int SEARCH_INLINE_PROPERTY_INDEX = 14;
    static constexpr int MATCH_INLINE_PROPERTY_INDEX = 15;
    static constexpr int MATCHALL_INLINE_PROPERTY_INDEX = 16;
    static constexpr int REPLACE_INLINE_PROPERTY_INDEX = 17;

    CAST_CHECK(JSRegExp, IsJSRegExp);

    static constexpr size_t REGEXP_BYTE_CODE_OFFSET = JSObject::SIZE;
    ACCESSORS(ByteCodeBuffer, REGEXP_BYTE_CODE_OFFSET, ORIGINAL_SOURCE_OFFSET)
    ACCESSORS_WITH_RB_MODE(OriginalSource, ORIGINAL_SOURCE_OFFSET, ORIGINAL_FLAGS_OFFSET)
    ACCESSORS_WITH_RB_MODE(OriginalFlags, ORIGINAL_FLAGS_OFFSET, GROUP_NAME_OFFSET)
    ACCESSORS(GroupName, GROUP_NAME_OFFSET, LENGTH_OFFSET)
    ACCESSORS_PRIMITIVE_FIELD(Length, uint32_t, LENGTH_OFFSET, LAST_OFFSET)
    DEFINE_ALIGN_SIZE(LAST_OFFSET);

    DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, REGEXP_BYTE_CODE_OFFSET, LENGTH_OFFSET)

    DECL_DUMP()
};
}  // namespace panda::ecmascript

#endif  // ECMASCRIPT_JSPRIMITIVEREF_H