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

Side by Side Diff: lib/runtime/dart/_interceptors.js

Issue 1348453004: fix some errors in our SDK, mostly around numbers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 5 years, 3 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 | « no previous file | lib/runtime/dart/_isolate_helper.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('dart/_interceptors', null, /* Imports */[ 1 dart_library.library('dart/_interceptors', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core', 3 'dart/core',
4 'dart/_internal', 4 'dart/_internal',
5 'dart/collection', 5 'dart/collection',
6 'dart/math' 6 'dart/math'
7 ], /* Lazy imports */[ 7 ], /* Lazy imports */[
8 'dart/_js_helper' 8 'dart/_js_helper'
9 ], function(exports, dart, core, _internal, collection, math, _js_helper) { 9 ], function(exports, dart, core, _internal, collection, math, _js_helper) {
10 'use strict'; 10 'use strict';
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 [dartx.toSet]() { 355 [dartx.toSet]() {
356 return core.Set$(E).from(this); 356 return core.Set$(E).from(this);
357 } 357 }
358 get [dartx.iterator]() { 358 get [dartx.iterator]() {
359 return new (_internal.ListIterator$(E))(this); 359 return new (_internal.ListIterator$(E))(this);
360 } 360 }
361 get hashCode() { 361 get hashCode() {
362 return _js_helper.Primitives.objectHashCode(this); 362 return _js_helper.Primitives.objectHashCode(this);
363 } 363 }
364 get [dartx.length]() { 364 get [dartx.length]() {
365 return dart.as(this.length, core.int); 365 return this.length;
366 } 366 }
367 set [dartx.length](newLength) { 367 set [dartx.length](newLength) {
368 if (!(typeof newLength == 'number')) 368 if (!(typeof newLength == 'number'))
369 dart.throw(new core.ArgumentError(newLength)); 369 dart.throw(new core.ArgumentError(newLength));
370 if (dart.notNull(newLength) < 0) 370 if (dart.notNull(newLength) < 0)
371 dart.throw(new core.RangeError.value(newLength)); 371 dart.throw(new core.RangeError.value(newLength));
372 this[dartx.checkGrowable]('set length'); 372 this[dartx.checkGrowable]('set length');
373 this.length = newLength; 373 this.length = newLength;
374 } 374 }
375 [dartx.get](index) { 375 [dartx.get](index) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 '~/', 525 '~/',
526 '<<', 526 '<<',
527 '>>', 527 '>>',
528 '&', 528 '&',
529 '|', 529 '|',
530 '^', 530 '^',
531 '<', 531 '<',
532 '>', 532 '>',
533 '<=', 533 '<=',
534 '>=', 534 '>=',
535 'runtimeType' 535 'isEven',
536 'isOdd',
537 'toUnsigned',
538 'toSigned',
539 'bitLength',
540 '~'
536 ]); 541 ]);
537 class JSNumber extends Interceptor { 542 class JSNumber extends Interceptor {
538 JSNumber() { 543 JSNumber() {
539 super.Interceptor(); 544 super.Interceptor();
540 } 545 }
541 [dartx.compareTo](b) { 546 [dartx.compareTo](b) {
542 if (!dart.is(b, core.num)) 547 if (!(typeof b == 'number'))
543 dart.throw(new core.ArgumentError(b)); 548 dart.throw(new core.ArgumentError(b));
544 if (dart.notNull(this[dartx['<']](b))) { 549 if (this < dart.notNull(b)) {
545 return -1; 550 return -1;
546 } else if (dart.notNull(this[dartx['>']](b))) { 551 } else if (this > dart.notNull(b)) {
547 return 1; 552 return 1;
548 } else if (dart.equals(this, b)) { 553 } else if (dart.equals(this, b)) {
549 if (dart.equals(this, 0)) { 554 if (dart.equals(this, 0)) {
550 let bIsNegative = b[dartx.isNegative]; 555 let bIsNegative = b[dartx.isNegative];
551 if (this[dartx.isNegative] == bIsNegative) 556 if (this[dartx.isNegative] == bIsNegative)
552 return 0; 557 return 0;
553 if (dart.notNull(this[dartx.isNegative])) 558 if (dart.notNull(this[dartx.isNegative]))
554 return -1; 559 return -1;
555 return 1; 560 return 1;
556 } 561 }
557 return 0; 562 return 0;
558 } else if (dart.notNull(this[dartx.isNaN])) { 563 } else if (dart.notNull(this[dartx.isNaN])) {
559 if (dart.notNull(b[dartx.isNaN])) { 564 if (dart.notNull(b[dartx.isNaN])) {
560 return 0; 565 return 0;
561 } 566 }
562 return 1; 567 return 1;
563 } else { 568 } else {
564 return -1; 569 return -1;
565 } 570 }
566 } 571 }
567 get [dartx.isNegative]() { 572 get [dartx.isNegative]() {
568 return dart.equals(this, 0) ? (1)[dartx['/']](this) < 0 : this[dartx['<']] (0); 573 return dart.equals(this, 0) ? 1 / this < 0 : this < 0;
569 } 574 }
570 get [dartx.isNaN]() { 575 get [dartx.isNaN]() {
571 return isNaN(this); 576 return isNaN(this);
572 } 577 }
573 get [dartx.isInfinite]() { 578 get [dartx.isInfinite]() {
574 return this == Infinity || this == -Infinity; 579 return this == Infinity || this == -Infinity;
575 } 580 }
576 get [dartx.isFinite]() { 581 get [dartx.isFinite]() {
577 return isFinite(this); 582 return isFinite(this);
578 } 583 }
579 [dartx.remainder](b) { 584 [dartx.remainder](b) {
580 _js_helper.checkNull(b); 585 _js_helper.checkNull(b);
581 if (!dart.is(b, core.num)) 586 if (!(typeof b == 'number'))
582 dart.throw(new core.ArgumentError(b)); 587 dart.throw(new core.ArgumentError(b));
583 return this % b; 588 return this % b;
584 } 589 }
585 [dartx.abs]() { 590 [dartx.abs]() {
586 return Math.abs(this); 591 return Math.abs(this);
587 } 592 }
588 get [dartx.sign]() { 593 get [dartx.sign]() {
589 return dart.notNull(this[dartx['>']](0)) ? 1 : dart.notNull(this[dartx['<' ]](0)) ? -1 : this; 594 return this > 0 ? 1 : this < 0 ? -1 : this;
590 } 595 }
591 [dartx.toInt]() { 596 [dartx.toInt]() {
592 if (dart.notNull(this[dartx['>=']](JSNumber._MIN_INT32)) && dart.notNull(t his[dartx['<=']](JSNumber._MAX_INT32))) { 597 if (this >= dart.notNull(JSNumber._MIN_INT32) && this <= dart.notNull(JSNu mber._MAX_INT32)) {
593 return this | 0; 598 return this | 0;
594 } 599 }
595 if (isFinite(this)) { 600 if (isFinite(this)) {
596 return this[dartx.truncateToDouble]() + 0; 601 return this[dartx.truncateToDouble]() + 0;
597 } 602 }
598 dart.throw(new core.UnsupportedError('' + this)); 603 dart.throw(new core.UnsupportedError('' + this));
599 } 604 }
600 [dartx.truncate]() { 605 [dartx.truncate]() {
601 return this[dartx.toInt](); 606 return this[dartx.toInt]();
602 } 607 }
603 [dartx.ceil]() { 608 [dartx.ceil]() {
604 return this[dartx.ceilToDouble]()[dartx.toInt](); 609 return this[dartx.ceilToDouble]()[dartx.toInt]();
605 } 610 }
606 [dartx.floor]() { 611 [dartx.floor]() {
607 return this[dartx.floorToDouble]()[dartx.toInt](); 612 return this[dartx.floorToDouble]()[dartx.toInt]();
608 } 613 }
609 [dartx.round]() { 614 [dartx.round]() {
610 return this[dartx.roundToDouble]()[dartx.toInt](); 615 return this[dartx.roundToDouble]()[dartx.toInt]();
611 } 616 }
612 [dartx.ceilToDouble]() { 617 [dartx.ceilToDouble]() {
613 return Math.ceil(this); 618 return Math.ceil(this);
614 } 619 }
615 [dartx.floorToDouble]() { 620 [dartx.floorToDouble]() {
616 return Math.floor(this); 621 return Math.floor(this);
617 } 622 }
618 [dartx.roundToDouble]() { 623 [dartx.roundToDouble]() {
619 if (dart.notNull(this[dartx['<']](0))) { 624 if (this < 0) {
620 return -Math.round(-this); 625 return -Math.round(-this);
621 } else { 626 } else {
622 return Math.round(this); 627 return Math.round(this);
623 } 628 }
624 } 629 }
625 [dartx.truncateToDouble]() { 630 [dartx.truncateToDouble]() {
626 return dart.notNull(this[dartx['<']](0)) ? this[dartx.ceilToDouble]() : th is[dartx.floorToDouble](); 631 return this < 0 ? this[dartx.ceilToDouble]() : this[dartx.floorToDouble]() ;
627 } 632 }
628 [dartx.clamp](lowerLimit, upperLimit) { 633 [dartx.clamp](lowerLimit, upperLimit) {
629 if (!dart.is(lowerLimit, core.num)) 634 if (!(typeof lowerLimit == 'number'))
630 dart.throw(new core.ArgumentError(lowerLimit)); 635 dart.throw(new core.ArgumentError(lowerLimit));
631 if (!dart.is(upperLimit, core.num)) 636 if (!(typeof upperLimit == 'number'))
632 dart.throw(new core.ArgumentError(upperLimit)); 637 dart.throw(new core.ArgumentError(upperLimit));
633 if (dart.notNull(lowerLimit[dartx.compareTo](upperLimit)) > 0) { 638 if (dart.notNull(lowerLimit[dartx.compareTo](upperLimit)) > 0) {
634 dart.throw(new core.ArgumentError(lowerLimit)); 639 dart.throw(new core.ArgumentError(lowerLimit));
635 } 640 }
636 if (dart.notNull(this[dartx.compareTo](lowerLimit)) < 0) 641 if (dart.notNull(this[dartx.compareTo](lowerLimit)) < 0)
637 return lowerLimit; 642 return lowerLimit;
638 if (dart.notNull(this[dartx.compareTo](upperLimit)) > 0) 643 if (dart.notNull(this[dartx.compareTo](upperLimit)) > 0)
639 return upperLimit; 644 return upperLimit;
640 return this; 645 return this;
641 } 646 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 return "" + this; 715 return "" + this;
711 } 716 }
712 } 717 }
713 get hashCode() { 718 get hashCode() {
714 return this & 0x1FFFFFFF; 719 return this & 0x1FFFFFFF;
715 } 720 }
716 [dartx['unary-']]() { 721 [dartx['unary-']]() {
717 return -this; 722 return -this;
718 } 723 }
719 [dartx['+']](other) { 724 [dartx['+']](other) {
720 if (!dart.is(other, core.num)) 725 if (!(typeof other == 'number'))
721 dart.throw(new core.ArgumentError(other)); 726 dart.throw(new core.ArgumentError(other));
722 return this + other; 727 return this + other;
723 } 728 }
724 [dartx['-']](other) { 729 [dartx['-']](other) {
725 if (!dart.is(other, core.num)) 730 if (!(typeof other == 'number'))
726 dart.throw(new core.ArgumentError(other)); 731 dart.throw(new core.ArgumentError(other));
727 return this - other; 732 return this - other;
728 } 733 }
729 [dartx['/']](other) { 734 [dartx['/']](other) {
730 if (!dart.is(other, core.num)) 735 if (!(typeof other == 'number'))
731 dart.throw(new core.ArgumentError(other)); 736 dart.throw(new core.ArgumentError(other));
732 return this / other; 737 return this / other;
733 } 738 }
734 [dartx['*']](other) { 739 [dartx['*']](other) {
735 if (!dart.is(other, core.num)) 740 if (!(typeof other == 'number'))
736 dart.throw(new core.ArgumentError(other)); 741 dart.throw(new core.ArgumentError(other));
737 return this * other; 742 return this * other;
738 } 743 }
739 [dartx['%']](other) { 744 [dartx['%']](other) {
740 if (!dart.is(other, core.num)) 745 if (!(typeof other == 'number'))
741 dart.throw(new core.ArgumentError(other)); 746 dart.throw(new core.ArgumentError(other));
742 let result = this % other; 747 let result = this % other;
743 if (result == 0) 748 if (result == 0)
744 return 0; 749 return 0;
745 if (dart.notNull(result) > 0) 750 if (dart.notNull(result) > 0)
746 return result; 751 return result;
747 if (other < 0) { 752 if (other < 0) {
748 return dart.notNull(result) - other; 753 return dart.notNull(result) - other;
749 } else { 754 } else {
750 return dart.notNull(result) + other; 755 return dart.notNull(result) + other;
751 } 756 }
752 } 757 }
753 [_isInt32](value) { 758 [_isInt32](value) {
754 return (value | 0) === value; 759 return (value | 0) === value;
755 } 760 }
756 [dartx['~/']](other) { 761 [dartx['~/']](other) {
757 if (false) 762 if (false)
758 this[_tdivFast](other); 763 this[_tdivFast](other);
759 if (dart.notNull(this[_isInt32](this)) && dart.notNull(this[_isInt32](othe r)) && 0 != other && -1 != other) { 764 if (dart.notNull(this[_isInt32](this)) && dart.notNull(this[_isInt32](othe r)) && 0 != other && -1 != other) {
760 return this / other | 0; 765 return this / other | 0;
761 } else { 766 } else {
762 return this[_tdivSlow](other); 767 return this[_tdivSlow](other);
763 } 768 }
764 } 769 }
765 [_tdivFast](other) { 770 [_tdivFast](other) {
766 return dart.notNull(this[_isInt32](this)) ? this / other | 0 : (this / oth er)[dartx.toInt](); 771 return dart.notNull(this[_isInt32](this)) ? this / other | 0 : (this / oth er)[dartx.toInt]();
767 } 772 }
768 [_tdivSlow](other) { 773 [_tdivSlow](other) {
769 if (!dart.is(other, core.num)) 774 if (!(typeof other == 'number'))
770 dart.throw(new core.ArgumentError(other)); 775 dart.throw(new core.ArgumentError(other));
771 return (this / other)[dartx.toInt](); 776 return (this / other)[dartx.toInt]();
772 } 777 }
773 [dartx['<<']](other) { 778 [dartx['<<']](other) {
774 if (!dart.is(other, core.num)) 779 if (!(typeof other == 'number'))
775 dart.throw(new core.ArgumentError(other)); 780 dart.throw(new core.ArgumentError(other));
776 if (other < 0) 781 if (other < 0)
777 dart.throw(new core.ArgumentError(other)); 782 dart.throw(new core.ArgumentError(other));
778 return this[_shlPositive](other); 783 return this[_shlPositive](other);
779 } 784 }
780 [_shlPositive](other) { 785 [_shlPositive](other) {
781 return other > 31 ? 0 : dart.as(this << other >>> 0, core.num); 786 return other > 31 ? 0 : this << other >>> 0;
782 } 787 }
783 [dartx['>>']](other) { 788 [dartx['>>']](other) {
784 if (false) 789 if (false)
785 this[_shrReceiverPositive](other); 790 this[_shrReceiverPositive](other);
786 if (!dart.is(other, core.num)) 791 if (!(typeof other == 'number'))
787 dart.throw(new core.ArgumentError(other)); 792 dart.throw(new core.ArgumentError(other));
788 if (other < 0) 793 if (other < 0)
789 dart.throw(new core.ArgumentError(other)); 794 dart.throw(new core.ArgumentError(other));
790 return this[_shrOtherPositive](other); 795 return this[_shrOtherPositive](other);
791 } 796 }
792 [_shrOtherPositive](other) { 797 [_shrOtherPositive](other) {
793 return this > 0 ? this[_shrBothPositive](other) : dart.as(this >> (dart.no tNull(other) > 31 ? 31 : other) >>> 0, core.num); 798 return this > 0 ? this[_shrBothPositive](other) : this >> (dart.notNull(ot her) > 31 ? 31 : other) >>> 0;
794 } 799 }
795 [_shrReceiverPositive](other) { 800 [_shrReceiverPositive](other) {
796 if (other < 0) 801 if (other < 0)
797 dart.throw(new core.ArgumentError(other)); 802 dart.throw(new core.ArgumentError(other));
798 return this[_shrBothPositive](other); 803 return this[_shrBothPositive](other);
799 } 804 }
800 [_shrBothPositive](other) { 805 [_shrBothPositive](other) {
801 return other > 31 ? 0 : dart.as(this >>> other, core.num); 806 return other > 31 ? 0 : this >>> other;
802 } 807 }
803 [dartx['&']](other) { 808 [dartx['&']](other) {
804 if (!dart.is(other, core.num)) 809 if (!(typeof other == 'number'))
805 dart.throw(new core.ArgumentError(other)); 810 dart.throw(new core.ArgumentError(other));
806 return dart.as((this & other) >>> 0, core.num); 811 return (this & other) >>> 0;
807 } 812 }
808 [dartx['|']](other) { 813 [dartx['|']](other) {
809 if (!dart.is(other, core.num)) 814 if (!(typeof other == 'number'))
810 dart.throw(new core.ArgumentError(other)); 815 dart.throw(new core.ArgumentError(other));
811 return dart.as((this | other) >>> 0, core.num); 816 return (this | other) >>> 0;
812 } 817 }
813 [dartx['^']](other) { 818 [dartx['^']](other) {
814 if (!dart.is(other, core.num)) 819 if (!(typeof other == 'number'))
815 dart.throw(new core.ArgumentError(other)); 820 dart.throw(new core.ArgumentError(other));
816 return dart.as((this ^ other) >>> 0, core.num); 821 return (this ^ other) >>> 0;
817 } 822 }
818 [dartx['<']](other) { 823 [dartx['<']](other) {
819 if (!dart.is(other, core.num)) 824 if (!(typeof other == 'number'))
820 dart.throw(new core.ArgumentError(other)); 825 dart.throw(new core.ArgumentError(other));
821 return this < other; 826 return this < other;
822 } 827 }
823 [dartx['>']](other) { 828 [dartx['>']](other) {
824 if (!dart.is(other, core.num)) 829 if (!(typeof other == 'number'))
825 dart.throw(new core.ArgumentError(other)); 830 dart.throw(new core.ArgumentError(other));
826 return this > other; 831 return this > other;
827 } 832 }
828 [dartx['<=']](other) { 833 [dartx['<=']](other) {
829 if (!dart.is(other, core.num)) 834 if (!(typeof other == 'number'))
830 dart.throw(new core.ArgumentError(other)); 835 dart.throw(new core.ArgumentError(other));
831 return this <= other; 836 return this <= other;
832 } 837 }
833 [dartx['>=']](other) { 838 [dartx['>=']](other) {
834 if (!dart.is(other, core.num)) 839 if (!(typeof other == 'number'))
835 dart.throw(new core.ArgumentError(other)); 840 dart.throw(new core.ArgumentError(other));
836 return this >= other; 841 return this >= other;
837 } 842 }
838 get runtimeType() {
839 return core.num;
840 }
841 }
842 JSNumber[dart.implements] = () => [core.num];
843 dart.setSignature(JSNumber, {
844 constructors: () => ({JSNumber: [JSNumber, []]}),
845 methods: () => ({
846 [dartx.compareTo]: [core.int, [core.num]],
847 [dartx.remainder]: [core.num, [core.num]],
848 [dartx.abs]: [core.num, []],
849 [dartx.toInt]: [core.int, []],
850 [dartx.truncate]: [core.int, []],
851 [dartx.ceil]: [core.int, []],
852 [dartx.floor]: [core.int, []],
853 [dartx.round]: [core.int, []],
854 [dartx.ceilToDouble]: [core.double, []],
855 [dartx.floorToDouble]: [core.double, []],
856 [dartx.roundToDouble]: [core.double, []],
857 [dartx.truncateToDouble]: [core.double, []],
858 [dartx.clamp]: [core.num, [core.num, core.num]],
859 [dartx.toDouble]: [core.double, []],
860 [dartx.toStringAsFixed]: [core.String, [core.int]],
861 [dartx.toStringAsExponential]: [core.String, [], [core.int]],
862 [dartx.toStringAsPrecision]: [core.String, [core.int]],
863 [dartx.toRadixString]: [core.String, [core.int]],
864 [dartx['unary-']]: [core.num, []],
865 [dartx['+']]: [core.num, [core.num]],
866 [dartx['-']]: [core.num, [core.num]],
867 [dartx['/']]: [core.double, [core.num]],
868 [dartx['*']]: [core.num, [core.num]],
869 [dartx['%']]: [core.num, [core.num]],
870 [_isInt32]: [core.bool, [dart.dynamic]],
871 [dartx['~/']]: [core.int, [core.num]],
872 [_tdivFast]: [core.int, [core.num]],
873 [_tdivSlow]: [core.int, [core.num]],
874 [dartx['<<']]: [core.num, [core.num]],
875 [_shlPositive]: [core.num, [core.num]],
876 [dartx['>>']]: [core.num, [core.num]],
877 [_shrOtherPositive]: [core.num, [core.num]],
878 [_shrReceiverPositive]: [core.num, [core.num]],
879 [_shrBothPositive]: [core.num, [core.num]],
880 [dartx['&']]: [core.num, [core.num]],
881 [dartx['|']]: [core.num, [core.num]],
882 [dartx['^']]: [core.num, [core.num]],
883 [dartx['<']]: [core.bool, [core.num]],
884 [dartx['>']]: [core.bool, [core.num]],
885 [dartx['<=']]: [core.bool, [core.num]],
886 [dartx['>=']]: [core.bool, [core.num]]
887 }),
888 statics: () => ({_handleIEtoString: [core.String, [core.String]]}),
889 names: ['_handleIEtoString']
890 });
891 JSNumber._MIN_INT32 = -2147483648;
892 JSNumber._MAX_INT32 = 2147483647;
893 dart.defineExtensionNames([
894 'isEven',
895 'isOdd',
896 'toUnsigned',
897 'toSigned',
898 'bitLength',
899 'runtimeType',
900 '~'
901 ]);
902 class JSInt extends JSNumber {
903 JSInt() {
904 super.JSNumber();
905 }
906 get [dartx.isEven]() { 843 get [dartx.isEven]() {
907 return this[dartx['&']](1) == 0; 844 return (this & 1) == 0;
908 } 845 }
909 get [dartx.isOdd]() { 846 get [dartx.isOdd]() {
910 return this[dartx['&']](1) == 1; 847 return (this & 1) == 1;
911 } 848 }
912 [dartx.toUnsigned](width) { 849 [dartx.toUnsigned](width) {
913 return this[dartx['&']]((1 << dart.notNull(width)) - 1); 850 return this & (1 << dart.notNull(width)) - 1;
914 } 851 }
915 [dartx.toSigned](width) { 852 [dartx.toSigned](width) {
916 let signMask = 1 << dart.notNull(width) - 1; 853 let signMask = 1 << dart.notNull(width) - 1;
917 return dart.notNull(this[dartx['&']](dart.notNull(signMask) - 1)) - dart.n otNull(this[dartx['&']](signMask)); 854 return (this & dart.notNull(signMask) - 1) - (this & dart.notNull(signMask ));
918 } 855 }
919 get [dartx.bitLength]() { 856 get [dartx.bitLength]() {
920 let nonneg = dart.notNull(this[dartx['<']](0)) ? dart.notNull(this[dartx[' unary-']]()) - 1 : this; 857 let nonneg = this < 0 ? -this - 1 : this;
921 if (dart.notNull(nonneg) >= 4294967296) { 858 if (dart.notNull(nonneg) >= 4294967296) {
922 nonneg = (dart.notNull(nonneg) / 4294967296)[dartx.truncate](); 859 nonneg = (dart.notNull(nonneg) / 4294967296)[dartx.truncate]();
923 return dart.notNull(JSInt._bitCount(JSInt._spread(nonneg))) + 32; 860 return dart.notNull(JSNumber._bitCount(JSNumber._spread(nonneg))) + 32;
924 } 861 }
925 return JSInt._bitCount(JSInt._spread(nonneg)); 862 return JSNumber._bitCount(JSNumber._spread(nonneg));
926 } 863 }
927 static _bitCount(i) { 864 static _bitCount(i) {
928 i = dart.notNull(JSInt._shru(i, 0)) - (dart.notNull(JSInt._shru(i, 1)) & 1 431655765); 865 i = dart.notNull(JSNumber._shru(i, 0)) - (dart.notNull(JSNumber._shru(i, 1 )) & 1431655765);
929 i = (dart.notNull(i) & 858993459) + (dart.notNull(JSInt._shru(i, 2)) & 858 993459); 866 i = (dart.notNull(i) & 858993459) + (dart.notNull(JSNumber._shru(i, 2)) & 858993459);
930 i = 252645135 & dart.notNull(i) + dart.notNull(JSInt._shru(i, 4)); 867 i = 252645135 & dart.notNull(i) + dart.notNull(JSNumber._shru(i, 4));
931 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 8)); 868 i = dart.notNull(i) + dart.notNull(JSNumber._shru(i, 8));
932 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 16)); 869 i = dart.notNull(i) + dart.notNull(JSNumber._shru(i, 16));
933 return dart.notNull(i) & 63; 870 return dart.notNull(i) & 63;
934 } 871 }
935 static _shru(value, shift) { 872 static _shru(value, shift) {
936 return value >>> shift; 873 return value >>> shift;
937 } 874 }
938 static _shrs(value, shift) { 875 static _shrs(value, shift) {
939 return value >> shift; 876 return value >> shift;
940 } 877 }
941 static _ors(a, b) { 878 static _ors(a, b) {
942 return a | b; 879 return a | b;
943 } 880 }
944 static _spread(i) { 881 static _spread(i) {
945 i = JSInt._ors(i, JSInt._shrs(i, 1)); 882 i = JSNumber._ors(i, JSNumber._shrs(i, 1));
946 i = JSInt._ors(i, JSInt._shrs(i, 2)); 883 i = JSNumber._ors(i, JSNumber._shrs(i, 2));
947 i = JSInt._ors(i, JSInt._shrs(i, 4)); 884 i = JSNumber._ors(i, JSNumber._shrs(i, 4));
948 i = JSInt._ors(i, JSInt._shrs(i, 8)); 885 i = JSNumber._ors(i, JSNumber._shrs(i, 8));
949 i = JSInt._shru(JSInt._ors(i, JSInt._shrs(i, 16)), 0); 886 i = JSNumber._shru(JSNumber._ors(i, JSNumber._shrs(i, 16)), 0);
950 return i; 887 return i;
951 } 888 }
952 get runtimeType() {
953 return core.int;
954 }
955 [dartx['~']]() { 889 [dartx['~']]() {
956 return dart.as(~this >>> 0, core.int); 890 return ~this >>> 0;
957 } 891 }
958 } 892 }
959 JSInt[dart.implements] = () => [core.int, core.double]; 893 JSNumber[dart.implements] = () => [core.int, core.double];
960 dart.setSignature(JSInt, { 894 dart.setSignature(JSNumber, {
961 constructors: () => ({JSInt: [JSInt, []]}), 895 constructors: () => ({JSNumber: [JSNumber, []]}),
962 methods: () => ({ 896 methods: () => ({
897 [dartx.compareTo]: [core.int, [core.num]],
898 [dartx.remainder]: [JSNumber, [core.num]],
899 [dartx.abs]: [JSNumber, []],
900 [dartx.toInt]: [core.int, []],
901 [dartx.truncate]: [core.int, []],
902 [dartx.ceil]: [core.int, []],
903 [dartx.floor]: [core.int, []],
904 [dartx.round]: [core.int, []],
905 [dartx.ceilToDouble]: [core.double, []],
906 [dartx.floorToDouble]: [core.double, []],
907 [dartx.roundToDouble]: [core.double, []],
908 [dartx.truncateToDouble]: [core.double, []],
909 [dartx.clamp]: [core.num, [core.num, core.num]],
910 [dartx.toDouble]: [core.double, []],
911 [dartx.toStringAsFixed]: [core.String, [core.int]],
912 [dartx.toStringAsExponential]: [core.String, [], [core.int]],
913 [dartx.toStringAsPrecision]: [core.String, [core.int]],
914 [dartx.toRadixString]: [core.String, [core.int]],
915 [dartx['unary-']]: [JSNumber, []],
916 [dartx['+']]: [JSNumber, [core.num]],
917 [dartx['-']]: [JSNumber, [core.num]],
918 [dartx['/']]: [core.double, [core.num]],
919 [dartx['*']]: [JSNumber, [core.num]],
920 [dartx['%']]: [JSNumber, [core.num]],
921 [_isInt32]: [core.bool, [dart.dynamic]],
922 [dartx['~/']]: [core.int, [core.num]],
923 [_tdivFast]: [core.int, [core.num]],
924 [_tdivSlow]: [core.int, [core.num]],
925 [dartx['<<']]: [core.int, [core.num]],
926 [_shlPositive]: [core.int, [core.num]],
927 [dartx['>>']]: [core.int, [core.num]],
928 [_shrOtherPositive]: [core.int, [core.num]],
929 [_shrReceiverPositive]: [core.int, [core.num]],
930 [_shrBothPositive]: [core.int, [core.num]],
931 [dartx['&']]: [core.int, [core.num]],
932 [dartx['|']]: [core.int, [core.num]],
933 [dartx['^']]: [core.int, [core.num]],
934 [dartx['<']]: [core.bool, [core.num]],
935 [dartx['>']]: [core.bool, [core.num]],
936 [dartx['<=']]: [core.bool, [core.num]],
937 [dartx['>=']]: [core.bool, [core.num]],
963 [dartx.toUnsigned]: [core.int, [core.int]], 938 [dartx.toUnsigned]: [core.int, [core.int]],
964 [dartx.toSigned]: [core.int, [core.int]], 939 [dartx.toSigned]: [core.int, [core.int]],
965 [dartx['~']]: [core.int, []] 940 [dartx['~']]: [core.int, []]
966 }), 941 }),
967 statics: () => ({ 942 statics: () => ({
943 _handleIEtoString: [core.String, [core.String]],
968 _bitCount: [core.int, [core.int]], 944 _bitCount: [core.int, [core.int]],
969 _shru: [core.int, [core.int, core.int]], 945 _shru: [core.int, [core.int, core.int]],
970 _shrs: [core.int, [core.int, core.int]], 946 _shrs: [core.int, [core.int, core.int]],
971 _ors: [core.int, [core.int, core.int]], 947 _ors: [core.int, [core.int, core.int]],
972 _spread: [core.int, [core.int]] 948 _spread: [core.int, [core.int]]
973 }), 949 }),
974 names: ['_bitCount', '_shru', '_shrs', '_ors', '_spread'] 950 names: ['_handleIEtoString', '_bitCount', '_shru', '_shrs', '_ors', '_spread ']
975 }); 951 });
976 JSInt[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({name: 'Number'}))]; 952 JSNumber[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({na me: 'Number'}))];
977 dart.registerExtension(dart.global.Number, JSInt); 953 dart.registerExtension(dart.global.Number, JSNumber);
978 dart.defineExtensionNames([ 954 JSNumber._MIN_INT32 = -2147483648;
979 'runtimeType' 955 JSNumber._MAX_INT32 = 2147483647;
980 ]);
981 class JSDouble extends JSNumber {
982 JSDouble() {
983 super.JSNumber();
984 }
985 get runtimeType() {
986 return core.double;
987 }
988 }
989 JSDouble[dart.implements] = () => [core.double];
990 dart.setSignature(JSDouble, {
991 constructors: () => ({JSDouble: [JSDouble, []]})
992 });
993 class JSPositiveInt extends JSInt {
994 JSPositiveInt() {
995 super.JSInt();
996 }
997 }
998 class JSUInt32 extends JSPositiveInt {}
999 class JSUInt31 extends JSUInt32 {}
1000 let _defaultSplit = Symbol('_defaultSplit'); 956 let _defaultSplit = Symbol('_defaultSplit');
1001 dart.defineExtensionNames([ 957 dart.defineExtensionNames([
1002 'codeUnitAt', 958 'codeUnitAt',
1003 'allMatches', 959 'allMatches',
1004 'matchAsPrefix', 960 'matchAsPrefix',
1005 '+', 961 '+',
1006 'endsWith', 962 'endsWith',
1007 'replaceAll', 963 'replaceAll',
1008 'replaceAllMapped', 964 'replaceAllMapped',
1009 'splitMapJoin', 965 'splitMapJoin',
(...skipping 27 matching lines...) Expand all
1037 JSString() { 993 JSString() {
1038 super.Interceptor(); 994 super.Interceptor();
1039 } 995 }
1040 [dartx.codeUnitAt](index) { 996 [dartx.codeUnitAt](index) {
1041 if (!(typeof index == 'number')) 997 if (!(typeof index == 'number'))
1042 dart.throw(new core.ArgumentError(index)); 998 dart.throw(new core.ArgumentError(index));
1043 if (dart.notNull(index) < 0) 999 if (dart.notNull(index) < 0)
1044 dart.throw(new core.RangeError.value(index)); 1000 dart.throw(new core.RangeError.value(index));
1045 if (dart.notNull(index) >= dart.notNull(this[dartx.length])) 1001 if (dart.notNull(index) >= dart.notNull(this[dartx.length]))
1046 dart.throw(new core.RangeError.value(index)); 1002 dart.throw(new core.RangeError.value(index));
1047 return dart.as(this.charCodeAt(index), core.int); 1003 return this.charCodeAt(index);
1048 } 1004 }
1049 [dartx.allMatches](string, start) { 1005 [dartx.allMatches](string, start) {
1050 if (start === void 0) 1006 if (start === void 0)
1051 start = 0; 1007 start = 0;
1052 _js_helper.checkString(string); 1008 _js_helper.checkString(string);
1053 _js_helper.checkInt(start); 1009 _js_helper.checkInt(start);
1054 if (0 > dart.notNull(start) || dart.notNull(start) > dart.notNull(string[d artx.length])) { 1010 if (0 > dart.notNull(start) || dart.notNull(start) > dart.notNull(string[d artx.length])) {
1055 dart.throw(new core.RangeError.range(start, 0, string[dartx.length])); 1011 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
1056 } 1012 }
1057 return _js_helper.allMatchesInStringUnchecked(this, string, start); 1013 return _js_helper.allMatchesInStringUnchecked(this, string, start);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 return result; 1267 return result;
1312 if (endIndex == 0) 1268 if (endIndex == 0)
1313 return ""; 1269 return "";
1314 return result.substring(0, endIndex); 1270 return result.substring(0, endIndex);
1315 } 1271 }
1316 [dartx['*']](times) { 1272 [dartx['*']](times) {
1317 if (0 >= dart.notNull(times)) 1273 if (0 >= dart.notNull(times))
1318 return ''; 1274 return '';
1319 if (times == 1 || this[dartx.length] == 0) 1275 if (times == 1 || this[dartx.length] == 0)
1320 return this; 1276 return this;
1321 if (!dart.equals(times, times >>> 0)) { 1277 if (times != times >>> 0) {
1322 dart.throw(dart.const(new core.OutOfMemoryError())); 1278 dart.throw(dart.const(new core.OutOfMemoryError()));
1323 } 1279 }
1324 let result = ''; 1280 let result = '';
1325 let s = this; 1281 let s = this;
1326 while (true) { 1282 while (true) {
1327 if ((dart.notNull(times) & 1) == 1) 1283 if ((dart.notNull(times) & 1) == 1)
1328 result = s[dartx['+']](result); 1284 result = dart.notNull(s) + dart.notNull(result);
1329 times = dart.as(times >>> 1, core.int); 1285 times = times >>> 1;
1330 if (times == 0) 1286 if (times == 0)
1331 break; 1287 break;
1332 s = s[dartx['+']](s); 1288 s = dart.notNull(s) + dart.notNull(s);
1333 } 1289 }
1334 return result; 1290 return result;
1335 } 1291 }
1336 [dartx.padLeft](width, padding) { 1292 [dartx.padLeft](width, padding) {
1337 if (padding === void 0) 1293 if (padding === void 0)
1338 padding = ' '; 1294 padding = ' ';
1339 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]); 1295 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]);
1340 if (dart.notNull(delta) <= 0) 1296 if (dart.notNull(delta) <= 0)
1341 return this; 1297 return this;
1342 return padding[dartx['*']](delta) + this; 1298 return padding[dartx['*']](delta) + this;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 exports.JSArray$ = JSArray$; 1533 exports.JSArray$ = JSArray$;
1578 exports.JSArray = JSArray; 1534 exports.JSArray = JSArray;
1579 exports.JSMutableArray$ = JSMutableArray$; 1535 exports.JSMutableArray$ = JSMutableArray$;
1580 exports.JSMutableArray = JSMutableArray; 1536 exports.JSMutableArray = JSMutableArray;
1581 exports.JSFixedArray$ = JSFixedArray$; 1537 exports.JSFixedArray$ = JSFixedArray$;
1582 exports.JSFixedArray = JSFixedArray; 1538 exports.JSFixedArray = JSFixedArray;
1583 exports.JSExtendableArray$ = JSExtendableArray$; 1539 exports.JSExtendableArray$ = JSExtendableArray$;
1584 exports.JSExtendableArray = JSExtendableArray; 1540 exports.JSExtendableArray = JSExtendableArray;
1585 exports.Interceptor = Interceptor; 1541 exports.Interceptor = Interceptor;
1586 exports.JSNumber = JSNumber; 1542 exports.JSNumber = JSNumber;
1587 exports.JSInt = JSInt;
1588 exports.JSDouble = JSDouble;
1589 exports.JSPositiveInt = JSPositiveInt;
1590 exports.JSUInt32 = JSUInt32;
1591 exports.JSUInt31 = JSUInt31;
1592 exports.JSString = JSString; 1543 exports.JSString = JSString;
1593 exports.getInterceptor = getInterceptor; 1544 exports.getInterceptor = getInterceptor;
1594 exports.JSBool = JSBool; 1545 exports.JSBool = JSBool;
1595 exports.JSIndexable = JSIndexable; 1546 exports.JSIndexable = JSIndexable;
1596 exports.JSMutableIndexable = JSMutableIndexable; 1547 exports.JSMutableIndexable = JSMutableIndexable;
1597 exports.JSObject = JSObject; 1548 exports.JSObject = JSObject;
1598 exports.JavaScriptObject = JavaScriptObject; 1549 exports.JavaScriptObject = JavaScriptObject;
1599 exports.PlainJavaScriptObject = PlainJavaScriptObject; 1550 exports.PlainJavaScriptObject = PlainJavaScriptObject;
1600 exports.UnknownJavaScriptObject = UnknownJavaScriptObject; 1551 exports.UnknownJavaScriptObject = UnknownJavaScriptObject;
1601 }); 1552 });
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart/_isolate_helper.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698