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

Side by Side Diff: src/string.js

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 | « src/runtime.cc ('k') | test/mjsunit/regexp-indexof.js » ('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-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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 152
153 // ECMA-262 section 15.5.4.10 153 // ECMA-262 section 15.5.4.10
154 function StringMatch(regexp) { 154 function StringMatch(regexp) {
155 if (!IS_REGEXP(regexp)) regexp = new ORIGINAL_REGEXP(regexp); 155 if (!IS_REGEXP(regexp)) regexp = new ORIGINAL_REGEXP(regexp);
156 var subject = ToString(this); 156 var subject = ToString(this);
157 157
158 if (!regexp.global) return regexp.exec(subject); 158 if (!regexp.global) return regexp.exec(subject);
159 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]); 159 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
160 var matches = DoRegExpExecGlobal(regexp, subject); 160 // lastMatchInfo is defined in regexp-delay.js
Erik Corry 2009/03/25 11:29:46 full stop
161 161 return %StringMatch(subject, regexp, lastMatchInfo);
162 // If the regexp did not match, return null.
163 if (matches.length == 0) return null;
164
165 // Build the result array.
166 var result = new $Array(match_string);
167 for (var i = 0; i < matches.length; ++i) {
168 var matchInfo = matches[i];
169 var match_string = subject.slice(matchInfo[CAPTURE0],
170 matchInfo[CAPTURE1]);
171 result[i] = match_string;
172 }
173
174 return result;
175 } 162 }
176 163
177 164
178 // SubString is an internal function that returns the sub string of 'string'. 165 // SubString is an internal function that returns the sub string of 'string'.
179 // If resulting string is of length 1, we use the one character cache 166 // If resulting string is of length 1, we use the one character cache
180 // otherwise we call the runtime system. 167 // otherwise we call the runtime system.
181 function SubString(string, start, end) { 168 function SubString(string, start, end) {
182 // Use the one character string cache. 169 // Use the one character string cache.
183 if (start + 1 == end) { 170 if (start + 1 == end) {
184 var char_code = %_FastCharCodeAt(string, start); 171 var char_code = %_FastCharCodeAt(string, start);
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 "italics", StringItalics, 855 "italics", StringItalics,
869 "small", StringSmall, 856 "small", StringSmall,
870 "strike", StringStrike, 857 "strike", StringStrike,
871 "sub", StringSub, 858 "sub", StringSub,
872 "sup", StringSup 859 "sup", StringSup
873 )); 860 ));
874 } 861 }
875 862
876 863
877 SetupString(); 864 SetupString();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/regexp-indexof.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698