OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 9397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9408 Handle<String> y); | 9408 Handle<String> y); |
9409 | 9409 |
9410 // Perform string match of pattern on subject, starting at start index. | 9410 // Perform string match of pattern on subject, starting at start index. |
9411 // Caller must ensure that 0 <= start_index <= sub->length(). | 9411 // Caller must ensure that 0 <= start_index <= sub->length(). |
9412 static int IndexOf(Isolate* isolate, Handle<String> sub, Handle<String> pat, | 9412 static int IndexOf(Isolate* isolate, Handle<String> sub, Handle<String> pat, |
9413 int start_index); | 9413 int start_index); |
9414 | 9414 |
9415 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver, | 9415 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver, |
9416 Handle<Object> search, Handle<Object> position); | 9416 Handle<Object> search, Handle<Object> position); |
9417 | 9417 |
| 9418 // Encapsulates logic related to a match and its capture groups as required |
| 9419 // by GetSubstitution. |
| 9420 class Match { |
| 9421 public: |
| 9422 virtual Handle<String> GetMatch() = 0; |
| 9423 virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0; |
| 9424 virtual Handle<String> GetPrefix() = 0; |
| 9425 virtual Handle<String> GetSuffix() = 0; |
| 9426 virtual int CaptureCount() = 0; |
| 9427 virtual ~Match() {} |
| 9428 }; |
| 9429 |
| 9430 // ES#sec-getsubstitution |
| 9431 // GetSubstitution(matched, str, position, captures, replacement) |
| 9432 // Expand the $-expressions in the string and return a new string with |
| 9433 // the result. |
| 9434 MUST_USE_RESULT static MaybeHandle<String> GetSubstitution( |
| 9435 Isolate* isolate, Match* match, Handle<String> replacement); |
| 9436 |
9418 // String equality operations. | 9437 // String equality operations. |
9419 inline bool Equals(String* other); | 9438 inline bool Equals(String* other); |
9420 inline static bool Equals(Handle<String> one, Handle<String> two); | 9439 inline static bool Equals(Handle<String> one, Handle<String> two); |
9421 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); | 9440 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); |
9422 bool IsOneByteEqualTo(Vector<const uint8_t> str); | 9441 bool IsOneByteEqualTo(Vector<const uint8_t> str); |
9423 bool IsTwoByteEqualTo(Vector<const uc16> str); | 9442 bool IsTwoByteEqualTo(Vector<const uc16> str); |
9424 | 9443 |
9425 // Return a UTF8 representation of the string. The string is null | 9444 // Return a UTF8 representation of the string. The string is null |
9426 // terminated but may optionally contain nulls. Length is returned | 9445 // terminated but may optionally contain nulls. Length is returned |
9427 // in length_output if length_output is not a null pointer The string | 9446 // in length_output if length_output is not a null pointer The string |
(...skipping 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11408 } | 11427 } |
11409 return value; | 11428 return value; |
11410 } | 11429 } |
11411 }; | 11430 }; |
11412 | 11431 |
11413 | 11432 |
11414 } // NOLINT, false-positive due to second-order macros. | 11433 } // NOLINT, false-positive due to second-order macros. |
11415 } // NOLINT, false-positive due to second-order macros. | 11434 } // NOLINT, false-positive due to second-order macros. |
11416 | 11435 |
11417 #endif // V8_OBJECTS_H_ | 11436 #endif // V8_OBJECTS_H_ |
OLD | NEW |