OLD | NEW |
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 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 if (IS_UNDEFINED(separator)) return [subject]; | 230 if (IS_UNDEFINED(separator)) return [subject]; |
231 | 231 |
232 var separator_length = separator_string.length; | 232 var separator_length = separator_string.length; |
233 | 233 |
234 // If the separator string is empty then return the elements in the subject. | 234 // If the separator string is empty then return the elements in the subject. |
235 if (separator_length === 0) return %StringToArray(subject, limit); | 235 if (separator_length === 0) return %StringToArray(subject, limit); |
236 | 236 |
237 return %StringSplit(subject, separator_string, limit); | 237 return %StringSplit(subject, separator_string, limit); |
238 } | 238 } |
239 | 239 |
240 // ecma262/#sec-string.prototype.substr | |
241 function StringSubstr(start, length) { | |
242 CHECK_OBJECT_COERCIBLE(this, "String.prototype.substr"); | |
243 var s = TO_STRING(this); | |
244 var size = s.length; | |
245 start = TO_INTEGER(start); | |
246 length = IS_UNDEFINED(length) ? size : TO_INTEGER(length); | |
247 | |
248 if (start < 0) start = MaxSimple(size + start, 0); | |
249 length = MinSimple(MaxSimple(length, 0), size - start); | |
250 | |
251 if (length <= 0) return ''; | |
252 return %_SubString(s, start, start + length); | |
253 } | |
254 | |
255 | 240 |
256 // ECMA-262, 15.5.4.16 | 241 // ECMA-262, 15.5.4.16 |
257 function StringToLowerCaseJS() { | 242 function StringToLowerCaseJS() { |
258 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase"); | 243 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase"); |
259 | 244 |
260 return %StringToLowerCase(TO_STRING(this)); | 245 return %StringToLowerCase(TO_STRING(this)); |
261 } | 246 } |
262 | 247 |
263 | 248 |
264 // ECMA-262, 15.5.4.17 | 249 // ECMA-262, 15.5.4.17 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 "concat", StringConcat, | 535 "concat", StringConcat, |
551 "endsWith", StringEndsWith, | 536 "endsWith", StringEndsWith, |
552 "includes", StringIncludes, | 537 "includes", StringIncludes, |
553 "indexOf", StringIndexOf, | 538 "indexOf", StringIndexOf, |
554 "match", StringMatchJS, | 539 "match", StringMatchJS, |
555 "repeat", StringRepeat, | 540 "repeat", StringRepeat, |
556 "replace", StringReplace, | 541 "replace", StringReplace, |
557 "search", StringSearch, | 542 "search", StringSearch, |
558 "slice", StringSlice, | 543 "slice", StringSlice, |
559 "split", StringSplitJS, | 544 "split", StringSplitJS, |
560 "substr", StringSubstr, | |
561 "startsWith", StringStartsWith, | 545 "startsWith", StringStartsWith, |
562 "toLowerCase", StringToLowerCaseJS, | 546 "toLowerCase", StringToLowerCaseJS, |
563 "toLocaleLowerCase", StringToLocaleLowerCase, | 547 "toLocaleLowerCase", StringToLocaleLowerCase, |
564 "toUpperCase", StringToUpperCaseJS, | 548 "toUpperCase", StringToUpperCaseJS, |
565 "toLocaleUpperCase", StringToLocaleUpperCase, | 549 "toLocaleUpperCase", StringToLocaleUpperCase, |
566 | 550 |
567 "link", StringLink, | 551 "link", StringLink, |
568 "anchor", StringAnchor, | 552 "anchor", StringAnchor, |
569 "fontcolor", StringFontcolor, | 553 "fontcolor", StringFontcolor, |
570 "fontsize", StringFontsize, | 554 "fontsize", StringFontsize, |
(...skipping 10 matching lines...) Expand all Loading... |
581 | 565 |
582 // ------------------------------------------------------------------- | 566 // ------------------------------------------------------------------- |
583 // Exports | 567 // Exports |
584 | 568 |
585 utils.Export(function(to) { | 569 utils.Export(function(to) { |
586 to.StringIndexOf = StringIndexOf; | 570 to.StringIndexOf = StringIndexOf; |
587 to.StringMatch = StringMatchJS; | 571 to.StringMatch = StringMatchJS; |
588 to.StringReplace = StringReplace; | 572 to.StringReplace = StringReplace; |
589 to.StringSlice = StringSlice; | 573 to.StringSlice = StringSlice; |
590 to.StringSplit = StringSplitJS; | 574 to.StringSplit = StringSplitJS; |
591 to.StringSubstr = StringSubstr; | |
592 }); | 575 }); |
593 | 576 |
594 }) | 577 }) |
OLD | NEW |