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

Side by Side Diff: src/string.js

Issue 1199813004: i18n.js was not using original functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use match instead of exec Created 5 years, 6 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/regexp.js ('k') | test/mjsunit/string-normalize.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 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
11 11
12 var GlobalRegExp = global.RegExp; 12 var GlobalRegExp = global.RegExp;
13 var GlobalString = global.String; 13 var GlobalString = global.String;
14 var InternalArray = utils.InternalArray; 14 var InternalArray = utils.InternalArray;
15 var InternalPackedArray = utils.InternalPackedArray; 15 var InternalPackedArray = utils.InternalPackedArray;
16 16
17 var ArrayIndexOf;
18 var ArrayJoin;
17 var MathMax; 19 var MathMax;
18 var MathMin; 20 var MathMin;
19 var RegExpExec; 21 var RegExpExec;
20 var RegExpExecNoTests; 22 var RegExpExecNoTests;
21 var RegExpLastMatchInfo; 23 var RegExpLastMatchInfo;
22 24
23 utils.Import(function(from) { 25 utils.Import(function(from) {
26 ArrayIndexOf = from.ArrayIndexOf;
27 ArrayJoin = from.ArrayJoin;
24 MathMax = from.MathMax; 28 MathMax = from.MathMax;
25 MathMin = from.MathMin; 29 MathMin = from.MathMin;
26 RegExpExec = from.RegExpExec; 30 RegExpExec = from.RegExpExec;
27 RegExpExecNoTests = from.RegExpExecNoTests; 31 RegExpExecNoTests = from.RegExpExecNoTests;
28 RegExpLastMatchInfo = from.RegExpLastMatchInfo; 32 RegExpLastMatchInfo = from.RegExpLastMatchInfo;
29 }); 33 });
30 34
31 //------------------------------------------------------------------- 35 //-------------------------------------------------------------------
32 36
33 function StringConstructor(x) { 37 function StringConstructor(x) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // 188 //
185 // For now we do nothing, as proper normalization requires big tables. 189 // For now we do nothing, as proper normalization requires big tables.
186 // If Intl is enabled, then i18n.js will override it and provide the the 190 // If Intl is enabled, then i18n.js will override it and provide the the
187 // proper functionality. 191 // proper functionality.
188 function StringNormalizeJS(form) { 192 function StringNormalizeJS(form) {
189 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); 193 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
190 194
191 var form = form ? TO_STRING_INLINE(form) : 'NFC'; 195 var form = form ? TO_STRING_INLINE(form) : 'NFC';
192 196
193 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; 197 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
194 198 var normalizationForm =
195 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); 199 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf);
196 if (normalizationForm === -1) { 200 if (normalizationForm === -1) {
197 throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', ')); 201 throw MakeRangeError(kNormalizationForm,
202 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin));
198 } 203 }
199 204
200 return %_ValueOf(this); 205 return %_ValueOf(this);
201 } 206 }
202 207
203 208
204 // This has the same size as the RegExpLastMatchInfo array, and can be used 209 // This has the same size as the RegExpLastMatchInfo array, and can be used
205 // for functions that expect that structure to be returned. It is used when 210 // for functions that expect that structure to be returned. It is used when
206 // the needle is a string rather than a regexp. In this case we can't update 211 // the needle is a string rather than a regexp. In this case we can't update
207 // lastMatchArray without erroneously affecting the properties on the global 212 // lastMatchArray without erroneously affecting the properties on the global
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 "sub", StringSub, 1189 "sub", StringSub,
1185 "sup", StringSup 1190 "sup", StringSup
1186 ]); 1191 ]);
1187 1192
1188 // ------------------------------------------------------------------- 1193 // -------------------------------------------------------------------
1189 // Exports 1194 // Exports
1190 1195
1191 utils.Export(function(to) { 1196 utils.Export(function(to) {
1192 to.StringCharAt = StringCharAtJS; 1197 to.StringCharAt = StringCharAtJS;
1193 to.StringIndexOf = StringIndexOfJS; 1198 to.StringIndexOf = StringIndexOfJS;
1199 to.StringLastIndexOf = StringLastIndexOfJS;
1200 to.StringMatch = StringMatchJS;
1201 to.StringReplace = StringReplace;
1202 to.StringSplit = StringSplitJS;
1203 to.StringSubstr = StringSubstr;
1194 to.StringSubstring = StringSubstring; 1204 to.StringSubstring = StringSubstring;
1195 }); 1205 });
1196 1206
1197 }) 1207 })
OLDNEW
« no previous file with comments | « src/regexp.js ('k') | test/mjsunit/string-normalize.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698