/* * Copyright (c) 2022, LI YUBEI * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace JS { // https://github.com/tc39/proposal-regexp-legacy-features#regexp // The %RegExp% intrinsic object, which is the builtin RegExp constructor, has the following additional internal slots: // [[RegExpInput]] // [[RegExpLastMatch]] // [[RegExpLastParen]] // [[RegExpLeftContext]] // [[RegExpRightContext]] // [[RegExpParen1]] ... [[RegExpParen9]] class RegExpLegacyStaticProperties { public: Optional const& input() const { return m_input; } Optional const& last_match() const { return m_last_match; } Optional const& last_paren() const { return m_last_paren; } Optional const& left_context() const { return m_left_context; } Optional const& right_context() const { return m_right_context; } Optional const& $1() const { return m_$1; } Optional const& $2() const { return m_$2; } Optional const& $3() const { return m_$3; } Optional const& $4() const { return m_$4; } Optional const& $5() const { return m_$5; } Optional const& $6() const { return m_$6; } Optional const& $7() const { return m_$7; } Optional const& $8() const { return m_$8; } Optional const& $9() const { return m_$9; } void set_input(Utf16String input) { m_input = move(input); } void set_last_match(Utf16String last_match) { m_last_match = move(last_match); } void set_last_paren(Utf16String last_paren) { m_last_paren = move(last_paren); } void set_left_context(Utf16String left_context) { m_left_context = move(left_context); } void set_right_context(Utf16String right_context) { m_right_context = move(right_context); } void set_$1(Utf16String value) { m_$1 = move(value); } void set_$2(Utf16String value) { m_$2 = move(value); } void set_$3(Utf16String value) { m_$3 = move(value); } void set_$4(Utf16String value) { m_$4 = move(value); } void set_$5(Utf16String value) { m_$5 = move(value); } void set_$6(Utf16String value) { m_$6 = move(value); } void set_$7(Utf16String value) { m_$7 = move(value); } void set_$8(Utf16String value) { m_$8 = move(value); } void set_$9(Utf16String value) { m_$9 = move(value); } void invalidate(); private: Optional m_input; Optional m_last_match; Optional m_last_paren; Optional m_left_context; Optional m_right_context; Optional m_$1; Optional m_$2; Optional m_$3; Optional m_$4; Optional m_$5; Optional m_$6; Optional m_$7; Optional m_$8; Optional m_$9; }; ThrowCompletionOr set_legacy_regexp_static_property(VM& vm, RegExpConstructor& constructor, Value this_value, void (RegExpLegacyStaticProperties::*property_setter)(Utf16String), Value value); ThrowCompletionOr get_legacy_regexp_static_property(VM& vm, RegExpConstructor& constructor, Value this_value, Optional const& (RegExpLegacyStaticProperties::*property_getter)() const); void update_legacy_regexp_static_properties(RegExpConstructor& constructor, Utf16String const& string, size_t start_index, size_t end_index, Vector const& captured_values); void invalidate_legacy_regexp_static_properties(RegExpConstructor& constructor); }