v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
regexp-utils.h
Go to the documentation of this file.
1// Copyright 2016 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_REGEXP_REGEXP_UTILS_H_
6#define V8_REGEXP_REGEXP_UTILS_H_
7
9
10namespace v8 {
11namespace internal {
12
13class JSReceiver;
14class Object;
15class RegExpMatchInfo;
16class String;
17
18// Helper methods for C++ regexp builtins.
19class RegExpUtils : public AllStatic {
20 public:
21 // Last match info accessors.
23 Isolate* isolate, DirectHandle<RegExpMatchInfo> match_info, int capture,
24 bool* ok = nullptr);
25 // Checks if the capture group referred to by index |capture| is part of the
26 // match.
27 static bool IsMatchedCapture(Tagged<RegExpMatchInfo> match_info, int capture);
28
29 // Last index (RegExp.lastIndex) accessors.
31 Isolate* isolate, DirectHandle<JSReceiver> regexp, uint64_t value);
33 Isolate* isolate, DirectHandle<JSReceiver> recv);
34
35 // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
37 Isolate* isolate, DirectHandle<JSReceiver> regexp,
39
40 // Checks whether the given object is an unmodified JSRegExp instance.
41 // Neither the object's map, nor its prototype's map, nor any relevant
42 // method on the prototype may be modified.
43 //
44 // Note: This check is limited may only be used in situations where the only
45 // relevant property is 'exec'.
46 static bool IsUnmodifiedRegExp(Isolate* isolate, DirectHandle<Object> obj);
47
48 // ES#sec-advancestringindex
49 // AdvanceStringIndex ( S, index, unicode )
50 static uint64_t AdvanceStringIndex(Tagged<String> string, uint64_t index,
51 bool unicode);
53 Isolate* isolate, DirectHandle<JSReceiver> regexp,
54 DirectHandle<String> string, bool unicode);
55};
56
57} // namespace internal
58} // namespace v8
59
60#endif // V8_REGEXP_REGEXP_UTILS_H_
static Handle< String > GenericCaptureGetter(Isolate *isolate, DirectHandle< RegExpMatchInfo > match_info, int capture, bool *ok=nullptr)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetLastIndex(Isolate *isolate, DirectHandle< JSReceiver > recv)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetAdvancedStringIndex(Isolate *isolate, DirectHandle< JSReceiver > regexp, DirectHandle< String > string, bool unicode)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetLastIndex(Isolate *isolate, DirectHandle< JSReceiver > regexp, uint64_t value)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSAny > RegExpExec(Isolate *isolate, DirectHandle< JSReceiver > regexp, DirectHandle< String > string, DirectHandle< Object > exec)
static uint64_t AdvanceStringIndex(Tagged< String > string, uint64_t index, bool unicode)
static bool IsMatchedCapture(Tagged< RegExpMatchInfo > match_info, int capture)
static bool IsUnmodifiedRegExp(Isolate *isolate, DirectHandle< Object > obj)
v8_inspector::String16 String
Definition string-util.h:26
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671