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

Side by Side Diff: src/regexp-delay.js

Issue 521028: Direct call to native RegExp code from JavaScript (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/regexp-macro-assembler.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // behavior. 129 // behavior.
130 if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) { 130 if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) {
131 DoConstructRegExp(this, 'undefined', flags, false); 131 DoConstructRegExp(this, 'undefined', flags, false);
132 } else { 132 } else {
133 DoConstructRegExp(this, pattern, flags, false); 133 DoConstructRegExp(this, pattern, flags, false);
134 } 134 }
135 } 135 }
136 136
137 137
138 function DoRegExpExec(regexp, string, index) { 138 function DoRegExpExec(regexp, string, index) {
139 return %RegExpExec(regexp, string, index, lastMatchInfo); 139 return %_RegExpExec(regexp, string, index, lastMatchInfo);
140 } 140 }
141 141
142 142
143 function RegExpExec(string) { 143 function RegExpExec(string) {
144 if (!IS_REGEXP(this)) { 144 if (!IS_REGEXP(this)) {
145 throw MakeTypeError('method_called_on_incompatible', 145 throw MakeTypeError('method_called_on_incompatible',
146 ['RegExp.prototype.exec', this]); 146 ['RegExp.prototype.exec', this]);
147 } 147 }
148 if (%_ArgumentsLength() == 0) { 148 if (%_ArgumentsLength() == 0) {
149 var regExpInput = LAST_INPUT(lastMatchInfo); 149 var regExpInput = LAST_INPUT(lastMatchInfo);
150 if (IS_UNDEFINED(regExpInput)) { 150 if (IS_UNDEFINED(regExpInput)) {
151 throw MakeError('no_input_to_regexp', [this]); 151 throw MakeError('no_input_to_regexp', [this]);
152 } 152 }
153 string = regExpInput; 153 string = regExpInput;
154 } 154 }
155 var s = ToString(string); 155 var s = ToString(string);
156 var length = s.length; 156 var length = s.length;
157 var lastIndex = this.lastIndex; 157 var lastIndex = this.lastIndex;
158 var i = this.global ? TO_INTEGER(lastIndex) : 0; 158 var i = this.global ? TO_INTEGER(lastIndex) : 0;
159 159
160 if (i < 0 || i > s.length) { 160 if (i < 0 || i > s.length) {
161 this.lastIndex = 0; 161 this.lastIndex = 0;
162 return null; 162 return null;
163 } 163 }
164 164
165 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); 165 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]);
166 // matchIndices is either null or the lastMatchInfo array. 166 // matchIndices is either null or the lastMatchInfo array.
167 var matchIndices = %RegExpExec(this, s, i, lastMatchInfo); 167 var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo);
168 168
169 if (matchIndices == null) { 169 if (matchIndices == null) {
170 if (this.global) this.lastIndex = 0; 170 if (this.global) this.lastIndex = 0;
171 return matchIndices; // no match 171 return matchIndices; // no match
172 } 172 }
173 173
174 var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; 174 var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1;
175 var result = new $Array(numResults); 175 var result = new $Array(numResults);
176 for (var i = 0; i < numResults; i++) { 176 for (var i = 0; i < numResults; i++) {
177 var matchStart = lastMatchInfo[CAPTURE(i << 1)]; 177 var matchStart = lastMatchInfo[CAPTURE(i << 1)];
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 var lastIndex = this.lastIndex; 214 var lastIndex = this.lastIndex;
215 var i = this.global ? TO_INTEGER(lastIndex) : 0; 215 var i = this.global ? TO_INTEGER(lastIndex) : 0;
216 216
217 if (i < 0 || i > s.length) { 217 if (i < 0 || i > s.length) {
218 this.lastIndex = 0; 218 this.lastIndex = 0;
219 return false; 219 return false;
220 } 220 }
221 221
222 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); 222 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]);
223 // matchIndices is either null or the lastMatchInfo array. 223 // matchIndices is either null or the lastMatchInfo array.
224 var matchIndices = %RegExpExec(this, s, i, lastMatchInfo); 224 var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo);
225 225
226 if (matchIndices == null) { 226 if (matchIndices == null) {
227 if (this.global) this.lastIndex = 0; 227 if (this.global) this.lastIndex = 0;
228 return false; 228 return false;
229 } 229 }
230 230
231 if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1]; 231 if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1];
232 return true; 232 return true;
233 } 233 }
234 234
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 397 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE);
398 398
399 for (var i = 1; i < 10; ++i) { 399 for (var i = 1; i < 10; ++i) {
400 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE); 400 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE);
401 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); 401 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE);
402 } 402 }
403 } 403 }
404 404
405 405
406 SetupRegExp(); 406 SetupRegExp();
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/regexp-macro-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698