// Copyright 2016 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_REGEXP_REGEXP_UTILS_H_ #define V8_REGEXP_REGEXP_UTILS_H_ #include "src/objects/objects.h" namespace v8 { namespace internal { class RegExpMatchInfo; // Helper methods for C++ regexp builtins. class RegExpUtils : public AllStatic { public: // Last match info accessors. static Handle GenericCaptureGetter(Isolate* isolate, Handle match_info, int capture, bool* ok = nullptr); // Last index (RegExp.lastIndex) accessors. static V8_WARN_UNUSED_RESULT MaybeHandle SetLastIndex( Isolate* isolate, Handle regexp, uint64_t value); static V8_WARN_UNUSED_RESULT MaybeHandle GetLastIndex( Isolate* isolate, Handle recv); // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S ) static V8_WARN_UNUSED_RESULT MaybeHandle RegExpExec( Isolate* isolate, Handle regexp, Handle string, Handle exec); // ES#sec-isregexp IsRegExp ( argument ) // Includes checking of the match property. static Maybe IsRegExp(Isolate* isolate, Handle object); // Checks whether the given object is an unmodified JSRegExp instance. // Neither the object's map, nor its prototype's map, nor any relevant // method on the prototype may be modified. // // Note: This check is limited may only be used in situations where the only // relevant property is 'exec'. static bool IsUnmodifiedRegExp(Isolate* isolate, Handle obj); // ES#sec-advancestringindex // AdvanceStringIndex ( S, index, unicode ) static uint64_t AdvanceStringIndex(Handle string, uint64_t index, bool unicode); static V8_WARN_UNUSED_RESULT MaybeHandle SetAdvancedStringIndex( Isolate* isolate, Handle regexp, Handle string, bool unicode); }; } // namespace internal } // namespace v8 #endif // V8_REGEXP_REGEXP_UTILS_H_