| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_REGEXP_JSREGEXP_H_ | 5 #ifndef V8_REGEXP_JSREGEXP_H_ |
| 6 #define V8_REGEXP_JSREGEXP_H_ | 6 #define V8_REGEXP_JSREGEXP_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/regexp/regexp-ast.h" | 10 #include "src/regexp/regexp-ast.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // generic data and choice of implementation - as well as what | 40 // generic data and choice of implementation - as well as what |
| 41 // the implementation wants to store in the data field. | 41 // the implementation wants to store in the data field. |
| 42 // Returns false if compilation fails. | 42 // Returns false if compilation fails. |
| 43 MUST_USE_RESULT static MaybeHandle<Object> Compile(Handle<JSRegExp> re, | 43 MUST_USE_RESULT static MaybeHandle<Object> Compile(Handle<JSRegExp> re, |
| 44 Handle<String> pattern, | 44 Handle<String> pattern, |
| 45 JSRegExp::Flags flags); | 45 JSRegExp::Flags flags); |
| 46 | 46 |
| 47 // See ECMA-262 section 15.10.6.2. | 47 // See ECMA-262 section 15.10.6.2. |
| 48 // This function calls the garbage collector if necessary. | 48 // This function calls the garbage collector if necessary. |
| 49 MUST_USE_RESULT static MaybeHandle<Object> Exec( | 49 MUST_USE_RESULT static MaybeHandle<Object> Exec( |
| 50 Handle<JSRegExp> regexp, | 50 Handle<JSRegExp> regexp, Handle<String> subject, int index, |
| 51 Handle<String> subject, | 51 Handle<JSObject> lastMatchInfo); |
| 52 int index, | |
| 53 Handle<JSArray> lastMatchInfo); | |
| 54 | 52 |
| 55 // Prepares a JSRegExp object with Irregexp-specific data. | 53 // Prepares a JSRegExp object with Irregexp-specific data. |
| 56 static void IrregexpInitialize(Handle<JSRegExp> re, | 54 static void IrregexpInitialize(Handle<JSRegExp> re, |
| 57 Handle<String> pattern, | 55 Handle<String> pattern, |
| 58 JSRegExp::Flags flags, | 56 JSRegExp::Flags flags, |
| 59 int capture_register_count); | 57 int capture_register_count); |
| 60 | 58 |
| 61 | 59 |
| 62 static void AtomCompile(Handle<JSRegExp> re, | 60 static void AtomCompile(Handle<JSRegExp> re, |
| 63 Handle<String> pattern, | 61 Handle<String> pattern, |
| 64 JSRegExp::Flags flags, | 62 JSRegExp::Flags flags, |
| 65 Handle<String> match_pattern); | 63 Handle<String> match_pattern); |
| 66 | 64 |
| 67 | 65 |
| 68 static int AtomExecRaw(Handle<JSRegExp> regexp, | 66 static int AtomExecRaw(Handle<JSRegExp> regexp, |
| 69 Handle<String> subject, | 67 Handle<String> subject, |
| 70 int index, | 68 int index, |
| 71 int32_t* output, | 69 int32_t* output, |
| 72 int output_size); | 70 int output_size); |
| 73 | 71 |
| 74 | |
| 75 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, | 72 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, |
| 76 Handle<String> subject, | 73 Handle<String> subject, int index, |
| 77 int index, | 74 Handle<JSObject> lastMatchInfo); |
| 78 Handle<JSArray> lastMatchInfo); | |
| 79 | 75 |
| 80 enum IrregexpResult { RE_FAILURE = 0, RE_SUCCESS = 1, RE_EXCEPTION = -1 }; | 76 enum IrregexpResult { RE_FAILURE = 0, RE_SUCCESS = 1, RE_EXCEPTION = -1 }; |
| 81 | 77 |
| 82 // Prepare a RegExp for being executed one or more times (using | 78 // Prepare a RegExp for being executed one or more times (using |
| 83 // IrregexpExecOnce) on the subject. | 79 // IrregexpExecOnce) on the subject. |
| 84 // This ensures that the regexp is compiled for the subject, and that | 80 // This ensures that the regexp is compiled for the subject, and that |
| 85 // the subject is flat. | 81 // the subject is flat. |
| 86 // Returns the number of integer spaces required by IrregexpExecOnce | 82 // Returns the number of integer spaces required by IrregexpExecOnce |
| 87 // as its "registers" argument. If the regexp cannot be compiled, | 83 // as its "registers" argument. If the regexp cannot be compiled, |
| 88 // an exception is set as pending, and this function returns negative. | 84 // an exception is set as pending, and this function returns negative. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 Handle<String> subject, | 95 Handle<String> subject, |
| 100 int index, | 96 int index, |
| 101 int32_t* output, | 97 int32_t* output, |
| 102 int output_size); | 98 int output_size); |
| 103 | 99 |
| 104 // Execute an Irregexp bytecode pattern. | 100 // Execute an Irregexp bytecode pattern. |
| 105 // On a successful match, the result is a JSArray containing | 101 // On a successful match, the result is a JSArray containing |
| 106 // captured positions. On a failure, the result is the null value. | 102 // captured positions. On a failure, the result is the null value. |
| 107 // Returns an empty handle in case of an exception. | 103 // Returns an empty handle in case of an exception. |
| 108 MUST_USE_RESULT static MaybeHandle<Object> IrregexpExec( | 104 MUST_USE_RESULT static MaybeHandle<Object> IrregexpExec( |
| 109 Handle<JSRegExp> regexp, | 105 Handle<JSRegExp> regexp, Handle<String> subject, int index, |
| 110 Handle<String> subject, | 106 Handle<JSObject> lastMatchInfo); |
| 111 int index, | |
| 112 Handle<JSArray> lastMatchInfo); | |
| 113 | 107 |
| 114 // Set last match info. If match is NULL, then setting captures is omitted. | 108 // Set last match info. If match is NULL, then setting captures is omitted. |
| 115 static Handle<JSArray> SetLastMatchInfo(Handle<JSArray> last_match_info, | 109 static Handle<JSObject> SetLastMatchInfo(Handle<JSObject> last_match_info, |
| 116 Handle<String> subject, | 110 Handle<String> subject, |
| 117 int capture_count, | 111 int capture_count, int32_t* match); |
| 118 int32_t* match); | |
| 119 | |
| 120 | 112 |
| 121 class GlobalCache { | 113 class GlobalCache { |
| 122 public: | 114 public: |
| 123 GlobalCache(Handle<JSRegExp> regexp, | 115 GlobalCache(Handle<JSRegExp> regexp, |
| 124 Handle<String> subject, | 116 Handle<String> subject, |
| 125 Isolate* isolate); | 117 Isolate* isolate); |
| 126 | 118 |
| 127 INLINE(~GlobalCache()); | 119 INLINE(~GlobalCache()); |
| 128 | 120 |
| 129 // Fetch the next entry in the cache for global regexp match results. | 121 // Fetch the next entry in the cache for global regexp match results. |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 static const int kStringOffset = 0; | 1578 static const int kStringOffset = 0; |
| 1587 static const int kPatternOffset = 1; | 1579 static const int kPatternOffset = 1; |
| 1588 static const int kArrayOffset = 2; | 1580 static const int kArrayOffset = 2; |
| 1589 static const int kLastMatchOffset = 3; | 1581 static const int kLastMatchOffset = 3; |
| 1590 }; | 1582 }; |
| 1591 | 1583 |
| 1592 } // namespace internal | 1584 } // namespace internal |
| 1593 } // namespace v8 | 1585 } // namespace v8 |
| 1594 | 1586 |
| 1595 #endif // V8_REGEXP_JSREGEXP_H_ | 1587 #endif // V8_REGEXP_JSREGEXP_H_ |
| OLD | NEW |