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 9466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9477 Handle<Object> search, Handle<Object> position); | 9477 Handle<Object> search, Handle<Object> position); |
9478 // Perform string match of pattern on subject, starting at start index. | 9478 // Perform string match of pattern on subject, starting at start index. |
9479 // Caller must ensure that 0 <= start_index <= sub->length(), as this does not | 9479 // Caller must ensure that 0 <= start_index <= sub->length(), as this does not |
9480 // check any arguments. | 9480 // check any arguments. |
9481 static int IndexOf(Isolate* isolate, Handle<String> receiver, | 9481 static int IndexOf(Isolate* isolate, Handle<String> receiver, |
9482 Handle<String> search, int start_index); | 9482 Handle<String> search, int start_index); |
9483 | 9483 |
9484 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver, | 9484 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver, |
9485 Handle<Object> search, Handle<Object> position); | 9485 Handle<Object> search, Handle<Object> position); |
9486 | 9486 |
| 9487 // Encapsulates logic related to a match and its capture groups as required |
| 9488 // by GetSubstitution. |
| 9489 class Match { |
| 9490 public: |
| 9491 virtual Handle<String> GetMatch() = 0; |
| 9492 virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0; |
| 9493 virtual Handle<String> GetPrefix() = 0; |
| 9494 virtual Handle<String> GetSuffix() = 0; |
| 9495 virtual int CaptureCount() = 0; |
| 9496 virtual ~Match() {} |
| 9497 }; |
| 9498 |
| 9499 // ES#sec-getsubstitution |
| 9500 // GetSubstitution(matched, str, position, captures, replacement) |
| 9501 // Expand the $-expressions in the string and return a new string with |
| 9502 // the result. |
| 9503 MUST_USE_RESULT static MaybeHandle<String> GetSubstitution( |
| 9504 Isolate* isolate, Match* match, Handle<String> replacement); |
| 9505 |
9487 // String equality operations. | 9506 // String equality operations. |
9488 inline bool Equals(String* other); | 9507 inline bool Equals(String* other); |
9489 inline static bool Equals(Handle<String> one, Handle<String> two); | 9508 inline static bool Equals(Handle<String> one, Handle<String> two); |
9490 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); | 9509 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); |
9491 bool IsOneByteEqualTo(Vector<const uint8_t> str); | 9510 bool IsOneByteEqualTo(Vector<const uint8_t> str); |
9492 bool IsTwoByteEqualTo(Vector<const uc16> str); | 9511 bool IsTwoByteEqualTo(Vector<const uc16> str); |
9493 | 9512 |
9494 // Return a UTF8 representation of the string. The string is null | 9513 // Return a UTF8 representation of the string. The string is null |
9495 // terminated but may optionally contain nulls. Length is returned | 9514 // terminated but may optionally contain nulls. Length is returned |
9496 // in length_output if length_output is not a null pointer The string | 9515 // in length_output if length_output is not a null pointer The string |
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11475 } | 11494 } |
11476 return value; | 11495 return value; |
11477 } | 11496 } |
11478 }; | 11497 }; |
11479 | 11498 |
11480 | 11499 |
11481 } // NOLINT, false-positive due to second-order macros. | 11500 } // NOLINT, false-positive due to second-order macros. |
11482 } // NOLINT, false-positive due to second-order macros. | 11501 } // NOLINT, false-positive due to second-order macros. |
11483 | 11502 |
11484 #endif // V8_OBJECTS_H_ | 11503 #endif // V8_OBJECTS_H_ |
OLD | NEW |