 Chromium Code Reviews
 Chromium Code Reviews Issue 1114001:
  Refactoring of RegExp interface to better support calling several times in a row.  (Closed)
    
  
    Issue 1114001:
  Refactoring of RegExp interface to better support calling several times in a row.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright | 
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. | 
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above | 
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following | 
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 Handle<String> flags); | 70 Handle<String> flags); | 
| 71 | 71 | 
| 72 // See ECMA-262 section 15.10.6.2. | 72 // See ECMA-262 section 15.10.6.2. | 
| 73 // This function calls the garbage collector if necessary. | 73 // This function calls the garbage collector if necessary. | 
| 74 static Handle<Object> Exec(Handle<JSRegExp> regexp, | 74 static Handle<Object> Exec(Handle<JSRegExp> regexp, | 
| 75 Handle<String> subject, | 75 Handle<String> subject, | 
| 76 int index, | 76 int index, | 
| 77 Handle<JSArray> lastMatchInfo); | 77 Handle<JSArray> lastMatchInfo); | 
| 78 | 78 | 
| 79 // Prepares a JSRegExp object with Irregexp-specific data. | 79 // Prepares a JSRegExp object with Irregexp-specific data. | 
| 80 static void IrregexpPrepare(Handle<JSRegExp> re, | 80 static void IrregexpInitialize(Handle<JSRegExp> re, | 
| 81 Handle<String> pattern, | 81 Handle<String> pattern, | 
| 
Erik Corry
2010/03/19 11:04:11
indent
 
Lasse Reichstein
2010/03/19 11:25:42
Done.
 | |
| 82 JSRegExp::Flags flags, | 82 JSRegExp::Flags flags, | 
| 83 int capture_register_count); | 83 int capture_register_count); | 
| 84 | 84 | 
| 85 | 85 | 
| 86 static void AtomCompile(Handle<JSRegExp> re, | 86 static void AtomCompile(Handle<JSRegExp> re, | 
| 87 Handle<String> pattern, | 87 Handle<String> pattern, | 
| 88 JSRegExp::Flags flags, | 88 JSRegExp::Flags flags, | 
| 89 Handle<String> match_pattern); | 89 Handle<String> match_pattern); | 
| 90 | 90 | 
| 91 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, | 91 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, | 
| 92 Handle<String> subject, | 92 Handle<String> subject, | 
| 93 int index, | 93 int index, | 
| 94 Handle<JSArray> lastMatchInfo); | 94 Handle<JSArray> lastMatchInfo); | 
| 95 | 95 | 
| 96 enum IrregexpResult { RE_FAILURE = 0, RE_SUCCESS = 1, RE_EXCEPTION = -1 }; | |
| 97 | |
| 98 // Prepare a RegExp for being executed one or more times (using | |
| 99 // IrregexpExecOnce) on the subject. | |
| 100 // This ensures that the regexp is compiled for the subject, and that | |
| 101 // the subject is flat. | |
| 102 // Returns the number of integer spaces required by IrregexpExecOnce | |
| 103 // as its "registers" argument. If the regexp cannot be compiled, | |
| 104 // an exeception is thrown, and this function returns negative. | |
| 
Erik Corry
2010/03/19 11:04:11
Unclear comment.  You can't both throw an exceptio
 
Lasse Reichstein
2010/03/19 11:25:42
Reworded.
 | |
| 105 static int IrregexpPrepare(Handle<JSRegExp> regexp, | |
| 106 Handle<String> subject); | |
| 107 | |
| 108 // Execute a regular expression once on the subject, starting from | |
| 109 // character "index". | |
| 110 // If successful, returns RE_SUCCESS and have set the capture positions | |
| 
Erik Corry
2010/03/19 11:04:11
have -> set
 | |
| 111 // in the first registers. | |
| 112 // If matching fails, returns RE_FAILURE. | |
| 113 // If execution fails, throws an exception and returns RE_EXCEPTION. | |
| 
Erik Corry
2010/03/19 11:04:11
Unclear again.
 
Lasse Reichstein
2010/03/19 11:25:42
Reworded.
 | |
| 114 static IrregexpResult IrregexpExecOnce(Handle<JSRegExp> regexp, | |
| 115 Handle<String> subject, | |
| 116 int index, | |
| 117 Vector<int32_t> registers); | |
| 118 | |
| 96 // Execute an Irregexp bytecode pattern. | 119 // Execute an Irregexp bytecode pattern. | 
| 97 // On a successful match, the result is a JSArray containing | 120 // On a successful match, the result is a JSArray containing | 
| 98 // captured positions. On a failure, the result is the null value. | 121 // captured positions. On a failure, the result is the null value. | 
| 99 // Returns an empty handle in case of an exception. | 122 // Returns an empty handle in case of an exception. | 
| 100 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, | 123 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, | 
| 101 Handle<String> subject, | 124 Handle<String> subject, | 
| 102 int index, | 125 int index, | 
| 103 Handle<JSArray> lastMatchInfo); | 126 Handle<JSArray> lastMatchInfo); | 
| 104 | 127 | 
| 105 // Array index in the lastMatchInfo array. | 128 // Array index in the lastMatchInfo array. | 
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 int offsets_vector_length_; | 1454 int offsets_vector_length_; | 
| 1432 static int static_offsets_vector_[kStaticOffsetsVectorSize]; | 1455 static int static_offsets_vector_[kStaticOffsetsVectorSize]; | 
| 1433 | 1456 | 
| 1434 friend class ExternalReference; | 1457 friend class ExternalReference; | 
| 1435 }; | 1458 }; | 
| 1436 | 1459 | 
| 1437 | 1460 | 
| 1438 } } // namespace v8::internal | 1461 } } // namespace v8::internal | 
| 1439 | 1462 | 
| 1440 #endif // V8_JSREGEXP_H_ | 1463 #endif // V8_JSREGEXP_H_ | 
| OLD | NEW |