Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: src/objects/regexp-match-info.h

Issue 2642353002: objects.h splitting: Move RegExpMatchInfo. (Closed)
Patch Set: code review (mstarzinger@) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/regexp/regexp-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects/regexp-match-info.h
diff --git a/src/objects/regexp-match-info.h b/src/objects/regexp-match-info.h
new file mode 100644
index 0000000000000000000000000000000000000000..327ded32472ea6448e7c38cd68a083f91b2781d1
--- /dev/null
+++ b/src/objects/regexp-match-info.h
@@ -0,0 +1,76 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_OBJECTS_REGEXP_MATCH_INFO_H_
+#define V8_OBJECTS_REGEXP_MATCH_INFO_H_
+
+#include "src/base/compiler-specific.h"
+#include "src/objects.h"
+
+// Has to be the last include (doesn't have include guards):
+#include "src/objects/object-macros.h"
+
+namespace v8 {
+namespace internal {
+
+class Object;
+class String;
+
+// The property RegExpMatchInfo includes the matchIndices
+// array of the last successful regexp match (an array of start/end index
+// pairs for the match and all the captured substrings), the invariant is
+// that there are at least two capture indices. The array also contains
+// the subject string for the last successful match.
+// After creation the result must be treated as a FixedArray in all regards.
+class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
+ public:
+ // Returns the number of captures, which is defined as the length of the
+ // matchIndices objects of the last match. matchIndices contains two indices
+ // for each capture (including the match itself), i.e. 2 * #captures + 2.
+ inline int NumberOfCaptureRegisters();
+ inline void SetNumberOfCaptureRegisters(int value);
+
+ // Returns the subject string of the last match.
+ inline String* LastSubject();
+ inline void SetLastSubject(String* value);
+
+ // Like LastSubject, but modifiable by the user.
+ inline Object* LastInput();
+ inline void SetLastInput(Object* value);
+
+ // Returns the i'th capture index, 0 <= i < NumberOfCaptures(). Capture(0) and
+ // Capture(1) determine the start- and endpoint of the match itself.
+ inline int Capture(int i);
+ inline void SetCapture(int i, int value);
+
+ // Reserves space for captures.
+ static Handle<RegExpMatchInfo> ReserveCaptures(
+ Handle<RegExpMatchInfo> match_info, int capture_count);
+
+ DECLARE_CAST(RegExpMatchInfo)
+
+ static const int kNumberOfCapturesIndex = 0;
+ static const int kLastSubjectIndex = 1;
+ static const int kLastInputIndex = 2;
+ static const int kFirstCaptureIndex = 3;
+ static const int kLastMatchOverhead = kFirstCaptureIndex;
+
+ static const int kNumberOfCapturesOffset = FixedArray::kHeaderSize;
+ static const int kLastSubjectOffset = kNumberOfCapturesOffset + kPointerSize;
+ static const int kLastInputOffset = kLastSubjectOffset + kPointerSize;
+ static const int kFirstCaptureOffset = kLastInputOffset + kPointerSize;
+
+ // Every match info is guaranteed to have enough space to store two captures.
+ static const int kInitialCaptureIndices = 2;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMatchInfo);
+};
+
+} // namespace internal
+} // namespace v8
+
+#include "src/objects/object-macros-undef.h"
+
+#endif // V8_OBJECTS_REGEXP_MATCH_INFO_H_
« no previous file with comments | « src/objects-inl.h ('k') | src/regexp/regexp-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698