Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: src/objects.h

Issue 2775303002: [regexp] Named capture support for string replacements (Closed)
Patch Set: Only cast if not undefined Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8251 matching lines...) Expand 10 before | Expand all | Expand 10 after
8262 Flags flags); 8262 Flags flags);
8263 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp); 8263 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp);
8264 8264
8265 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, 8265 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
8266 Handle<String> source, Flags flags); 8266 Handle<String> source, Flags flags);
8267 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, 8267 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
8268 Handle<String> source, 8268 Handle<String> source,
8269 Handle<String> flags_string); 8269 Handle<String> flags_string);
8270 8270
8271 inline Type TypeTag(); 8271 inline Type TypeTag();
8272 // Number of captures (without the match itself).
8272 inline int CaptureCount(); 8273 inline int CaptureCount();
8273 inline Flags GetFlags(); 8274 inline Flags GetFlags();
8274 inline String* Pattern(); 8275 inline String* Pattern();
8275 inline Object* CaptureNameMap(); 8276 inline Object* CaptureNameMap();
8276 inline Object* DataAt(int index); 8277 inline Object* DataAt(int index);
8277 // Set implementation data after the object has been prepared. 8278 // Set implementation data after the object has been prepared.
8278 inline void SetDataAt(int index, Object* value); 8279 inline void SetDataAt(int index, Object* value);
8279 8280
8280 inline void SetLastIndex(int index); 8281 inline void SetLastIndex(int index);
8281 inline Object* LastIndex(); 8282 inline Object* LastIndex();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
8334 // Saved instance of Irregexp compiled code or bytecode for UC16 that is 8335 // Saved instance of Irregexp compiled code or bytecode for UC16 that is
8335 // a potential candidate for flushing. 8336 // a potential candidate for flushing.
8336 static const int kIrregexpUC16CodeSavedIndex = kDataIndex + 3; 8337 static const int kIrregexpUC16CodeSavedIndex = kDataIndex + 3;
8337 8338
8338 // Maximal number of registers used by either Latin1 or UC16. 8339 // Maximal number of registers used by either Latin1 or UC16.
8339 // Only used to check that there is enough stack space 8340 // Only used to check that there is enough stack space
8340 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 4; 8341 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 4;
8341 // Number of captures in the compiled regexp. 8342 // Number of captures in the compiled regexp.
8342 static const int kIrregexpCaptureCountIndex = kDataIndex + 5; 8343 static const int kIrregexpCaptureCountIndex = kDataIndex + 5;
8343 // Maps names of named capture groups (at indices 2i) to their corresponding 8344 // Maps names of named capture groups (at indices 2i) to their corresponding
8344 // capture group indices (at indices 2i + 1). 8345 // (1-based) capture group indices (at indices 2i + 1).
8345 static const int kIrregexpCaptureNameMapIndex = kDataIndex + 6; 8346 static const int kIrregexpCaptureNameMapIndex = kDataIndex + 6;
8346 8347
8347 static const int kIrregexpDataSize = kIrregexpCaptureNameMapIndex + 1; 8348 static const int kIrregexpDataSize = kIrregexpCaptureNameMapIndex + 1;
8348 8349
8349 // In-object fields. 8350 // In-object fields.
8350 static const int kLastIndexFieldIndex = 0; 8351 static const int kLastIndexFieldIndex = 0;
8351 static const int kInObjectFieldCount = 1; 8352 static const int kInObjectFieldCount = 1;
8352 8353
8353 // The uninitialized value for a regexp code object. 8354 // The uninitialized value for a regexp code object.
8354 static const int kUninitializedValue = -1; 8355 static const int kUninitializedValue = -1;
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
9189 Handle<String> search, int start_index); 9190 Handle<String> search, int start_index);
9190 9191
9191 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver, 9192 static Object* LastIndexOf(Isolate* isolate, Handle<Object> receiver,
9192 Handle<Object> search, Handle<Object> position); 9193 Handle<Object> search, Handle<Object> position);
9193 9194
9194 // Encapsulates logic related to a match and its capture groups as required 9195 // Encapsulates logic related to a match and its capture groups as required
9195 // by GetSubstitution. 9196 // by GetSubstitution.
9196 class Match { 9197 class Match {
9197 public: 9198 public:
9198 virtual Handle<String> GetMatch() = 0; 9199 virtual Handle<String> GetMatch() = 0;
9199 virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0;
9200 virtual Handle<String> GetPrefix() = 0; 9200 virtual Handle<String> GetPrefix() = 0;
9201 virtual Handle<String> GetSuffix() = 0; 9201 virtual Handle<String> GetSuffix() = 0;
9202
9202 virtual int CaptureCount() = 0; 9203 virtual int CaptureCount() = 0;
9204 virtual bool HasNamedCaptures() = 0;
9205 virtual MaybeHandle<String> GetCapture(int i, bool* capture_exists) = 0;
9206 virtual MaybeHandle<String> GetNamedCapture(Handle<String> name,
9207 bool* capture_exists) = 0;
9208
9203 virtual ~Match() {} 9209 virtual ~Match() {}
9204 }; 9210 };
9205 9211
9206 // ES#sec-getsubstitution 9212 // ES#sec-getsubstitution
9207 // GetSubstitution(matched, str, position, captures, replacement) 9213 // GetSubstitution(matched, str, position, captures, replacement)
9208 // Expand the $-expressions in the string and return a new string with 9214 // Expand the $-expressions in the string and return a new string with
9209 // the result. 9215 // the result.
9210 MUST_USE_RESULT static MaybeHandle<String> GetSubstitution( 9216 MUST_USE_RESULT static MaybeHandle<String> GetSubstitution(
9211 Isolate* isolate, Match* match, Handle<String> replacement); 9217 Isolate* isolate, Match* match, Handle<String> replacement);
9212 9218
9213 // String equality operations. 9219 // String equality operations.
9214 inline bool Equals(String* other); 9220 inline bool Equals(String* other);
9215 inline static bool Equals(Handle<String> one, Handle<String> two); 9221 inline static bool Equals(Handle<String> one, Handle<String> two);
9216 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); 9222 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false);
9223
9224 // Dispatches to Is{One,Two}ByteEqualTo.
9225 template <typename Char>
9226 bool IsEqualTo(Vector<const Char> str);
9227
9217 bool IsOneByteEqualTo(Vector<const uint8_t> str); 9228 bool IsOneByteEqualTo(Vector<const uint8_t> str);
9218 bool IsTwoByteEqualTo(Vector<const uc16> str); 9229 bool IsTwoByteEqualTo(Vector<const uc16> str);
9219 9230
9220 // Return a UTF8 representation of the string. The string is null 9231 // Return a UTF8 representation of the string. The string is null
9221 // terminated but may optionally contain nulls. Length is returned 9232 // terminated but may optionally contain nulls. Length is returned
9222 // in length_output if length_output is not a null pointer The string 9233 // in length_output if length_output is not a null pointer The string
9223 // should be nearly flat, otherwise the performance of this method may 9234 // should be nearly flat, otherwise the performance of this method may
9224 // be very slow (quadratic in the length). Setting robustness_flag to 9235 // be very slow (quadratic in the length). Setting robustness_flag to
9225 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it 9236 // ROBUST_STRING_TRAVERSAL invokes behaviour that is robust This means it
9226 // handles unexpected data without causing assert failures and it does not 9237 // handles unexpected data without causing assert failures and it does not
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after
11318 } 11329 }
11319 }; 11330 };
11320 11331
11321 11332
11322 } // NOLINT, false-positive due to second-order macros. 11333 } // NOLINT, false-positive due to second-order macros.
11323 } // NOLINT, false-positive due to second-order macros. 11334 } // NOLINT, false-positive due to second-order macros.
11324 11335
11325 #include "src/objects/object-macros-undef.h" 11336 #include "src/objects/object-macros-undef.h"
11326 11337
11327 #endif // V8_OBJECTS_H_ 11338 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698