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

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: 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 | « lib/runtime/_operations.js ('k') | lib/runtime/dart/_isolate_helper.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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 }); 477 });
478 let JSExtendableArray = JSExtendableArray$(); 478 let JSExtendableArray = JSExtendableArray$();
479 class Interceptor extends core.Object { 479 class Interceptor extends core.Object {
480 Interceptor() { 480 Interceptor() {
481 } 481 }
482 } 482 }
483 dart.setSignature(Interceptor, { 483 dart.setSignature(Interceptor, {
484 constructors: () => ({Interceptor: [Interceptor, []]}) 484 constructors: () => ({Interceptor: [Interceptor, []]})
485 }); 485 });
486 let _isInt32 = Symbol('_isInt32'); 486 let _isInt32 = Symbol('_isInt32');
487 let _tdivFast = Symbol('_tdivFast');
488 let _tdivSlow = Symbol('_tdivSlow'); 487 let _tdivSlow = Symbol('_tdivSlow');
489 let _shlPositive = Symbol('_shlPositive'); 488 let _shlPositive = Symbol('_shlPositive');
490 let _shrReceiverPositive = Symbol('_shrReceiverPositive');
491 let _shrOtherPositive = Symbol('_shrOtherPositive'); 489 let _shrOtherPositive = Symbol('_shrOtherPositive');
492 let _shrBothPositive = Symbol('_shrBothPositive'); 490 let _shrBothPositive = Symbol('_shrBothPositive');
493 dart.defineExtensionNames([ 491 dart.defineExtensionNames([
494 'compareTo', 492 'compareTo',
495 'isNegative', 493 'isNegative',
496 'isNaN', 494 'isNaN',
497 'isInfinite', 495 'isInfinite',
498 'isFinite', 496 'isFinite',
499 'remainder', 497 'remainder',
500 'abs', 498 'abs',
(...skipping 24 matching lines...) Expand all
525 '~/', 523 '~/',
526 '<<', 524 '<<',
527 '>>', 525 '>>',
528 '&', 526 '&',
529 '|', 527 '|',
530 '^', 528 '^',
531 '<', 529 '<',
532 '>', 530 '>',
533 '<=', 531 '<=',
534 '>=', 532 '>=',
535 'runtimeType' 533 'isEven',
534 'isOdd',
535 'toUnsigned',
536 'toSigned',
537 'bitLength',
538 '~'
536 ]); 539 ]);
537 class JSNumber extends Interceptor { 540 class JSNumber extends Interceptor {
538 JSNumber() { 541 JSNumber() {
539 super.Interceptor(); 542 super.Interceptor();
540 } 543 }
541 [dartx.compareTo](b) { 544 [dartx.compareTo](b) {
542 if (!dart.is(b, core.num)) 545 if (this < dart.notNull(b)) {
543 dart.throw(new core.ArgumentError(b));
544 if (dart.notNull(this[dartx['<']](b))) {
545 return -1; 546 return -1;
546 } else if (dart.notNull(this[dartx['>']](b))) { 547 } else if (this > dart.notNull(b)) {
547 return 1; 548 return 1;
548 } else if (dart.equals(this, b)) { 549 } else if (dart.equals(this, b)) {
549 if (dart.equals(this, 0)) { 550 if (dart.equals(this, 0)) {
550 let bIsNegative = b[dartx.isNegative]; 551 let bIsNegative = b[dartx.isNegative];
551 if (this[dartx.isNegative] == bIsNegative) 552 if (this[dartx.isNegative] == bIsNegative)
552 return 0; 553 return 0;
553 if (dart.notNull(this[dartx.isNegative])) 554 if (dart.notNull(this[dartx.isNegative]))
554 return -1; 555 return -1;
555 return 1; 556 return 1;
556 } 557 }
557 return 0; 558 return 0;
558 } else if (dart.notNull(this[dartx.isNaN])) { 559 } else if (dart.notNull(this[dartx.isNaN])) {
559 if (dart.notNull(b[dartx.isNaN])) { 560 if (dart.notNull(b[dartx.isNaN])) {
560 return 0; 561 return 0;
561 } 562 }
562 return 1; 563 return 1;
563 } else { 564 } else {
564 return -1; 565 return -1;
565 } 566 }
566 } 567 }
567 get [dartx.isNegative]() { 568 get [dartx.isNegative]() {
568 return dart.equals(this, 0) ? (1)[dartx['/']](this) < 0 : this[dartx['<']] (0); 569 return dart.equals(this, 0) ? 1 / this < 0 : this < 0;
569 } 570 }
570 get [dartx.isNaN]() { 571 get [dartx.isNaN]() {
571 return isNaN(this); 572 return isNaN(this);
572 } 573 }
573 get [dartx.isInfinite]() { 574 get [dartx.isInfinite]() {
574 return this == Infinity || this == -Infinity; 575 return this == Infinity || this == -Infinity;
575 } 576 }
576 get [dartx.isFinite]() { 577 get [dartx.isFinite]() {
577 return isFinite(this); 578 return isFinite(this);
578 } 579 }
579 [dartx.remainder](b) { 580 [dartx.remainder](b) {
580 _js_helper.checkNull(b); 581 _js_helper.checkNull(b);
581 if (!dart.is(b, core.num))
582 dart.throw(new core.ArgumentError(b));
583 return this % b; 582 return this % b;
584 } 583 }
585 [dartx.abs]() { 584 [dartx.abs]() {
586 return Math.abs(this); 585 return Math.abs(this);
587 } 586 }
588 get [dartx.sign]() { 587 get [dartx.sign]() {
589 return dart.notNull(this[dartx['>']](0)) ? 1 : dart.notNull(this[dartx['<' ]](0)) ? -1 : this; 588 return this > 0 ? 1 : this < 0 ? -1 : this;
590 } 589 }
591 [dartx.toInt]() { 590 [dartx.toInt]() {
592 if (dart.notNull(this[dartx['>=']](JSNumber._MIN_INT32)) && dart.notNull(t his[dartx['<=']](JSNumber._MAX_INT32))) { 591 if (this >= dart.notNull(JSNumber._MIN_INT32) && this <= dart.notNull(JSNu mber._MAX_INT32)) {
593 return this | 0; 592 return this | 0;
594 } 593 }
595 if (isFinite(this)) { 594 if (isFinite(this)) {
596 return this[dartx.truncateToDouble]() + 0; 595 return this[dartx.truncateToDouble]() + 0;
597 } 596 }
598 dart.throw(new core.UnsupportedError('' + this)); 597 dart.throw(new core.UnsupportedError('' + this));
599 } 598 }
600 [dartx.truncate]() { 599 [dartx.truncate]() {
601 return this[dartx.toInt](); 600 return this[dartx.toInt]();
602 } 601 }
603 [dartx.ceil]() { 602 [dartx.ceil]() {
604 return this[dartx.ceilToDouble]()[dartx.toInt](); 603 return this[dartx.ceilToDouble]()[dartx.toInt]();
605 } 604 }
606 [dartx.floor]() { 605 [dartx.floor]() {
607 return this[dartx.floorToDouble]()[dartx.toInt](); 606 return this[dartx.floorToDouble]()[dartx.toInt]();
608 } 607 }
609 [dartx.round]() { 608 [dartx.round]() {
610 return this[dartx.roundToDouble]()[dartx.toInt](); 609 return this[dartx.roundToDouble]()[dartx.toInt]();
611 } 610 }
612 [dartx.ceilToDouble]() { 611 [dartx.ceilToDouble]() {
613 return Math.ceil(this); 612 return Math.ceil(this);
614 } 613 }
615 [dartx.floorToDouble]() { 614 [dartx.floorToDouble]() {
616 return Math.floor(this); 615 return Math.floor(this);
617 } 616 }
618 [dartx.roundToDouble]() { 617 [dartx.roundToDouble]() {
619 if (dart.notNull(this[dartx['<']](0))) { 618 if (this < 0) {
620 return -Math.round(-this); 619 return -Math.round(-this);
621 } else { 620 } else {
622 return Math.round(this); 621 return Math.round(this);
623 } 622 }
624 } 623 }
625 [dartx.truncateToDouble]() { 624 [dartx.truncateToDouble]() {
626 return dart.notNull(this[dartx['<']](0)) ? this[dartx.ceilToDouble]() : th is[dartx.floorToDouble](); 625 return this < 0 ? this[dartx.ceilToDouble]() : this[dartx.floorToDouble]() ;
627 } 626 }
628 [dartx.clamp](lowerLimit, upperLimit) { 627 [dartx.clamp](lowerLimit, upperLimit) {
629 if (!dart.is(lowerLimit, core.num))
630 dart.throw(new core.ArgumentError(lowerLimit));
631 if (!dart.is(upperLimit, core.num))
632 dart.throw(new core.ArgumentError(upperLimit));
633 if (dart.notNull(lowerLimit[dartx.compareTo](upperLimit)) > 0) { 628 if (dart.notNull(lowerLimit[dartx.compareTo](upperLimit)) > 0) {
634 dart.throw(new core.ArgumentError(lowerLimit)); 629 dart.throw(new core.ArgumentError(lowerLimit));
635 } 630 }
636 if (dart.notNull(this[dartx.compareTo](lowerLimit)) < 0) 631 if (dart.notNull(this[dartx.compareTo](lowerLimit)) < 0)
637 return lowerLimit; 632 return lowerLimit;
638 if (dart.notNull(this[dartx.compareTo](upperLimit)) > 0) 633 if (dart.notNull(this[dartx.compareTo](upperLimit)) > 0)
639 return upperLimit; 634 return upperLimit;
640 return this; 635 return this;
641 } 636 }
642 [dartx.toDouble]() { 637 [dartx.toDouble]() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 return "" + this; 705 return "" + this;
711 } 706 }
712 } 707 }
713 get hashCode() { 708 get hashCode() {
714 return this & 0x1FFFFFFF; 709 return this & 0x1FFFFFFF;
715 } 710 }
716 [dartx['unary-']]() { 711 [dartx['unary-']]() {
717 return -this; 712 return -this;
718 } 713 }
719 [dartx['+']](other) { 714 [dartx['+']](other) {
720 if (!dart.is(other, core.num)) 715 _js_helper.checkNull(other);
721 dart.throw(new core.ArgumentError(other));
722 return this + other; 716 return this + other;
723 } 717 }
724 [dartx['-']](other) { 718 [dartx['-']](other) {
725 if (!dart.is(other, core.num)) 719 _js_helper.checkNull(other);
726 dart.throw(new core.ArgumentError(other));
727 return this - other; 720 return this - other;
728 } 721 }
729 [dartx['/']](other) { 722 [dartx['/']](other) {
730 if (!dart.is(other, core.num)) 723 _js_helper.checkNull(other);
731 dart.throw(new core.ArgumentError(other));
732 return this / other; 724 return this / other;
733 } 725 }
734 [dartx['*']](other) { 726 [dartx['*']](other) {
735 if (!dart.is(other, core.num)) 727 _js_helper.checkNull(other);
736 dart.throw(new core.ArgumentError(other));
737 return this * other; 728 return this * other;
738 } 729 }
739 [dartx['%']](other) { 730 [dartx['%']](other) {
740 if (!dart.is(other, core.num)) 731 _js_helper.checkNull(other);
741 dart.throw(new core.ArgumentError(other));
742 let result = this % other; 732 let result = this % other;
743 if (result == 0) 733 if (result == 0)
744 return 0; 734 return 0;
745 if (dart.notNull(result) > 0) 735 if (dart.notNull(result) > 0)
746 return result; 736 return result;
747 if (other < 0) { 737 if (other < 0) {
748 return dart.notNull(result) - other; 738 return dart.notNull(result) - other;
749 } else { 739 } else {
750 return dart.notNull(result) + other; 740 return dart.notNull(result) + other;
751 } 741 }
752 } 742 }
753 [_isInt32](value) { 743 [_isInt32](value) {
754 return (value | 0) === value; 744 return (value | 0) === value;
755 } 745 }
756 [dartx['~/']](other) { 746 [dartx['~/']](other) {
757 if (false)
758 this[_tdivFast](other);
759 if (dart.notNull(this[_isInt32](this)) && dart.notNull(this[_isInt32](othe r)) && 0 != other && -1 != other) { 747 if (dart.notNull(this[_isInt32](this)) && dart.notNull(this[_isInt32](othe r)) && 0 != other && -1 != other) {
760 return this / other | 0; 748 return this / other | 0;
761 } else { 749 } else {
762 return this[_tdivSlow](other); 750 return this[_tdivSlow](other);
763 } 751 }
764 } 752 }
765 [_tdivFast](other) {
766 return dart.notNull(this[_isInt32](this)) ? this / other | 0 : (this / oth er)[dartx.toInt]();
767 }
768 [_tdivSlow](other) { 753 [_tdivSlow](other) {
769 if (!dart.is(other, core.num)) 754 _js_helper.checkNull(other);
770 dart.throw(new core.ArgumentError(other));
771 return (this / other)[dartx.toInt](); 755 return (this / other)[dartx.toInt]();
772 } 756 }
773 [dartx['<<']](other) { 757 [dartx['<<']](other) {
774 if (!dart.is(other, core.num)) 758 if (dart.notNull(other) < 0)
775 dart.throw(new core.ArgumentError(other));
776 if (other < 0)
777 dart.throw(new core.ArgumentError(other)); 759 dart.throw(new core.ArgumentError(other));
778 return this[_shlPositive](other); 760 return this[_shlPositive](other);
779 } 761 }
780 [_shlPositive](other) { 762 [_shlPositive](other) {
781 return other > 31 ? 0 : dart.as(this << other >>> 0, core.num); 763 return other > 31 ? 0 : this << other >>> 0;
782 } 764 }
783 [dartx['>>']](other) { 765 [dartx['>>']](other) {
784 if (false) 766 if (dart.notNull(other) < 0)
785 this[_shrReceiverPositive](other);
786 if (!dart.is(other, core.num))
787 dart.throw(new core.ArgumentError(other));
788 if (other < 0)
789 dart.throw(new core.ArgumentError(other)); 767 dart.throw(new core.ArgumentError(other));
790 return this[_shrOtherPositive](other); 768 return this[_shrOtherPositive](other);
791 } 769 }
792 [_shrOtherPositive](other) { 770 [_shrOtherPositive](other) {
793 return this > 0 ? this[_shrBothPositive](other) : dart.as(this >> (dart.no tNull(other) > 31 ? 31 : other) >>> 0, core.num); 771 return this > 0 ? this[_shrBothPositive](other) : this >> (dart.notNull(ot her) > 31 ? 31 : other) >>> 0;
794 }
795 [_shrReceiverPositive](other) {
796 if (other < 0)
797 dart.throw(new core.ArgumentError(other));
798 return this[_shrBothPositive](other);
799 } 772 }
800 [_shrBothPositive](other) { 773 [_shrBothPositive](other) {
801 return other > 31 ? 0 : dart.as(this >>> other, core.num); 774 return other > 31 ? 0 : this >>> other;
802 } 775 }
803 [dartx['&']](other) { 776 [dartx['&']](other) {
804 if (!dart.is(other, core.num)) 777 _js_helper.checkNull(other);
805 dart.throw(new core.ArgumentError(other)); 778 return (this & other) >>> 0;
806 return dart.as((this & other) >>> 0, core.num);
807 } 779 }
808 [dartx['|']](other) { 780 [dartx['|']](other) {
809 if (!dart.is(other, core.num)) 781 _js_helper.checkNull(other);
810 dart.throw(new core.ArgumentError(other)); 782 return (this | other) >>> 0;
811 return dart.as((this | other) >>> 0, core.num);
812 } 783 }
813 [dartx['^']](other) { 784 [dartx['^']](other) {
814 if (!dart.is(other, core.num)) 785 _js_helper.checkNull(other);
815 dart.throw(new core.ArgumentError(other)); 786 return (this ^ other) >>> 0;
816 return dart.as((this ^ other) >>> 0, core.num);
817 } 787 }
818 [dartx['<']](other) { 788 [dartx['<']](other) {
819 if (!dart.is(other, core.num)) 789 _js_helper.checkNull(other);
820 dart.throw(new core.ArgumentError(other));
821 return this < other; 790 return this < other;
822 } 791 }
823 [dartx['>']](other) { 792 [dartx['>']](other) {
824 if (!dart.is(other, core.num)) 793 _js_helper.checkNull(other);
825 dart.throw(new core.ArgumentError(other));
826 return this > other; 794 return this > other;
827 } 795 }
828 [dartx['<=']](other) { 796 [dartx['<=']](other) {
829 if (!dart.is(other, core.num)) 797 _js_helper.checkNull(other);
830 dart.throw(new core.ArgumentError(other));
831 return this <= other; 798 return this <= other;
832 } 799 }
833 [dartx['>=']](other) { 800 [dartx['>=']](other) {
834 if (!dart.is(other, core.num)) 801 _js_helper.checkNull(other);
835 dart.throw(new core.ArgumentError(other));
836 return this >= other; 802 return this >= other;
837 } 803 }
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]() { 804 get [dartx.isEven]() {
907 return this[dartx['&']](1) == 0; 805 return (this & 1) == 0;
908 } 806 }
909 get [dartx.isOdd]() { 807 get [dartx.isOdd]() {
910 return this[dartx['&']](1) == 1; 808 return (this & 1) == 1;
911 } 809 }
912 [dartx.toUnsigned](width) { 810 [dartx.toUnsigned](width) {
913 return this[dartx['&']]((1 << dart.notNull(width)) - 1); 811 return this & (1 << dart.notNull(width)) - 1;
914 } 812 }
915 [dartx.toSigned](width) { 813 [dartx.toSigned](width) {
916 let signMask = 1 << dart.notNull(width) - 1; 814 let signMask = 1 << dart.notNull(width) - 1;
917 return dart.notNull(this[dartx['&']](dart.notNull(signMask) - 1)) - dart.n otNull(this[dartx['&']](signMask)); 815 return (this & dart.notNull(signMask) - 1) - (this & dart.notNull(signMask ));
918 } 816 }
919 get [dartx.bitLength]() { 817 get [dartx.bitLength]() {
920 let nonneg = dart.notNull(this[dartx['<']](0)) ? dart.notNull(this[dartx[' unary-']]()) - 1 : this; 818 let nonneg = this < 0 ? -this - 1 : this;
921 if (dart.notNull(nonneg) >= 4294967296) { 819 if (dart.notNull(nonneg) >= 4294967296) {
922 nonneg = (dart.notNull(nonneg) / 4294967296)[dartx.truncate](); 820 nonneg = (dart.notNull(nonneg) / 4294967296)[dartx.truncate]();
923 return dart.notNull(JSInt._bitCount(JSInt._spread(nonneg))) + 32; 821 return dart.notNull(JSNumber._bitCount(JSNumber._spread(nonneg))) + 32;
924 } 822 }
925 return JSInt._bitCount(JSInt._spread(nonneg)); 823 return JSNumber._bitCount(JSNumber._spread(nonneg));
926 } 824 }
927 static _bitCount(i) { 825 static _bitCount(i) {
928 i = dart.notNull(JSInt._shru(i, 0)) - (dart.notNull(JSInt._shru(i, 1)) & 1 431655765); 826 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); 827 i = (dart.notNull(i) & 858993459) + (dart.notNull(JSNumber._shru(i, 2)) & 858993459);
930 i = 252645135 & dart.notNull(i) + dart.notNull(JSInt._shru(i, 4)); 828 i = 252645135 & dart.notNull(i) + dart.notNull(JSNumber._shru(i, 4));
931 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 8)); 829 i = dart.notNull(i) + dart.notNull(JSNumber._shru(i, 8));
932 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 16)); 830 i = dart.notNull(i) + dart.notNull(JSNumber._shru(i, 16));
933 return dart.notNull(i) & 63; 831 return dart.notNull(i) & 63;
934 } 832 }
935 static _shru(value, shift) { 833 static _shru(value, shift) {
936 return value >>> shift; 834 return value >>> shift;
937 } 835 }
938 static _shrs(value, shift) { 836 static _shrs(value, shift) {
939 return value >> shift; 837 return value >> shift;
940 } 838 }
941 static _ors(a, b) { 839 static _ors(a, b) {
942 return a | b; 840 return a | b;
943 } 841 }
944 static _spread(i) { 842 static _spread(i) {
945 i = JSInt._ors(i, JSInt._shrs(i, 1)); 843 i = JSNumber._ors(i, JSNumber._shrs(i, 1));
946 i = JSInt._ors(i, JSInt._shrs(i, 2)); 844 i = JSNumber._ors(i, JSNumber._shrs(i, 2));
947 i = JSInt._ors(i, JSInt._shrs(i, 4)); 845 i = JSNumber._ors(i, JSNumber._shrs(i, 4));
948 i = JSInt._ors(i, JSInt._shrs(i, 8)); 846 i = JSNumber._ors(i, JSNumber._shrs(i, 8));
949 i = JSInt._shru(JSInt._ors(i, JSInt._shrs(i, 16)), 0); 847 i = JSNumber._shru(JSNumber._ors(i, JSNumber._shrs(i, 16)), 0);
950 return i; 848 return i;
951 } 849 }
952 get runtimeType() {
953 return core.int;
954 }
955 [dartx['~']]() { 850 [dartx['~']]() {
956 return dart.as(~this >>> 0, core.int); 851 return ~this >>> 0;
957 } 852 }
958 } 853 }
959 JSInt[dart.implements] = () => [core.int, core.double]; 854 JSNumber[dart.implements] = () => [core.int, core.double];
960 dart.setSignature(JSInt, { 855 dart.setSignature(JSNumber, {
961 constructors: () => ({JSInt: [JSInt, []]}), 856 constructors: () => ({JSNumber: [JSNumber, []]}),
962 methods: () => ({ 857 methods: () => ({
858 [dartx.compareTo]: [core.int, [core.num]],
859 [dartx.remainder]: [JSNumber, [core.num]],
860 [dartx.abs]: [JSNumber, []],
861 [dartx.toInt]: [core.int, []],
862 [dartx.truncate]: [core.int, []],
863 [dartx.ceil]: [core.int, []],
864 [dartx.floor]: [core.int, []],
865 [dartx.round]: [core.int, []],
866 [dartx.ceilToDouble]: [core.double, []],
867 [dartx.floorToDouble]: [core.double, []],
868 [dartx.roundToDouble]: [core.double, []],
869 [dartx.truncateToDouble]: [core.double, []],
870 [dartx.clamp]: [core.num, [core.num, core.num]],
871 [dartx.toDouble]: [core.double, []],
872 [dartx.toStringAsFixed]: [core.String, [core.int]],
873 [dartx.toStringAsExponential]: [core.String, [], [core.int]],
874 [dartx.toStringAsPrecision]: [core.String, [core.int]],
875 [dartx.toRadixString]: [core.String, [core.int]],
876 [dartx['unary-']]: [JSNumber, []],
877 [dartx['+']]: [JSNumber, [core.num]],
878 [dartx['-']]: [JSNumber, [core.num]],
879 [dartx['/']]: [core.double, [core.num]],
880 [dartx['*']]: [JSNumber, [core.num]],
881 [dartx['%']]: [JSNumber, [core.num]],
882 [_isInt32]: [core.bool, [dart.dynamic]],
883 [dartx['~/']]: [core.int, [core.num]],
884 [_tdivSlow]: [core.int, [core.num]],
885 [dartx['<<']]: [core.int, [core.num]],
886 [_shlPositive]: [core.int, [core.num]],
887 [dartx['>>']]: [core.int, [core.num]],
888 [_shrOtherPositive]: [core.int, [core.num]],
889 [_shrBothPositive]: [core.int, [core.num]],
890 [dartx['&']]: [core.int, [core.num]],
891 [dartx['|']]: [core.int, [core.num]],
892 [dartx['^']]: [core.int, [core.num]],
893 [dartx['<']]: [core.bool, [core.num]],
894 [dartx['>']]: [core.bool, [core.num]],
895 [dartx['<=']]: [core.bool, [core.num]],
896 [dartx['>=']]: [core.bool, [core.num]],
963 [dartx.toUnsigned]: [core.int, [core.int]], 897 [dartx.toUnsigned]: [core.int, [core.int]],
964 [dartx.toSigned]: [core.int, [core.int]], 898 [dartx.toSigned]: [core.int, [core.int]],
965 [dartx['~']]: [core.int, []] 899 [dartx['~']]: [core.int, []]
966 }), 900 }),
967 statics: () => ({ 901 statics: () => ({
902 _handleIEtoString: [core.String, [core.String]],
968 _bitCount: [core.int, [core.int]], 903 _bitCount: [core.int, [core.int]],
969 _shru: [core.int, [core.int, core.int]], 904 _shru: [core.int, [core.int, core.int]],
970 _shrs: [core.int, [core.int, core.int]], 905 _shrs: [core.int, [core.int, core.int]],
971 _ors: [core.int, [core.int, core.int]], 906 _ors: [core.int, [core.int, core.int]],
972 _spread: [core.int, [core.int]] 907 _spread: [core.int, [core.int]]
973 }), 908 }),
974 names: ['_bitCount', '_shru', '_shrs', '_ors', '_spread'] 909 names: ['_handleIEtoString', '_bitCount', '_shru', '_shrs', '_ors', '_spread ']
975 }); 910 });
976 JSInt[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({name: 'Number'}))]; 911 JSNumber[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({na me: 'Number'}))];
977 dart.registerExtension(dart.global.Number, JSInt); 912 dart.registerExtension(dart.global.Number, JSNumber);
978 dart.defineExtensionNames([ 913 JSNumber._MIN_INT32 = -2147483648;
979 'runtimeType' 914 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'); 915 let _defaultSplit = Symbol('_defaultSplit');
1001 dart.defineExtensionNames([ 916 dart.defineExtensionNames([
1002 'codeUnitAt', 917 'codeUnitAt',
1003 'allMatches', 918 'allMatches',
1004 'matchAsPrefix', 919 'matchAsPrefix',
1005 '+', 920 '+',
1006 'endsWith', 921 'endsWith',
1007 'replaceAll', 922 'replaceAll',
1008 'replaceAllMapped', 923 'replaceAllMapped',
1009 'splitMapJoin', 924 'splitMapJoin',
(...skipping 27 matching lines...) Expand all
1037 JSString() { 952 JSString() {
1038 super.Interceptor(); 953 super.Interceptor();
1039 } 954 }
1040 [dartx.codeUnitAt](index) { 955 [dartx.codeUnitAt](index) {
1041 if (!(typeof index == 'number')) 956 if (!(typeof index == 'number'))
1042 dart.throw(new core.ArgumentError(index)); 957 dart.throw(new core.ArgumentError(index));
1043 if (dart.notNull(index) < 0) 958 if (dart.notNull(index) < 0)
1044 dart.throw(new core.RangeError.value(index)); 959 dart.throw(new core.RangeError.value(index));
1045 if (dart.notNull(index) >= dart.notNull(this[dartx.length])) 960 if (dart.notNull(index) >= dart.notNull(this[dartx.length]))
1046 dart.throw(new core.RangeError.value(index)); 961 dart.throw(new core.RangeError.value(index));
1047 return dart.as(this.charCodeAt(index), core.int); 962 return this.charCodeAt(index);
1048 } 963 }
1049 [dartx.allMatches](string, start) { 964 [dartx.allMatches](string, start) {
1050 if (start === void 0) 965 if (start === void 0)
1051 start = 0; 966 start = 0;
1052 _js_helper.checkString(string); 967 _js_helper.checkString(string);
1053 _js_helper.checkInt(start); 968 _js_helper.checkInt(start);
1054 if (0 > dart.notNull(start) || dart.notNull(start) > dart.notNull(string[d artx.length])) { 969 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])); 970 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
1056 } 971 }
1057 return _js_helper.allMatchesInStringUnchecked(this, string, start); 972 return _js_helper.allMatchesInStringUnchecked(this, string, start);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 return result; 1226 return result;
1312 if (endIndex == 0) 1227 if (endIndex == 0)
1313 return ""; 1228 return "";
1314 return result.substring(0, endIndex); 1229 return result.substring(0, endIndex);
1315 } 1230 }
1316 [dartx['*']](times) { 1231 [dartx['*']](times) {
1317 if (0 >= dart.notNull(times)) 1232 if (0 >= dart.notNull(times))
1318 return ''; 1233 return '';
1319 if (times == 1 || this[dartx.length] == 0) 1234 if (times == 1 || this[dartx.length] == 0)
1320 return this; 1235 return this;
1321 if (!dart.equals(times, times >>> 0)) { 1236 if (times != times >>> 0) {
1322 dart.throw(dart.const(new core.OutOfMemoryError())); 1237 dart.throw(dart.const(new core.OutOfMemoryError()));
1323 } 1238 }
1324 let result = ''; 1239 let result = '';
1325 let s = this; 1240 let s = this;
1326 while (true) { 1241 while (true) {
1327 if ((dart.notNull(times) & 1) == 1) 1242 if ((dart.notNull(times) & 1) == 1)
1328 result = s[dartx['+']](result); 1243 result = dart.notNull(s) + dart.notNull(result);
1329 times = dart.as(times >>> 1, core.int); 1244 times = times >>> 1;
1330 if (times == 0) 1245 if (times == 0)
1331 break; 1246 break;
1332 s = s[dartx['+']](s); 1247 s = dart.notNull(s) + dart.notNull(s);
1333 } 1248 }
1334 return result; 1249 return result;
1335 } 1250 }
1336 [dartx.padLeft](width, padding) { 1251 [dartx.padLeft](width, padding) {
1337 if (padding === void 0) 1252 if (padding === void 0)
1338 padding = ' '; 1253 padding = ' ';
1339 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]); 1254 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]);
1340 if (dart.notNull(delta) <= 0) 1255 if (dart.notNull(delta) <= 0)
1341 return this; 1256 return this;
1342 return padding[dartx['*']](delta) + this; 1257 return padding[dartx['*']](delta) + this;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 exports.JSArray$ = JSArray$; 1492 exports.JSArray$ = JSArray$;
1578 exports.JSArray = JSArray; 1493 exports.JSArray = JSArray;
1579 exports.JSMutableArray$ = JSMutableArray$; 1494 exports.JSMutableArray$ = JSMutableArray$;
1580 exports.JSMutableArray = JSMutableArray; 1495 exports.JSMutableArray = JSMutableArray;
1581 exports.JSFixedArray$ = JSFixedArray$; 1496 exports.JSFixedArray$ = JSFixedArray$;
1582 exports.JSFixedArray = JSFixedArray; 1497 exports.JSFixedArray = JSFixedArray;
1583 exports.JSExtendableArray$ = JSExtendableArray$; 1498 exports.JSExtendableArray$ = JSExtendableArray$;
1584 exports.JSExtendableArray = JSExtendableArray; 1499 exports.JSExtendableArray = JSExtendableArray;
1585 exports.Interceptor = Interceptor; 1500 exports.Interceptor = Interceptor;
1586 exports.JSNumber = JSNumber; 1501 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; 1502 exports.JSString = JSString;
1593 exports.getInterceptor = getInterceptor; 1503 exports.getInterceptor = getInterceptor;
1594 exports.JSBool = JSBool; 1504 exports.JSBool = JSBool;
1595 exports.JSIndexable = JSIndexable; 1505 exports.JSIndexable = JSIndexable;
1596 exports.JSMutableIndexable = JSMutableIndexable; 1506 exports.JSMutableIndexable = JSMutableIndexable;
1597 exports.JSObject = JSObject; 1507 exports.JSObject = JSObject;
1598 exports.JavaScriptObject = JavaScriptObject; 1508 exports.JavaScriptObject = JavaScriptObject;
1599 exports.PlainJavaScriptObject = PlainJavaScriptObject; 1509 exports.PlainJavaScriptObject = PlainJavaScriptObject;
1600 exports.UnknownJavaScriptObject = UnknownJavaScriptObject; 1510 exports.UnknownJavaScriptObject = UnknownJavaScriptObject;
1601 }); 1511 });
OLDNEW
« no previous file with comments | « lib/runtime/_operations.js ('k') | lib/runtime/dart/_isolate_helper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698