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

Side by Side Diff: dart/frog/leg/lib/js_helper.dart

Issue 9852018: Minor tweaks to the core library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('js_helper'); 5 #library('js_helper');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #source('constant_map.dart'); 9 #source('constant_map.dart');
10 #source('date_helper.dart'); 10 #source('date_helper.dart');
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 588
589 builtin$getRange$2(receiver, start, length) { 589 builtin$getRange$2(receiver, start, length) {
590 if (!isJsArray(receiver)) { 590 if (!isJsArray(receiver)) {
591 return UNINTERCEPTED(receiver.getRange(start, length)); 591 return UNINTERCEPTED(receiver.getRange(start, length));
592 } 592 }
593 if (0 === length) return []; 593 if (0 === length) return [];
594 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. 594 checkNull(start); // TODO(ahe): This is not specified but co19 tests it.
595 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. 595 checkNull(length); // TODO(ahe): This is not specified but co19 tests it.
596 if (start is !int) throw new IllegalArgumentException(start); 596 if (start is !int) throw new IllegalArgumentException(start);
597 if (length is !int) throw new IllegalArgumentException(length); 597 if (length is !int) throw new IllegalArgumentException(length);
598 if (length < 0) throw new IllegalArgumentException(length);
598 if (start < 0) throw new IndexOutOfRangeException(start); 599 if (start < 0) throw new IndexOutOfRangeException(start);
599 if (length < 0) throw new IllegalArgumentException(length);
600 var end = start + length; 600 var end = start + length;
601 if (end > receiver.length) { 601 if (end > receiver.length) {
602 throw new IndexOutOfRangeException(length); 602 throw new IndexOutOfRangeException(length);
603 } 603 }
604 if (length < 0) throw new IllegalArgumentException(length); 604 if (length < 0) throw new IllegalArgumentException(length);
605 return JS('Object', @'#.slice(#, #)', receiver, start, end); 605 return JS('Object', @'#.slice(#, #)', receiver, start, end);
606 } 606 }
607 607
608 builtin$indexOf$1(receiver, element) { 608 builtin$indexOf$1(receiver, element) {
609 if (isJsArray(receiver) || receiver is String) { 609 if (isJsArray(receiver) || receiver is String) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 690
691 builtin$lastIndexOf$2(receiver, element, start) { 691 builtin$lastIndexOf$2(receiver, element, start) {
692 if (isJsArray(receiver)) { 692 if (isJsArray(receiver)) {
693 return Arrays.lastIndexOf(receiver, element, start); 693 return Arrays.lastIndexOf(receiver, element, start);
694 } else if (receiver is String) { 694 } else if (receiver is String) {
695 checkNull(element); 695 checkNull(element);
696 if (element is !String) throw new IllegalArgumentException(element); 696 if (element is !String) throw new IllegalArgumentException(element);
697 if (start !== null) { 697 if (start !== null) {
698 if (start is !num) throw new IllegalArgumentException(start); 698 if (start is !num) throw new IllegalArgumentException(start);
699 if (start < 0) return -1; 699 if (start < 0) return -1;
700 if (start >= receiver.length) start = receiver.length - 1; 700 if (start >= receiver.length) {
701 if (element == "") return receiver.length;
702 start = receiver.length - 1;
703 }
701 } 704 }
702 return stringLastIndexOfUnchecked(receiver, element, start); 705 return stringLastIndexOfUnchecked(receiver, element, start);
703 } 706 }
704 return UNINTERCEPTED(receiver.lastIndexOf(element, start)); 707 return UNINTERCEPTED(receiver.lastIndexOf(element, start));
705 } 708 }
706 709
707 stringLastIndexOfUnchecked(receiver, element, start) 710 stringLastIndexOfUnchecked(receiver, element, start)
708 => JS('int', @'#.lastIndexOf(#, #)', receiver, element, start); 711 => JS('int', @'#.lastIndexOf(#, #)', receiver, element, start);
709 712
710 builtin$removeRange$2(receiver, start, length) { 713 builtin$removeRange$2(receiver, start, length) {
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1359 }
1357 1360
1358 /** 1361 /**
1359 * Represents the type of Null. The compiler treats this specially. 1362 * Represents the type of Null. The compiler treats this specially.
1360 */ 1363 */
1361 class Null { 1364 class Null {
1362 factory Null() { 1365 factory Null() {
1363 throw UnsupportedOperationException('new Null()'); 1366 throw UnsupportedOperationException('new Null()');
1364 } 1367 }
1365 } 1368 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/lib/string_helper.dart » ('j') | dart/frog/leg/lib/string_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698