Home | History | Annotate | Download | only in regexp
      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 
      8 #include "src/objects.h"
      9 
     10 namespace v8 {
     11 namespace internal {
     12 
     13 class RegExpMatchInfo;
     14 
     15 // Helper methods for C++ regexp builtins.
     16 class RegExpUtils : public AllStatic {
     17  public:
     18   // Last match info accessors.
     19   static Handle<String> GenericCaptureGetter(Isolate* isolate,
     20                                              Handle<RegExpMatchInfo> match_info,
     21                                              int capture, bool* ok = nullptr);
     22 
     23   // Last index (RegExp.lastIndex) accessors.
     24   static V8_WARN_UNUSED_RESULT MaybeHandle<Object> SetLastIndex(
     25       Isolate* isolate, Handle<JSReceiver> regexp, uint64_t value);
     26   static V8_WARN_UNUSED_RESULT MaybeHandle<Object> GetLastIndex(
     27       Isolate* isolate, Handle<JSReceiver> recv);
     28 
     29   // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
     30   static V8_WARN_UNUSED_RESULT MaybeHandle<Object> RegExpExec(
     31       Isolate* isolate, Handle<JSReceiver> regexp, Handle<String> string,
     32       Handle<Object> exec);
     33 
     34   // ES#sec-isregexp IsRegExp ( argument )
     35   // Includes checking of the match property.
     36   static Maybe<bool> IsRegExp(Isolate* isolate, Handle<Object> object);
     37 
     38   // Checks whether the given object is an unmodified JSRegExp instance.
     39   // Neither the object's map, nor its prototype's map may be modified.
     40   static bool IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj);
     41 
     42   // ES#sec-advancestringindex
     43   // AdvanceStringIndex ( S, index, unicode )
     44   static uint64_t AdvanceStringIndex(Handle<String> string, uint64_t index,
     45                                      bool unicode);
     46   static V8_WARN_UNUSED_RESULT MaybeHandle<Object> SetAdvancedStringIndex(
     47       Isolate* isolate, Handle<JSReceiver> regexp, Handle<String> string,
     48       bool unicode);
     49 };
     50 
     51 }  // namespace internal
     52 }  // namespace v8
     53 
     54 #endif  // V8_REGEXP_REGEXP_UTILS_H_
     55