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

Side by Side Diff: src/jsregexp.h

Issue 53047: Implement string.match in C++. (Closed)
Patch Set: Created 11 years, 9 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 | « no previous file | src/jsregexp.cc » ('j') | src/string.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 static void AtomCompile(Handle<JSRegExp> re, 87 static void AtomCompile(Handle<JSRegExp> re,
88 Handle<String> pattern, 88 Handle<String> pattern,
89 JSRegExp::Flags flags, 89 JSRegExp::Flags flags,
90 Handle<String> match_pattern); 90 Handle<String> match_pattern);
91 91
92 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, 92 static Handle<Object> AtomExec(Handle<JSRegExp> regexp,
93 Handle<String> subject, 93 Handle<String> subject,
94 int index, 94 int index,
95 Handle<JSArray> lastMatchInfo); 95 Handle<JSArray> lastMatchInfo);
96 96
97 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp,
98 Handle<String> subject,
99 Handle<JSArray> lastMatchInfo);
100
101 // Execute an Irregexp bytecode pattern. 97 // Execute an Irregexp bytecode pattern.
98 // On a successful match, the result is a JSArray containing
99 // captured positions. On a failure, the result is the null value.
100 // Returns an empty handle in case of an exception.
102 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, 101 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp,
103 Handle<String> subject, 102 Handle<String> subject,
104 int index, 103 int index,
105 Handle<JSArray> lastMatchInfo); 104 Handle<JSArray> lastMatchInfo);
106 105
107 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp,
108 Handle<String> subject,
109 Handle<JSArray> lastMatchInfo);
110
111 // Offsets in the lastMatchInfo array. 106 // Offsets in the lastMatchInfo array.
112 static const int kLastCaptureCount = 0; 107 static const int kLastCaptureCount = 0;
113 static const int kLastSubject = 1; 108 static const int kLastSubject = 1;
114 static const int kLastInput = 2; 109 static const int kLastInput = 2;
115 static const int kFirstCapture = 3; 110 static const int kFirstCapture = 3;
116 static const int kLastMatchOverhead = 3; 111 static const int kLastMatchOverhead = 3;
117 112
118 // Used to access the lastMatchInfo array. 113 // Used to access the lastMatchInfo array.
119 static int GetCapture(FixedArray* array, int index) { 114 static int GetCapture(FixedArray* array, int index) {
120 return Smi::cast(array->get(index + kFirstCapture))->value(); 115 return Smi::cast(array->get(index + kFirstCapture))->value();
(...skipping 27 matching lines...) Expand all
148 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii); 143 static ByteArray* IrregexpByteCode(FixedArray* re, bool is_ascii);
149 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii); 144 static Code* IrregexpNativeCode(FixedArray* re, bool is_ascii);
150 145
151 private: 146 private:
152 static String* last_ascii_string_; 147 static String* last_ascii_string_;
153 static String* two_byte_cached_string_; 148 static String* two_byte_cached_string_;
154 149
155 static bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii); 150 static bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii);
156 151
157 152
158 // On a successful match, the result is a JSArray containing
159 // captured positions. On a failure, the result is the null value.
160 // Returns an empty handle in case of an exception.
161 static Handle<Object> IrregexpExecOnce(Handle<JSRegExp> jsregexp,
162 int num_captures,
163 Handle<JSArray> lastMatchInfo,
164 Handle<String> subject16,
165 int previous_index,
166 int* ovector,
167 int ovector_length);
168
169 // Set the subject cache. The previous string buffer is not deleted, so the 153 // Set the subject cache. The previous string buffer is not deleted, so the
170 // caller should ensure that it doesn't leak. 154 // caller should ensure that it doesn't leak.
171 static void SetSubjectCache(String* subject, 155 static void SetSubjectCache(String* subject,
172 char* utf8_subject, 156 char* utf8_subject,
173 int uft8_length, 157 int uft8_length,
174 int character_position, 158 int character_position,
175 int utf8_position); 159 int utf8_position);
176 160
177 // A one element cache of the last utf8_subject string and its length. The 161 // A one element cache of the last utf8_subject string and its length. The
178 // subject JS String object is cached in the heap. We also cache a 162 // subject JS String object is cached in the heap. We also cache a
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 Handle<String> pattern, 1363 Handle<String> pattern,
1380 bool is_ascii); 1364 bool is_ascii);
1381 1365
1382 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1366 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1383 }; 1367 };
1384 1368
1385 1369
1386 } } // namespace v8::internal 1370 } } // namespace v8::internal
1387 1371
1388 #endif // V8_JSREGEXP_H_ 1372 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « no previous file | src/jsregexp.cc » ('j') | src/string.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698