v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
regexp-match-info.h
Go to the documentation of this file.
1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_OBJECTS_REGEXP_MATCH_INFO_H_
6#define V8_OBJECTS_REGEXP_MATCH_INFO_H_
7
10#include "src/objects/objects.h"
11
12// Has to be the last include (doesn't have include guards):
14
15namespace v8 {
16namespace internal {
17
18class Object;
19class String;
20
21// TODO(jgruber): These should no longer be included here; instead, all
22// TorqueGeneratedFooAsserts should be emitted into a global .cc file.
23#include "torque-generated/src/objects/regexp-match-info-tq.inc"
24
25class RegExpMatchInfoShape final : public AllStatic {
26 public:
27 using ElementT = Smi;
29 static constexpr RootIndex kMapRootIndex = RootIndex::kRegExpMatchInfoMap;
30 static constexpr bool kLengthEqualsCapacity = true;
31
33 TaggedMember<Smi> number_of_capture_registers_;
34 TaggedMember<String> last_subject_;
35 TaggedMember<Object> last_input_;
36 });
37};
38
39// The property RegExpMatchInfo includes the matchIndices array of the last
40// successful regexp match (an array of start/end index pairs for the match and
41// all the captured substrings), the invariant is that there are at least two
42// capture indices. The array also contains the subject string for the last
43// successful match.
45 : public TaggedArrayBase<RegExpMatchInfo, RegExpMatchInfoShape> {
47
48 public:
50
52 Isolate* isolate, int capture_count,
54
56 Isolate* isolate, DirectHandle<RegExpMatchInfo> match_info,
57 int capture_count);
58
59 // Returns the number of captures, which is defined as the length of the
60 // matchIndices objects of the last match. matchIndices contains two indices
61 // for each capture (including the match itself), i.e. 2 * #captures + 2.
62 inline int number_of_capture_registers() const;
63 inline void set_number_of_capture_registers(int value);
64
65 // Returns the subject string of the last match.
66 inline Tagged<String> last_subject() const;
67 inline void set_last_subject(Tagged<String> value,
69
70 // Like |last_subject|, but modifiable by the user.
71 inline Tagged<Object> last_input() const;
72 inline void set_last_input(Tagged<Object> value,
74
75 inline int capture(int index) const;
76 inline void set_capture(int index, int value);
77
78 static constexpr int capture_start_index(int capture_index) {
79 return capture_index * 2;
80 }
81 static constexpr int capture_end_index(int capture_index) {
82 return capture_index * 2 + 1;
83 }
84
85 static constexpr int kMinCapacity = 2;
86
89
90 class BodyDescriptor;
92
93} // namespace internal
94} // namespace v8
95
97
98#endif // V8_OBJECTS_REGEXP_MATCH_INFO_H_
V8_ARRAY_EXTRA_FIELDS({ TaggedMember< Smi > number_of_capture_registers_;TaggedMember< String > last_subject_;TaggedMember< Object > last_input_;})
static constexpr RootIndex kMapRootIndex
static constexpr bool kLengthEqualsCapacity
void set_last_input(Tagged< Object > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
Tagged< Object > last_input() const
void set_capture(int index, int value)
static DirectHandle< RegExpMatchInfo > ReserveCaptures(Isolate *isolate, DirectHandle< RegExpMatchInfo > match_info, int capture_count)
static constexpr int capture_start_index(int capture_index)
static constexpr int capture_end_index(int capture_index)
void set_last_subject(Tagged< String > value, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static constexpr int kMinCapacity
static V8_EXPORT_PRIVATE DirectHandle< RegExpMatchInfo > New(Isolate *isolate, int capture_count, AllocationType allocation=AllocationType::kYoung)
Tagged< String > last_subject() const
@ UPDATE_WRITE_BARRIER
Definition objects.h:55
v8::internal::LoadHandler V8_OBJECT_END
v8_inspector::String16 String
Definition string-util.h:26
#define DECL_VERIFIER(Name)
#define V8_OBJECT
#define DECL_PRINTER(Name)
#define V8_EXPORT_PRIVATE
Definition macros.h:460