/src/serenity/Userland/Libraries/LibJS/Bytecode/RegexTable.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/ByteString.h> |
10 | | #include <AK/DistinctNumeric.h> |
11 | | #include <AK/Vector.h> |
12 | | #include <LibRegex/RegexParser.h> |
13 | | |
14 | | namespace JS::Bytecode { |
15 | | |
16 | | AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(size_t, RegexTableIndex, Comparison); |
17 | | |
18 | | struct ParsedRegex { |
19 | | regex::Parser::Result regex; |
20 | | ByteString pattern; |
21 | | regex::RegexOptions<ECMAScriptFlags> flags; |
22 | | }; |
23 | | |
24 | | class RegexTable { |
25 | | AK_MAKE_NONMOVABLE(RegexTable); |
26 | | AK_MAKE_NONCOPYABLE(RegexTable); |
27 | | |
28 | | public: |
29 | 22 | RegexTable() = default; |
30 | | |
31 | | RegexTableIndex insert(ParsedRegex); |
32 | | ParsedRegex const& get(RegexTableIndex) const; |
33 | | void dump() const; |
34 | 0 | bool is_empty() const { return m_regexes.is_empty(); } |
35 | | |
36 | | private: |
37 | | Vector<ParsedRegex> m_regexes; |
38 | | }; |
39 | | |
40 | | } |