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

Side by Side Diff: frog/minfrog

Issue 8914024: frog: better binding of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 9 years 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
« no previous file with comments | « frog/member.dart ('k') | frog/tests/frog/frog.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env node 1 #!/usr/bin/env node
2 // ********** Library dart:core ************** 2 // ********** Library dart:core **************
3 // ********** Natives dart:core ************** 3 // ********** Natives dart:core **************
4 /** 4 /**
5 * Generates a dynamic call stub for a function. 5 * Generates a dynamic call stub for a function.
6 * Our goal is to create a stub method like this on-the-fly: 6 * Our goal is to create a stub method like this on-the-fly:
7 * function($0, $1, capture) { return this($0, $1, true, capture); } 7 * function($0, $1, capture) { return this($0, $1, true, capture); }
8 * 8 *
9 * This stub then replaces the dynamic one on Function, with one that is 9 * This stub then replaces the dynamic one on Function, with one that is
10 * specialized for that particular function, taking into account its default 10 * specialized for that particular function, taking into account its default
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // ********** Code for NoSuchMethodException ************** 400 // ********** Code for NoSuchMethodException **************
401 function NoSuchMethodException(_receiver, _functionName, _arguments) { 401 function NoSuchMethodException(_receiver, _functionName, _arguments) {
402 this._receiver = _receiver; 402 this._receiver = _receiver;
403 this._functionName = _functionName; 403 this._functionName = _functionName;
404 this._arguments = _arguments; 404 this._arguments = _arguments;
405 // Initializers done 405 // Initializers done
406 } 406 }
407 NoSuchMethodException.prototype.toString = function() { 407 NoSuchMethodException.prototype.toString = function() {
408 var sb = new StringBufferImpl(""); 408 var sb = new StringBufferImpl("");
409 for (var i = 0; 409 for (var i = 0;
410 i < this._arguments.length; i++) { 410 i < this._arguments.get$length(); i++) {
411 if (i > 0) { 411 if (i > 0) {
412 sb.add(", "); 412 sb.add(", ");
413 } 413 }
414 sb.add(this._arguments.$index(i)); 414 sb.add(this._arguments.$index(i));
415 } 415 }
416 sb.add("]"); 416 sb.add("]");
417 return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("fun ction name: '" + this._functionName + "' arguments: [" + sb + "]"); 417 return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("fun ction name: '" + this._functionName + "' arguments: [" + sb + "]");
418 } 418 }
419 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS tring; 419 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS tring;
420 // ********** Code for ObjectNotClosureException ************** 420 // ********** Code for ObjectNotClosureException **************
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (obj) obj = obj.toString(); 525 if (obj) obj = obj.toString();
526 console.log(obj); 526 console.log(obj);
527 } else { 527 } else {
528 write(obj); 528 write(obj);
529 write('\n'); 529 write('\n');
530 } 530 }
531 } 531 }
532 function _map(itemsAndKeys) { 532 function _map(itemsAndKeys) {
533 var ret = new LinkedHashMapImplementation(); 533 var ret = new LinkedHashMapImplementation();
534 for (var i = 0; 534 for (var i = 0;
535 i < itemsAndKeys.length; ) { 535 i < itemsAndKeys.get$length(); ) {
536 ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++)); 536 ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++));
537 } 537 }
538 return ret; 538 return ret;
539 } 539 }
540 function _toDartException(e) { 540 function _toDartException(e) {
541 function attachStack(dartEx) { 541 function attachStack(dartEx) {
542 // TODO(jmesserly): setting the stack property is not a long term solution. 542 // TODO(jmesserly): setting the stack property is not a long term solution.
543 var stack = e.stack; 543 var stack = e.stack;
544 // The stack contains the error message, and the stack is all that is 544 // The stack contains the error message, and the stack is all that is
545 // printed (the exception's toString() is never called). Make the Dart 545 // printed (the exception's toString() is never called). Make the Dart
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 ListFactory = Array; 594 ListFactory = Array;
595 ListFactory.prototype.is$List = function(){return true}; 595 ListFactory.prototype.is$List = function(){return true};
596 ListFactory.ListFactory$from$factory = function(other) { 596 ListFactory.ListFactory$from$factory = function(other) {
597 var list = []; 597 var list = [];
598 for (var $$i = other.iterator(); $$i.hasNext$0(); ) { 598 for (var $$i = other.iterator(); $$i.hasNext$0(); ) {
599 var e = $$i.next$0(); 599 var e = $$i.next$0();
600 list.add(e); 600 list.add(e);
601 } 601 }
602 return list; 602 return list;
603 } 603 }
604 ListFactory.prototype.get$length = function() { return this.length; };
605 ListFactory.prototype.set$length = function(value) { return this.length = value; };
604 ListFactory.prototype.add = function(value) { 606 ListFactory.prototype.add = function(value) {
605 this.push(value); 607 this.push(value);
606 } 608 }
607 ListFactory.prototype.addLast = function(value) { 609 ListFactory.prototype.addLast = function(value) {
608 this.push(value); 610 this.push(value);
609 } 611 }
610 ListFactory.prototype.addAll = function(collection) { 612 ListFactory.prototype.addAll = function(collection) {
611 for (var $$i = collection.iterator(); $$i.hasNext$0(); ) { 613 for (var $$i = collection.iterator(); $$i.hasNext$0(); ) {
612 var item = $$i.next$0(); 614 var item = $$i.next$0();
613 this.add(item); 615 this.add(item);
614 } 616 }
615 } 617 }
616 ListFactory.prototype.clear = function() { 618 ListFactory.prototype.clear = function() {
617 this.length = 0; 619 this.set$length(0);
618 } 620 }
619 ListFactory.prototype.removeLast = function() { 621 ListFactory.prototype.removeLast = function() {
620 return this.pop(); 622 return this.pop();
621 } 623 }
622 ListFactory.prototype.last = function() { 624 ListFactory.prototype.last = function() {
623 return this[this.length - 1]; 625 return this[this.get$length() - 1];
624 } 626 }
625 ListFactory.prototype.getRange = function(start, length) { 627 ListFactory.prototype.getRange = function(start, length) {
626 return this.slice(start, start + length); 628 return this.slice(start, start + length);
627 } 629 }
628 ListFactory.prototype.isEmpty = function() { 630 ListFactory.prototype.isEmpty = function() {
629 return this.length == 0; 631 return this.get$length() == 0;
630 } 632 }
631 ListFactory.prototype.iterator = function() { 633 ListFactory.prototype.iterator = function() {
632 return new ListIterator(this); 634 return new ListIterator(this);
633 } 635 }
634 ListFactory.prototype.add$1 = ListFactory.prototype.add; 636 ListFactory.prototype.add$1 = ListFactory.prototype.add;
635 ListFactory.prototype.addAll$1 = ListFactory.prototype.addAll; 637 ListFactory.prototype.addAll$1 = ListFactory.prototype.addAll;
636 ListFactory.prototype.every$1 = function($0) { 638 ListFactory.prototype.every$1 = function($0) {
637 return this.every(to$call$1($0)); 639 return this.every(to$call$1($0));
638 }; 640 };
639 ListFactory.prototype.filter$1 = function($0) { 641 ListFactory.prototype.filter$1 = function($0) {
(...skipping 17 matching lines...) Expand all
657 ListFactory_K = ListFactory; 659 ListFactory_K = ListFactory;
658 ListFactory_String = ListFactory; 660 ListFactory_String = ListFactory;
659 ListFactory_V = ListFactory; 661 ListFactory_V = ListFactory;
660 // ********** Code for ListIterator ************** 662 // ********** Code for ListIterator **************
661 function ListIterator(array) { 663 function ListIterator(array) {
662 this._array = array; 664 this._array = array;
663 this._dart_coreimpl_pos = 0; 665 this._dart_coreimpl_pos = 0;
664 // Initializers done 666 // Initializers done
665 } 667 }
666 ListIterator.prototype.hasNext = function() { 668 ListIterator.prototype.hasNext = function() {
667 return this._array.length > this._dart_coreimpl_pos; 669 return this._array.get$length() > this._dart_coreimpl_pos;
668 } 670 }
669 ListIterator.prototype.next = function() { 671 ListIterator.prototype.next = function() {
670 if (!this.hasNext()) { 672 if (!this.hasNext()) {
671 $throw(const$8/*const NoMoreElementsException()*/); 673 $throw(const$8/*const NoMoreElementsException()*/);
672 } 674 }
673 return this._array.$index(this._dart_coreimpl_pos++); 675 return this._array.$index(this._dart_coreimpl_pos++);
674 } 676 }
675 ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext; 677 ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext;
676 ListIterator.prototype.next$0 = ListIterator.prototype.next; 678 ListIterator.prototype.next$0 = ListIterator.prototype.next;
677 // ********** Code for NumImplementation ************** 679 // ********** Code for NumImplementation **************
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 HashMapImplementation._computeLoadLimit = function(capacity) { 750 HashMapImplementation._computeLoadLimit = function(capacity) {
749 return $truncdiv((capacity * 3), 4); 751 return $truncdiv((capacity * 3), 4);
750 } 752 }
751 HashMapImplementation._firstProbe = function(hashCode, length) { 753 HashMapImplementation._firstProbe = function(hashCode, length) {
752 return hashCode & (length - 1); 754 return hashCode & (length - 1);
753 } 755 }
754 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length ) { 756 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length ) {
755 return (currentProbe + numberOfProbes) & (length - 1); 757 return (currentProbe + numberOfProbes) & (length - 1);
756 } 758 }
757 HashMapImplementation.prototype._probeForAdding = function(key) { 759 HashMapImplementation.prototype._probeForAdding = function(key) {
758 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.leng th); 760 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
759 var numberOfProbes = 1; 761 var numberOfProbes = 1;
760 var initialHash = hash; 762 var initialHash = hash;
761 var insertionIndex = -1; 763 var insertionIndex = -1;
762 while (true) { 764 while (true) {
763 var existingKey = this._keys.$index(hash); 765 var existingKey = this._keys.$index(hash);
764 if (existingKey == null) { 766 if (existingKey == null) {
765 if (insertionIndex < 0) return hash; 767 if (insertionIndex < 0) return hash;
766 return insertionIndex; 768 return insertionIndex;
767 } 769 }
768 else if ($eq(existingKey, key)) { 770 else if ($eq(existingKey, key)) {
769 return hash; 771 return hash;
770 } 772 }
771 else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) { 773 else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) {
772 insertionIndex = hash; 774 insertionIndex = hash;
773 } 775 }
774 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.l ength); 776 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
775 } 777 }
776 } 778 }
777 HashMapImplementation.prototype._probeForLookup = function(key) { 779 HashMapImplementation.prototype._probeForLookup = function(key) {
778 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.leng th); 780 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
779 var numberOfProbes = 1; 781 var numberOfProbes = 1;
780 var initialHash = hash; 782 var initialHash = hash;
781 while (true) { 783 while (true) {
782 var existingKey = this._keys.$index(hash); 784 var existingKey = this._keys.$index(hash);
783 if (existingKey == null) return -1; 785 if (existingKey == null) return -1;
784 if ($eq(existingKey, key)) return hash; 786 if ($eq(existingKey, key)) return hash;
785 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.l ength); 787 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
786 } 788 }
787 } 789 }
788 HashMapImplementation.prototype._ensureCapacity = function() { 790 HashMapImplementation.prototype._ensureCapacity = function() {
789 var newNumberOfEntries = this._numberOfEntries + 1; 791 var newNumberOfEntries = this._numberOfEntries + 1;
790 if (newNumberOfEntries >= this._loadLimit) { 792 if (newNumberOfEntries >= this._loadLimit) {
791 this._grow(this._keys.length * 2); 793 this._grow(this._keys.get$length() * 2);
792 return; 794 return;
793 } 795 }
794 var capacity = this._keys.length; 796 var capacity = this._keys.get$length();
795 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; 797 var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
796 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; 798 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
797 if (this._numberOfDeleted > numberOfFree) { 799 if (this._numberOfDeleted > numberOfFree) {
798 this._grow(this._keys.length); 800 this._grow(this._keys.get$length());
799 } 801 }
800 } 802 }
801 HashMapImplementation._isPowerOfTwo = function(x) { 803 HashMapImplementation._isPowerOfTwo = function(x) {
802 return ((x & (x - 1)) == 0); 804 return ((x & (x - 1)) == 0);
803 } 805 }
804 HashMapImplementation.prototype._grow = function(newCapacity) { 806 HashMapImplementation.prototype._grow = function(newCapacity) {
805 var capacity = this._keys.length; 807 var capacity = this._keys.get$length();
806 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); 808 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
807 var oldKeys = this._keys; 809 var oldKeys = this._keys;
808 var oldValues = this._values; 810 var oldValues = this._values;
809 this._keys = new ListFactory(newCapacity); 811 this._keys = new ListFactory(newCapacity);
810 this._values = new ListFactory(newCapacity); 812 this._values = new ListFactory(newCapacity);
811 for (var i = 0; 813 for (var i = 0;
812 i < capacity; i++) { 814 i < capacity; i++) {
813 var key = oldKeys.$index(i); 815 var key = oldKeys.$index(i);
814 if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) { 816 if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) {
815 continue; 817 continue;
(...skipping 30 matching lines...) Expand all
846 return value; 848 return value;
847 } 849 }
848 return null; 850 return null;
849 } 851 }
850 HashMapImplementation.prototype.isEmpty = function() { 852 HashMapImplementation.prototype.isEmpty = function() {
851 return this._numberOfEntries == 0; 853 return this._numberOfEntries == 0;
852 } 854 }
853 HashMapImplementation.prototype.get$length = function() { 855 HashMapImplementation.prototype.get$length = function() {
854 return this._numberOfEntries; 856 return this._numberOfEntries;
855 } 857 }
856 Object.defineProperty(HashMapImplementation.prototype, "length", {
857 get: HashMapImplementation.prototype.get$length
858 });
859 HashMapImplementation.prototype.forEach = function(f) { 858 HashMapImplementation.prototype.forEach = function(f) {
860 var length = this._keys.length; 859 var length = this._keys.get$length();
861 for (var i = 0; 860 for (var i = 0;
862 i < length; i++) { 861 i < length; i++) {
863 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*Has hMapImplementation._DELETED_KEY*/)) { 862 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*Has hMapImplementation._DELETED_KEY*/)) {
864 f(this._keys.$index(i), this._values.$index(i)); 863 f(this._keys.$index(i), this._values.$index(i));
865 } 864 }
866 } 865 }
867 } 866 }
868 HashMapImplementation.prototype.getKeys = function() { 867 HashMapImplementation.prototype.getKeys = function() {
869 var list = new ListFactory(this.get$length()); 868 var list = new ListFactory(this.get$length());
870 var i = 0; 869 var i = 0;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 HashMapImplementation_E$E._computeLoadLimit = function(capacity) { 916 HashMapImplementation_E$E._computeLoadLimit = function(capacity) {
918 return $truncdiv((capacity * 3), 4); 917 return $truncdiv((capacity * 3), 4);
919 } 918 }
920 HashMapImplementation_E$E._firstProbe = function(hashCode, length) { 919 HashMapImplementation_E$E._firstProbe = function(hashCode, length) {
921 return hashCode & (length - 1); 920 return hashCode & (length - 1);
922 } 921 }
923 HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, le ngth) { 922 HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, le ngth) {
924 return (currentProbe + numberOfProbes) & (length - 1); 923 return (currentProbe + numberOfProbes) & (length - 1);
925 } 924 }
926 HashMapImplementation_E$E.prototype._probeForAdding = function(key) { 925 HashMapImplementation_E$E.prototype._probeForAdding = function(key) {
927 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.leng th); 926 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
928 var numberOfProbes = 1; 927 var numberOfProbes = 1;
929 var initialHash = hash; 928 var initialHash = hash;
930 var insertionIndex = -1; 929 var insertionIndex = -1;
931 while (true) { 930 while (true) {
932 var existingKey = this._keys.$index(hash); 931 var existingKey = this._keys.$index(hash);
933 if (existingKey == null) { 932 if (existingKey == null) {
934 if (insertionIndex < 0) return hash; 933 if (insertionIndex < 0) return hash;
935 return insertionIndex; 934 return insertionIndex;
936 } 935 }
937 else if ($eq(existingKey, key)) { 936 else if ($eq(existingKey, key)) {
938 return hash; 937 return hash;
939 } 938 }
940 else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) { 939 else if ((insertionIndex < 0) && (const$3/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) {
941 insertionIndex = hash; 940 insertionIndex = hash;
942 } 941 }
943 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.l ength); 942 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
944 } 943 }
945 } 944 }
946 HashMapImplementation_E$E.prototype._probeForLookup = function(key) { 945 HashMapImplementation_E$E.prototype._probeForLookup = function(key) {
947 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.leng th); 946 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
948 var numberOfProbes = 1; 947 var numberOfProbes = 1;
949 var initialHash = hash; 948 var initialHash = hash;
950 while (true) { 949 while (true) {
951 var existingKey = this._keys.$index(hash); 950 var existingKey = this._keys.$index(hash);
952 if (existingKey == null) return -1; 951 if (existingKey == null) return -1;
953 if ($eq(existingKey, key)) return hash; 952 if ($eq(existingKey, key)) return hash;
954 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.l ength); 953 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
955 } 954 }
956 } 955 }
957 HashMapImplementation_E$E.prototype._ensureCapacity = function() { 956 HashMapImplementation_E$E.prototype._ensureCapacity = function() {
958 var newNumberOfEntries = this._numberOfEntries + 1; 957 var newNumberOfEntries = this._numberOfEntries + 1;
959 if (newNumberOfEntries >= this._loadLimit) { 958 if (newNumberOfEntries >= this._loadLimit) {
960 this._grow(this._keys.length * 2); 959 this._grow(this._keys.get$length() * 2);
961 return; 960 return;
962 } 961 }
963 var capacity = this._keys.length; 962 var capacity = this._keys.get$length();
964 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; 963 var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
965 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; 964 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
966 if (this._numberOfDeleted > numberOfFree) { 965 if (this._numberOfDeleted > numberOfFree) {
967 this._grow(this._keys.length); 966 this._grow(this._keys.get$length());
968 } 967 }
969 } 968 }
970 HashMapImplementation_E$E._isPowerOfTwo = function(x) { 969 HashMapImplementation_E$E._isPowerOfTwo = function(x) {
971 return ((x & (x - 1)) == 0); 970 return ((x & (x - 1)) == 0);
972 } 971 }
973 HashMapImplementation_E$E.prototype._grow = function(newCapacity) { 972 HashMapImplementation_E$E.prototype._grow = function(newCapacity) {
974 var capacity = this._keys.length; 973 var capacity = this._keys.get$length();
975 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); 974 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
976 var oldKeys = this._keys; 975 var oldKeys = this._keys;
977 var oldValues = this._values; 976 var oldValues = this._values;
978 this._keys = new ListFactory(newCapacity); 977 this._keys = new ListFactory(newCapacity);
979 this._values = new ListFactory(newCapacity); 978 this._values = new ListFactory(newCapacity);
980 for (var i = 0; 979 for (var i = 0;
981 i < capacity; i++) { 980 i < capacity; i++) {
982 var key = oldKeys.$index(i); 981 var key = oldKeys.$index(i);
983 if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) { 982 if (key == null || key === const$3/*HashMapImplementation._DELETED_KEY*/) {
984 continue; 983 continue;
(...skipping 23 matching lines...) Expand all
1008 this._keys.$setindex(index, const$3/*HashMapImplementation._DELETED_KEY*/); 1007 this._keys.$setindex(index, const$3/*HashMapImplementation._DELETED_KEY*/);
1009 this._numberOfDeleted++; 1008 this._numberOfDeleted++;
1010 return value; 1009 return value;
1011 } 1010 }
1012 return null; 1011 return null;
1013 } 1012 }
1014 HashMapImplementation_E$E.prototype.isEmpty = function() { 1013 HashMapImplementation_E$E.prototype.isEmpty = function() {
1015 return this._numberOfEntries == 0; 1014 return this._numberOfEntries == 0;
1016 } 1015 }
1017 HashMapImplementation_E$E.prototype.forEach = function(f) { 1016 HashMapImplementation_E$E.prototype.forEach = function(f) {
1018 var length = this._keys.length; 1017 var length = this._keys.get$length();
1019 for (var i = 0; 1018 for (var i = 0;
1020 i < length; i++) { 1019 i < length; i++) {
1021 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*Has hMapImplementation._DELETED_KEY*/)) { 1020 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$3/*Has hMapImplementation._DELETED_KEY*/)) {
1022 f(this._keys.$index(i), this._values.$index(i)); 1021 f(this._keys.$index(i), this._values.$index(i));
1023 } 1022 }
1024 } 1023 }
1025 } 1024 }
1026 HashMapImplementation_E$E.prototype.getKeys = function() { 1025 HashMapImplementation_E$E.prototype.getKeys = function() {
1027 var list = new ListFactory(this.get$length()); 1026 var list = new ListFactory(this.get$length());
1028 var i = 0; 1027 var i = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 HashSetImplementation.prototype.some = function(f) { 1092 HashSetImplementation.prototype.some = function(f) {
1094 var keys = this._backingMap.getKeys(); 1093 var keys = this._backingMap.getKeys();
1095 return keys.some(f); 1094 return keys.some(f);
1096 } 1095 }
1097 HashSetImplementation.prototype.isEmpty = function() { 1096 HashSetImplementation.prototype.isEmpty = function() {
1098 return this._backingMap.isEmpty(); 1097 return this._backingMap.isEmpty();
1099 } 1098 }
1100 HashSetImplementation.prototype.get$length = function() { 1099 HashSetImplementation.prototype.get$length = function() {
1101 return this._backingMap.get$length(); 1100 return this._backingMap.get$length();
1102 } 1101 }
1103 Object.defineProperty(HashSetImplementation.prototype, "length", {
1104 get: HashSetImplementation.prototype.get$length
1105 });
1106 HashSetImplementation.prototype.iterator = function() { 1102 HashSetImplementation.prototype.iterator = function() {
1107 return new HashSetIterator_E(this); 1103 return new HashSetIterator_E(this);
1108 } 1104 }
1109 HashSetImplementation.prototype.add$1 = HashSetImplementation.prototype.add; 1105 HashSetImplementation.prototype.add$1 = HashSetImplementation.prototype.add;
1110 HashSetImplementation.prototype.addAll$1 = HashSetImplementation.prototype.addAl l; 1106 HashSetImplementation.prototype.addAll$1 = HashSetImplementation.prototype.addAl l;
1111 HashSetImplementation.prototype.contains$1 = HashSetImplementation.prototype.con tains; 1107 HashSetImplementation.prototype.contains$1 = HashSetImplementation.prototype.con tains;
1112 HashSetImplementation.prototype.every$1 = function($0) { 1108 HashSetImplementation.prototype.every$1 = function($0) {
1113 return this.every(to$call$1($0)); 1109 return this.every(to$call$1($0));
1114 }; 1110 };
1115 HashSetImplementation.prototype.filter$1 = function($0) { 1111 HashSetImplementation.prototype.filter$1 = function($0) {
(...skipping 20 matching lines...) Expand all
1136 $inherits(HashSetImplementation_Type, HashSetImplementation); 1132 $inherits(HashSetImplementation_Type, HashSetImplementation);
1137 function HashSetImplementation_Type() {} 1133 function HashSetImplementation_Type() {}
1138 // ********** Code for HashSetIterator ************** 1134 // ********** Code for HashSetIterator **************
1139 function HashSetIterator(set_) { 1135 function HashSetIterator(set_) {
1140 this._nextValidIndex = -1; 1136 this._nextValidIndex = -1;
1141 this._entries = set_._backingMap._keys; 1137 this._entries = set_._backingMap._keys;
1142 // Initializers done 1138 // Initializers done
1143 this._advance(); 1139 this._advance();
1144 } 1140 }
1145 HashSetIterator.prototype.hasNext = function() { 1141 HashSetIterator.prototype.hasNext = function() {
1146 if (this._nextValidIndex >= this._entries.length) return false; 1142 if (this._nextValidIndex >= this._entries.get$length()) return false;
1147 if (this._entries.$index(this._nextValidIndex) === const$3/*HashMapImplementat ion._DELETED_KEY*/) { 1143 if (this._entries.$index(this._nextValidIndex) === const$3/*HashMapImplementat ion._DELETED_KEY*/) {
1148 this._advance(); 1144 this._advance();
1149 } 1145 }
1150 return this._nextValidIndex < this._entries.length; 1146 return this._nextValidIndex < this._entries.get$length();
1151 } 1147 }
1152 HashSetIterator.prototype.next = function() { 1148 HashSetIterator.prototype.next = function() {
1153 if (!this.hasNext()) { 1149 if (!this.hasNext()) {
1154 $throw(const$8/*const NoMoreElementsException()*/); 1150 $throw(const$8/*const NoMoreElementsException()*/);
1155 } 1151 }
1156 var res = this._entries.$index(this._nextValidIndex); 1152 var res = this._entries.$index(this._nextValidIndex);
1157 this._advance(); 1153 this._advance();
1158 return res; 1154 return res;
1159 } 1155 }
1160 HashSetIterator.prototype._advance = function() { 1156 HashSetIterator.prototype._advance = function() {
1161 var length = this._entries.length; 1157 var length = this._entries.get$length();
1162 var entry; 1158 var entry;
1163 var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/; 1159 var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/;
1164 do { 1160 do {
1165 if (++this._nextValidIndex >= length) break; 1161 if (++this._nextValidIndex >= length) break;
1166 entry = this._entries.$index(this._nextValidIndex); 1162 entry = this._entries.$index(this._nextValidIndex);
1167 } 1163 }
1168 while ((entry == null) || (entry === deletedKey)) 1164 while ((entry == null) || (entry === deletedKey))
1169 } 1165 }
1170 HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext; 1166 HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext;
1171 HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next; 1167 HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next;
1172 // ********** Code for HashSetIterator_E ************** 1168 // ********** Code for HashSetIterator_E **************
1173 $inherits(HashSetIterator_E, HashSetIterator); 1169 $inherits(HashSetIterator_E, HashSetIterator);
1174 function HashSetIterator_E(set_) { 1170 function HashSetIterator_E(set_) {
1175 this._nextValidIndex = -1; 1171 this._nextValidIndex = -1;
1176 this._entries = set_._backingMap._keys; 1172 this._entries = set_._backingMap._keys;
1177 // Initializers done 1173 // Initializers done
1178 this._advance(); 1174 this._advance();
1179 } 1175 }
1180 HashSetIterator_E.prototype._advance = function() { 1176 HashSetIterator_E.prototype._advance = function() {
1181 var length = this._entries.length; 1177 var length = this._entries.get$length();
1182 var entry; 1178 var entry;
1183 var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/; 1179 var deletedKey = const$3/*HashMapImplementation._DELETED_KEY*/;
1184 do { 1180 do {
1185 if (++this._nextValidIndex >= length) break; 1181 if (++this._nextValidIndex >= length) break;
1186 entry = this._entries.$index(this._nextValidIndex); 1182 entry = this._entries.$index(this._nextValidIndex);
1187 } 1183 }
1188 while ((entry == null) || (entry === deletedKey)) 1184 while ((entry == null) || (entry === deletedKey))
1189 } 1185 }
1190 // ********** Code for _DeletedKeySentinel ************** 1186 // ********** Code for _DeletedKeySentinel **************
1191 function _DeletedKeySentinel() { 1187 function _DeletedKeySentinel() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 f(entry.key, entry.value); 1245 f(entry.key, entry.value);
1250 } 1246 }
1251 ); 1247 );
1252 } 1248 }
1253 LinkedHashMapImplementation.prototype.containsKey = function(key) { 1249 LinkedHashMapImplementation.prototype.containsKey = function(key) {
1254 return this._map.containsKey(key); 1250 return this._map.containsKey(key);
1255 } 1251 }
1256 LinkedHashMapImplementation.prototype.get$length = function() { 1252 LinkedHashMapImplementation.prototype.get$length = function() {
1257 return this._map.get$length(); 1253 return this._map.get$length();
1258 } 1254 }
1259 Object.defineProperty(LinkedHashMapImplementation.prototype, "length", {
1260 get: LinkedHashMapImplementation.prototype.get$length
1261 });
1262 LinkedHashMapImplementation.prototype.isEmpty = function() { 1255 LinkedHashMapImplementation.prototype.isEmpty = function() {
1263 return this.get$length() == 0; 1256 return this.get$length() == 0;
1264 } 1257 }
1265 LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementatio n.prototype.containsKey; 1258 LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementatio n.prototype.containsKey;
1266 LinkedHashMapImplementation.prototype.forEach$1 = function($0) { 1259 LinkedHashMapImplementation.prototype.forEach$1 = function($0) {
1267 return this.forEach(to$call$2($0)); 1260 return this.forEach(to$call$2($0));
1268 }; 1261 };
1269 LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.pr ototype.getKeys; 1262 LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.pr ototype.getKeys;
1270 LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation. prototype.getValues; 1263 LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation. prototype.getValues;
1271 LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.pr ototype.isEmpty; 1264 LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.pr ototype.isEmpty;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 return this._sentinel.previousEntry(); 1409 return this._sentinel.previousEntry();
1417 } 1410 }
1418 DoubleLinkedQueue.prototype.get$length = function() { 1411 DoubleLinkedQueue.prototype.get$length = function() {
1419 var counter = 0; 1412 var counter = 0;
1420 this.forEach(function _(element) { 1413 this.forEach(function _(element) {
1421 counter++; 1414 counter++;
1422 } 1415 }
1423 ); 1416 );
1424 return counter; 1417 return counter;
1425 } 1418 }
1426 Object.defineProperty(DoubleLinkedQueue.prototype, "length", {
1427 get: DoubleLinkedQueue.prototype.get$length
1428 });
1429 DoubleLinkedQueue.prototype.isEmpty = function() { 1419 DoubleLinkedQueue.prototype.isEmpty = function() {
1430 return (this._sentinel._next === this._sentinel); 1420 return (this._sentinel._next === this._sentinel);
1431 } 1421 }
1432 DoubleLinkedQueue.prototype.forEach = function(f) { 1422 DoubleLinkedQueue.prototype.forEach = function(f) {
1433 var entry = this._sentinel._next; 1423 var entry = this._sentinel._next;
1434 while (entry !== this._sentinel) { 1424 while (entry !== this._sentinel) {
1435 var nextEntry = entry._next; 1425 var nextEntry = entry._next;
1436 f(entry._element); 1426 f(entry._element);
1437 entry = nextEntry; 1427 entry = nextEntry;
1438 } 1428 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 this._start = Clock.now(); 1535 this._start = Clock.now();
1546 } 1536 }
1547 else { 1537 else {
1548 if (this._stop == null) { 1538 if (this._stop == null) {
1549 return; 1539 return;
1550 } 1540 }
1551 this._start = Clock.now() - (this._stop - this._start); 1541 this._start = Clock.now() - (this._stop - this._start);
1552 } 1542 }
1553 } 1543 }
1554 StopwatchImplementation.prototype.get$start = function() { 1544 StopwatchImplementation.prototype.get$start = function() {
1555 return StopwatchImplementation.prototype.start.bind(this); 1545 return StopwatchImplementation.prototype.start.bind(this)
1556 } 1546 }
1557 StopwatchImplementation.prototype.stop = function() { 1547 StopwatchImplementation.prototype.stop = function() {
1558 if (this._start == null) { 1548 if (this._start == null) {
1559 return; 1549 return;
1560 } 1550 }
1561 this._stop = Clock.now(); 1551 this._stop = Clock.now();
1562 } 1552 }
1563 StopwatchImplementation.prototype.elapsed = function() { 1553 StopwatchImplementation.prototype.elapsed = function() {
1564 if (this._start == null) { 1554 if (this._start == null) {
1565 return 0; 1555 return 0;
1566 } 1556 }
1567 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this ._start); 1557 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this ._start);
1568 } 1558 }
1569 StopwatchImplementation.prototype.elapsedInMs = function() { 1559 StopwatchImplementation.prototype.elapsedInMs = function() {
1570 return $truncdiv((this.elapsed() * 1000), this.frequency()); 1560 return $truncdiv((this.elapsed() * 1000), this.frequency());
1571 } 1561 }
1572 StopwatchImplementation.prototype.frequency = function() { 1562 StopwatchImplementation.prototype.frequency = function() {
1573 return Clock.frequency(); 1563 return Clock.frequency();
1574 } 1564 }
1575 StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.st art; 1565 StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.st art;
1576 // ********** Code for StringBufferImpl ************** 1566 // ********** Code for StringBufferImpl **************
1577 function StringBufferImpl(content) { 1567 function StringBufferImpl(content) {
1578 // Initializers done 1568 // Initializers done
1579 this.clear(); 1569 this.clear();
1580 this.add(content); 1570 this.add(content);
1581 } 1571 }
1582 StringBufferImpl.prototype.get$length = function() { 1572 StringBufferImpl.prototype.get$length = function() {
1583 return this._length; 1573 return this._length;
1584 } 1574 }
1585 Object.defineProperty(StringBufferImpl.prototype, "length", {
1586 get: StringBufferImpl.prototype.get$length
1587 });
1588 StringBufferImpl.prototype.isEmpty = function() { 1575 StringBufferImpl.prototype.isEmpty = function() {
1589 return this._length == 0; 1576 return this._length == 0;
1590 } 1577 }
1591 StringBufferImpl.prototype.add = function(obj) { 1578 StringBufferImpl.prototype.add = function(obj) {
1592 var str = obj.toString(); 1579 var str = obj.toString();
1593 if (str == null || str.isEmpty()) return this; 1580 if (str == null || str.isEmpty()) return this;
1594 this._buffer.add(str); 1581 this._buffer.add(str);
1595 this._length += str.length; 1582 this._length += str.length;
1596 return this; 1583 return this;
1597 } 1584 }
1598 StringBufferImpl.prototype.addAll = function(objects) { 1585 StringBufferImpl.prototype.addAll = function(objects) {
1599 for (var $$i = objects.iterator(); $$i.hasNext$0(); ) { 1586 for (var $$i = objects.iterator(); $$i.hasNext$0(); ) {
1600 var obj = $$i.next$0(); 1587 var obj = $$i.next$0();
1601 this.add(obj); 1588 this.add(obj);
1602 } 1589 }
1603 return this; 1590 return this;
1604 } 1591 }
1605 StringBufferImpl.prototype.clear = function() { 1592 StringBufferImpl.prototype.clear = function() {
1606 this._buffer = new ListFactory(); 1593 this._buffer = new ListFactory();
1607 this._length = 0; 1594 this._length = 0;
1608 return this; 1595 return this;
1609 } 1596 }
1610 StringBufferImpl.prototype.toString = function() { 1597 StringBufferImpl.prototype.toString = function() {
1611 if (this._buffer.length == 0) return ""; 1598 if (this._buffer.get$length() == 0) return "";
1612 if (this._buffer.length == 1) return this._buffer.$index(0); 1599 if (this._buffer.get$length() == 1) return this._buffer.$index(0);
1613 var result = StringBase.concatAll(this._buffer); 1600 var result = StringBase.concatAll(this._buffer);
1614 this._buffer.clear(); 1601 this._buffer.clear();
1615 this._buffer.add(result); 1602 this._buffer.add(result);
1616 return result; 1603 return result;
1617 } 1604 }
1618 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add; 1605 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add;
1619 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll; 1606 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll;
1620 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty; 1607 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty;
1621 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString; 1608 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString;
1622 // ********** Code for StringBase ************** 1609 // ********** Code for StringBase **************
1623 function StringBase() {} 1610 function StringBase() {}
1624 StringBase.join = function(strings, separator) { 1611 StringBase.join = function(strings, separator) {
1625 if (strings.length == 0) return ''; 1612 if (strings.get$length() == 0) return '';
1626 var s = strings.$index(0); 1613 var s = strings.$index(0);
1627 for (var i = 1; 1614 for (var i = 1;
1628 i < strings.length; i++) { 1615 i < strings.get$length(); i++) {
1629 s = s + separator + strings.$index(i); 1616 s = s + separator + strings.$index(i);
1630 } 1617 }
1631 return s; 1618 return s;
1632 } 1619 }
1633 StringBase.concatAll = function(strings) { 1620 StringBase.concatAll = function(strings) {
1634 return StringBase.join(strings, ""); 1621 return StringBase.join(strings, "");
1635 } 1622 }
1636 // ********** Code for StringImplementation ************** 1623 // ********** Code for StringImplementation **************
1637 StringImplementation = String; 1624 StringImplementation = String;
1625 StringImplementation.prototype.get$length = function() { return this.length; };
1638 StringImplementation.prototype.endsWith = function(other) { 1626 StringImplementation.prototype.endsWith = function(other) {
1639 if (other.length > this.length) return false; 1627 if (other.length > this.length) return false;
1640 return other == this.substring(this.length - other.length); 1628 return other == this.substring(this.length - other.length);
1641 } 1629 }
1642 StringImplementation.prototype.startsWith = function(other) { 1630 StringImplementation.prototype.startsWith = function(other) {
1643 if (other.length > this.length) return false; 1631 if (other.length > this.length) return false;
1644 return other == this.substring(0, other.length); 1632 return other == this.substring(0, other.length);
1645 } 1633 }
1646 StringImplementation.prototype.isEmpty = function() { 1634 StringImplementation.prototype.isEmpty = function() {
1647 return this.length == 0; 1635 return this.length == 0;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 // ********** Code for top level ************** 1740 // ********** Code for top level **************
1753 function createSandbox() { 1741 function createSandbox() {
1754 return {'require': require, 'process': process, 'console': console, 1742 return {'require': require, 'process': process, 'console': console,
1755 'setTimeout': setTimeout, 'clearTimeout': clearTimeout}; 1743 'setTimeout': setTimeout, 'clearTimeout': clearTimeout};
1756 } 1744 }
1757 // ********** Library file_system ************** 1745 // ********** Library file_system **************
1758 // ********** Code for top level ************** 1746 // ********** Code for top level **************
1759 function joinPaths(path1, path2) { 1747 function joinPaths(path1, path2) {
1760 var pieces = path1.split('/'); 1748 var pieces = path1.split('/');
1761 var $$list = path2.split('/'); 1749 var $$list = path2.split('/');
1762 for (var $$i = 0;$$i < $$list.length; $$i++) { 1750 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
1763 var piece = $$list.$index($$i); 1751 var piece = $$list.$index($$i);
1764 if ($eq(piece, '..') && pieces.length > 0 && $ne(pieces.last$0(), '.') && $n e(pieces.last$0(), '..')) { 1752 if ($eq(piece, '..') && pieces.get$length() > 0 && $ne(pieces.last$0(), '.') && $ne(pieces.last$0(), '..')) {
1765 pieces.removeLast$0(); 1753 pieces.removeLast$0();
1766 } 1754 }
1767 else if ($ne(piece, '')) { 1755 else if ($ne(piece, '')) {
1768 if (pieces.length > 0 && $eq(pieces.last$0(), '.')) { 1756 if (pieces.get$length() > 0 && $eq(pieces.last$0(), '.')) {
1769 pieces.removeLast$0(); 1757 pieces.removeLast$0();
1770 } 1758 }
1771 pieces.add$1(piece); 1759 pieces.add$1(piece);
1772 } 1760 }
1773 } 1761 }
1774 return Strings.join(pieces, '/'); 1762 return Strings.join(pieces, '/');
1775 } 1763 }
1776 function dirname(path) { 1764 function dirname(path) {
1777 var lastSlash = path.lastIndexOf('/', path.length); 1765 var lastSlash = path.lastIndexOf('/', path.length);
1778 if (lastSlash == -1) { 1766 if (lastSlash == -1) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 if (this.writeComments) { 1817 if (this.writeComments) {
1830 this.writeln(text); 1818 this.writeln(text);
1831 } 1819 }
1832 } 1820 }
1833 CodeWriter.prototype.write = function(text) { 1821 CodeWriter.prototype.write = function(text) {
1834 if (text.length == 0) return; 1822 if (text.length == 0) return;
1835 if (this._pendingIndent) this._indent(); 1823 if (this._pendingIndent) this._indent();
1836 if (text.indexOf('\n') != -1) { 1824 if (text.indexOf('\n') != -1) {
1837 var lines = text.split('\n'); 1825 var lines = text.split('\n');
1838 for (var i = 0; 1826 for (var i = 0;
1839 i < lines.length - 1; i++) { 1827 i < lines.get$length() - 1; i++) {
1840 this.writeln(lines.$index(i)); 1828 this.writeln(lines.$index(i));
1841 } 1829 }
1842 this.write(lines.$index(lines.length - 1)); 1830 this.write(lines.$index(lines.get$length() - 1));
1843 } 1831 }
1844 else { 1832 else {
1845 this._buf.add(text); 1833 this._buf.add(text);
1846 } 1834 }
1847 } 1835 }
1848 CodeWriter.prototype.writeln = function(text) { 1836 CodeWriter.prototype.writeln = function(text) {
1849 if (text != null) { 1837 if (text != null) {
1850 this.write(text); 1838 this.write(text);
1851 } 1839 }
1852 if (!text.endsWith('\n')) this._buf.add('\n'/*CodeWriter.NEWLINE*/); 1840 if (!text.endsWith('\n')) this._buf.add('\n'/*CodeWriter.NEWLINE*/);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 } 1976 }
1989 else { 1977 else {
1990 if (this.useWrap0) { 1978 if (this.useWrap0) {
1991 w.writeln("function $wrap_call$0(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L0_FUNCTION*/); 1979 w.writeln("function $wrap_call$0(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L0_FUNCTION*/);
1992 } 1980 }
1993 if (this.useWrap1) { 1981 if (this.useWrap1) {
1994 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L1_FUNCTION*/); 1982 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L1_FUNCTION*/);
1995 } 1983 }
1996 } 1984 }
1997 var $$list = orderValuesByKeys(this._usedOperators); 1985 var $$list = orderValuesByKeys(this._usedOperators);
1998 for (var $$i = 0;$$i < $$list.length; $$i++) { 1986 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
1999 var opImpl = $$list.$index($$i); 1987 var opImpl = $$list.$index($$i);
2000 w.writeln(opImpl); 1988 w.writeln(opImpl);
2001 } 1989 }
2002 } 1990 }
2003 CoreJs.prototype.generate$1 = CoreJs.prototype.generate; 1991 CoreJs.prototype.generate$1 = CoreJs.prototype.generate;
2004 // ********** Code for Element ************** 1992 // ********** Code for Element **************
2005 function Element(name, _enclosingElement) { 1993 function Element(name, _enclosingElement) {
2006 this.name = name; 1994 this.name = name;
2007 this._enclosingElement = _enclosingElement; 1995 this._enclosingElement = _enclosingElement;
2008 // Initializers done 1996 // Initializers done
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 var typeRef = node; 2034 var typeRef = node;
2047 var name; 2035 var name;
2048 if (typeRef.names != null) { 2036 if (typeRef.names != null) {
2049 name = typeRef.names.last().get$name(); 2037 name = typeRef.names.last().get$name();
2050 } 2038 }
2051 else { 2039 else {
2052 name = typeRef.name.name; 2040 name = typeRef.name.name;
2053 } 2041 }
2054 if (this.get$typeParameters() != null) { 2042 if (this.get$typeParameters() != null) {
2055 var $$list = this.get$typeParameters(); 2043 var $$list = this.get$typeParameters();
2056 for (var $$i = 0;$$i < $$list.length; $$i++) { 2044 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2057 var tp = $$list.$index($$i); 2045 var tp = $$list.$index($$i);
2058 if ($eq(tp.get$name(), name)) { 2046 if ($eq(tp.get$name(), name)) {
2059 typeRef.type = tp; 2047 typeRef.type = tp;
2060 } 2048 }
2061 } 2049 }
2062 } 2050 }
2063 if (typeRef.type != null) { 2051 if (typeRef.type != null) {
2064 return typeRef.type; 2052 return typeRef.type;
2065 } 2053 }
2066 return this.get$enclosingElement().resolveType(node, typeErrors); 2054 return this.get$enclosingElement().resolveType(node, typeErrors);
2067 } 2055 }
2068 else if ((node instanceof GenericTypeReference)) { 2056 else if ((node instanceof GenericTypeReference)) {
2069 var typeRef = node; 2057 var typeRef = node;
2070 var baseType = this.resolveType(typeRef.baseType, typeErrors); 2058 var baseType = this.resolveType(typeRef.baseType, typeErrors);
2071 if (!baseType.get$isGeneric()) { 2059 if (!baseType.get$isGeneric()) {
2072 $globals.world.error(('' + baseType.get$name() + ' is not generic'), typeR ef.span); 2060 $globals.world.error(('' + baseType.get$name() + ' is not generic'), typeR ef.span);
2073 return null; 2061 return null;
2074 } 2062 }
2075 if (typeRef.typeArguments.length != baseType.get$typeParameters().length) { 2063 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$ length()) {
2076 $globals.world.error('wrong number of type arguments', typeRef.span); 2064 $globals.world.error('wrong number of type arguments', typeRef.span);
2077 return null; 2065 return null;
2078 } 2066 }
2079 var typeArgs = []; 2067 var typeArgs = [];
2080 for (var i = 0; 2068 for (var i = 0;
2081 i < typeRef.typeArguments.length; i++) { 2069 i < typeRef.typeArguments.get$length(); i++) {
2082 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s)); 2070 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s));
2083 } 2071 }
2084 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs); 2072 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs);
2085 } 2073 }
2086 else if ((node instanceof FunctionTypeReference)) { 2074 else if ((node instanceof FunctionTypeReference)) {
2087 var typeRef = node; 2075 var typeRef = node;
2088 var name = ''; 2076 var name = '';
2089 if (typeRef.func.name != null) { 2077 if (typeRef.func.name != null) {
2090 name = typeRef.func.name.name; 2078 name = typeRef.func.name.name;
2091 } 2079 }
(...skipping 21 matching lines...) Expand all
2113 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY (), false); 2101 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY (), false);
2114 this.main.declaringType.markUsed(); 2102 this.main.declaringType.markUsed();
2115 if ($globals.options.compileAll) { 2103 if ($globals.options.compileAll) {
2116 this.markLibrariesUsed([$globals.world.get$coreimpl(), $globals.world.coreli b, this.main.declaringType.get$library()]); 2104 this.markLibrariesUsed([$globals.world.get$coreimpl(), $globals.world.coreli b, this.main.declaringType.get$library()]);
2117 } 2105 }
2118 else { 2106 else {
2119 $globals.world.corelib.types.$index('BadNumberFormatException').markUsed$0() ; 2107 $globals.world.corelib.types.$index('BadNumberFormatException').markUsed$0() ;
2120 $globals.world.get$coreimpl().types.$index('NumImplementation').markUsed$0() ; 2108 $globals.world.get$coreimpl().types.$index('NumImplementation').markUsed$0() ;
2121 $globals.world.get$coreimpl().types.$index('StringImplementation').markUsed$ 0(); 2109 $globals.world.get$coreimpl().types.$index('StringImplementation').markUsed$ 0();
2122 this.genMethod($globals.world.get$coreimpl().types.$index('StringImplementat ion').getMember$1('contains')); 2110 this.genMethod($globals.world.get$coreimpl().types.$index('StringImplementat ion').getMember$1('contains'));
2111 if ($globals.world.corelib.types.$index('String').get$isUsed()) {
2112 $globals.world.get$coreimpl().types.$index('ListFactory').markUsed$0();
2113 }
2123 } 2114 }
2124 if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.wo rld.get$coreimpl().types.$index('ReceivePortImpl').get$isUsed()) { 2115 if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.wo rld.get$coreimpl().types.$index('ReceivePortImpl').get$isUsed()) {
2125 if (this.corejs.useWrap0 || this.corejs.useWrap1) { 2116 if (this.corejs.useWrap0 || this.corejs.useWrap1) {
2126 this.genMethod($globals.world.get$coreimpl().types.$index('IsolateContext' ).getMember$1('eval')); 2117 this.genMethod($globals.world.get$coreimpl().types.$index('IsolateContext' ).getMember$1('eval'));
2127 this.genMethod($globals.world.get$coreimpl().types.$index('EventLoop').get Member$1('run')); 2118 this.genMethod($globals.world.get$coreimpl().types.$index('EventLoop').get Member$1('run'));
2128 } 2119 }
2129 this.corejs.useIsolates = true; 2120 this.corejs.useIsolates = true;
2130 var isolateMain = $globals.world.get$coreimpl().topType.resolveMember('start RootIsolate').members.$index(0); 2121 var isolateMain = $globals.world.get$coreimpl().topType.resolveMember('start RootIsolate').members.$index(0);
2131 var isolateMainTarget = new Value.type$ctor($globals.world.get$coreimpl().to pType, this.main.get$span()); 2122 var isolateMainTarget = new Value.type$ctor($globals.world.get$coreimpl().to pType, this.main.get$span());
2132 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); 2123 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false);
(...skipping 15 matching lines...) Expand all
2148 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members ().getValues().every$1((function (m) { 2139 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members ().getValues().every$1((function (m) {
2149 return m.get$isStatic() && !m.get$isFactory(); 2140 return m.get$isStatic() && !m.get$isFactory();
2150 }) 2141 })
2151 )); 2142 ));
2152 var members = ListFactory.ListFactory$from$factory(type.get$members().getValue s()); 2143 var members = ListFactory.ListFactory$from$factory(type.get$members().getValue s());
2153 members.addAll(type.get$constructors().getValues()); 2144 members.addAll(type.get$constructors().getValues());
2154 type.get$factories().forEach((function (f) { 2145 type.get$factories().forEach((function (f) {
2155 return members.add(f); 2146 return members.add(f);
2156 }) 2147 })
2157 ); 2148 );
2158 for (var $$i = 0;$$i < members.length; $$i++) { 2149 for (var $$i = 0;$$i < members.get$length(); $$i++) {
2159 var member = members.$index($$i); 2150 var member = members.$index($$i);
2160 if ((member instanceof PropertyMember)) { 2151 if ((member instanceof PropertyMember)) {
2161 if (member.get$getter() != null) this.genMethod(member.get$getter()); 2152 if (member.get$getter() != null) this.genMethod(member.get$getter());
2162 if (member.get$setter() != null) this.genMethod(member.get$setter()); 2153 if (member.get$setter() != null) this.genMethod(member.get$setter());
2163 } 2154 }
2164 if ((member instanceof MethodMember)) this.genMethod(member); 2155 if ((member instanceof MethodMember)) this.genMethod(member);
2165 } 2156 }
2166 } 2157 }
2167 WorldGenerator.prototype.get$markTypeUsed = function() { 2158 WorldGenerator.prototype.get$markTypeUsed = function() {
2168 return WorldGenerator.prototype.markTypeUsed.bind(this); 2159 return WorldGenerator.prototype.markTypeUsed.bind(this)
2169 } 2160 }
2170 WorldGenerator.prototype.getAllTypes = function(libs) { 2161 WorldGenerator.prototype.getAllTypes = function(libs) {
2171 var types = []; 2162 var types = [];
2172 var seen = new HashSetImplementation(); 2163 var seen = new HashSetImplementation();
2173 for (var $$i = 0;$$i < libs.length; $$i++) { 2164 for (var $$i = 0;$$i < libs.get$length(); $$i++) {
2174 var mainLib = libs.$index($$i); 2165 var mainLib = libs.$index($$i);
2175 var toCheck = DoubleLinkedQueue.DoubleLinkedQueue$from$factory([mainLib]); 2166 var toCheck = DoubleLinkedQueue.DoubleLinkedQueue$from$factory([mainLib]);
2176 while (!toCheck.isEmpty()) { 2167 while (!toCheck.isEmpty()) {
2177 var lib = toCheck.removeFirst(); 2168 var lib = toCheck.removeFirst();
2178 if (seen.contains(lib)) continue; 2169 if (seen.contains(lib)) continue;
2179 seen.add(lib); 2170 seen.add(lib);
2180 lib.get$imports().forEach$1((function (lib, toCheck, i) { 2171 lib.get$imports().forEach$1((function (lib, toCheck, i) {
2181 return toCheck.addLast(lib); 2172 return toCheck.addLast(lib);
2182 }).bind(null, lib, toCheck) 2173 }).bind(null, lib, toCheck)
2183 ); 2174 );
(...skipping 17 matching lines...) Expand all
2201 var key = exp.get$type().get$jsname() + ':' + exp.canonicalCode; 2192 var key = exp.get$type().get$jsname() + ':' + exp.canonicalCode;
2202 if (!this.globals.containsKey(key)) { 2193 if (!this.globals.containsKey(key)) {
2203 this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.g lobals.get$length(), exp, dependencies)); 2194 this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.g lobals.get$length(), exp, dependencies));
2204 } 2195 }
2205 return this.globals.$index(key); 2196 return this.globals.$index(key);
2206 } 2197 }
2207 WorldGenerator.prototype.writeTypes = function(lib) { 2198 WorldGenerator.prototype.writeTypes = function(lib) {
2208 if (lib.isWritten) return; 2199 if (lib.isWritten) return;
2209 lib.isWritten = true; 2200 lib.isWritten = true;
2210 var $$list = lib.imports; 2201 var $$list = lib.imports;
2211 for (var $$i = 0;$$i < $$list.length; $$i++) { 2202 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2212 var import_ = $$list.$index($$i); 2203 var import_ = $$list.$index($$i);
2213 this.writeTypes(import_.get$library()); 2204 this.writeTypes(import_.get$library());
2214 } 2205 }
2215 for (var i = 0; 2206 for (var i = 0;
2216 i < lib.sources.length; i++) { 2207 i < lib.sources.get$length(); i++) {
2217 lib.sources.$index(i).set$orderInLibrary(i); 2208 lib.sources.$index(i).set$orderInLibrary(i);
2218 } 2209 }
2219 this.writer.comment(('// ********** Library ' + lib.name + ' **************') ); 2210 this.writer.comment(('// ********** Library ' + lib.name + ' **************') );
2220 if (lib.get$isCore()) { 2211 if (lib.get$isCore()) {
2221 this.writer.comment('// ********** Natives dart:core **************'); 2212 this.writer.comment('// ********** Natives dart:core **************');
2222 this.corejs.generate(this.writer); 2213 this.corejs.generate(this.writer);
2223 } 2214 }
2224 var $$list = lib.natives; 2215 var $$list = lib.natives;
2225 for (var $$i = 0;$$i < $$list.length; $$i++) { 2216 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2226 var file = $$list.$index($$i); 2217 var file = $$list.$index($$i);
2227 var filename = basename(file.get$filename()); 2218 var filename = basename(file.get$filename());
2228 this.writer.comment(('// ********** Natives ' + filename + ' ************** ')); 2219 this.writer.comment(('// ********** Natives ' + filename + ' ************** '));
2229 this.writer.writeln(file.get$text()); 2220 this.writer.writeln(file.get$text());
2230 } 2221 }
2231 lib.topType.markUsed(); 2222 lib.topType.markUsed();
2232 var $$list = this._orderValues(lib.types); 2223 var $$list = this._orderValues(lib.types);
2233 for (var $$i = 0;$$i < $$list.length; $$i++) { 2224 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2234 var type = $$list.$index($$i); 2225 var type = $$list.$index($$i);
2235 if ((type.get$isUsed() || $eq(type.get$library(), $globals.world.get$dom()) || type.get$isHiddenNativeType()) && type.get$isClass()) { 2226 if ((type.get$isUsed() || $eq(type.get$library(), $globals.world.get$dom()) || type.get$isHiddenNativeType()) && type.get$isClass()) {
2236 this.writeType(type); 2227 this.writeType(type);
2237 if (type.get$isGeneric()) { 2228 if (type.get$isGeneric()) {
2238 var $list0 = this._orderValues(type.get$_concreteTypes()); 2229 var $list0 = this._orderValues(type.get$_concreteTypes());
2239 for (var $i0 = 0;$i0 < $list0.length; $i0++) { 2230 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) {
2240 var ct = $list0.$index($i0); 2231 var ct = $list0.$index($i0);
2241 this.writeType(ct); 2232 this.writeType(ct);
2242 } 2233 }
2243 } 2234 }
2244 } 2235 }
2245 else if (type.get$isFunction() && type.get$varStubs().length > 0) { 2236 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) {
2246 this.writer.comment(('// ********** Code for ' + type.get$jsname() + ' *** ***********')); 2237 this.writer.comment(('// ********** Code for ' + type.get$jsname() + ' *** ***********'));
2247 this._writeDynamicStubs(type); 2238 this._writeDynamicStubs(type);
2248 } 2239 }
2249 if (type.get$typeCheckCode() != null) { 2240 if (type.get$typeCheckCode() != null) {
2250 this.writer.writeln(type.get$typeCheckCode()); 2241 this.writer.writeln(type.get$typeCheckCode());
2251 } 2242 }
2252 } 2243 }
2253 } 2244 }
2254 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) { 2245 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) {
2255 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) { 2246 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) {
2256 new MethodGenerator(meth, enclosingMethod).run(); 2247 new MethodGenerator(meth, enclosingMethod).run();
2257 } 2248 }
2258 } 2249 }
2259 WorldGenerator.prototype._prototypeOf = function(type, name) { 2250 WorldGenerator.prototype._prototypeOf = function(type, name) {
2260 if (type.get$isSingletonNative()) { 2251 if (type.get$isSingletonNative()) {
2261 return ('' + type.get$jsname() + '.' + name); 2252 return ('' + type.get$jsname() + '.' + name);
2262 } 2253 }
2263 else if (type.get$isHiddenNativeType()) { 2254 else if (type.get$isHiddenNativeType()) {
2264 this.corejs.ensureDynamicProto(); 2255 this.corejs.ensureDynamicProto();
2265 return ('\$dynamic("' + name + '").' + type.get$jsname()); 2256 return ('\$dynamic("' + name + '").' + type.get$jsname());
2266 } 2257 }
2267 else { 2258 else {
2268 return ('' + type.get$jsname() + '.prototype.' + name); 2259 return ('' + type.get$jsname() + '.prototype.' + name);
2269 } 2260 }
2270 } 2261 }
2262 WorldGenerator.prototype._boundMethod = function(type, name) {
2263 if (type.get$isSingletonNative()) {
2264 return ('' + type.get$jsname() + '.' + name + '.bind(' + type.get$jsname() + ')');
2265 }
2266 else if (type.get$isHiddenNativeType()) {
2267 return ('Object.getPrototype(this).' + type.get$jsname() + '.bind(this)');
2268 }
2269 else {
2270 return ('' + type.get$jsname() + '.prototype.' + name + '.bind(this)');
2271 }
2272 }
2271 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) { 2273 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) {
2272 var isSubtype = onType.isSubtypeOf(checkType); 2274 var isSubtype = onType.isSubtypeOf(checkType);
2273 if (checkType.isTested) { 2275 if (checkType.isTested) {
2274 this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname ())) + (' = function(){return ' + isSubtype + '};')); 2276 this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname ())) + (' = function(){return ' + isSubtype + '};'));
2275 } 2277 }
2276 if (checkType.isChecked) { 2278 if (checkType.isChecked) {
2277 var body = 'return this'; 2279 var body = 'return this';
2278 var checkName = ('assert\$' + checkType.get$jsname()); 2280 var checkName = ('assert\$' + checkType.get$jsname());
2279 if (!isSubtype) { 2281 if (!isSubtype) {
2280 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); 2282 body = $globals.world.objectType.varStubs.$index(checkName).get$body();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 if (c.get$generator() != null && $ne(c, standardConstructor)) { 2349 if (c.get$generator() != null && $ne(c, standardConstructor)) {
2348 c.get$generator().writeDefinition$2(this.writer); 2350 c.get$generator().writeDefinition$2(this.writer);
2349 } 2351 }
2350 } 2352 }
2351 } 2353 }
2352 if (!(type instanceof ConcreteType)) { 2354 if (!(type instanceof ConcreteType)) {
2353 this._maybeIsTest(type, type); 2355 this._maybeIsTest(type, type);
2354 } 2356 }
2355 if (type.get$genericType()._concreteTypes != null) { 2357 if (type.get$genericType()._concreteTypes != null) {
2356 var $$list = this._orderValues(type.get$genericType()._concreteTypes); 2358 var $$list = this._orderValues(type.get$genericType()._concreteTypes);
2357 for (var $$i = 0;$$i < $$list.length; $$i++) { 2359 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2358 var ct = $$list.$index($$i); 2360 var ct = $$list.$index($$i);
2359 this._maybeIsTest(type, ct); 2361 this._maybeIsTest(type, ct);
2360 } 2362 }
2361 } 2363 }
2362 if (type.get$interfaces() != null) { 2364 if (type.get$interfaces() != null) {
2363 var seen = new HashSetImplementation(); 2365 var seen = new HashSetImplementation();
2364 var worklist = []; 2366 var worklist = [];
2365 worklist.addAll(type.get$interfaces()); 2367 worklist.addAll(type.get$interfaces());
2366 seen.addAll(type.get$interfaces()); 2368 seen.addAll(type.get$interfaces());
2367 while (!worklist.isEmpty()) { 2369 while (!worklist.isEmpty()) {
2368 var interface_ = worklist.removeLast(); 2370 var interface_ = worklist.removeLast();
2369 this._maybeIsTest(type, interface_.get$genericType()); 2371 this._maybeIsTest(type, interface_.get$genericType());
2370 if (interface_.get$genericType().get$_concreteTypes() != null) { 2372 if (interface_.get$genericType().get$_concreteTypes() != null) {
2371 var $$list = this._orderValues(interface_.get$genericType().get$_concret eTypes()); 2373 var $$list = this._orderValues(interface_.get$genericType().get$_concret eTypes());
2372 for (var $$i = 0;$$i < $$list.length; $$i++) { 2374 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2373 var ct = $$list.$index($$i); 2375 var ct = $$list.$index($$i);
2374 this._maybeIsTest(type, ct); 2376 this._maybeIsTest(type, ct);
2375 } 2377 }
2376 } 2378 }
2377 var $$list = interface_.get$interfaces(); 2379 var $$list = interface_.get$interfaces();
2378 for (var $$i = interface_.get$interfaces().iterator$0(); $$i.hasNext$0(); ) { 2380 for (var $$i = interface_.get$interfaces().iterator$0(); $$i.hasNext$0(); ) {
2379 var other = $$i.next$0(); 2381 var other = $$i.next$0();
2380 if (!seen.contains(other)) { 2382 if (!seen.contains(other)) {
2381 worklist.addLast(other); 2383 worklist.addLast(other);
2382 seen.add(other); 2384 seen.add(other);
2383 } 2385 }
2384 } 2386 }
2385 } 2387 }
2386 } 2388 }
2387 type.get$factories().forEach(this.get$_writeMethod()); 2389 type.get$factories().forEach(this.get$_writeMethod());
2388 var $$list = this._orderValues(type.get$members()); 2390 var $$list = this._orderValues(type.get$members());
2389 for (var $$i = 0;$$i < $$list.length; $$i++) { 2391 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2390 var member = $$list.$index($$i); 2392 var member = $$list.$index($$i);
2391 if ((member instanceof FieldMember)) { 2393 if ((member instanceof FieldMember)) {
2392 this._writeField(member); 2394 this._writeField(member);
2393 } 2395 }
2394 if ((member instanceof PropertyMember)) { 2396 if ((member instanceof PropertyMember)) {
2395 this._writeProperty(member); 2397 this._writeProperty(member);
2396 } 2398 }
2397 if (member.get$isMethod()) { 2399 if (member.get$isMethod()) {
2398 this._writeMethod(member); 2400 this._writeMethod(member);
2399 } 2401 }
2400 } 2402 }
2401 this._writeDynamicStubs(type); 2403 this._writeDynamicStubs(type);
2402 } 2404 }
2403 WorldGenerator.prototype._ensureInheritMembersHelper = function() { 2405 WorldGenerator.prototype._ensureInheritMembersHelper = function() {
2404 if (this._mixins != null) return; 2406 if (this._mixins != null) return;
2405 this._mixins = new CodeWriter(); 2407 this._mixins = new CodeWriter();
2406 this._mixins.comment('// ********** Generic Type Inheritance **************'); 2408 this._mixins.comment('// ********** Generic Type Inheritance **************');
2407 this._mixins.writeln("/** Implements extends for generic types. */\nfunction $ inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent. prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n i f (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}"); 2409 this._mixins.writeln("/** Implements extends for generic types. */\nfunction $ inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent. prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n i f (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}");
2408 } 2410 }
2409 WorldGenerator.prototype._writeDynamicStubs = function(type) { 2411 WorldGenerator.prototype._writeDynamicStubs = function(type) {
2410 var $$list = orderValuesByKeys(type.varStubs); 2412 var $$list = orderValuesByKeys(type.varStubs);
2411 for (var $$i = 0;$$i < $$list.length; $$i++) { 2413 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2412 var stub = $$list.$index($$i); 2414 var stub = $$list.$index($$i);
2413 if (!stub.get$isGenerated()) stub.generate$1(this.writer); 2415 if (!stub.get$isGenerated()) stub.generate$1(this.writer);
2414 } 2416 }
2415 } 2417 }
2416 WorldGenerator.prototype._writeStaticField = function(field) { 2418 WorldGenerator.prototype._writeStaticField = function(field) {
2417 if (field.isFinal) return; 2419 if (field.isFinal) return;
2418 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ()); 2420 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ());
2419 if (this.globals.containsKey(fullname)) { 2421 if (this.globals.containsKey(fullname)) {
2420 var value = this.globals.$index(fullname); 2422 var value = this.globals.$index(fullname);
2421 if (field.declaringType.get$isTop() && !field.isNative) { 2423 if (field.declaringType.get$isTop() && !field.isNative) {
(...skipping 23 matching lines...) Expand all
2445 if (property.getter != null) { 2447 if (property.getter != null) {
2446 this.writer.write(('get: ' + property.declaringType.get$jsname() + '.proto type.' + property.getter.get$jsname())); 2448 this.writer.write(('get: ' + property.declaringType.get$jsname() + '.proto type.' + property.getter.get$jsname()));
2447 this.writer.writeln(property.setter == null ? '' : ','); 2449 this.writer.writeln(property.setter == null ? '' : ',');
2448 } 2450 }
2449 if (property.setter != null) { 2451 if (property.setter != null) {
2450 this.writer.writeln(('set: ' + property.declaringType.get$jsname() + '.pro totype.' + property.setter.get$jsname())); 2452 this.writer.writeln(('set: ' + property.declaringType.get$jsname() + '.pro totype.' + property.setter.get$jsname()));
2451 } 2453 }
2452 this.writer.exitBlock('});'); 2454 this.writer.exitBlock('});');
2453 } 2455 }
2454 } 2456 }
2455 WorldGenerator.prototype._writeMethod = function(method) { 2457 WorldGenerator.prototype._writeMethod = function(m) {
2456 if (method.generator != null) { 2458 if (m.generator != null) {
2457 method.generator.writeDefinition(this.writer, null); 2459 m.generator.writeDefinition(this.writer, null);
2460 }
2461 else if ((m instanceof MethodMember) && m.get$isNative() && m.get$dynamic().ge t$_providePropertySyntax() && !m.get$dynamic().get$_provideFieldSyntax()) {
2462 MethodGenerator._maybeGenerateBoundGetter(m, this.writer);
2458 } 2463 }
2459 } 2464 }
2460 WorldGenerator.prototype.get$_writeMethod = function() { 2465 WorldGenerator.prototype.get$_writeMethod = function() {
2461 return WorldGenerator.prototype._writeMethod.bind(this); 2466 return WorldGenerator.prototype._writeMethod.bind(this)
2462 } 2467 }
2463 WorldGenerator.prototype.writeGlobals = function() { 2468 WorldGenerator.prototype.writeGlobals = function() {
2464 if (this.globals.get$length() > 0) { 2469 if (this.globals.get$length() > 0) {
2465 this.writer.comment('// ********** Globals **************'); 2470 this.writer.comment('// ********** Globals **************');
2466 var list = this.globals.getValues(); 2471 var list = this.globals.getValues();
2467 list.sort$1((function (a, b) { 2472 list.sort$1((function (a, b) {
2468 return a.compareTo$1(b); 2473 return a.compareTo$1(b);
2469 }) 2474 })
2470 ); 2475 );
2471 this.writer.enterBlock('function \$static_init(){'); 2476 this.writer.enterBlock('function \$static_init(){');
(...skipping 28 matching lines...) Expand all
2500 WorldGenerator.prototype._compareMembers = function(x, y) { 2505 WorldGenerator.prototype._compareMembers = function(x, y) {
2501 if (x.get$span() != null && y.get$span() != null) { 2506 if (x.get$span() != null && y.get$span() != null) {
2502 var spans = x.get$span().compareTo$1(y.get$span()); 2507 var spans = x.get$span().compareTo$1(y.get$span());
2503 if (spans != 0) return spans; 2508 if (spans != 0) return spans;
2504 } 2509 }
2505 if (x.get$span() == null) return 1; 2510 if (x.get$span() == null) return 1;
2506 if (y.get$span() == null) return -1; 2511 if (y.get$span() == null) return -1;
2507 return x.get$name().compareTo$1(y.get$name()); 2512 return x.get$name().compareTo$1(y.get$name());
2508 } 2513 }
2509 WorldGenerator.prototype.get$_compareMembers = function() { 2514 WorldGenerator.prototype.get$_compareMembers = function() {
2510 return WorldGenerator.prototype._compareMembers.bind(this); 2515 return WorldGenerator.prototype._compareMembers.bind(this)
2511 } 2516 }
2512 // ********** Code for BlockScope ************** 2517 // ********** Code for BlockScope **************
2513 function BlockScope(enclosingMethod, parent, reentrant) { 2518 function BlockScope(enclosingMethod, parent, reentrant) {
2514 this.enclosingMethod = enclosingMethod; 2519 this.enclosingMethod = enclosingMethod;
2515 this.parent = parent; 2520 this.parent = parent;
2516 this.reentrant = reentrant; 2521 this.reentrant = reentrant;
2517 this._vars = new HashMapImplementation(); 2522 this._vars = new HashMapImplementation();
2518 this._jsNames = new HashSetImplementation(); 2523 this._jsNames = new HashSetImplementation();
2519 // Initializers done 2524 // Initializers done
2520 if (this.get$isMethodScope()) { 2525 if (this.get$isMethodScope()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 if (this.enclosingMethod != null) { 2621 if (this.enclosingMethod != null) {
2617 this._scope = new BlockScope(this, this.enclosingMethod._scope, false); 2622 this._scope = new BlockScope(this, this.enclosingMethod._scope, false);
2618 this.captures = new HashSetImplementation(); 2623 this.captures = new HashSetImplementation();
2619 } 2624 }
2620 else { 2625 else {
2621 this._scope = new BlockScope(this, null, false); 2626 this._scope = new BlockScope(this, null, false);
2622 } 2627 }
2623 this._usedTemps = new HashSetImplementation(); 2628 this._usedTemps = new HashSetImplementation();
2624 this._freeTemps = []; 2629 this._freeTemps = [];
2625 } 2630 }
2631 MethodGenerator.prototype.get$method = function() { return this.method; };
2632 MethodGenerator.prototype.set$method = function(value) { return this.method = va lue; };
2626 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi ngMethod; }; 2633 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi ngMethod; };
2627 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en closingMethod = value; }; 2634 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en closingMethod = value; };
2628 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; }; 2635 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; };
2629 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi s = value; }; 2636 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi s = value; };
2630 MethodGenerator.prototype.get$library = function() { 2637 MethodGenerator.prototype.get$library = function() {
2631 return this.method.get$library(); 2638 return this.method.get$library();
2632 } 2639 }
2633 MethodGenerator.prototype.findMembers = function(name) { 2640 MethodGenerator.prototype.findMembers = function(name) {
2634 return this.get$library()._findMembers(name); 2641 return this.get$library()._findMembers(name);
2635 } 2642 }
2636 MethodGenerator.prototype.get$isClosure = function() { 2643 MethodGenerator.prototype.get$isClosure = function() {
2637 return (this.enclosingMethod != null); 2644 return (this.enclosingMethod != null);
2638 } 2645 }
2639 MethodGenerator.prototype.get$isStatic = function() { 2646 MethodGenerator.prototype.get$isStatic = function() {
2640 return this.method.get$isStatic(); 2647 return this.method.get$isStatic();
2641 } 2648 }
2642 MethodGenerator.prototype.getTemp = function(value) { 2649 MethodGenerator.prototype.getTemp = function(value) {
2643 return value.needsTemp ? this.forceTemp(value) : value; 2650 return value.needsTemp ? this.forceTemp(value) : value;
2644 } 2651 }
2645 MethodGenerator.prototype.forceTemp = function(value) { 2652 MethodGenerator.prototype.forceTemp = function(value) {
2646 var name; 2653 var name;
2647 if (this._freeTemps.length > 0) { 2654 if (this._freeTemps.get$length() > 0) {
2648 name = this._freeTemps.removeLast(); 2655 name = this._freeTemps.removeLast();
2649 } 2656 }
2650 else { 2657 else {
2651 name = '\$' + this._usedTemps.get$length(); 2658 name = '\$' + this._usedTemps.get$length();
2652 } 2659 }
2653 this._usedTemps.add(name); 2660 this._usedTemps.add(name);
2654 return new Value(value.get$type(), name, value.span, false); 2661 return new Value(value.get$type(), name, value.span, false);
2655 } 2662 }
2656 MethodGenerator.prototype.assignTemp = function(tmp, v) { 2663 MethodGenerator.prototype.assignTemp = function(tmp, v) {
2657 if ($eq(tmp, v)) { 2664 if ($eq(tmp, v)) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 } 2741 }
2735 else if (this.method.get$isStatic()) { 2742 else if (this.method.get$isStatic()) {
2736 defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + th is.method.get$jsname() + ' = function' + _params + ' {')); 2743 defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + th is.method.get$jsname() + ' = function' + _params + ' {'));
2737 } 2744 }
2738 else { 2745 else {
2739 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (' = function' + _params + ' {')); 2746 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (' = function' + _params + ' {'));
2740 } 2747 }
2741 if (this.needsThis) { 2748 if (this.needsThis) {
2742 defWriter.writeln('var \$this = this; // closure support'); 2749 defWriter.writeln('var \$this = this; // closure support');
2743 } 2750 }
2744 if (this._usedTemps.get$length() > 0 || this._freeTemps.length > 0) { 2751 if (this._usedTemps.get$length() > 0 || this._freeTemps.get$length() > 0) {
2745 this._freeTemps.addAll(this._usedTemps); 2752 this._freeTemps.addAll(this._usedTemps);
2746 this._freeTemps.sort((function (x, y) { 2753 this._freeTemps.sort((function (x, y) {
2747 return x.compareTo$1(y); 2754 return x.compareTo$1(y);
2748 }) 2755 })
2749 ); 2756 );
2750 defWriter.writeln(('var ' + Strings.join(this._freeTemps, ", ") + ';')); 2757 defWriter.writeln(('var ' + Strings.join(this._freeTemps, ", ") + ';'));
2751 } 2758 }
2752 defWriter.writeln(this.writer.get$text()); 2759 defWriter.writeln(this.writer.get$text());
2753 if (names != null) { 2760 if (names != null) {
2754 defWriter.exitBlock(('}).bind(null, ' + Strings.join(names, ", ") + ')')); 2761 defWriter.exitBlock(('}).bind(null, ' + Strings.join(names, ", ") + ')'));
2755 } 2762 }
2756 else if (this.get$isClosure() && this.method.name == '') { 2763 else if (this.get$isClosure() && this.method.name == '') {
2757 defWriter.exitBlock('})'); 2764 defWriter.exitBlock('})');
2758 } 2765 }
2759 else { 2766 else {
2760 defWriter.exitBlock('}'); 2767 defWriter.exitBlock('}');
2761 } 2768 }
2762 if (this.method.get$isConstructor() && this.method.get$constructorName() != '' ) { 2769 if (this.method.get$isConstructor() && this.method.get$constructorName() != '' ) {
2763 defWriter.writeln(('' + this.method.declaringType.get$jsname() + '.' + this. method.get$constructorName() + '\$ctor.prototype = ') + ('' + this.method.declar ingType.get$jsname() + '.prototype;')); 2770 defWriter.writeln(('' + this.method.declaringType.get$jsname() + '.' + this. method.get$constructorName() + '\$ctor.prototype = ') + ('' + this.method.declar ingType.get$jsname() + '.prototype;'));
2764 } 2771 }
2765 this._provideOptionalParamInfo(defWriter); 2772 this._provideOptionalParamInfo(defWriter);
2766 if ((this.method instanceof MethodMember)) { 2773 if ((this.method instanceof MethodMember)) {
2767 var m = this.method; 2774 var m = this.method;
2768 if (m._providePropertySyntax) { 2775 MethodGenerator._maybeGenerateBoundGetter(m, defWriter);
2769 defWriter.enterBlock(('' + m.declaringType.get$jsname() + '.prototype') + ('.get\$' + m.get$jsname() + ' = function() {')); 2776 }
2770 defWriter.writeln(('return ' + m.declaringType.get$jsname() + '.prototype. ') + ('' + m.get$jsname() + '.bind(this);')); 2777 }
2771 defWriter.exitBlock('}'); 2778 MethodGenerator._maybeGenerateBoundGetter = function(m, defWriter) {
2772 if (m._provideFieldSyntax) { 2779 if (m._providePropertySyntax && !m.declaringType.get$isSingletonNative()) {
2773 $globals.world.internalError('bound m accessed with field syntax'); 2780 defWriter.enterBlock($globals.world.gen._prototypeOf(m.declaringType, "get\$ " + m.get$jsname()) + ' = function() {');
2774 } 2781 defWriter.writeln('return ' + $globals.world.gen._boundMethod(m.declaringTyp e, m.get$jsname()));
2782 defWriter.exitBlock('}');
2783 if (m._provideFieldSyntax) {
2784 $globals.world.internalError(('bound "' + m.name + '" accessed with field syntax'), m.definition.span);
2775 } 2785 }
2776 } 2786 }
2777 } 2787 }
2778 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) { 2788 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) {
2779 if ((this.method instanceof MethodMember)) { 2789 if ((this.method instanceof MethodMember)) {
2780 var meth = this.method; 2790 var meth = this.method;
2781 if (meth._provideOptionalParamInfo) { 2791 if (meth._provideOptionalParamInfo) {
2782 var optNames = []; 2792 var optNames = [];
2783 var optValues = []; 2793 var optValues = [];
2784 meth.genParameterValues(); 2794 meth.genParameterValues();
2785 var $$list = meth.parameters; 2795 var $$list = meth.parameters;
2786 for (var $$i = 0;$$i < $$list.length; $$i++) { 2796 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2787 var param = $$list.$index($$i); 2797 var param = $$list.$index($$i);
2788 if (param.get$isOptional()) { 2798 if (param.get$isOptional()) {
2789 optNames.add$1(param.get$name()); 2799 optNames.add$1(param.get$name());
2790 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de())); 2800 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de()));
2791 } 2801 }
2792 } 2802 }
2793 if (optNames.length > 0) { 2803 if (optNames.get$length() > 0) {
2794 var start = ''; 2804 var start = '';
2795 if (meth.isStatic) { 2805 if (meth.isStatic) {
2796 if (!meth.declaringType.get$isTop()) { 2806 if (!meth.declaringType.get$isTop()) {
2797 start = meth.declaringType.get$jsname() + '.'; 2807 start = meth.declaringType.get$jsname() + '.';
2798 } 2808 }
2799 } 2809 }
2800 else { 2810 else {
2801 start = meth.declaringType.get$jsname() + '.prototype.'; 2811 start = meth.declaringType.get$jsname() + '.prototype.';
2802 } 2812 }
2803 optNames.addAll$1(optValues); 2813 optNames.addAll$1(optValues);
(...skipping 17 matching lines...) Expand all
2821 var cv = f.computeValue$0(); 2831 var cv = f.computeValue$0();
2822 if (cv != null) { 2832 if (cv != null) {
2823 initializers.add$1(('this.' + f.get$jsname() + ' = ' + cv.get$code())) ; 2833 initializers.add$1(('this.' + f.get$jsname() + ' = ' + cv.get$code())) ;
2824 initializedFields.add$1(f.get$name()); 2834 initializedFields.add$1(f.get$name());
2825 } 2835 }
2826 } 2836 }
2827 } 2837 }
2828 } 2838 }
2829 this._paramCode = []; 2839 this._paramCode = [];
2830 var $$list = this.method.get$parameters(); 2840 var $$list = this.method.get$parameters();
2831 for (var $$i = 0;$$i < $$list.length; $$i++) { 2841 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2832 var p = $$list.$index($$i); 2842 var p = $$list.$index($$i);
2833 if (initializers != null && p.get$isInitializer()) { 2843 if (initializers != null && p.get$isInitializer()) {
2834 var field = this.method.declaringType.getMember(p.get$name()); 2844 var field = this.method.declaringType.getMember(p.get$name());
2835 if (field == null) { 2845 if (field == null) {
2836 $globals.world.error('bad this parameter - no matching field', p.get$def inition().get$span()); 2846 $globals.world.error('bad this parameter - no matching field', p.get$def inition().get$span());
2837 } 2847 }
2838 if (!field.get$isField()) { 2848 if (!field.get$isField()) {
2839 $globals.world.error(('"this.' + p.get$name() + '" does not refer to a f ield'), p.get$definition().get$span()); 2849 $globals.world.error(('"this.' + p.get$name() + '" does not refer to a f ield'), p.get$definition().get$span());
2840 } 2850 }
2841 var paramValue = new Value(field.get$returnType(), p.get$name(), p.get$def inition().get$span(), false); 2851 var paramValue = new Value(field.get$returnType(), p.get$name(), p.get$def inition().get$span(), false);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 } 2905 }
2896 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) { 2906 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) {
2897 var parentType = this.method.declaringType.get$parent(); 2907 var parentType = this.method.declaringType.get$parent();
2898 if (parentType != null && !parentType.get$isObject()) { 2908 if (parentType != null && !parentType.get$isObject()) {
2899 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span()); 2909 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span());
2900 } 2910 }
2901 } 2911 }
2902 if (initializerCall != null) { 2912 if (initializerCall != null) {
2903 var target = this._writeInitializerCall(initializerCall); 2913 var target = this._writeInitializerCall(initializerCall);
2904 if (!target.get$isSuper()) { 2914 if (!target.get$isSuper()) {
2905 if (initializers.length > 0) { 2915 if (initializers.get$length() > 0) {
2906 var $$list = this.method.get$parameters(); 2916 var $$list = this.method.get$parameters();
2907 for (var $$i = 0;$$i < $$list.length; $$i++) { 2917 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2908 var p = $$list.$index($$i); 2918 var p = $$list.$index($$i);
2909 if (p.get$isInitializer()) { 2919 if (p.get$isInitializer()) {
2910 $globals.world.error('no initialization allowed on redirecting const ructors', p.get$definition().get$span()); 2920 $globals.world.error('no initialization allowed on redirecting const ructors', p.get$definition().get$span());
2911 break; 2921 break;
2912 } 2922 }
2913 } 2923 }
2914 } 2924 }
2915 if (declaredInitializers != null && declaredInitializers.length > 1) { 2925 if (declaredInitializers != null && declaredInitializers.get$length() > 1) {
2916 var init = $eq(declaredInitializers.$index(0), initializerCall) ? declar edInitializers.$index(1) : declaredInitializers.$index(0); 2926 var init = $eq(declaredInitializers.$index(0), initializerCall) ? declar edInitializers.$index(1) : declaredInitializers.$index(0);
2917 $globals.world.error('no initialization allowed on redirecting construct ors', init.get$span()); 2927 $globals.world.error('no initialization allowed on redirecting construct ors', init.get$span());
2918 } 2928 }
2919 initializedFields = null; 2929 initializedFields = null;
2920 } 2930 }
2921 } 2931 }
2922 if (initializedFields != null) { 2932 if (initializedFields != null) {
2923 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) { 2933 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
2924 var member = $$i.next$0(); 2934 var member = $$i.next$0();
2925 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) { 2935 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2964 $globals.world.gen.genMethod(m); 2974 $globals.world.gen.genMethod(m);
2965 var value = m.invoke$4(this, node, target, this._makeArgs(node.arguments)); 2975 var value = m.invoke$4(this, node, target, this._makeArgs(node.arguments));
2966 if ($ne(target.get$type(), $globals.world.objectType)) { 2976 if ($ne(target.get$type(), $globals.world.objectType)) {
2967 this.writer.writeln(('' + value.get$code() + ';')); 2977 this.writer.writeln(('' + value.get$code() + ';'));
2968 } 2978 }
2969 return target; 2979 return target;
2970 } 2980 }
2971 MethodGenerator.prototype._makeArgs = function(arguments) { 2981 MethodGenerator.prototype._makeArgs = function(arguments) {
2972 var args = []; 2982 var args = [];
2973 var seenLabel = false; 2983 var seenLabel = false;
2974 for (var $$i = 0;$$i < arguments.length; $$i++) { 2984 for (var $$i = 0;$$i < arguments.get$length(); $$i++) {
2975 var arg = arguments.$index($$i); 2985 var arg = arguments.$index($$i);
2976 if (arg.get$label() != null) { 2986 if (arg.get$label() != null) {
2977 seenLabel = true; 2987 seenLabel = true;
2978 } 2988 }
2979 else if (seenLabel) { 2989 else if (seenLabel) {
2980 $globals.world.error('bare argument can not follow named arguments', arg.g et$span()); 2990 $globals.world.error('bare argument can not follow named arguments', arg.g et$span());
2981 } 2991 }
2982 args.add$1(this.visitValue(arg.get$value())); 2992 args.add$1(this.visitValue(arg.get$value()));
2983 } 2993 }
2984 return new Arguments(arguments, args); 2994 return new Arguments(arguments, args);
2985 } 2995 }
2986 MethodGenerator.prototype._invokeNative = function(name, arguments) { 2996 MethodGenerator.prototype._invokeNative = function(name, arguments) {
2987 var args = Arguments.get$EMPTY(); 2997 var args = Arguments.get$EMPTY();
2988 if (arguments.length > 0) { 2998 if (arguments.get$length() > 0) {
2989 args = new Arguments(null, arguments); 2999 args = new Arguments(null, arguments);
2990 } 3000 }
2991 var method = $globals.world.corelib.topType.members.$index(name); 3001 var method = $globals.world.corelib.topType.members.$index(name);
2992 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args); 3002 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args);
2993 } 3003 }
2994 MethodGenerator._escapeString = function(text) { 3004 MethodGenerator._escapeString = function(text) {
2995 return text.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', ' \\n').replaceAll('\r', '\\r'); 3005 return text.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', ' \\n').replaceAll('\r', '\\r');
2996 } 3006 }
2997 MethodGenerator.prototype.visitStatementsInBlock = function(body) { 3007 MethodGenerator.prototype.visitStatementsInBlock = function(body) {
2998 if ((body instanceof BlockStatement)) { 3008 if ((body instanceof BlockStatement)) {
2999 var block = body; 3009 var block = body;
3000 var $$list = block.body; 3010 var $$list = block.body;
3001 for (var $$i = 0;$$i < $$list.length; $$i++) { 3011 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3002 var stmt = $$list.$index($$i); 3012 var stmt = $$list.$index($$i);
3003 stmt.visit$1(this); 3013 stmt.visit$1(this);
3004 } 3014 }
3005 } 3015 }
3006 else { 3016 else {
3007 if (body != null) body.visit(this); 3017 if (body != null) body.visit(this);
3008 } 3018 }
3009 return false; 3019 return false;
3010 } 3020 }
3011 MethodGenerator.prototype._pushBlock = function(reentrant) { 3021 MethodGenerator.prototype._pushBlock = function(reentrant) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 return false; 3063 return false;
3054 } 3064 }
3055 MethodGenerator.prototype.visitVariableDefinition = function(node) { 3065 MethodGenerator.prototype.visitVariableDefinition = function(node) {
3056 var isFinal = false; 3066 var isFinal = false;
3057 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) { 3067 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) {
3058 isFinal = true; 3068 isFinal = true;
3059 } 3069 }
3060 this.writer.write('var '); 3070 this.writer.write('var ');
3061 var type = this.method.resolveType(node.type, false); 3071 var type = this.method.resolveType(node.type, false);
3062 for (var i = 0; 3072 for (var i = 0;
3063 i < node.names.length; i++) { 3073 i < node.names.get$length(); i++) {
3064 var thisType = type; 3074 var thisType = type;
3065 if (i > 0) { 3075 if (i > 0) {
3066 this.writer.write(', '); 3076 this.writer.write(', ');
3067 } 3077 }
3068 var name = node.names.$index(i).get$name(); 3078 var name = node.names.$index(i).get$name();
3069 var value = this.visitValue(node.values.$index(i)); 3079 var value = this.visitValue(node.values.$index(i));
3070 if (isFinal) { 3080 if (isFinal) {
3071 if (value == null) { 3081 if (value == null) {
3072 $globals.world.error('no value specified for final variable', node.span) ; 3082 $globals.world.error('no value specified for final variable', node.span) ;
3073 } 3083 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3198 else this.writer.write(';'); 3208 else this.writer.write(';');
3199 if (node.test != null) { 3209 if (node.test != null) {
3200 var test = this.visitBool(node.test); 3210 var test = this.visitBool(node.test);
3201 this.writer.write((' ' + test.get$code() + '; ')); 3211 this.writer.write((' ' + test.get$code() + '; '));
3202 } 3212 }
3203 else { 3213 else {
3204 this.writer.write('; '); 3214 this.writer.write('; ');
3205 } 3215 }
3206 var needsComma = false; 3216 var needsComma = false;
3207 var $$list = node.step; 3217 var $$list = node.step;
3208 for (var $$i = 0;$$i < $$list.length; $$i++) { 3218 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3209 var s = $$list.$index($$i); 3219 var s = $$list.$index($$i);
3210 if (needsComma) this.writer.write(', '); 3220 if (needsComma) this.writer.write(', ');
3211 var sv = this.visitVoid(s); 3221 var sv = this.visitVoid(s);
3212 this.writer.write(sv.get$code()); 3222 this.writer.write(sv.get$code());
3213 needsComma = true; 3223 needsComma = true;
3214 } 3224 }
3215 this.writer.write(') '); 3225 this.writer.write(') ');
3216 this._pushBlock(true); 3226 this._pushBlock(true);
3217 node.body.visit(this); 3227 node.body.visit(this);
3218 this._popBlock(); 3228 this._popBlock();
(...skipping 13 matching lines...) Expand all
3232 this._pushBlock(true); 3242 this._pushBlock(true);
3233 var isFinal = this._isFinal(node.item.type); 3243 var isFinal = this._isFinal(node.item.type);
3234 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false); 3244 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false);
3235 var listVar = list; 3245 var listVar = list;
3236 if (list.get$needsTemp()) { 3246 if (list.get$needsTemp()) {
3237 listVar = this._scope.create('\$list', list.get$type(), null, false, false); 3247 listVar = this._scope.create('\$list', list.get$type(), null, false, false);
3238 this.writer.writeln(('var ' + listVar.code + ' = ' + list.get$code() + ';')) ; 3248 this.writer.writeln(('var ' + listVar.code + ' = ' + list.get$code() + ';')) ;
3239 } 3249 }
3240 if (list.get$type().get$isList()) { 3250 if (list.get$type().get$isList()) {
3241 var tmpi = this._scope.create('\$i', $globals.world.numType, null, false, fa lse); 3251 var tmpi = this._scope.create('\$i', $globals.world.numType, null, false, fa lse);
3242 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = 0;') + ('' + tmp i.get$code() + ' < ' + listVar.code + '.length; ' + tmpi.get$code() + '++) {')); 3252 var listLength = listVar.get_(this, 'length', node.list);
3253 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = 0;') + ('' + tmp i.get$code() + ' < ' + listLength.get$code() + '; ' + tmpi.get$code() + '++) {') );
3243 var value = listVar.invoke(this, ':index', node.list, new Arguments(null, [t mpi]), false); 3254 var value = listVar.invoke(this, ':index', node.list, new Arguments(null, [t mpi]), false);
3244 this.writer.writeln(('var ' + item.get$code() + ' = ' + value.get$code() + ' ;')); 3255 this.writer.writeln(('var ' + item.get$code() + ' = ' + value.get$code() + ' ;'));
3245 } 3256 }
3246 else { 3257 else {
3247 this._pushBlock(false); 3258 this._pushBlock(false);
3248 var iterator = list.invoke$4(this, 'iterator', node.list, Arguments.get$EMPT Y()); 3259 var iterator = list.invoke$4(this, 'iterator', node.list, Arguments.get$EMPT Y());
3249 var tmpi = this._scope.create('\$i', iterator.get$type(), null, false, false ); 3260 var tmpi = this._scope.create('\$i', iterator.get$type(), null, false, false );
3250 var hasNext = tmpi.invoke$4(this, 'hasNext', node.list, Arguments.get$EMPTY( )); 3261 var hasNext = tmpi.invoke$4(this, 'hasNext', node.list, Arguments.get$EMPTY( ));
3251 var next = tmpi.invoke$4(this, 'next', node.list, Arguments.get$EMPTY()); 3262 var next = tmpi.invoke$4(this, 'next', node.list, Arguments.get$EMPTY());
3252 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = ' + iterator.get $code() + '; ' + hasNext.get$code() + '; ) {')); 3263 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = ' + iterator.get $code() + '; ' + hasNext.get$code() + '; ) {'));
3253 this.writer.writeln(('var ' + item.get$code() + ' = ' + next.get$code() + '; ')); 3264 this.writer.writeln(('var ' + item.get$code() + ' = ' + next.get$code() + '; '));
3254 } 3265 }
3255 this.visitStatementsInBlock(node.body); 3266 this.visitStatementsInBlock(node.body);
3256 this.writer.exitBlock('}'); 3267 this.writer.exitBlock('}');
3257 this._popBlock(); 3268 this._popBlock();
3258 return false; 3269 return false;
3259 } 3270 }
3260 MethodGenerator.prototype._genToDartException = function(ex, node) { 3271 MethodGenerator.prototype._genToDartException = function(ex, node) {
3261 var result = this._invokeNative("_toDartException", [ex]); 3272 var result = this._invokeNative("_toDartException", [ex]);
3262 this.writer.writeln(('' + ex.code + ' = ' + result.get$code() + ';')); 3273 this.writer.writeln(('' + ex.code + ' = ' + result.get$code() + ';'));
3263 } 3274 }
3264 MethodGenerator.prototype.visitTryStatement = function(node) { 3275 MethodGenerator.prototype.visitTryStatement = function(node) {
3265 this.writer.enterBlock('try {'); 3276 this.writer.enterBlock('try {');
3266 this._pushBlock(false); 3277 this._pushBlock(false);
3267 this.visitStatementsInBlock(node.body); 3278 this.visitStatementsInBlock(node.body);
3268 this._popBlock(); 3279 this._popBlock();
3269 if (node.catches.length == 1) { 3280 if (node.catches.get$length() == 1) {
3270 var catch_ = node.catches.$index(0); 3281 var catch_ = node.catches.$index(0);
3271 this._pushBlock(false); 3282 this._pushBlock(false);
3272 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e); 3283 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e);
3273 var ex = this._scope.declare(catch_.get$exception()); 3284 var ex = this._scope.declare(catch_.get$exception());
3274 this._scope.rethrow = ex; 3285 this._scope.rethrow = ex;
3275 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {')); 3286 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {'));
3276 if (catch_.get$trace() != null) { 3287 if (catch_.get$trace() != null) {
3277 var trace = this._scope.declare(catch_.get$trace()); 3288 var trace = this._scope.declare(catch_.get$trace());
3278 this.writer.writeln(('var ' + trace.get$code() + ' = \$stackTraceOf(' + ex .get$code() + ');')); 3289 this.writer.writeln(('var ' + trace.get$code() + ' = \$stackTraceOf(' + ex .get$code() + ');'));
3279 $globals.world.gen.corejs.useStackTraceOf = true; 3290 $globals.world.gen.corejs.useStackTraceOf = true;
3280 } 3291 }
3281 this._genToDartException(ex, node); 3292 this._genToDartException(ex, node);
3282 if (!exType.get$isVarOrObject()) { 3293 if (!exType.get$isVarOrObject()) {
3283 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true); 3294 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true);
3284 this.writer.writeln(('if (' + test.get$code() + ') throw ' + ex.get$code() + ';')); 3295 this.writer.writeln(('if (' + test.get$code() + ') throw ' + ex.get$code() + ';'));
3285 } 3296 }
3286 this.visitStatementsInBlock(node.catches.$index(0).get$body()); 3297 this.visitStatementsInBlock(node.catches.$index(0).get$body());
3287 this._popBlock(); 3298 this._popBlock();
3288 } 3299 }
3289 else if (node.catches.length > 0) { 3300 else if (node.catches.get$length() > 0) {
3290 this._pushBlock(false); 3301 this._pushBlock(false);
3291 var ex = this._scope.create('\$ex', $globals.world.varType, null, false, fal se); 3302 var ex = this._scope.create('\$ex', $globals.world.varType, null, false, fal se);
3292 this._scope.rethrow = ex; 3303 this._scope.rethrow = ex;
3293 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {')); 3304 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {'));
3294 var trace = null; 3305 var trace = null;
3295 if (node.catches.some((function (c) { 3306 if (node.catches.some((function (c) {
3296 return c.get$trace() != null; 3307 return c.get$trace() != null;
3297 }) 3308 })
3298 )) { 3309 )) {
3299 trace = this._scope.create('\$trace', $globals.world.varType, null, false, false); 3310 trace = this._scope.create('\$trace', $globals.world.varType, null, false, false);
3300 this.writer.writeln(('var ' + trace.get$code() + ' = \$stackTraceOf(' + ex .get$code() + ');')); 3311 this.writer.writeln(('var ' + trace.get$code() + ' = \$stackTraceOf(' + ex .get$code() + ');'));
3301 $globals.world.gen.corejs.useStackTraceOf = true; 3312 $globals.world.gen.corejs.useStackTraceOf = true;
3302 } 3313 }
3303 this._genToDartException(ex, node); 3314 this._genToDartException(ex, node);
3304 var needsRethrow = true; 3315 var needsRethrow = true;
3305 for (var i = 0; 3316 for (var i = 0;
3306 i < node.catches.length; i++) { 3317 i < node.catches.get$length(); i++) {
3307 var catch_ = node.catches.$index(i); 3318 var catch_ = node.catches.$index(i);
3308 this._pushBlock(false); 3319 this._pushBlock(false);
3309 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse); 3320 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse);
3310 var tmp = this._scope.declare(catch_.get$exception()); 3321 var tmp = this._scope.declare(catch_.get$exception());
3311 if (!tmpType.get$isVarOrObject()) { 3322 if (!tmpType.get$isVarOrObject()) {
3312 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true); 3323 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true);
3313 if (i == 0) { 3324 if (i == 0) {
3314 this.writer.enterBlock(('if (' + test.get$code() + ') {')); 3325 this.writer.enterBlock(('if (' + test.get$code() + ') {'));
3315 } 3326 }
3316 else { 3327 else {
3317 this.writer.nextBlock(('} else if (' + test.get$code() + ') {')); 3328 this.writer.nextBlock(('} else if (' + test.get$code() + ') {'));
3318 } 3329 }
3319 } 3330 }
3320 else if (i > 0) { 3331 else if (i > 0) {
3321 this.writer.nextBlock('} else {'); 3332 this.writer.nextBlock('} else {');
3322 } 3333 }
3323 this.writer.writeln(('var ' + tmp.get$code() + ' = ' + ex.get$code() + ';' )); 3334 this.writer.writeln(('var ' + tmp.get$code() + ' = ' + ex.get$code() + ';' ));
3324 if (catch_.get$trace() != null) { 3335 if (catch_.get$trace() != null) {
3325 var tmptrace = this._scope.declare(catch_.get$trace()); 3336 var tmptrace = this._scope.declare(catch_.get$trace());
3326 this.writer.writeln(('var ' + tmptrace.get$code() + ' = ' + trace.get$co de() + ';')); 3337 this.writer.writeln(('var ' + tmptrace.get$code() + ' = ' + trace.get$co de() + ';'));
3327 } 3338 }
3328 this.visitStatementsInBlock(catch_.get$body()); 3339 this.visitStatementsInBlock(catch_.get$body());
3329 this._popBlock(); 3340 this._popBlock();
3330 if (tmpType.get$isVarOrObject()) { 3341 if (tmpType.get$isVarOrObject()) {
3331 if (i + 1 < node.catches.length) { 3342 if (i + 1 < node.catches.get$length()) {
3332 $globals.world.error('Unreachable catch clause', node.catches.$index(i + 1).get$span()); 3343 $globals.world.error('Unreachable catch clause', node.catches.$index(i + 1).get$span());
3333 } 3344 }
3334 if (i > 0) { 3345 if (i > 0) {
3335 this.writer.exitBlock('}'); 3346 this.writer.exitBlock('}');
3336 } 3347 }
3337 needsRethrow = false; 3348 needsRethrow = false;
3338 break; 3349 break;
3339 } 3350 }
3340 } 3351 }
3341 if (needsRethrow) { 3352 if (needsRethrow) {
3342 this.writer.nextBlock('} else {'); 3353 this.writer.nextBlock('} else {');
3343 this.writer.writeln(('throw ' + ex.get$code() + ';')); 3354 this.writer.writeln(('throw ' + ex.get$code() + ';'));
3344 this.writer.exitBlock('}'); 3355 this.writer.exitBlock('}');
3345 } 3356 }
3346 this._popBlock(); 3357 this._popBlock();
3347 } 3358 }
3348 if (node.finallyBlock != null) { 3359 if (node.finallyBlock != null) {
3349 this.writer.nextBlock('} finally {'); 3360 this.writer.nextBlock('} finally {');
3350 this._pushBlock(false); 3361 this._pushBlock(false);
3351 this.visitStatementsInBlock(node.finallyBlock); 3362 this.visitStatementsInBlock(node.finallyBlock);
3352 this._popBlock(); 3363 this._popBlock();
3353 } 3364 }
3354 this.writer.exitBlock('}'); 3365 this.writer.exitBlock('}');
3355 return false; 3366 return false;
3356 } 3367 }
3357 MethodGenerator.prototype.visitSwitchStatement = function(node) { 3368 MethodGenerator.prototype.visitSwitchStatement = function(node) {
3358 var test = this.visitValue(node.test); 3369 var test = this.visitValue(node.test);
3359 this.writer.enterBlock(('switch (' + test.get$code() + ') {')); 3370 this.writer.enterBlock(('switch (' + test.get$code() + ') {'));
3360 var $$list = node.cases; 3371 var $$list = node.cases;
3361 for (var $$i = 0;$$i < $$list.length; $$i++) { 3372 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3362 var case_ = $$list.$index($$i); 3373 var case_ = $$list.$index($$i);
3363 if (case_.get$label() != null) { 3374 if (case_.get$label() != null) {
3364 $globals.world.error('unimplemented: labeled case statement', case_.get$sp an()); 3375 $globals.world.error('unimplemented: labeled case statement', case_.get$sp an());
3365 } 3376 }
3366 this._pushBlock(false); 3377 this._pushBlock(false);
3367 for (var i = 0; 3378 for (var i = 0;
3368 i < case_.get$cases().length; i++) { 3379 i < case_.get$cases().get$length(); i++) {
3369 var expr = case_.get$cases().$index(i); 3380 var expr = case_.get$cases().$index(i);
3370 if (expr == null) { 3381 if (expr == null) {
3371 if (i < case_.get$cases().length - 1) { 3382 if (i < case_.get$cases().get$length() - 1) {
3372 $globals.world.error('default clause must be the last case', case_.get $span()); 3383 $globals.world.error('default clause must be the last case', case_.get $span());
3373 } 3384 }
3374 this.writer.writeln('default:'); 3385 this.writer.writeln('default:');
3375 } 3386 }
3376 else { 3387 else {
3377 var value = this.visitValue(expr); 3388 var value = this.visitValue(expr);
3378 this.writer.writeln(('case ' + value.get$code() + ':')); 3389 this.writer.writeln(('case ' + value.get$code() + ':'));
3379 } 3390 }
3380 } 3391 }
3381 this.writer.enterBlock(''); 3392 this.writer.enterBlock('');
3382 var caseExits = this._visitAllStatements(case_.get$statements(), false); 3393 var caseExits = this._visitAllStatements(case_.get$statements(), false);
3383 if ($ne(case_, node.cases.$index(node.cases.length - 1)) && !caseExits) { 3394 if ($ne(case_, node.cases.$index(node.cases.get$length() - 1)) && !caseExits ) {
3384 var span = case_.get$statements().$index(case_.get$statements().length - 1 ).get$span(); 3395 var span = case_.get$statements().$index(case_.get$statements().get$length () - 1).get$span();
3385 this.writer.writeln('\$throw(new FallThroughError());'); 3396 this.writer.writeln('\$throw(new FallThroughError());');
3386 $globals.world.gen.corejs.useThrow = true; 3397 $globals.world.gen.corejs.useThrow = true;
3387 } 3398 }
3388 this.writer.exitBlock(''); 3399 this.writer.exitBlock('');
3389 this._popBlock(); 3400 this._popBlock();
3390 } 3401 }
3391 this.writer.exitBlock('}'); 3402 this.writer.exitBlock('}');
3392 return false; 3403 return false;
3393 } 3404 }
3394 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) { 3405 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) {
3395 for (var i = 0; 3406 for (var i = 0;
3396 i < statementList.length; i++) { 3407 i < statementList.get$length(); i++) {
3397 var stmt = statementList.$index(i); 3408 var stmt = statementList.$index(i);
3398 exits = stmt.visit$1(this); 3409 exits = stmt.visit$1(this);
3399 if ($ne(stmt, statementList.$index(statementList.length - 1)) && exits) { 3410 if ($ne(stmt, statementList.$index(statementList.get$length() - 1)) && exits ) {
3400 $globals.world.warning('unreachable code', statementList.$index(i + 1).get $span()); 3411 $globals.world.warning('unreachable code', statementList.$index(i + 1).get $span());
3401 } 3412 }
3402 } 3413 }
3403 return exits; 3414 return exits;
3404 } 3415 }
3405 MethodGenerator.prototype.visitBlockStatement = function(node) { 3416 MethodGenerator.prototype.visitBlockStatement = function(node) {
3406 this._pushBlock(false); 3417 this._pushBlock(false);
3407 this.writer.enterBlock('{'); 3418 this.writer.enterBlock('{');
3408 var exits = this._visitAllStatements(node.body, false); 3419 var exits = this._visitAllStatements(node.body, false);
3409 this.writer.exitBlock('}'); 3420 this.writer.exitBlock('}');
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 } 3467 }
3457 else { 3468 else {
3458 return 'this'; 3469 return 'this';
3459 } 3470 }
3460 } 3471 }
3461 MethodGenerator.prototype._makeThisValue = function(node) { 3472 MethodGenerator.prototype._makeThisValue = function(node) {
3462 if (this.enclosingMethod != null) { 3473 if (this.enclosingMethod != null) {
3463 var outermostMethod = this._getOutermostMethod(); 3474 var outermostMethod = this._getOutermostMethod();
3464 outermostMethod._checkNonStatic$1(node); 3475 outermostMethod._checkNonStatic$1(node);
3465 outermostMethod.set$needsThis(true); 3476 outermostMethod.set$needsThis(true);
3466 return new Value(outermostMethod.method.get$declaringType(), '\$this', node != null ? node.span : null, false); 3477 return new Value(outermostMethod.get$method().get$declaringType(), '\$this', node != null ? node.span : null, false);
3467 } 3478 }
3468 else { 3479 else {
3469 this._checkNonStatic(node); 3480 this._checkNonStatic(node);
3470 return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false); 3481 return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false);
3471 } 3482 }
3472 } 3483 }
3473 MethodGenerator.prototype.visitLambdaExpression = function(node) { 3484 MethodGenerator.prototype.visitLambdaExpression = function(node) {
3474 var name = (node.func.name != null) ? node.func.name.name : ''; 3485 var name = (node.func.name != null) ? node.func.name.name : '';
3475 var meth = this._makeLambdaMethod(name, node.func); 3486 var meth = this._makeLambdaMethod(name, node.func);
3476 var lambdaGen = new MethodGenerator(meth, this); 3487 var lambdaGen = new MethodGenerator(meth, this);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 return new Value($globals.world.nonNullBool, code, node.span, true); 3537 return new Value($globals.world.nonNullBool, code, node.span, true);
3527 } 3538 }
3528 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT* /) { 3539 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT* /) {
3529 var x = this.visitValue(node.x); 3540 var x = this.visitValue(node.x);
3530 var y = this.visitValue(node.y); 3541 var y = this.visitValue(node.y);
3531 if (x.get$isConst() && y.get$isConst()) { 3542 if (x.get$isConst() && y.get$isConst()) {
3532 var xVal = x.get$actualValue(); 3543 var xVal = x.get$actualValue();
3533 var yVal = y.get$actualValue(); 3544 var yVal = y.get$actualValue();
3534 if (x.get$type().get$isString() && y.get$type().get$isString() && $ne(xVal .$index(0), yVal.$index(0))) { 3545 if (x.get$type().get$isString() && y.get$type().get$isString() && $ne(xVal .$index(0), yVal.$index(0))) {
3535 if ($eq(xVal.$index(0), '"')) { 3546 if ($eq(xVal.$index(0), '"')) {
3536 xVal = xVal.substring$2(1, xVal.length - 1); 3547 xVal = xVal.substring$2(1, xVal.get$length() - 1);
3537 yVal = toDoubleQuote(yVal.substring$2(1, yVal.length - 1)); 3548 yVal = toDoubleQuote(yVal.substring$2(1, yVal.get$length() - 1));
3538 } 3549 }
3539 else { 3550 else {
3540 xVal = toDoubleQuote(xVal.substring$2(1, xVal.length - 1)); 3551 xVal = toDoubleQuote(xVal.substring$2(1, xVal.get$length() - 1));
3541 yVal = yVal.substring$2(1, yVal.length - 1); 3552 yVal = yVal.substring$2(1, yVal.get$length() - 1);
3542 } 3553 }
3543 } 3554 }
3544 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal , yVal); 3555 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal , yVal);
3545 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ("" + value), node.span); 3556 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ("" + value), node.span);
3546 } 3557 }
3547 if ($eq(x.get$code(), 'null') || $eq(y.get$code(), 'null')) { 3558 if ($eq(x.get$code(), 'null') || $eq(y.get$code(), 'null')) {
3548 var op = node.op.toString().substring(0, 2); 3559 var op = node.op.toString().substring(0, 2);
3549 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + op + ' ' + y.get$code()), node.span, true); 3560 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + op + ' ' + y.get$code()), node.span, true);
3550 } 3561 }
3551 else { 3562 else {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3780 } 3791 }
3781 MethodGenerator.prototype.visitNewExpression = function(node) { 3792 MethodGenerator.prototype.visitNewExpression = function(node) {
3782 var typeRef = node.type; 3793 var typeRef = node.type;
3783 var constructorName = ''; 3794 var constructorName = '';
3784 if (node.name != null) { 3795 if (node.name != null) {
3785 constructorName = node.name.name; 3796 constructorName = node.name.name;
3786 } 3797 }
3787 if ($eq(constructorName, '') && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) { 3798 if ($eq(constructorName, '') && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) {
3788 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); 3799 var names = ListFactory.ListFactory$from$factory(typeRef.get$names());
3789 constructorName = names.removeLast$0().get$name(); 3800 constructorName = names.removeLast$0().get$name();
3790 if ($eq(names.length, 0)) names = null; 3801 if ($eq(names.get$length(), 0)) names = null;
3791 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span()); 3802 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span());
3792 } 3803 }
3793 var type = this.method.resolveType(typeRef, true); 3804 var type = this.method.resolveType(typeRef, true);
3794 if (type.get$isTop()) { 3805 if (type.get$isTop()) {
3795 type = type.get$library().findTypeByName$1(constructorName); 3806 type = type.get$library().findTypeByName$1(constructorName);
3796 constructorName = ''; 3807 constructorName = '';
3797 } 3808 }
3798 if ((type instanceof ParameterType)) { 3809 if ((type instanceof ParameterType)) {
3799 $globals.world.error('cannot instantiate a type parameter', node.span); 3810 $globals.world.error('cannot instantiate a type parameter', node.span);
3800 return this._makeMissingValue(constructorName); 3811 return this._makeMissingValue(constructorName);
3801 } 3812 }
3802 var m = type.getConstructor$1(constructorName); 3813 var m = type.getConstructor$1(constructorName);
3803 if (m == null) { 3814 if (m == null) {
3804 var name = type.get$jsname(); 3815 var name = type.get$jsname();
3805 if (type.get$isVar()) { 3816 if (type.get$isVar()) {
3806 name = typeRef.get$name().get$name(); 3817 name = typeRef.get$name().get$name();
3807 } 3818 }
3808 $globals.world.error(('no matching constructor for ' + name), node.span); 3819 $globals.world.error(('no matching constructor for ' + name), node.span);
3809 return this._makeMissingValue(name); 3820 return this._makeMissingValue(name);
3810 } 3821 }
3811 if (node.isConst) { 3822 if (node.isConst) {
3812 if (!m.get$isConst()) { 3823 if (!m.get$isConst()) {
3813 $globals.world.error('can\'t use const on a non-const constructor', node.s pan); 3824 $globals.world.error('can\'t use const on a non-const constructor', node.s pan);
3814 } 3825 }
3815 var $$list = node.arguments; 3826 var $$list = node.arguments;
3816 for (var $$i = 0;$$i < $$list.length; $$i++) { 3827 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3817 var arg = $$list.$index($$i); 3828 var arg = $$list.$index($$i);
3818 if (!this.visitValue(arg.get$value()).get$isConst()) { 3829 if (!this.visitValue(arg.get$value()).get$isConst()) {
3819 $globals.world.error('const constructor expects const arguments', arg.ge t$span()); 3830 $globals.world.error('const constructor expects const arguments', arg.ge t$span());
3820 } 3831 }
3821 } 3832 }
3822 } 3833 }
3823 var target = new Value.type$ctor(type, typeRef.get$span()); 3834 var target = new Value.type$ctor(type, typeRef.get$span());
3824 return m.invoke$4(this, node, target, this._makeArgs(node.arguments)); 3835 return m.invoke$4(this, node, target, this._makeArgs(node.arguments));
3825 } 3836 }
3826 MethodGenerator.prototype.visitListExpression = function(node) { 3837 MethodGenerator.prototype.visitListExpression = function(node) {
3827 var argsCode = []; 3838 var argsCode = [];
3828 var argValues = []; 3839 var argValues = [];
3829 var type = null; 3840 var type = null;
3830 if (node.type != null) { 3841 if (node.type != null) {
3831 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (0); 3842 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (0);
3832 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 3843 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) {
3833 $globals.world.error('type parameter cannot be used in const list literals '); 3844 $globals.world.error('type parameter cannot be used in const list literals ');
3834 } 3845 }
3835 } 3846 }
3836 var $$list = node.values; 3847 var $$list = node.values;
3837 for (var $$i = 0;$$i < $$list.length; $$i++) { 3848 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3838 var item = $$list.$index($$i); 3849 var item = $$list.$index($$i);
3839 var arg = this.visitTypedValue(item, type); 3850 var arg = this.visitTypedValue(item, type);
3840 argValues.add$1(arg); 3851 argValues.add$1(arg);
3841 if (node.isConst) { 3852 if (node.isConst) {
3842 if (!arg.get$isConst()) { 3853 if (!arg.get$isConst()) {
3843 $globals.world.error('const list can only contain const values', item.ge t$span()); 3854 $globals.world.error('const list can only contain const values', item.ge t$span());
3844 argsCode.add$1(arg.get$code()); 3855 argsCode.add$1(arg.get$code());
3845 } 3856 }
3846 else { 3857 else {
3847 argsCode.add$1(arg.get$canonicalCode()); 3858 argsCode.add$1(arg.get$canonicalCode());
3848 } 3859 }
3849 } 3860 }
3850 else { 3861 else {
3851 argsCode.add$1(arg.get$code()); 3862 argsCode.add$1(arg.get$code());
3852 } 3863 }
3853 } 3864 }
3854 $globals.world.get$coreimpl().types.$index('ListFactory').markUsed$0(); 3865 $globals.world.get$coreimpl().types.$index('ListFactory').markUsed$0();
3855 var code = ('[' + Strings.join(argsCode, ", ") + ']'); 3866 var code = ('[' + Strings.join(argsCode, ", ") + ']');
3856 var value = new Value($globals.world.listType, code, node.span, true); 3867 var value = new Value($globals.world.listType, code, node.span, true);
3857 if (node.isConst) { 3868 if (node.isConst) {
3858 var immutableList = $globals.world.get$coreimpl().types.$index('ImmutableLis t'); 3869 var immutableList = $globals.world.get$coreimpl().types.$index('ImmutableLis t');
3859 var immutableListCtor = immutableList.getConstructor$1('from'); 3870 var immutableListCtor = immutableList.getConstructor$1('from');
3860 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu e.get$type(), node.span), new Arguments(null, [value])); 3871 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu e.get$type(), node.span), new Arguments(null, [value]));
3861 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact ory(immutableList, argValues, ('const ' + code), result.get$code(), node.span), argValues); 3872 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact ory(immutableList, argValues, ('const ' + code), result.get$code(), node.span), argValues);
3862 } 3873 }
3863 return value; 3874 return value;
3864 } 3875 }
3865 MethodGenerator.prototype.visitMapExpression = function(node) { 3876 MethodGenerator.prototype.visitMapExpression = function(node) {
3866 if (node.items.length == 0 && !node.isConst) { 3877 if (node.items.get$length() == 0 && !node.isConst) {
3867 return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY()); 3878 return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY());
3868 } 3879 }
3869 var argValues = []; 3880 var argValues = [];
3870 var argsCode = []; 3881 var argsCode = [];
3871 var type = null; 3882 var type = null;
3872 if (node.type != null) { 3883 if (node.type != null) {
3873 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (1); 3884 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (1);
3874 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 3885 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) {
3875 $globals.world.error('type parameter cannot be used in const map literals' ); 3886 $globals.world.error('type parameter cannot be used in const map literals' );
3876 } 3887 }
3877 } 3888 }
3878 for (var i = 0; 3889 for (var i = 0;
3879 i < node.items.length; i += 2) { 3890 i < node.items.get$length(); i += 2) {
3880 var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringTy pe); 3891 var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringTy pe);
3881 var valueItem = node.items.$index(i + 1); 3892 var valueItem = node.items.$index(i + 1);
3882 var value = this.visitTypedValue(valueItem, type); 3893 var value = this.visitTypedValue(valueItem, type);
3883 argValues.add$1(key); 3894 argValues.add$1(key);
3884 argValues.add$1(value); 3895 argValues.add$1(value);
3885 if (node.isConst) { 3896 if (node.isConst) {
3886 if (!key.get$isConst() || !value.get$isConst()) { 3897 if (!key.get$isConst() || !value.get$isConst()) {
3887 $globals.world.error('const map can only contain const values', valueIte m.get$span()); 3898 $globals.world.error('const map can only contain const values', valueIte m.get$span());
3888 argsCode.add$1(key.get$code()); 3899 argsCode.add$1(key.get$code());
3889 argsCode.add$1(value.get$code()); 3900 argsCode.add$1(value.get$code());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3971 var items = []; 3982 var items = [];
3972 var $$list = node.value; 3983 var $$list = node.value;
3973 for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) { 3984 for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) {
3974 var item = $$i.next$0(); 3985 var item = $$i.next$0();
3975 var val = this.visitValue(item); 3986 var val = this.visitValue(item);
3976 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY()); 3987 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY());
3977 var code = val.get$code(); 3988 var code = val.get$code();
3978 if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpr ession) || (item instanceof PostfixExpression) || this._isUnaryIncrement(item)) { 3989 if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpr ession) || (item instanceof PostfixExpression) || this._isUnaryIncrement(item)) {
3979 code = ('(' + code + ')'); 3990 code = ('(' + code + ')');
3980 } 3991 }
3981 if ($eq(items.length, 0) || ($ne(code, "''") && $ne(code, '""'))) { 3992 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) {
3982 items.add$1(code); 3993 items.add$1(code);
3983 } 3994 }
3984 } 3995 }
3985 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true); 3996 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true);
3986 } 3997 }
3987 var text = node.text; 3998 var text = node.text;
3988 if (type.get$isString()) { 3999 if (type.get$isString()) {
3989 if (text.startsWith$1('@')) { 4000 if (text.startsWith$1('@')) {
3990 text = MethodGenerator._escapeString(parseStringLiteral(text)); 4001 text = MethodGenerator._escapeString(parseStringLiteral(text));
3991 text = ('"' + text + '"'); 4002 text = ('"' + text + '"');
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4033 } 4044 }
4034 Arguments.prototype.get$values = function() { return this.values; }; 4045 Arguments.prototype.get$values = function() { return this.values; };
4035 Arguments.prototype.set$values = function(value) { return this.values = value; } ; 4046 Arguments.prototype.set$values = function(value) { return this.values = value; } ;
4036 Arguments.prototype.get$nameCount = function() { 4047 Arguments.prototype.get$nameCount = function() {
4037 return this.get$length() - this.get$bareCount(); 4048 return this.get$length() - this.get$bareCount();
4038 } 4049 }
4039 Arguments.prototype.get$hasNames = function() { 4050 Arguments.prototype.get$hasNames = function() {
4040 return this.get$bareCount() < this.get$length(); 4051 return this.get$bareCount() < this.get$length();
4041 } 4052 }
4042 Arguments.prototype.get$length = function() { 4053 Arguments.prototype.get$length = function() {
4043 return this.values.length; 4054 return this.values.get$length();
4044 } 4055 }
4045 Object.defineProperty(Arguments.prototype, "length", {
4046 get: Arguments.prototype.get$length
4047 });
4048 Arguments.prototype.getName = function(i) { 4056 Arguments.prototype.getName = function(i) {
4049 return this.nodes.$index(i).get$label().get$name(); 4057 return this.nodes.$index(i).get$label().get$name();
4050 } 4058 }
4051 Arguments.prototype.getIndexOfName = function(name) { 4059 Arguments.prototype.getIndexOfName = function(name) {
4052 for (var i = this.get$bareCount(); 4060 for (var i = this.get$bareCount();
4053 i < this.get$length(); i++) { 4061 i < this.get$length(); i++) {
4054 if (this.getName(i) == name) { 4062 if (this.getName(i) == name) {
4055 return i; 4063 return i;
4056 } 4064 }
4057 } 4065 }
4058 return -1; 4066 return -1;
4059 } 4067 }
4060 Arguments.prototype.getValue = function(name) { 4068 Arguments.prototype.getValue = function(name) {
4061 var i = this.getIndexOfName(name); 4069 var i = this.getIndexOfName(name);
4062 return i >= 0 ? this.values.$index(i) : null; 4070 return i >= 0 ? this.values.$index(i) : null;
4063 } 4071 }
4064 Arguments.prototype.get$bareCount = function() { 4072 Arguments.prototype.get$bareCount = function() {
4065 if (this._bareCount == null) { 4073 if (this._bareCount == null) {
4066 this._bareCount = this.get$length(); 4074 this._bareCount = this.get$length();
4067 if (this.nodes != null) { 4075 if (this.nodes != null) {
4068 for (var i = 0; 4076 for (var i = 0;
4069 i < this.nodes.length; i++) { 4077 i < this.nodes.get$length(); i++) {
4070 if (this.nodes.$index(i).get$label() != null) { 4078 if (this.nodes.$index(i).get$label() != null) {
4071 this._bareCount = i; 4079 this._bareCount = i;
4072 break; 4080 break;
4073 } 4081 }
4074 } 4082 }
4075 } 4083 }
4076 } 4084 }
4077 return this._bareCount; 4085 return this._bareCount;
4078 } 4086 }
4079 Arguments.prototype.getCode = function() { 4087 Arguments.prototype.getCode = function() {
4080 var argsCode = []; 4088 var argsCode = [];
4081 for (var i = 0; 4089 for (var i = 0;
4082 i < this.get$length(); i++) { 4090 i < this.get$length(); i++) {
4083 argsCode.add$1(this.values.$index(i).get$code()); 4091 argsCode.add$1(this.values.$index(i).get$code());
4084 } 4092 }
4085 Arguments.removeTrailingNulls(argsCode); 4093 Arguments.removeTrailingNulls(argsCode);
4086 return Strings.join(argsCode, ", "); 4094 return Strings.join(argsCode, ", ");
4087 } 4095 }
4088 Arguments.removeTrailingNulls = function(argsCode) { 4096 Arguments.removeTrailingNulls = function(argsCode) {
4089 while (argsCode.length > 0 && $eq(argsCode.last(), 'null')) { 4097 while (argsCode.get$length() > 0 && $eq(argsCode.last(), 'null')) {
4090 argsCode.removeLast(); 4098 argsCode.removeLast();
4091 } 4099 }
4092 } 4100 }
4093 Arguments.prototype.getNames = function() { 4101 Arguments.prototype.getNames = function() {
4094 var names = []; 4102 var names = [];
4095 for (var i = this.get$bareCount(); 4103 for (var i = this.get$bareCount();
4096 i < this.get$length(); i++) { 4104 i < this.get$length(); i++) {
4097 names.add$1(this.getName(i)); 4105 names.add$1(this.getName(i));
4098 } 4106 }
4099 return names; 4107 return names;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4238 } 4246 }
4239 else { 4247 else {
4240 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ; 4248 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ;
4241 } 4249 }
4242 return this.types.$index(name); 4250 return this.types.$index(name);
4243 } 4251 }
4244 Library.prototype.findType = function(type) { 4252 Library.prototype.findType = function(type) {
4245 var result = this.findTypeByName(type.name.name); 4253 var result = this.findTypeByName(type.name.name);
4246 if (result == null) return null; 4254 if (result == null) return null;
4247 if (type.names != null) { 4255 if (type.names != null) {
4248 if (type.names.length > 1) { 4256 if (type.names.get$length() > 1) {
4249 return null; 4257 return null;
4250 } 4258 }
4251 if (!result.get$isTop()) { 4259 if (!result.get$isTop()) {
4252 return null; 4260 return null;
4253 } 4261 }
4254 return result.get$library().findTypeByName(type.names.$index(0).get$name()); 4262 return result.get$library().findTypeByName(type.names.$index(0).get$name());
4255 } 4263 }
4256 return result; 4264 return result;
4257 } 4265 }
4258 Library.prototype.findTypeByName = function(name) { 4266 Library.prototype.findTypeByName = function(name) {
4259 var ret = this.types.$index(name); 4267 var ret = this.types.$index(name);
4260 var $$list = this.imports; 4268 var $$list = this.imports;
4261 for (var $$i = 0;$$i < $$list.length; $$i++) { 4269 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4262 var imported = $$list.$index($$i); 4270 var imported = $$list.$index($$i);
4263 var newRet = null; 4271 var newRet = null;
4264 if (imported.get$prefix() == null) { 4272 if (imported.get$prefix() == null) {
4265 newRet = imported.get$library().get$types().$index(name); 4273 newRet = imported.get$library().get$types().$index(name);
4266 } 4274 }
4267 else if ($eq(imported.get$prefix(), name)) { 4275 else if ($eq(imported.get$prefix(), name)) {
4268 newRet = imported.get$library().get$topType(); 4276 newRet = imported.get$library().get$topType();
4269 } 4277 }
4270 if (newRet != null) { 4278 if (newRet != null) {
4271 if (ret != null && $ne(ret, newRet)) { 4279 if (ret != null && $ne(ret, newRet)) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4316 var newRet = this.topType.getMember(name); 4324 var newRet = this.topType.getMember(name);
4317 if (newRet != null) { 4325 if (newRet != null) {
4318 if (ret != null && $ne(ret, newRet)) { 4326 if (ret != null && $ne(ret, newRet)) {
4319 $globals.world.error(('conflicting members for "' + name + '"'), span, ret .get$span(), newRet.get$span()); 4327 $globals.world.error(('conflicting members for "' + name + '"'), span, ret .get$span(), newRet.get$span());
4320 } 4328 }
4321 else { 4329 else {
4322 ret = newRet; 4330 ret = newRet;
4323 } 4331 }
4324 } 4332 }
4325 var $$list = this.imports; 4333 var $$list = this.imports;
4326 for (var $$i = 0;$$i < $$list.length; $$i++) { 4334 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4327 var imported = $$list.$index($$i); 4335 var imported = $$list.$index($$i);
4328 if (imported.get$prefix() == null) { 4336 if (imported.get$prefix() == null) {
4329 newRet = imported.get$library().get$topType().getMember$1(name); 4337 newRet = imported.get$library().get$topType().getMember$1(name);
4330 if (newRet != null) { 4338 if (newRet != null) {
4331 if (ret != null && $ne(ret, newRet)) { 4339 if (ret != null && $ne(ret, newRet)) {
4332 $globals.world.error(('conflicting members for "' + name + '"'), span, ret.get$span(), newRet.get$span()); 4340 $globals.world.error(('conflicting members for "' + name + '"'), span, ret.get$span(), newRet.get$span());
4333 } 4341 }
4334 else { 4342 else {
4335 ret = newRet; 4343 ret = newRet;
4336 } 4344 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4452 else { 4460 else {
4453 $globals.world.error('already specified library name', node.span); 4461 $globals.world.error('already specified library name', node.span);
4454 } 4462 }
4455 break; 4463 break;
4456 4464
4457 case "import": 4465 case "import":
4458 4466
4459 this.seenImport = true; 4467 this.seenImport = true;
4460 name = this.getFirstStringArg(node); 4468 name = this.getFirstStringArg(node);
4461 var prefix = this.tryGetNamedStringArg(node, 'prefix'); 4469 var prefix = this.tryGetNamedStringArg(node, 'prefix');
4462 if (node.arguments.length > 2 || node.arguments.length == 2 && prefix == n ull) { 4470 if (node.arguments.get$length() > 2 || node.arguments.get$length() == 2 && prefix == null) {
4463 $globals.world.error('expected at most one "name" argument and one optio nal "prefix"' + (' but found ' + node.arguments.length), node.span); 4471 $globals.world.error('expected at most one "name" argument and one optio nal "prefix"' + (' but found ' + node.arguments.get$length()), node.span);
4464 } 4472 }
4465 else if (prefix != null && prefix.indexOf$1('.') >= 0) { 4473 else if (prefix != null && prefix.indexOf$1('.') >= 0) {
4466 $globals.world.error('library prefix canot contain "."', node.span); 4474 $globals.world.error('library prefix canot contain "."', node.span);
4467 } 4475 }
4468 else if (this.seenSource || this.seenResource) { 4476 else if (this.seenSource || this.seenResource) {
4469 $globals.world.error('#imports must come before any #source or #resource ', node.span); 4477 $globals.world.error('#imports must come before any #source or #resource ', node.span);
4470 } 4478 }
4471 if ($eq(prefix, '')) prefix = null; 4479 if ($eq(prefix, '')) prefix = null;
4472 var filename = this.library.makeFullPath(name); 4480 var filename = this.library.makeFullPath(name);
4473 if (this.library.imports.some((function (li) { 4481 if (this.library.imports.some((function (li) {
(...skipping 28 matching lines...) Expand all
4502 this.getFirstStringArg(node); 4510 this.getFirstStringArg(node);
4503 break; 4511 break;
4504 4512
4505 default: 4513 default:
4506 4514
4507 $globals.world.error(('unknown directive: ' + node.name.name), node.span); 4515 $globals.world.error(('unknown directive: ' + node.name.name), node.span);
4508 4516
4509 } 4517 }
4510 } 4518 }
4511 _LibraryVisitor.prototype.getSingleStringArg = function(node) { 4519 _LibraryVisitor.prototype.getSingleStringArg = function(node) {
4512 if (node.arguments.length != 1) { 4520 if (node.arguments.get$length() != 1) {
4513 $globals.world.error(('expected exactly one argument but found ' + node.argu ments.length), node.span); 4521 $globals.world.error(('expected exactly one argument but found ' + node.argu ments.get$length()), node.span);
4514 } 4522 }
4515 return this.getFirstStringArg(node); 4523 return this.getFirstStringArg(node);
4516 } 4524 }
4517 _LibraryVisitor.prototype.getFirstStringArg = function(node) { 4525 _LibraryVisitor.prototype.getFirstStringArg = function(node) {
4518 if (node.arguments.length < 1) { 4526 if (node.arguments.get$length() < 1) {
4519 $globals.world.error(('expected at least one argument but found ' + node.arg uments.length), node.span); 4527 $globals.world.error(('expected at least one argument but found ' + node.arg uments.get$length()), node.span);
4520 } 4528 }
4521 var arg = node.arguments.$index(0); 4529 var arg = node.arguments.$index(0);
4522 if (arg.get$label() != null) { 4530 if (arg.get$label() != null) {
4523 $globals.world.error('label not allowed for directive', node.span); 4531 $globals.world.error('label not allowed for directive', node.span);
4524 } 4532 }
4525 return this._parseStringArgument(arg); 4533 return this._parseStringArgument(arg);
4526 } 4534 }
4527 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { 4535 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) {
4528 var args = node.arguments.filter((function (a) { 4536 var args = node.arguments.filter((function (a) {
4529 return a.get$label() != null && $eq(a.get$label().get$name(), argName); 4537 return a.get$label() != null && $eq(a.get$label().get$name(), argName);
4530 }) 4538 })
4531 ); 4539 );
4532 if ($eq(args.length, 0)) { 4540 if ($eq(args.get$length(), 0)) {
4533 return null; 4541 return null;
4534 } 4542 }
4535 if (args.length > 1) { 4543 if (args.get$length() > 1) {
4536 $globals.world.error(('expected at most one "' + argName + '" argument but f ound ') + node.arguments.length, node.span); 4544 $globals.world.error(('expected at most one "' + argName + '" argument but f ound ') + node.arguments.get$length(), node.span);
4537 } 4545 }
4538 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) { 4546 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) {
4539 var arg = $$i.next$0(); 4547 var arg = $$i.next$0();
4540 return this._parseStringArgument(arg); 4548 return this._parseStringArgument(arg);
4541 } 4549 }
4542 } 4550 }
4543 _LibraryVisitor.prototype._parseStringArgument = function(arg) { 4551 _LibraryVisitor.prototype._parseStringArgument = function(arg) {
4544 var expr = arg.value; 4552 var expr = arg.value;
4545 if (!(expr instanceof LiteralExpression) || !expr.get$type().get$type().get$is String()) { 4553 if (!(expr instanceof LiteralExpression) || !expr.get$type().get$type().get$is String()) {
4546 $globals.world.error('expected string', expr.get$span()); 4554 $globals.world.error('expected string', expr.get$span());
4547 } 4555 }
4548 return parseStringLiteral(expr.get$value()); 4556 return parseStringLiteral(expr.get$value());
4549 } 4557 }
4550 _LibraryVisitor.prototype.visitTypeDefinition = function(node) { 4558 _LibraryVisitor.prototype.visitTypeDefinition = function(node) {
4551 var oldType = this.currentType; 4559 var oldType = this.currentType;
4552 this.currentType = this.library.addType(node.name.name, node, node.isClass); 4560 this.currentType = this.library.addType(node.name.name, node, node.isClass);
4553 var $$list = node.body; 4561 var $$list = node.body;
4554 for (var $$i = 0;$$i < $$list.length; $$i++) { 4562 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4555 var member = $$list.$index($$i); 4563 var member = $$list.$index($$i);
4556 member.visit$1(this); 4564 member.visit$1(this);
4557 } 4565 }
4558 this.currentType = oldType; 4566 this.currentType = oldType;
4559 } 4567 }
4560 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { 4568 _LibraryVisitor.prototype.visitVariableDefinition = function(node) {
4561 this.currentType.addField(node); 4569 this.currentType.addField(node);
4562 } 4570 }
4563 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { 4571 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) {
4564 this.currentType.addMethod(node.name.name, node); 4572 this.currentType.addMethod(node.name.name, node);
4565 } 4573 }
4566 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { 4574 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) {
4567 var type = this.library.addType(node.func.name.name, node, false); 4575 var type = this.library.addType(node.func.name.name, node, false);
4568 type.addMethod$2(':call', node.func); 4576 type.addMethod$2(':call', node.func);
4569 } 4577 }
4570 _LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource; 4578 _LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource;
4571 // ********** Code for Parameter ************** 4579 // ********** Code for Parameter **************
4572 function Parameter(definition, method) { 4580 function Parameter(definition, method) {
4573 this.isInitializer = false 4581 this.isInitializer = false
4574 this.definition = definition; 4582 this.definition = definition;
4575 this.method = method; 4583 this.method = method;
4576 // Initializers done 4584 // Initializers done
4577 } 4585 }
4578 Parameter.prototype.get$definition = function() { return this.definition; }; 4586 Parameter.prototype.get$definition = function() { return this.definition; };
4579 Parameter.prototype.set$definition = function(value) { return this.definition = value; }; 4587 Parameter.prototype.set$definition = function(value) { return this.definition = value; };
4588 Parameter.prototype.get$method = function() { return this.method; };
4589 Parameter.prototype.set$method = function(value) { return this.method = value; } ;
4580 Parameter.prototype.get$name = function() { return this.name; }; 4590 Parameter.prototype.get$name = function() { return this.name; };
4581 Parameter.prototype.set$name = function(value) { return this.name = value; }; 4591 Parameter.prototype.set$name = function(value) { return this.name = value; };
4582 Parameter.prototype.get$type = function() { return this.type; }; 4592 Parameter.prototype.get$type = function() { return this.type; };
4583 Parameter.prototype.set$type = function(value) { return this.type = value; }; 4593 Parameter.prototype.set$type = function(value) { return this.type = value; };
4584 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; }; 4594 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; };
4585 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; }; 4595 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; };
4586 Parameter.prototype.get$value = function() { return this.value; }; 4596 Parameter.prototype.get$value = function() { return this.value; };
4587 Parameter.prototype.set$value = function(value) { return this.value = value; }; 4597 Parameter.prototype.set$value = function(value) { return this.value = value; };
4588 Parameter.prototype.resolve = function() { 4598 Parameter.prototype.resolve = function() {
4589 this.name = this.definition.name.name; 4599 this.name = this.definition.name.name;
4590 if (this.name.startsWith('this.')) { 4600 if (this.name.startsWith('this.')) {
4591 this.name = this.name.substring(5); 4601 this.name = this.name.substring(5);
4592 this.isInitializer = true; 4602 this.isInitializer = true;
4593 } 4603 }
4594 this.type = this.method.resolveType(this.definition.type, false); 4604 this.type = this.method.resolveType(this.definition.type, false);
4595 if (this.definition.value != null) { 4605 if (this.definition.value != null) {
4596 if (!this.get$hasDefaultValue()) return; 4606 if (!this.get$hasDefaultValue()) return;
4597 if (this.method.name == ':call') { 4607 if (this.method.name == ':call') {
4598 if (this.method.get$definition().get$body() == null) { 4608 if (this.method.get$definition().get$body() == null && !this.method.get$is Native()) {
4599 $globals.world.error('default value not allowed on function type', this. definition.span); 4609 $globals.world.error('default value not allowed on function type', this. definition.span);
4600 } 4610 }
4601 } 4611 }
4602 else if (this.method.get$isAbstract()) { 4612 else if (this.method.get$isAbstract()) {
4603 $globals.world.error('default value not allowed on abstract methods', this .definition.span); 4613 $globals.world.error('default value not allowed on abstract methods', this .definition.span);
4604 } 4614 }
4605 } 4615 }
4606 else if (this.isInitializer && !this.method.get$isConstructor()) { 4616 else if (this.isInitializer && !this.method.get$isConstructor()) {
4607 $globals.world.error('initializer parameters only allowed on constructors', this.definition.span); 4617 $globals.world.error('initializer parameters only allowed on constructors', this.definition.span);
4608 } 4618 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 } 4686 }
4677 Member.prototype.get$isFactory = function() { 4687 Member.prototype.get$isFactory = function() {
4678 return false; 4688 return false;
4679 } 4689 }
4680 Member.prototype.get$isOperator = function() { 4690 Member.prototype.get$isOperator = function() {
4681 return this.name.startsWith(':'); 4691 return this.name.startsWith(':');
4682 } 4692 }
4683 Member.prototype.get$isCallMethod = function() { 4693 Member.prototype.get$isCallMethod = function() {
4684 return this.name == ':call'; 4694 return this.name == ':call';
4685 } 4695 }
4686 Member.prototype.get$prefersPropertySyntax = function() { 4696 Member.prototype.get$requiresPropertySyntax = function() {
4687 return true; 4697 return false;
4688 } 4698 }
4689 Member.prototype.get$requiresFieldSyntax = function() { 4699 Member.prototype.get$requiresFieldSyntax = function() {
4690 return false; 4700 return false;
4691 } 4701 }
4692 Member.prototype.get$isNative = function() { 4702 Member.prototype.get$isNative = function() {
4693 return false; 4703 return false;
4694 } 4704 }
4695 Member.prototype.get$constructorName = function() { 4705 Member.prototype.get$constructorName = function() {
4696 $globals.world.internalError('can not be a constructor', this.get$span()); 4706 $globals.world.internalError('can not be a constructor', this.get$span());
4697 } 4707 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4842 FieldMember.prototype.get$definition = function() { return this.definition; }; 4852 FieldMember.prototype.get$definition = function() { return this.definition; };
4843 FieldMember.prototype.get$value = function() { return this.value; }; 4853 FieldMember.prototype.get$value = function() { return this.value; };
4844 FieldMember.prototype.get$type = function() { return this.type; }; 4854 FieldMember.prototype.get$type = function() { return this.type; };
4845 FieldMember.prototype.set$type = function(value) { return this.type = value; }; 4855 FieldMember.prototype.set$type = function(value) { return this.type = value; };
4846 FieldMember.prototype.get$isStatic = function() { return this.isStatic; }; 4856 FieldMember.prototype.get$isStatic = function() { return this.isStatic; };
4847 FieldMember.prototype.set$isStatic = function(value) { return this.isStatic = va lue; }; 4857 FieldMember.prototype.set$isStatic = function(value) { return this.isStatic = va lue; };
4848 FieldMember.prototype.get$isFinal = function() { return this.isFinal; }; 4858 FieldMember.prototype.get$isFinal = function() { return this.isFinal; };
4849 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu e; }; 4859 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu e; };
4850 FieldMember.prototype.get$isNative = function() { return this.isNative; }; 4860 FieldMember.prototype.get$isNative = function() { return this.isNative; };
4851 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va lue; }; 4861 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va lue; };
4862 FieldMember.prototype.get$_providePropertySyntax = function() { return this._pro videPropertySyntax; };
4863 FieldMember.prototype.set$_providePropertySyntax = function(value) { return this ._providePropertySyntax = value; };
4852 FieldMember.prototype.override = function(other) { 4864 FieldMember.prototype.override = function(other) {
4853 if (!Member.prototype.override.call(this, other)) return false; 4865 if (!Member.prototype.override.call(this, other)) return false;
4854 if (other.get$isProperty()) { 4866 if (other.get$isProperty()) {
4855 return true; 4867 return true;
4856 } 4868 }
4857 else { 4869 else {
4858 $globals.world.error('field can not override anything but property', this.ge t$span(), other.get$span()); 4870 $globals.world.error('field can not override anything but property', this.ge t$span(), other.get$span());
4859 return false; 4871 return false;
4860 } 4872 }
4861 } 4873 }
4862 FieldMember.prototype.get$prefersPropertySyntax = function() {
4863 return false;
4864 }
4865 FieldMember.prototype.get$requiresFieldSyntax = function() {
4866 return this.isNative;
4867 }
4868 FieldMember.prototype.provideFieldSyntax = function() { 4874 FieldMember.prototype.provideFieldSyntax = function() {
4869 4875
4870 } 4876 }
4871 FieldMember.prototype.providePropertySyntax = function() { 4877 FieldMember.prototype.providePropertySyntax = function() {
4872 this._providePropertySyntax = true; 4878 this._providePropertySyntax = true;
4873 } 4879 }
4874 FieldMember.prototype.get$span = function() { 4880 FieldMember.prototype.get$span = function() {
4875 return this.definition == null ? null : this.definition.span; 4881 return this.definition == null ? null : this.definition.span;
4876 } 4882 }
4877 FieldMember.prototype.get$returnType = function() { 4883 FieldMember.prototype.get$returnType = function() {
4878 return this.type; 4884 return this.type;
4879 } 4885 }
4880 FieldMember.prototype.get$canGet = function() { 4886 FieldMember.prototype.get$canGet = function() {
4881 return true; 4887 return true;
4882 } 4888 }
4883 FieldMember.prototype.get$canSet = function() { 4889 FieldMember.prototype.get$canSet = function() {
4884 return !this.isFinal; 4890 return !this.isFinal;
4885 } 4891 }
4886 FieldMember.prototype.get$isField = function() { 4892 FieldMember.prototype.get$isField = function() {
4887 return true; 4893 return true;
4888 } 4894 }
4889 FieldMember.prototype.resolve = function() { 4895 FieldMember.prototype.resolve = function() {
4890 this.isStatic = this.declaringType.get$isTop(); 4896 this.isStatic = this.declaringType.get$isTop();
4891 this.isFinal = false; 4897 this.isFinal = false;
4892 if (this.definition.modifiers != null) { 4898 if (this.definition.modifiers != null) {
4893 var $$list = this.definition.modifiers; 4899 var $$list = this.definition.modifiers;
4894 for (var $$i = 0;$$i < $$list.length; $$i++) { 4900 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4895 var mod = $$list.$index($$i); 4901 var mod = $$list.$index($$i);
4896 if ($eq(mod.get$kind(), 86/*TokenKind.STATIC*/)) { 4902 if ($eq(mod.get$kind(), 86/*TokenKind.STATIC*/)) {
4897 if (this.isStatic) { 4903 if (this.isStatic) {
4898 $globals.world.error('duplicate static modifier', mod.get$span()); 4904 $globals.world.error('duplicate static modifier', mod.get$span());
4899 } 4905 }
4900 this.isStatic = true; 4906 this.isStatic = true;
4901 } 4907 }
4902 else if ($eq(mod.get$kind(), 98/*TokenKind.FINAL*/)) { 4908 else if ($eq(mod.get$kind(), 98/*TokenKind.FINAL*/)) {
4903 if (this.isFinal) { 4909 if (this.isFinal) {
4904 $globals.world.error('duplicate final modifier', mod.get$span()); 4910 $globals.world.error('duplicate final modifier', mod.get$span());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4980 else { 4986 else {
4981 return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname( ) + '_' + this.get$jsname()), node.span, true); 4987 return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname( ) + '_' + this.get$jsname()), node.span, true);
4982 } 4988 }
4983 } 4989 }
4984 else if (target.get$isConst() && this.isFinal) { 4990 else if (target.get$isConst() && this.isFinal) {
4985 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get $exp() : target; 4991 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get $exp() : target;
4986 if ((constTarget instanceof ConstObjectValue)) { 4992 if ((constTarget instanceof ConstObjectValue)) {
4987 return constTarget.get$fields().$index(this.name); 4993 return constTarget.get$fields().$index(this.name);
4988 } 4994 }
4989 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name == 'length') { 4995 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name == 'length') {
4990 return new Value(this.type, ('' + constTarget.get$actualValue().length), n ode.span, true); 4996 return new Value(this.type, ('' + constTarget.get$actualValue().get$length ()), node.span, true);
4991 } 4997 }
4992 } 4998 }
4993 return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node .span, true); 4999 return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node .span, true);
4994 } 5000 }
4995 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { 5001 FieldMember.prototype._set = function(context, node, target, value, isDynamic) {
4996 var lhs = this._get(context, node, target, isDynamic); 5002 var lhs = this._get(context, node, target, isDynamic);
4997 value = value.convertTo(context, this.type, node, isDynamic); 5003 value = value.convertTo(context, this.type, node, isDynamic);
4998 return new Value(this.type, ('' + lhs.get$code() + ' = ' + value.code), node.s pan, true); 5004 return new Value(this.type, ('' + lhs.get$code() + ' = ' + value.code), node.s pan, true);
4999 } 5005 }
5000 FieldMember.prototype._get$3 = function($0, $1, $2) { 5006 FieldMember.prototype._get$3 = function($0, $1, $2) {
(...skipping 14 matching lines...) Expand all
5015 $inherits(PropertyMember, Member); 5021 $inherits(PropertyMember, Member);
5016 function PropertyMember(name, declaringType) { 5022 function PropertyMember(name, declaringType) {
5017 this._provideFieldSyntax = false 5023 this._provideFieldSyntax = false
5018 // Initializers done 5024 // Initializers done
5019 Member.call(this, name, declaringType); 5025 Member.call(this, name, declaringType);
5020 } 5026 }
5021 PropertyMember.prototype.get$getter = function() { return this.getter; }; 5027 PropertyMember.prototype.get$getter = function() { return this.getter; };
5022 PropertyMember.prototype.set$getter = function(value) { return this.getter = val ue; }; 5028 PropertyMember.prototype.set$getter = function(value) { return this.getter = val ue; };
5023 PropertyMember.prototype.get$setter = function() { return this.setter; }; 5029 PropertyMember.prototype.get$setter = function() { return this.setter; };
5024 PropertyMember.prototype.set$setter = function(value) { return this.setter = val ue; }; 5030 PropertyMember.prototype.set$setter = function(value) { return this.setter = val ue; };
5031 PropertyMember.prototype.get$_provideFieldSyntax = function() { return this._pro videFieldSyntax; };
5032 PropertyMember.prototype.set$_provideFieldSyntax = function(value) { return this ._provideFieldSyntax = value; };
5025 PropertyMember.prototype.get$span = function() { 5033 PropertyMember.prototype.get$span = function() {
5026 return this.getter != null ? this.getter.get$span() : null; 5034 return this.getter != null ? this.getter.get$span() : null;
5027 } 5035 }
5028 PropertyMember.prototype.get$canGet = function() { 5036 PropertyMember.prototype.get$canGet = function() {
5029 return this.getter != null; 5037 return this.getter != null;
5030 } 5038 }
5031 PropertyMember.prototype.get$canSet = function() { 5039 PropertyMember.prototype.get$canSet = function() {
5032 return this.setter != null; 5040 return this.setter != null;
5033 } 5041 }
5034 PropertyMember.prototype.get$prefersPropertySyntax = function() { 5042 PropertyMember.prototype.get$requiresPropertySyntax = function() {
5035 return true; 5043 return this.declaringType.get$isClass();
5036 }
5037 PropertyMember.prototype.get$requiresFieldSyntax = function() {
5038 return false;
5039 } 5044 }
5040 PropertyMember.prototype.provideFieldSyntax = function() { 5045 PropertyMember.prototype.provideFieldSyntax = function() {
5041 this._provideFieldSyntax = true; 5046 this._provideFieldSyntax = true;
5042 } 5047 }
5043 PropertyMember.prototype.providePropertySyntax = function() { 5048 PropertyMember.prototype.providePropertySyntax = function() {
5044 5049 if (this._overriddenField != null && this._overriddenField.get$isNative()) {
5050 this.provideFieldSyntax();
5051 }
5045 } 5052 }
5046 PropertyMember.prototype.get$isStatic = function() { 5053 PropertyMember.prototype.get$isStatic = function() {
5047 return this.getter == null ? this.setter.isStatic : this.getter.isStatic; 5054 return this.getter == null ? this.setter.isStatic : this.getter.isStatic;
5048 } 5055 }
5049 PropertyMember.prototype.get$isProperty = function() { 5056 PropertyMember.prototype.get$isProperty = function() {
5050 return true; 5057 return true;
5051 } 5058 }
5052 PropertyMember.prototype.get$returnType = function() { 5059 PropertyMember.prototype.get$returnType = function() {
5053 return this.getter == null ? this.setter.returnType : this.getter.returnType; 5060 return this.getter == null ? this.setter.returnType : this.getter.returnType;
5054 } 5061 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5090 } 5097 }
5091 else { 5098 else {
5092 parent = parentMember; 5099 parent = parentMember;
5093 } 5100 }
5094 if (this.getter == null) this.getter = parent.getter; 5101 if (this.getter == null) this.getter = parent.getter;
5095 if (this.setter == null) this.setter = parent.setter; 5102 if (this.setter == null) this.setter = parent.setter;
5096 } 5103 }
5097 PropertyMember.prototype.resolve = function() { 5104 PropertyMember.prototype.resolve = function() {
5098 if (this.getter != null) { 5105 if (this.getter != null) {
5099 this.getter.resolve(); 5106 this.getter.resolve();
5100 if (this.getter.parameters.length != 0) { 5107 if (this.getter.parameters.get$length() != 0) {
5101 $globals.world.error('getter methods should take no arguments', this.gette r.definition.span); 5108 $globals.world.error('getter methods should take no arguments', this.gette r.definition.span);
5102 } 5109 }
5103 if (this.getter.returnType.get$isVoid()) { 5110 if (this.getter.returnType.get$isVoid()) {
5104 $globals.world.warning('getter methods should not be void', this.getter.de finition.returnType.span); 5111 $globals.world.warning('getter methods should not be void', this.getter.de finition.returnType.span);
5105 } 5112 }
5106 } 5113 }
5107 if (this.setter != null) { 5114 if (this.setter != null) {
5108 this.setter.resolve(); 5115 this.setter.resolve();
5109 if (this.setter.parameters.length != 1) { 5116 if (this.setter.parameters.get$length() != 1) {
5110 $globals.world.error('setter methods should take a single argument', this. setter.definition.span); 5117 $globals.world.error('setter methods should take a single argument', this. setter.definition.span);
5111 } 5118 }
5112 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) { 5119 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) {
5113 $globals.world.warning('setter methods should be void', this.setter.defini tion.returnType.span); 5120 $globals.world.warning('setter methods should be void', this.setter.defini tion.returnType.span);
5114 } 5121 }
5115 } 5122 }
5116 this.get$library()._addMember(this); 5123 this.get$library()._addMember(this);
5117 } 5124 }
5118 PropertyMember.prototype._get$3 = function($0, $1, $2) { 5125 PropertyMember.prototype._get$3 = function($0, $1, $2) {
5119 return this._get($0, $1, $2, false); 5126 return this._get($0, $1, $2, false);
(...skipping 10 matching lines...) Expand all
5130 PropertyMember.prototype.resolve$0 = PropertyMember.prototype.resolve; 5137 PropertyMember.prototype.resolve$0 = PropertyMember.prototype.resolve;
5131 // ********** Code for ConcreteMember ************** 5138 // ********** Code for ConcreteMember **************
5132 $inherits(ConcreteMember, Member); 5139 $inherits(ConcreteMember, Member);
5133 function ConcreteMember(name, declaringType, baseMember) { 5140 function ConcreteMember(name, declaringType, baseMember) {
5134 this.baseMember = baseMember; 5141 this.baseMember = baseMember;
5135 // Initializers done 5142 // Initializers done
5136 Member.call(this, name, declaringType); 5143 Member.call(this, name, declaringType);
5137 this.parameters = []; 5144 this.parameters = [];
5138 this.returnType = this.baseMember.get$returnType().resolveTypeParams(declaring Type); 5145 this.returnType = this.baseMember.get$returnType().resolveTypeParams(declaring Type);
5139 var $$list = this.baseMember.get$parameters(); 5146 var $$list = this.baseMember.get$parameters();
5140 for (var $$i = 0;$$i < $$list.length; $$i++) { 5147 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5141 var p = $$list.$index($$i); 5148 var p = $$list.$index($$i);
5142 var newType = p.get$type().resolveTypeParams$1(declaringType); 5149 var newType = p.get$type().resolveTypeParams$1(declaringType);
5143 if ($ne(newType, p.get$type())) { 5150 if ($ne(newType, p.get$type())) {
5144 this.parameters.add(p.copyWithNewType$2(this, newType)); 5151 this.parameters.add(p.copyWithNewType$2(this, newType));
5145 } 5152 }
5146 else { 5153 else {
5147 this.parameters.add(p); 5154 this.parameters.add(p);
5148 } 5155 }
5149 } 5156 }
5150 } 5157 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5187 } 5194 }
5188 ConcreteMember.prototype.get$isField = function() { 5195 ConcreteMember.prototype.get$isField = function() {
5189 return this.baseMember.get$isField(); 5196 return this.baseMember.get$isField();
5190 } 5197 }
5191 ConcreteMember.prototype.get$isMethod = function() { 5198 ConcreteMember.prototype.get$isMethod = function() {
5192 return this.baseMember.get$isMethod(); 5199 return this.baseMember.get$isMethod();
5193 } 5200 }
5194 ConcreteMember.prototype.get$isProperty = function() { 5201 ConcreteMember.prototype.get$isProperty = function() {
5195 return this.baseMember.get$isProperty(); 5202 return this.baseMember.get$isProperty();
5196 } 5203 }
5197 ConcreteMember.prototype.get$prefersPropertySyntax = function() { 5204 ConcreteMember.prototype.get$requiresPropertySyntax = function() {
5198 return this.baseMember.get$prefersPropertySyntax(); 5205 return this.baseMember.get$requiresPropertySyntax();
5199 } 5206 }
5200 ConcreteMember.prototype.get$requiresFieldSyntax = function() { 5207 ConcreteMember.prototype.get$requiresFieldSyntax = function() {
5201 return this.baseMember.get$requiresFieldSyntax(); 5208 return this.baseMember.get$requiresFieldSyntax();
5202 } 5209 }
5203 ConcreteMember.prototype.provideFieldSyntax = function() { 5210 ConcreteMember.prototype.provideFieldSyntax = function() {
5204 return this.baseMember.provideFieldSyntax(); 5211 return this.baseMember.provideFieldSyntax();
5205 } 5212 }
5206 ConcreteMember.prototype.providePropertySyntax = function() { 5213 ConcreteMember.prototype.providePropertySyntax = function() {
5207 return this.baseMember.providePropertySyntax(); 5214 return this.baseMember.providePropertySyntax();
5208 } 5215 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
5295 MethodMember.prototype.get$isStatic = function() { return this.isStatic; }; 5302 MethodMember.prototype.get$isStatic = function() { return this.isStatic; };
5296 MethodMember.prototype.set$isStatic = function(value) { return this.isStatic = v alue; }; 5303 MethodMember.prototype.set$isStatic = function(value) { return this.isStatic = v alue; };
5297 MethodMember.prototype.get$isAbstract = function() { return this.isAbstract; }; 5304 MethodMember.prototype.get$isAbstract = function() { return this.isAbstract; };
5298 MethodMember.prototype.set$isAbstract = function(value) { return this.isAbstract = value; }; 5305 MethodMember.prototype.set$isAbstract = function(value) { return this.isAbstract = value; };
5299 MethodMember.prototype.get$isConst = function() { return this.isConst; }; 5306 MethodMember.prototype.get$isConst = function() { return this.isConst; };
5300 MethodMember.prototype.set$isConst = function(value) { return this.isConst = val ue; }; 5307 MethodMember.prototype.set$isConst = function(value) { return this.isConst = val ue; };
5301 MethodMember.prototype.get$isFactory = function() { return this.isFactory; }; 5308 MethodMember.prototype.get$isFactory = function() { return this.isFactory; };
5302 MethodMember.prototype.set$isFactory = function(value) { return this.isFactory = value; }; 5309 MethodMember.prototype.set$isFactory = function(value) { return this.isFactory = value; };
5303 MethodMember.prototype.get$isLambda = function() { return this.isLambda; }; 5310 MethodMember.prototype.get$isLambda = function() { return this.isLambda; };
5304 MethodMember.prototype.set$isLambda = function(value) { return this.isLambda = v alue; }; 5311 MethodMember.prototype.set$isLambda = function(value) { return this.isLambda = v alue; };
5312 MethodMember.prototype.get$_providePropertySyntax = function() { return this._pr ovidePropertySyntax; };
5313 MethodMember.prototype.set$_providePropertySyntax = function(value) { return thi s._providePropertySyntax = value; };
5314 MethodMember.prototype.get$_provideFieldSyntax = function() { return this._provi deFieldSyntax; };
5315 MethodMember.prototype.set$_provideFieldSyntax = function(value) { return this._ provideFieldSyntax = value; };
5305 MethodMember.prototype.get$initDelegate = function() { return this.initDelegate; }; 5316 MethodMember.prototype.get$initDelegate = function() { return this.initDelegate; };
5306 MethodMember.prototype.set$initDelegate = function(value) { return this.initDele gate = value; }; 5317 MethodMember.prototype.set$initDelegate = function(value) { return this.initDele gate = value; };
5307 MethodMember.prototype.get$isConstructor = function() { 5318 MethodMember.prototype.get$isConstructor = function() {
5308 return this.name == this.declaringType.name; 5319 return this.name == this.declaringType.name;
5309 } 5320 }
5310 MethodMember.prototype.get$isMethod = function() { 5321 MethodMember.prototype.get$isMethod = function() {
5311 return !this.get$isConstructor(); 5322 return !this.get$isConstructor();
5312 } 5323 }
5313 MethodMember.prototype.get$isNative = function() { 5324 MethodMember.prototype.get$isNative = function() {
5314 return this.definition.nativeBody != null; 5325 return this.definition.nativeBody != null;
5315 } 5326 }
5316 MethodMember.prototype.get$canGet = function() { 5327 MethodMember.prototype.get$canGet = function() {
5317 return false; 5328 return true;
5318 } 5329 }
5319 MethodMember.prototype.get$canSet = function() { 5330 MethodMember.prototype.get$canSet = function() {
5320 return false; 5331 return false;
5321 } 5332 }
5333 MethodMember.prototype.get$requiresPropertySyntax = function() {
5334 return true;
5335 }
5322 MethodMember.prototype.get$span = function() { 5336 MethodMember.prototype.get$span = function() {
5323 return this.definition == null ? null : this.definition.span; 5337 return this.definition == null ? null : this.definition.span;
5324 } 5338 }
5325 MethodMember.prototype.get$constructorName = function() { 5339 MethodMember.prototype.get$constructorName = function() {
5326 var returnType = this.definition.returnType; 5340 var returnType = this.definition.returnType;
5327 if (returnType == null) return ''; 5341 if (returnType == null) return '';
5328 if ((returnType instanceof GenericTypeReference)) { 5342 if ((returnType instanceof GenericTypeReference)) {
5329 return ''; 5343 return '';
5330 } 5344 }
5331 if (returnType.get$names() != null) { 5345 if (returnType.get$names() != null) {
(...skipping 18 matching lines...) Expand all
5350 if (other.get$isMethod()) { 5364 if (other.get$isMethod()) {
5351 return true; 5365 return true;
5352 } 5366 }
5353 else { 5367 else {
5354 $globals.world.error('method can only override methods', this.get$span(), ot her.get$span()); 5368 $globals.world.error('method can only override methods', this.get$span(), ot her.get$span());
5355 return false; 5369 return false;
5356 } 5370 }
5357 } 5371 }
5358 MethodMember.prototype.canInvoke = function(context, args) { 5372 MethodMember.prototype.canInvoke = function(context, args) {
5359 var bareCount = args.get$bareCount(); 5373 var bareCount = args.get$bareCount();
5360 if (bareCount > this.parameters.length) return false; 5374 if (bareCount > this.parameters.get$length()) return false;
5361 if (bareCount == this.parameters.length) { 5375 if (bareCount == this.parameters.get$length()) {
5362 if (bareCount != args.get$length()) return false; 5376 if (bareCount != args.get$length()) return false;
5363 } 5377 }
5364 else { 5378 else {
5365 if (!this.parameters.$index(bareCount).get$isOptional()) return false; 5379 if (!this.parameters.$index(bareCount).get$isOptional()) return false;
5366 for (var i = bareCount; 5380 for (var i = bareCount;
5367 i < args.get$length(); i++) { 5381 i < args.get$length(); i++) {
5368 if (this.indexOfParameter(args.getName(i)) < 0) { 5382 if (this.indexOfParameter(args.getName(i)) < 0) {
5369 return false; 5383 return false;
5370 } 5384 }
5371 } 5385 }
5372 } 5386 }
5373 return true; 5387 return true;
5374 } 5388 }
5375 MethodMember.prototype.indexOfParameter = function(name) { 5389 MethodMember.prototype.indexOfParameter = function(name) {
5376 for (var i = 0; 5390 for (var i = 0;
5377 i < this.parameters.length; i++) { 5391 i < this.parameters.get$length(); i++) {
5378 var p = this.parameters.$index(i); 5392 var p = this.parameters.$index(i);
5379 if (p.get$isOptional() && $eq(p.get$name(), name)) { 5393 if (p.get$isOptional() && $eq(p.get$name(), name)) {
5380 return i; 5394 return i;
5381 } 5395 }
5382 } 5396 }
5383 return -1; 5397 return -1;
5384 } 5398 }
5385 MethodMember.prototype.get$prefersPropertySyntax = function() {
5386 return true;
5387 }
5388 MethodMember.prototype.get$requiresFieldSyntax = function() {
5389 return false;
5390 }
5391 MethodMember.prototype.provideFieldSyntax = function() { 5399 MethodMember.prototype.provideFieldSyntax = function() {
5392 this._provideFieldSyntax = true; 5400 this._provideFieldSyntax = true;
5393 } 5401 }
5394 MethodMember.prototype.providePropertySyntax = function() { 5402 MethodMember.prototype.providePropertySyntax = function() {
5395 this._providePropertySyntax = true; 5403 this._providePropertySyntax = true;
5396 } 5404 }
5397 MethodMember.prototype._set = function(context, node, target, value, isDynamic) { 5405 MethodMember.prototype._set = function(context, node, target, value, isDynamic) {
5398 $globals.world.error('cannot set method', node.span); 5406 $globals.world.error('cannot set method', node.span);
5399 } 5407 }
5400 MethodMember.prototype._get = function(context, node, target, isDynamic) { 5408 MethodMember.prototype._get = function(context, node, target, isDynamic) {
5401 this.declaringType.genMethod(this); 5409 this.declaringType.genMethod(this);
5402 this._provideOptionalParamInfo = true; 5410 this._provideOptionalParamInfo = true;
5403 if (this.isStatic) { 5411 if (this.isStatic) {
5404 this.declaringType.markUsed(); 5412 this.declaringType.markUsed();
5405 var type = this.declaringType.get$isTop() ? '' : ('' + this.declaringType.ge t$jsname() + '.'); 5413 var type = this.declaringType.get$isTop() ? '' : ('' + this.declaringType.ge t$jsname() + '.');
5406 return new Value(this.get$functionType(), ('' + type + this.get$jsname()), n ode.span, true); 5414 return new Value(this.get$functionType(), ('' + type + this.get$jsname()), n ode.span, true);
5407 } 5415 }
5408 this._providePropertySyntax = true; 5416 this._providePropertySyntax = true;
5409 return new Value(this.get$functionType(), ('' + target.code + '.get\$' + this. get$jsname() + '()'), node.span, true); 5417 return new Value(this.get$functionType(), ('' + target.code + '.get\$' + this. get$jsname() + '()'), node.span, true);
5410 } 5418 }
5411 MethodMember.prototype.namesInOrder = function(args) { 5419 MethodMember.prototype.namesInOrder = function(args) {
5412 if (!args.get$hasNames()) return true; 5420 if (!args.get$hasNames()) return true;
5413 var lastParameter = null; 5421 var lastParameter = null;
5414 for (var i = args.get$bareCount(); 5422 for (var i = args.get$bareCount();
5415 i < this.parameters.length; i++) { 5423 i < this.parameters.get$length(); i++) {
5416 var p = args.getIndexOfName(this.parameters.$index(i).get$name()); 5424 var p = args.getIndexOfName(this.parameters.$index(i).get$name());
5417 if (p >= 0 && args.values.$index(p).get$needsTemp()) { 5425 if (p >= 0 && args.values.$index(p).get$needsTemp()) {
5418 if (lastParameter != null && lastParameter > p) { 5426 if (lastParameter != null && lastParameter > p) {
5419 return false; 5427 return false;
5420 } 5428 }
5421 lastParameter = p; 5429 lastParameter = p;
5422 } 5430 }
5423 } 5431 }
5424 return true; 5432 return true;
5425 } 5433 }
5426 MethodMember.prototype.needsArgumentConversion = function(args) { 5434 MethodMember.prototype.needsArgumentConversion = function(args) {
5427 var bareCount = args.get$bareCount(); 5435 var bareCount = args.get$bareCount();
5428 for (var i = 0; 5436 for (var i = 0;
5429 i < bareCount; i++) { 5437 i < bareCount; i++) {
5430 var arg = args.values.$index(i); 5438 var arg = args.values.$index(i);
5431 if (arg.needsConversion$1(this.parameters.$index(i).get$type())) { 5439 if (arg.needsConversion$1(this.parameters.$index(i).get$type())) {
5432 return true; 5440 return true;
5433 } 5441 }
5434 } 5442 }
5435 if (bareCount < this.parameters.length) { 5443 if (bareCount < this.parameters.get$length()) {
5436 this.genParameterValues(); 5444 this.genParameterValues();
5437 for (var i = bareCount; 5445 for (var i = bareCount;
5438 i < this.parameters.length; i++) { 5446 i < this.parameters.get$length(); i++) {
5439 var arg = args.getValue(this.parameters.$index(i).get$name()); 5447 var arg = args.getValue(this.parameters.$index(i).get$name());
5440 if (arg != null && arg.needsConversion$1(this.parameters.$index(i).get$typ e())) { 5448 if (arg != null && arg.needsConversion$1(this.parameters.$index(i).get$typ e())) {
5441 return true; 5449 return true;
5442 } 5450 }
5443 } 5451 }
5444 } 5452 }
5445 return false; 5453 return false;
5446 } 5454 }
5447 MethodMember._argCountMsg = function(actual, expected, atLeast) { 5455 MethodMember._argCountMsg = function(actual, expected, atLeast) {
5448 return 'wrong number of positional arguments, expected ' + ('' + (atLeast ? "a t least " : "") + expected + ' but found ' + actual); 5456 return 'wrong number of positional arguments, expected ' + ('' + (atLeast ? "a t least " : "") + expected + ' but found ' + actual);
5449 } 5457 }
5450 MethodMember.prototype._argError = function(context, node, target, args, msg, sp an) { 5458 MethodMember.prototype._argError = function(context, node, target, args, msg, sp an) {
5451 if (this.isStatic || this.get$isConstructor()) { 5459 if (this.isStatic || this.get$isConstructor()) {
5452 $globals.world.error(msg, span); 5460 $globals.world.error(msg, span);
5453 } 5461 }
5454 else { 5462 else {
5455 $globals.world.warning(msg, span); 5463 $globals.world.warning(msg, span);
5456 } 5464 }
5457 return target.invokeNoSuchMethod(context, this.name, node, args); 5465 return target.invokeNoSuchMethod(context, this.name, node, args);
5458 } 5466 }
5459 MethodMember.prototype.genParameterValues = function() { 5467 MethodMember.prototype.genParameterValues = function() {
5460 var $$list = this.parameters; 5468 var $$list = this.parameters;
5461 for (var $$i = 0;$$i < $$list.length; $$i++) { 5469 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5462 var p = $$list.$index($$i); 5470 var p = $$list.$index($$i);
5463 p.genValue$2(this, this.generator); 5471 p.genValue$2(this, this.generator);
5464 } 5472 }
5465 } 5473 }
5466 MethodMember.prototype.invoke = function(context, node, target, args, isDynamic) { 5474 MethodMember.prototype.invoke = function(context, node, target, args, isDynamic) {
5467 if (this.parameters == null) { 5475 if (this.parameters == null) {
5468 $globals.world.info(('surprised to need to resolve: ' + this.declaringType.n ame + '.' + this.name)); 5476 $globals.world.info(('surprised to need to resolve: ' + this.declaringType.n ame + '.' + this.name));
5469 this.resolve(); 5477 this.resolve();
5470 } 5478 }
5471 this.declaringType.genMethod(this); 5479 this.declaringType.genMethod(this);
5472 if (this.isStatic || this.isFactory) { 5480 if (this.isStatic || this.isFactory) {
5473 this.declaringType.markUsed(); 5481 this.declaringType.markUsed();
5474 } 5482 }
5475 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ; 5483 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ;
5476 if (!this.namesInOrder(args)) { 5484 if (!this.namesInOrder(args)) {
5477 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s); 5485 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s);
5478 } 5486 }
5479 var argsCode = []; 5487 var argsCode = [];
5480 if (!target.isType && (this.get$isConstructor() || target.isSuper)) { 5488 if (!target.isType && (this.get$isConstructor() || target.isSuper)) {
5481 argsCode.add$1('this'); 5489 argsCode.add$1('this');
5482 } 5490 }
5483 var bareCount = args.get$bareCount(); 5491 var bareCount = args.get$bareCount();
5484 for (var i = 0; 5492 for (var i = 0;
5485 i < bareCount; i++) { 5493 i < bareCount; i++) {
5486 var arg = args.values.$index(i); 5494 var arg = args.values.$index(i);
5487 if (i >= this.parameters.length) { 5495 if (i >= this.parameters.get$length()) {
5488 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.len gth, false); 5496 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get $length(), false);
5489 return this._argError(context, node, target, args, msg, args.nodes.$index( i).get$span()); 5497 return this._argError(context, node, target, args, msg, args.nodes.$index( i).get$span());
5490 } 5498 }
5491 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), node, i sDynamic); 5499 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), node, i sDynamic);
5492 if (this.isConst && arg.get$isConst()) { 5500 if (this.isConst && arg.get$isConst()) {
5493 argsCode.add$1(arg.get$canonicalCode()); 5501 argsCode.add$1(arg.get$canonicalCode());
5494 } 5502 }
5495 else { 5503 else {
5496 argsCode.add$1(arg.get$code()); 5504 argsCode.add$1(arg.get$code());
5497 } 5505 }
5498 } 5506 }
5499 var namedArgsUsed = 0; 5507 var namedArgsUsed = 0;
5500 if (bareCount < this.parameters.length) { 5508 if (bareCount < this.parameters.get$length()) {
5501 this.genParameterValues(); 5509 this.genParameterValues();
5502 for (var i = bareCount; 5510 for (var i = bareCount;
5503 i < this.parameters.length; i++) { 5511 i < this.parameters.get$length(); i++) {
5504 var arg = args.getValue(this.parameters.$index(i).get$name()); 5512 var arg = args.getValue(this.parameters.$index(i).get$name());
5505 if (arg == null) { 5513 if (arg == null) {
5506 arg = this.parameters.$index(i).get$value(); 5514 arg = this.parameters.$index(i).get$value();
5507 } 5515 }
5508 else { 5516 else {
5509 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), nod e, isDynamic); 5517 arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), nod e, isDynamic);
5510 namedArgsUsed++; 5518 namedArgsUsed++;
5511 } 5519 }
5512 if (arg == null || !this.parameters.$index(i).get$isOptional()) { 5520 if (arg == null || !this.parameters.$index(i).get$isOptional()) {
5513 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + 1, true); 5521 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + 1, true);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5557 } 5565 }
5558 return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsn ame() + '.' + this.get$jsname() + '(' + argsString + ')'), node.span, true); 5566 return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsn ame() + '.' + this.get$jsname() + '(' + argsString + ')'), node.span, true);
5559 } 5567 }
5560 var code = ('' + target.code + '.' + this.get$jsname() + '(' + argsString + ') '); 5568 var code = ('' + target.code + '.' + this.get$jsname() + '(' + argsString + ') ');
5561 if (target.get$isConst()) { 5569 if (target.get$isConst()) {
5562 if ((target instanceof GlobalValue)) { 5570 if ((target instanceof GlobalValue)) {
5563 target = target.get$dynamic().get$exp(); 5571 target = target.get$dynamic().get$exp();
5564 } 5572 }
5565 if (this.name == 'get:length') { 5573 if (this.name == 'get:length') {
5566 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) { 5574 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5567 code = ('' + target.get$dynamic().get$values().length); 5575 code = ('' + target.get$dynamic().get$values().get$length());
5568 } 5576 }
5569 } 5577 }
5570 else if (this.name == 'isEmpty') { 5578 else if (this.name == 'isEmpty') {
5571 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) { 5579 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5572 code = ('' + target.get$dynamic().get$values().isEmpty$0()); 5580 code = ('' + target.get$dynamic().get$values().isEmpty$0());
5573 } 5581 }
5574 } 5582 }
5575 } 5583 }
5576 if (this.name == 'get:typeName' && $eq(this.declaringType.get$library(), $glob als.world.get$dom())) { 5584 if (this.name == 'get:typeName' && $eq(this.declaringType.get$library(), $glob als.world.get$dom())) {
5577 $globals.world.gen.corejs.ensureTypeNameOf(); 5585 $globals.world.gen.corejs.ensureTypeNameOf();
(...skipping 12 matching lines...) Expand all
5590 return this._invokeConstConstructor(node, code, target, args); 5598 return this._invokeConstConstructor(node, code, target, args);
5591 } 5599 }
5592 else { 5600 else {
5593 return new Value(target.get$type(), code, node.span, true); 5601 return new Value(target.get$type(), code, node.span, true);
5594 } 5602 }
5595 } 5603 }
5596 } 5604 }
5597 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) { 5605 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) {
5598 var fields = new HashMapImplementation(); 5606 var fields = new HashMapImplementation();
5599 for (var i = 0; 5607 for (var i = 0;
5600 i < this.parameters.length; i++) { 5608 i < this.parameters.get$length(); i++) {
5601 var param = this.parameters.$index(i); 5609 var param = this.parameters.$index(i);
5602 if (param.get$isInitializer()) { 5610 if (param.get$isInitializer()) {
5603 var value = null; 5611 var value = null;
5604 if (i < args.get$length()) { 5612 if (i < args.get$length()) {
5605 value = args.values.$index(i); 5613 value = args.values.$index(i);
5606 } 5614 }
5607 else { 5615 else {
5608 value = args.getValue(param.get$name()); 5616 value = args.getValue(param.get$name());
5609 if (value == null) { 5617 if (value == null) {
5610 value = param.get$value(); 5618 value = param.get$value();
5611 } 5619 }
5612 } 5620 }
5613 fields.$setindex(param.get$name(), value); 5621 fields.$setindex(param.get$name(), value);
5614 } 5622 }
5615 } 5623 }
5616 if (this.definition.initializers != null) { 5624 if (this.definition.initializers != null) {
5617 this.generator._pushBlock(false); 5625 this.generator._pushBlock(false);
5618 for (var j = 0; 5626 for (var j = 0;
5619 j < this.definition.formals.length; j++) { 5627 j < this.definition.formals.get$length(); j++) {
5620 var name = this.definition.formals.$index(j).get$name().get$name(); 5628 var name = this.definition.formals.$index(j).get$name().get$name();
5621 var value = null; 5629 var value = null;
5622 if (j < args.get$length()) { 5630 if (j < args.get$length()) {
5623 value = args.values.$index(j); 5631 value = args.values.$index(j);
5624 } 5632 }
5625 else { 5633 else {
5626 value = args.getValue(this.parameters.$index(j).get$name()); 5634 value = args.getValue(this.parameters.$index(j).get$name());
5627 if (value == null) { 5635 if (value == null) {
5628 value = this.parameters.$index(j).get$value(); 5636 value = this.parameters.$index(j).get$value();
5629 } 5637 }
5630 } 5638 }
5631 this.generator._scope._vars.$setindex(name, value); 5639 this.generator._scope._vars.$setindex(name, value);
5632 } 5640 }
5633 var $$list = this.definition.initializers; 5641 var $$list = this.definition.initializers;
5634 for (var $$i = 0;$$i < $$list.length; $$i++) { 5642 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5635 var init = $$list.$index($$i); 5643 var init = $$list.$index($$i);
5636 if ((init instanceof CallExpression)) { 5644 if ((init instanceof CallExpression)) {
5637 var delegateArgs = this.generator._makeArgs(init.get$arguments()); 5645 var delegateArgs = this.generator._makeArgs(init.get$arguments());
5638 var value = this.initDelegate.invoke(this.generator, node, target, deleg ateArgs, false); 5646 var value = this.initDelegate.invoke(this.generator, node, target, deleg ateArgs, false);
5639 if ((init.get$target() instanceof ThisExpression)) { 5647 if ((init.get$target() instanceof ThisExpression)) {
5640 return value; 5648 return value;
5641 } 5649 }
5642 else { 5650 else {
5643 if ((value instanceof GlobalValue)) { 5651 if ((value instanceof GlobalValue)) {
5644 value = value.get$exp(); 5652 value = value.get$exp();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5699 var op = TokenKind.rawOperatorFromMethod(this.name); 5707 var op = TokenKind.rawOperatorFromMethod(this.name);
5700 code = ('' + target.code + ' ' + op + ' ' + argsCode.$index(0)); 5708 code = ('' + target.code + ' ' + op + ' ' + argsCode.$index(0));
5701 } 5709 }
5702 return new Value(this.get$inferredResult(), code, node.span, true); 5710 return new Value(this.get$inferredResult(), code, node.span, true);
5703 } 5711 }
5704 else { 5712 else {
5705 var value; 5713 var value;
5706 var val0, val1, ival0, ival1; 5714 var val0, val1, ival0, ival1;
5707 val0 = target.get$dynamic().get$actualValue(); 5715 val0 = target.get$dynamic().get$actualValue();
5708 ival0 = val0.toInt(); 5716 ival0 = val0.toInt();
5709 if (args.values.length > 0) { 5717 if (args.values.get$length() > 0) {
5710 val1 = args.values.$index(0).get$dynamic().get$actualValue(); 5718 val1 = args.values.$index(0).get$dynamic().get$actualValue();
5711 ival1 = val1.toInt(); 5719 ival1 = val1.toInt();
5712 } 5720 }
5713 switch (this.name) { 5721 switch (this.name) {
5714 case ':negate': 5722 case ':negate':
5715 5723
5716 value = -val0; 5724 value = -val0;
5717 break; 5725 break;
5718 5726
5719 case ':add': 5727 case ':add':
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
5864 } 5872 }
5865 else if (this.name == ':setindex') { 5873 else if (this.name == ':setindex') {
5866 $globals.world.gen.corejs.useSetIndex = true; 5874 $globals.world.gen.corejs.useSetIndex = true;
5867 } 5875 }
5868 var argsString = Strings.join(argsCode, ', '); 5876 var argsString = Strings.join(argsCode, ', ');
5869 return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get $jsname() + '(' + argsString + ')'), node.span, true); 5877 return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get $jsname() + '(' + argsString + ')'), node.span, true);
5870 } 5878 }
5871 MethodMember.prototype._normConcat = function(a, b) { 5879 MethodMember.prototype._normConcat = function(a, b) {
5872 var val0 = a.get$dynamic().get$actualValue(); 5880 var val0 = a.get$dynamic().get$actualValue();
5873 var quote0 = val0.$index(0); 5881 var quote0 = val0.$index(0);
5874 val0 = val0.substring$2(1, val0.length - 1); 5882 val0 = val0.substring$2(1, val0.get$length() - 1);
5875 var val1 = b.get$dynamic().get$actualValue(); 5883 var val1 = b.get$dynamic().get$actualValue();
5876 var quote1 = null; 5884 var quote1 = null;
5877 if (b.get$type().get$isString()) { 5885 if (b.get$type().get$isString()) {
5878 quote1 = val1.$index(0); 5886 quote1 = val1.$index(0);
5879 val1 = val1.substring$2(1, val1.length - 1); 5887 val1 = val1.substring$2(1, val1.get$length() - 1);
5880 } 5888 }
5881 var value; 5889 var value;
5882 if ($eq(quote0, quote1) || quote1 == null) { 5890 if ($eq(quote0, quote1) || quote1 == null) {
5883 value = ('' + quote0 + val0 + val1 + quote0); 5891 value = ('' + quote0 + val0 + val1 + quote0);
5884 } 5892 }
5885 else if ($eq(quote0, '"')) { 5893 else if ($eq(quote0, '"')) {
5886 value = ('' + quote0 + val0 + toDoubleQuote(val1) + quote0); 5894 value = ('' + quote0 + val0 + toDoubleQuote(val1) + quote0);
5887 } 5895 }
5888 else { 5896 else {
5889 value = ('' + quote1 + toDoubleQuote(val0) + val1 + quote1); 5897 value = ('' + quote1 + toDoubleQuote(val0) + val1 + quote1);
5890 } 5898 }
5891 return value; 5899 return value;
5892 } 5900 }
5893 MethodMember.prototype.resolve = function() { 5901 MethodMember.prototype.resolve = function() {
5894 this.isStatic = this.declaringType.get$isTop(); 5902 this.isStatic = this.declaringType.get$isTop();
5895 this.isConst = false; 5903 this.isConst = false;
5896 this.isFactory = false; 5904 this.isFactory = false;
5897 this.isAbstract = !this.declaringType.get$isClass(); 5905 this.isAbstract = !this.declaringType.get$isClass();
5898 if (this.definition.modifiers != null) { 5906 if (this.definition.modifiers != null) {
5899 var $$list = this.definition.modifiers; 5907 var $$list = this.definition.modifiers;
5900 for (var $$i = 0;$$i < $$list.length; $$i++) { 5908 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5901 var mod = $$list.$index($$i); 5909 var mod = $$list.$index($$i);
5902 if ($eq(mod.get$kind(), 86/*TokenKind.STATIC*/)) { 5910 if ($eq(mod.get$kind(), 86/*TokenKind.STATIC*/)) {
5903 if (this.isStatic) { 5911 if (this.isStatic) {
5904 $globals.world.error('duplicate static modifier', mod.get$span()); 5912 $globals.world.error('duplicate static modifier', mod.get$span());
5905 } 5913 }
5906 this.isStatic = true; 5914 this.isStatic = true;
5907 } 5915 }
5908 else if (this.get$isConstructor() && $eq(mod.get$kind(), 92/*TokenKind.CON ST*/)) { 5916 else if (this.get$isConstructor() && $eq(mod.get$kind(), 92/*TokenKind.CON ST*/)) {
5909 if (this.isConst) { 5917 if (this.isConst) {
5910 $globals.world.error('duplicate const modifier', mod.get$span()); 5918 $globals.world.error('duplicate const modifier', mod.get$span());
(...skipping 25 matching lines...) Expand all
5936 if (this.isFactory) { 5944 if (this.isFactory) {
5937 this.isStatic = true; 5945 this.isStatic = true;
5938 } 5946 }
5939 if (this.definition.typeParameters != null) { 5947 if (this.definition.typeParameters != null) {
5940 if (!this.isFactory) { 5948 if (!this.isFactory) {
5941 $globals.world.error('Only factories are allowed to have explicit type par ameters', this.definition.typeParameters.$index(0).get$span()); 5949 $globals.world.error('Only factories are allowed to have explicit type par ameters', this.definition.typeParameters.$index(0).get$span());
5942 } 5950 }
5943 else { 5951 else {
5944 this.typeParameters = this.definition.typeParameters; 5952 this.typeParameters = this.definition.typeParameters;
5945 var $$list = this.definition.typeParameters; 5953 var $$list = this.definition.typeParameters;
5946 for (var $$i = 0;$$i < $$list.length; $$i++) { 5954 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5947 var tp = $$list.$index($$i); 5955 var tp = $$list.$index($$i);
5948 tp.set$enclosingElement(this); 5956 tp.set$enclosingElement(this);
5949 tp.resolve$0(); 5957 tp.resolve$0();
5950 } 5958 }
5951 } 5959 }
5952 } 5960 }
5953 if (this.get$isOperator() && this.isStatic && !this.get$isCallMethod()) { 5961 if (this.get$isOperator() && this.isStatic && !this.get$isCallMethod()) {
5954 $globals.world.error(('operator method may not be static "' + this.name + '" '), this.get$span()); 5962 $globals.world.error(('operator method may not be static "' + this.name + '" '), this.get$span());
5955 } 5963 }
5956 if (this.isAbstract) { 5964 if (this.isAbstract) {
(...skipping 10 matching lines...) Expand all
5967 } 5975 }
5968 } 5976 }
5969 if (this.get$isConstructor() && !this.isFactory) { 5977 if (this.get$isConstructor() && !this.isFactory) {
5970 this.returnType = this.declaringType; 5978 this.returnType = this.declaringType;
5971 } 5979 }
5972 else { 5980 else {
5973 this.returnType = this.resolveType(this.definition.returnType, false); 5981 this.returnType = this.resolveType(this.definition.returnType, false);
5974 } 5982 }
5975 this.parameters = []; 5983 this.parameters = [];
5976 var $$list = this.definition.formals; 5984 var $$list = this.definition.formals;
5977 for (var $$i = 0;$$i < $$list.length; $$i++) { 5985 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5978 var formal = $$list.$index($$i); 5986 var formal = $$list.$index($$i);
5979 var param = new Parameter(formal, this); 5987 var param = new Parameter(formal, this);
5980 param.resolve$0(); 5988 param.resolve$0();
5981 this.parameters.add(param); 5989 this.parameters.add(param);
5982 } 5990 }
5983 if (!this.isLambda) { 5991 if (!this.isLambda) {
5984 this.get$library()._addMember(this); 5992 this.get$library()._addMember(this);
5985 } 5993 }
5986 } 5994 }
5987 MethodMember.prototype.resolveType = function(node, typeErrors) { 5995 MethodMember.prototype.resolveType = function(node, typeErrors) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6020 this.members = [member]; 6028 this.members = [member];
6021 this.jsname = member.get$jsname(); 6029 this.jsname = member.get$jsname();
6022 this.isVar = isVar; 6030 this.isVar = isVar;
6023 // Initializers done 6031 // Initializers done
6024 } 6032 }
6025 MemberSet.prototype.get$name = function() { return this.name; }; 6033 MemberSet.prototype.get$name = function() { return this.name; };
6026 MemberSet.prototype.get$members = function() { return this.members; }; 6034 MemberSet.prototype.get$members = function() { return this.members; };
6027 MemberSet.prototype.get$jsname = function() { return this.jsname; }; 6035 MemberSet.prototype.get$jsname = function() { return this.jsname; };
6028 MemberSet.prototype.get$isVar = function() { return this.isVar; }; 6036 MemberSet.prototype.get$isVar = function() { return this.isVar; };
6029 MemberSet.prototype.toString = function() { 6037 MemberSet.prototype.toString = function() {
6030 return ('' + this.name + ':' + this.members.length); 6038 return ('' + this.name + ':' + this.members.get$length());
6031 } 6039 }
6032 MemberSet.prototype.get$containsMethods = function() { 6040 MemberSet.prototype.get$containsMethods = function() {
6033 return this.members.some((function (m) { 6041 return this.members.some((function (m) {
6034 return (m instanceof MethodMember); 6042 return (m instanceof MethodMember);
6035 }) 6043 })
6036 ); 6044 );
6037 } 6045 }
6038 MemberSet.prototype.add = function(member) { 6046 MemberSet.prototype.add = function(member) {
6039 return this.members.add(member); 6047 return this.members.add(member);
6040 } 6048 }
6041 MemberSet.prototype.get$isStatic = function() { 6049 MemberSet.prototype.get$isStatic = function() {
6042 return this.members.length == 1 && this.members.$index(0).get$isStatic(); 6050 return this.members.get$length() == 1 && this.members.$index(0).get$isStatic() ;
6043 } 6051 }
6044 MemberSet.prototype.get$isOperator = function() { 6052 MemberSet.prototype.get$isOperator = function() {
6045 return this.members.$index(0).get$isOperator(); 6053 return this.members.$index(0).get$isOperator();
6046 } 6054 }
6047 MemberSet.prototype.canInvoke = function(context, args) { 6055 MemberSet.prototype.canInvoke = function(context, args) {
6048 return this.members.some((function (m) { 6056 return this.members.some((function (m) {
6049 return m.canInvoke$2(context, args); 6057 return m.canInvoke$2(context, args);
6050 }) 6058 })
6051 ); 6059 );
6052 } 6060 }
6053 MemberSet.prototype._makeError = function(node, target, action) { 6061 MemberSet.prototype._makeError = function(node, target, action) {
6054 if (!target.get$type().get$isVar()) { 6062 if (!target.get$type().get$isVar()) {
6055 $globals.world.warning(('could not find applicable ' + action + ' for "' + t his.name + '"'), node.span); 6063 $globals.world.warning(('could not find applicable ' + action + ' for "' + t his.name + '"'), node.span);
6056 } 6064 }
6057 return new Value($globals.world.varType, ('' + target.code + '.' + this.jsname + '() /*no applicable ' + action + '*/'), node.span, true); 6065 return new Value($globals.world.varType, ('' + target.code + '.' + this.jsname + '() /*no applicable ' + action + '*/'), node.span, true);
6058 } 6066 }
6059 MemberSet.prototype.get$treatAsField = function() { 6067 MemberSet.prototype.get$treatAsField = function() {
6060 if (this._treatAsField == null) { 6068 if (this._treatAsField == null) {
6061 this._treatAsField = !this.isVar; 6069 this._treatAsField = !this.isVar && (this.members.some((function (m) {
6070 return m.get$requiresFieldSyntax();
6071 })
6072 ) || this.members.every((function (m) {
6073 return !m.get$requiresPropertySyntax();
6074 })
6075 ));
6062 var $$list = this.members; 6076 var $$list = this.members;
6063 for (var $$i = 0;$$i < $$list.length; $$i++) { 6077 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
6064 var member = $$list.$index($$i);
6065 if (member.get$requiresFieldSyntax()) {
6066 this._treatAsField = true;
6067 break;
6068 }
6069 if (member.get$prefersPropertySyntax()) {
6070 this._treatAsField = false;
6071 }
6072 }
6073 var $$list = this.members;
6074 for (var $$i = 0;$$i < $$list.length; $$i++) {
6075 var member = $$list.$index($$i); 6078 var member = $$list.$index($$i);
6076 if (this._treatAsField) { 6079 if (this._treatAsField) {
6077 member.provideFieldSyntax$0(); 6080 member.provideFieldSyntax$0();
6078 } 6081 }
6079 else { 6082 else {
6080 member.providePropertySyntax$0(); 6083 member.providePropertySyntax$0();
6081 } 6084 }
6082 } 6085 }
6083 } 6086 }
6084 return this._treatAsField; 6087 return this._treatAsField;
6085 } 6088 }
6086 MemberSet.prototype._get = function(context, node, target, isDynamic) { 6089 MemberSet.prototype._get = function(context, node, target, isDynamic) {
6087 var returnValue; 6090 var returnValue;
6088 var targets = this.members.filter((function (m) { 6091 var targets = this.members.filter((function (m) {
6089 return m.get$canGet(); 6092 return m.get$canGet();
6090 }) 6093 })
6091 ); 6094 );
6092 if (this.isVar) { 6095 if (this.isVar) {
6093 targets.forEach$1((function (m) { 6096 targets.forEach$1((function (m) {
6094 return m._get$3$isDynamic(context, node, target, true); 6097 return m._get$3$isDynamic(context, node, target, true);
6095 }) 6098 })
6096 ); 6099 );
6097 returnValue = new Value(this._foldTypes(targets), null, node.span, true); 6100 returnValue = new Value(this._foldTypes(targets), null, node.span, true);
6098 } 6101 }
6099 else { 6102 else {
6100 if (this.members.length == 1) { 6103 if (this.members.get$length() == 1) {
6101 return this.members.$index(0)._get$4(context, node, target, isDynamic); 6104 return this.members.$index(0)._get$4(context, node, target, isDynamic);
6102 } 6105 }
6103 else if ($eq(targets.length, 1)) { 6106 else if ($eq(targets.get$length(), 1)) {
6104 return targets.$index(0)._get$4(context, node, target, isDynamic); 6107 return targets.$index(0)._get$4(context, node, target, isDynamic);
6105 } 6108 }
6106 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6109 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6107 var member = $$i.next$0(); 6110 var member = $$i.next$0();
6108 var value = member._get$3$isDynamic(context, node, target, true); 6111 var value = member._get$3$isDynamic(context, node, target, true);
6109 returnValue = this._tryUnion(returnValue, value, node); 6112 returnValue = this._tryUnion(returnValue, value, node);
6110 } 6113 }
6111 if (returnValue == null) { 6114 if (returnValue == null) {
6112 return this._makeError(node, target, 'getter'); 6115 return this._makeError(node, target, 'getter');
6113 } 6116 }
(...skipping 15 matching lines...) Expand all
6129 }) 6132 })
6130 ); 6133 );
6131 if (this.isVar) { 6134 if (this.isVar) {
6132 targets.forEach$1((function (m) { 6135 targets.forEach$1((function (m) {
6133 return m._set$4$isDynamic(context, node, target, value, true); 6136 return m._set$4$isDynamic(context, node, target, value, true);
6134 }) 6137 })
6135 ); 6138 );
6136 returnValue = new Value(this._foldTypes(targets), null, node.span, true); 6139 returnValue = new Value(this._foldTypes(targets), null, node.span, true);
6137 } 6140 }
6138 else { 6141 else {
6139 if (this.members.length == 1) { 6142 if (this.members.get$length() == 1) {
6140 return this.members.$index(0)._set$5(context, node, target, value, isDynam ic); 6143 return this.members.$index(0)._set$5(context, node, target, value, isDynam ic);
6141 } 6144 }
6142 else if ($eq(targets.length, 1)) { 6145 else if ($eq(targets.get$length(), 1)) {
6143 return targets.$index(0)._set$5(context, node, target, value, isDynamic); 6146 return targets.$index(0)._set$5(context, node, target, value, isDynamic);
6144 } 6147 }
6145 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6148 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6146 var member = $$i.next$0(); 6149 var member = $$i.next$0();
6147 var res = member._set$4$isDynamic(context, node, target, value, true); 6150 var res = member._set$4$isDynamic(context, node, target, value, true);
6148 returnValue = this._tryUnion(returnValue, res, node); 6151 returnValue = this._tryUnion(returnValue, res, node);
6149 } 6152 }
6150 if (returnValue == null) { 6153 if (returnValue == null) {
6151 return this._makeError(node, target, 'setter'); 6154 return this._makeError(node, target, 'setter');
6152 } 6155 }
6153 } 6156 }
6154 if (returnValue.code == null) { 6157 if (returnValue.code == null) {
6155 if (this.get$treatAsField()) { 6158 if (this.get$treatAsField()) {
6156 return new Value(returnValue.get$type(), ('' + target.code + '.' + this.js name + ' = ' + value.code), node.span, true); 6159 return new Value(returnValue.get$type(), ('' + target.code + '.' + this.js name + ' = ' + value.code), node.span, true);
6157 } 6160 }
6158 else { 6161 else {
6159 return new Value(returnValue.get$type(), ('' + target.code + '.set\$' + th is.jsname + '(' + value.code + ')'), node.span, true); 6162 return new Value(returnValue.get$type(), ('' + target.code + '.set\$' + th is.jsname + '(' + value.code + ')'), node.span, true);
6160 } 6163 }
6161 } 6164 }
6162 return returnValue; 6165 return returnValue;
6163 } 6166 }
6164 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) { 6167 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) {
6165 if (this.isVar && !this.get$isOperator()) { 6168 if (this.isVar && !this.get$isOperator()) {
6166 return this.invokeOnVar(context, node, target, args); 6169 return this.invokeOnVar(context, node, target, args);
6167 } 6170 }
6168 if (this.members.length == 1) { 6171 if (this.members.get$length() == 1) {
6169 return this.members.$index(0).invoke$5(context, node, target, args, isDynami c); 6172 return this.members.$index(0).invoke$5(context, node, target, args, isDynami c);
6170 } 6173 }
6171 var targets = this.members.filter((function (m) { 6174 var targets = this.members.filter((function (m) {
6172 return m.canInvoke$2(context, args); 6175 return m.canInvoke$2(context, args);
6173 }) 6176 })
6174 ); 6177 );
6175 if ($eq(targets.length, 1)) { 6178 if ($eq(targets.get$length(), 1)) {
6176 return targets.$index(0).invoke$5(context, node, target, args, isDynamic); 6179 return targets.$index(0).invoke$5(context, node, target, args, isDynamic);
6177 } 6180 }
6178 var returnValue = null; 6181 var returnValue = null;
6179 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6182 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6180 var member = $$i.next$0(); 6183 var member = $$i.next$0();
6181 var res = member.invoke$4$isDynamic(context, node, target, args, true); 6184 var res = member.invoke$4$isDynamic(context, node, target, args, true);
6182 returnValue = this._tryUnion(returnValue, res, node); 6185 returnValue = this._tryUnion(returnValue, res, node);
6183 } 6186 }
6184 if (returnValue == null) { 6187 if (returnValue == null) {
6185 return this._makeError(node, target, 'method'); 6188 return this._makeError(node, target, 'method');
(...skipping 10 matching lines...) Expand all
6196 } 6199 }
6197 } 6200 }
6198 return returnValue; 6201 return returnValue;
6199 } 6202 }
6200 MemberSet.prototype.invokeSpecial = function(target, args, returnType) { 6203 MemberSet.prototype.invokeSpecial = function(target, args, returnType) {
6201 var argsString = args.getCode(); 6204 var argsString = args.getCode();
6202 if (this.name == ':index' || this.name == ':setindex') { 6205 if (this.name == ':index' || this.name == ':setindex') {
6203 return new Value(returnType, ('' + target.code + '.' + this.jsname + '(' + a rgsString + ')'), target.span, true); 6206 return new Value(returnType, ('' + target.code + '.' + this.jsname + '(' + a rgsString + ')'), target.span, true);
6204 } 6207 }
6205 else { 6208 else {
6206 if (argsString.length > 0) argsString = (', ' + argsString); 6209 if (argsString.get$length() > 0) argsString = (', ' + argsString);
6207 $globals.world.gen.corejs.useOperator(this.name); 6210 $globals.world.gen.corejs.useOperator(this.name);
6208 return new Value(returnType, ('' + this.jsname + '(' + target.code + argsStr ing + ')'), target.span, true); 6211 return new Value(returnType, ('' + this.jsname + '(' + target.code + argsStr ing + ')'), target.span, true);
6209 } 6212 }
6210 } 6213 }
6211 MemberSet.prototype.invokeOnVar = function(context, node, target, args) { 6214 MemberSet.prototype.invokeOnVar = function(context, node, target, args) {
6212 var member = this.getVarMember(context, node, args); 6215 var member = this.getVarMember(context, node, args);
6213 return member.invoke$4(context, node, target, args); 6216 return member.invoke$4(context, node, target, args);
6214 } 6217 }
6215 MemberSet.prototype._tryUnion = function(x, y, node) { 6218 MemberSet.prototype._tryUnion = function(x, y, node) {
6216 if (x == null) return y; 6219 if (x == null) return y;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
6318 Token.prototype.get$kind = function() { return this.kind; }; 6321 Token.prototype.get$kind = function() { return this.kind; };
6319 Token.prototype.get$end = function() { return this.end; }; 6322 Token.prototype.get$end = function() { return this.end; };
6320 Token.prototype.get$start = function() { return this.start; }; 6323 Token.prototype.get$start = function() { return this.start; };
6321 Token.prototype.get$text = function() { 6324 Token.prototype.get$text = function() {
6322 return this.source.get$text().substring(this.start, this.end); 6325 return this.source.get$text().substring(this.start, this.end);
6323 } 6326 }
6324 Token.prototype.toString = function() { 6327 Token.prototype.toString = function() {
6325 var kindText = TokenKind.kindToString(this.kind); 6328 var kindText = TokenKind.kindToString(this.kind);
6326 var actualText = this.get$text(); 6329 var actualText = this.get$text();
6327 if ($ne(kindText, actualText)) { 6330 if ($ne(kindText, actualText)) {
6328 if (actualText.length > 10) { 6331 if (actualText.get$length() > 10) {
6329 actualText = actualText.substring$2(0, 8) + '...'; 6332 actualText = actualText.substring$2(0, 8) + '...';
6330 } 6333 }
6331 return ('' + kindText + '(' + actualText + ')'); 6334 return ('' + kindText + '(' + actualText + ')');
6332 } 6335 }
6333 else { 6336 else {
6334 return kindText; 6337 return kindText;
6335 } 6338 }
6336 } 6339 }
6337 Token.prototype.get$span = function() { 6340 Token.prototype.get$span = function() {
6338 return new SourceSpan(this.source, this.start, this.end); 6341 return new SourceSpan(this.source, this.start, this.end);
6339 } 6342 }
6340 Token.prototype.end$0 = function() { 6343 Token.prototype.end$0 = function() {
6341 return this.end(); 6344 return this.end.call$0();
6342 }; 6345 };
6343 Token.prototype.start$0 = function() { 6346 Token.prototype.start$0 = function() {
6344 return this.start(); 6347 return this.start.call$0();
6345 }; 6348 };
6346 Token.prototype.toString$0 = Token.prototype.toString; 6349 Token.prototype.toString$0 = Token.prototype.toString;
6347 // ********** Code for ErrorToken ************** 6350 // ********** Code for ErrorToken **************
6348 $inherits(ErrorToken, Token); 6351 $inherits(ErrorToken, Token);
6349 function ErrorToken(kind, source, start, end, message) { 6352 function ErrorToken(kind, source, start, end, message) {
6350 this.message = message; 6353 this.message = message;
6351 // Initializers done 6354 // Initializers done
6352 Token.call(this, kind, source, start, end); 6355 Token.call(this, kind, source, start, end);
6353 } 6356 }
6354 ErrorToken.prototype.get$message = function() { return this.message; }; 6357 ErrorToken.prototype.get$message = function() { return this.message; };
(...skipping 20 matching lines...) Expand all
6375 starts.add$1(index); 6378 starts.add$1(index);
6376 } 6379 }
6377 starts.add$1(this.get$text().length + 1); 6380 starts.add$1(this.get$text().length + 1);
6378 this._lineStarts = starts; 6381 this._lineStarts = starts;
6379 } 6382 }
6380 return this._lineStarts; 6383 return this._lineStarts;
6381 } 6384 }
6382 SourceFile.prototype.getLine = function(position) { 6385 SourceFile.prototype.getLine = function(position) {
6383 var starts = this.get$lineStarts(); 6386 var starts = this.get$lineStarts();
6384 for (var i = 0; 6387 for (var i = 0;
6385 i < starts.length; i++) { 6388 i < starts.get$length(); i++) {
6386 if (starts.$index(i) > position) return i - 1; 6389 if (starts.$index(i) > position) return i - 1;
6387 } 6390 }
6388 $globals.world.internalError('bad position'); 6391 $globals.world.internalError('bad position');
6389 } 6392 }
6390 SourceFile.prototype.getColumn = function(line, position) { 6393 SourceFile.prototype.getColumn = function(line, position) {
6391 return position - this.get$lineStarts().$index(line); 6394 return position - this.get$lineStarts().$index(line);
6392 } 6395 }
6393 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) { 6396 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) {
6394 var line = this.getLine(start); 6397 var line = this.getLine(start);
6395 var column = this.getColumn(line, start); 6398 var column = this.getColumn(line, start);
6396 var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' + (column + 1) + ': ' + message)); 6399 var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' + (column + 1) + ': ' + message));
6397 if (includeText) { 6400 if (includeText) {
6398 buf.add$1('\n'); 6401 buf.add$1('\n');
6399 var textLine; 6402 var textLine;
6400 if ((line + 2) < this._lineStarts.length) { 6403 if ((line + 2) < this._lineStarts.get$length()) {
6401 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + 1)); 6404 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + 1));
6402 } 6405 }
6403 else { 6406 else {
6404 textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n' ; 6407 textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n' ;
6405 } 6408 }
6406 var toColumn = Math.min(column + (end - start), textLine.length); 6409 var toColumn = Math.min(column + (end - start), textLine.get$length());
6407 if ($globals.options.useColors) { 6410 if ($globals.options.useColors) {
6408 buf.add$1(textLine.substring$2(0, column)); 6411 buf.add$1(textLine.substring$2(0, column));
6409 buf.add$1($globals._RED_COLOR); 6412 buf.add$1($globals._RED_COLOR);
6410 buf.add$1(textLine.substring$2(column, toColumn)); 6413 buf.add$1(textLine.substring$2(column, toColumn));
6411 buf.add$1($globals._NO_COLOR); 6414 buf.add$1($globals._NO_COLOR);
6412 buf.add$1(textLine.substring$1(toColumn)); 6415 buf.add$1(textLine.substring$1(toColumn));
6413 } 6416 }
6414 else { 6417 else {
6415 buf.add$1(textLine); 6418 buf.add$1(textLine);
6416 } 6419 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6460 } 6463 }
6461 SourceSpan.prototype.compareTo = function(other) { 6464 SourceSpan.prototype.compareTo = function(other) {
6462 if ($eq(this.file, other.file)) { 6465 if ($eq(this.file, other.file)) {
6463 var d = this.start - other.start; 6466 var d = this.start - other.start;
6464 return d == 0 ? (this.end - other.end) : d; 6467 return d == 0 ? (this.end - other.end) : d;
6465 } 6468 }
6466 return this.file.compareTo(other.file); 6469 return this.file.compareTo(other.file);
6467 } 6470 }
6468 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo; 6471 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo;
6469 SourceSpan.prototype.end$0 = function() { 6472 SourceSpan.prototype.end$0 = function() {
6470 return this.end(); 6473 return this.end.call$0();
6471 }; 6474 };
6472 SourceSpan.prototype.start$0 = function() { 6475 SourceSpan.prototype.start$0 = function() {
6473 return this.start(); 6476 return this.start.call$0();
6474 }; 6477 };
6475 // ********** Code for InterpStack ************** 6478 // ********** Code for InterpStack **************
6476 function InterpStack(previous, quote, isMultiline) { 6479 function InterpStack(previous, quote, isMultiline) {
6477 this.previous = previous; 6480 this.previous = previous;
6478 this.quote = quote; 6481 this.quote = quote;
6479 this.isMultiline = isMultiline; 6482 this.isMultiline = isMultiline;
6480 this.depth = -1; 6483 this.depth = -1;
6481 // Initializers done 6484 // Initializers done
6482 } 6485 }
6483 InterpStack.prototype.get$previous = function() { return this.previous; }; 6486 InterpStack.prototype.get$previous = function() { return this.previous; };
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after
8422 this._inhibitLambda = true; 8425 this._inhibitLambda = true;
8423 var ret = []; 8426 var ret = [];
8424 do { 8427 do {
8425 ret.add$1(this.expression()); 8428 ret.add$1(this.expression());
8426 } 8429 }
8427 while (this._maybeEat(11/*TokenKind.COMMA*/)) 8430 while (this._maybeEat(11/*TokenKind.COMMA*/))
8428 this._inhibitLambda = false; 8431 this._inhibitLambda = false;
8429 return ret; 8432 return ret;
8430 } 8433 }
8431 Parser.prototype.get$initializers = function() { 8434 Parser.prototype.get$initializers = function() {
8432 return Parser.prototype.initializers.bind(this); 8435 return Parser.prototype.initializers.bind(this)
8433 } 8436 }
8434 Parser.prototype.functionBody = function(inExpression) { 8437 Parser.prototype.functionBody = function(inExpression) {
8435 var start = this._peekToken.start; 8438 var start = this._peekToken.start;
8436 if (this._maybeEat(9/*TokenKind.ARROW*/)) { 8439 if (this._maybeEat(9/*TokenKind.ARROW*/)) {
8437 var expr = this.expression(); 8440 var expr = this.expression();
8438 if (!inExpression) { 8441 if (!inExpression) {
8439 this._eatSemicolon(); 8442 this._eatSemicolon();
8440 } 8443 }
8441 return new ReturnStatement(expr, this._makeSpan(start)); 8444 return new ReturnStatement(expr, this._makeSpan(start));
8442 } 8445 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8529 var typeParams = null; 8532 var typeParams = null;
8530 if (this._peekKind(52/*TokenKind.LT*/)) { 8533 if (this._peekKind(52/*TokenKind.LT*/)) {
8531 typeParams = this.typeParameters(); 8534 typeParams = this.typeParameters();
8532 } 8535 }
8533 var name = null; 8536 var name = null;
8534 var type = null; 8537 var type = null;
8535 if (this._maybeEat(14/*TokenKind.DOT*/)) { 8538 if (this._maybeEat(14/*TokenKind.DOT*/)) {
8536 name = this.identifier(); 8539 name = this.identifier();
8537 } 8540 }
8538 else if (typeParams == null) { 8541 else if (typeParams == null) {
8539 if (names.length > 1) { 8542 if (names.get$length() > 1) {
8540 name = names.removeLast$0(); 8543 name = names.removeLast$0();
8541 } 8544 }
8542 else { 8545 else {
8543 name = new Identifier('', names.$index(0).get$span()); 8546 name = new Identifier('', names.$index(0).get$span());
8544 } 8547 }
8545 } 8548 }
8546 else { 8549 else {
8547 name = new Identifier('', names.$index(0).get$span()); 8550 name = new Identifier('', names.$index(0).get$span());
8548 } 8551 }
8549 if (names.length > 1) { 8552 if (names.get$length() > 1) {
8550 this._error('unsupported qualified name for factory', names.$index(0).get$sp an()); 8553 this._error('unsupported qualified name for factory', names.$index(0).get$sp an());
8551 } 8554 }
8552 type = new NameTypeReference(false, names.$index(0), null, names.$index(0).get $span()); 8555 type = new NameTypeReference(false, names.$index(0), null, names.$index(0).get $span());
8553 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); 8556 var di = new DeclaredIdentifier(type, name, this._makeSpan(start));
8554 return this.finishDefinition(start, [factoryToken], di, typeParams); 8557 return this.finishDefinition(start, [factoryToken], di, typeParams);
8555 } 8558 }
8556 Parser.prototype.statement = function() { 8559 Parser.prototype.statement = function() {
8557 switch (this._peek()) { 8560 switch (this._peek()) {
8558 case 89/*TokenKind.BREAK*/: 8561 case 89/*TokenKind.BREAK*/:
8559 8562
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
8818 this._eat(8/*TokenKind.COLON*/); 8821 this._eat(8/*TokenKind.COLON*/);
8819 } 8822 }
8820 else if (this._maybeEat(94/*TokenKind.DEFAULT*/)) { 8823 else if (this._maybeEat(94/*TokenKind.DEFAULT*/)) {
8821 cases.add$1(); 8824 cases.add$1();
8822 this._eat(8/*TokenKind.COLON*/); 8825 this._eat(8/*TokenKind.COLON*/);
8823 } 8826 }
8824 else { 8827 else {
8825 break; 8828 break;
8826 } 8829 }
8827 } 8830 }
8828 if ($eq(cases.length, 0)) { 8831 if ($eq(cases.get$length(), 0)) {
8829 this._error('case or default'); 8832 this._error('case or default');
8830 } 8833 }
8831 var stmts = []; 8834 var stmts = [];
8832 while (!this._peekCaseEnd()) { 8835 while (!this._peekCaseEnd()) {
8833 stmts.add$1(this.statement()); 8836 stmts.add$1(this.statement());
8834 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 90/*TokenKind.C ASE*/, 94/*TokenKind.DEFAULT*/)) { 8837 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 90/*TokenKind.C ASE*/, 94/*TokenKind.DEFAULT*/)) {
8835 break; 8838 break;
8836 } 8839 }
8837 } 8840 }
8838 return new CaseNode(label, cases, stmts, this._makeSpan(start)); 8841 return new CaseNode(label, cases, stmts, this._makeSpan(start));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
9033 do { 9036 do {
9034 args.add$1(this.argument()); 9037 args.add$1(this.argument());
9035 } 9038 }
9036 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9039 while (this._maybeEat(11/*TokenKind.COMMA*/))
9037 this._eat(3/*TokenKind.RPAREN*/); 9040 this._eat(3/*TokenKind.RPAREN*/);
9038 } 9041 }
9039 this._inhibitLambda = saved; 9042 this._inhibitLambda = saved;
9040 return args; 9043 return args;
9041 } 9044 }
9042 Parser.prototype.get$arguments = function() { 9045 Parser.prototype.get$arguments = function() {
9043 return Parser.prototype.arguments.bind(this); 9046 return Parser.prototype.arguments.bind(this)
9044 } 9047 }
9045 Parser.prototype.finishPostfixExpression = function(expr) { 9048 Parser.prototype.finishPostfixExpression = function(expr) {
9046 switch (this._peek()) { 9049 switch (this._peek()) {
9047 case 2/*TokenKind.LPAREN*/: 9050 case 2/*TokenKind.LPAREN*/:
9048 9051
9049 return this.finishCallOrLambdaExpression(expr); 9052 return this.finishCallOrLambdaExpression(expr);
9050 9053
9051 case 4/*TokenKind.LBRACK*/: 9054 case 4/*TokenKind.LBRACK*/:
9052 9055
9053 this._eat(4/*TokenKind.LBRACK*/); 9056 this._eat(4/*TokenKind.LBRACK*/);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
9225 var token = this._next(); 9228 var token = this._next();
9226 var text = token.get$text(); 9229 var text = token.get$text();
9227 if (startQuote == null) { 9230 if (startQuote == null) {
9228 if (isMultilineString(text)) { 9231 if (isMultilineString(text)) {
9229 endQuote = text.substring$2(0, 3); 9232 endQuote = text.substring$2(0, 3);
9230 startQuote = endQuote + '\n'; 9233 startQuote = endQuote + '\n';
9231 } 9234 }
9232 else { 9235 else {
9233 startQuote = endQuote = text.$index(0); 9236 startQuote = endQuote = text.$index(0);
9234 } 9237 }
9235 text = text.substring$2(0, text.length - 1) + endQuote; 9238 text = text.substring$2(0, text.get$length() - 1) + endQuote;
9236 } 9239 }
9237 else { 9240 else {
9238 text = startQuote + text.substring$2(0, text.length - 1) + endQuote; 9241 text = startQuote + text.substring$2(0, text.get$length() - 1) + endQuote;
9239 } 9242 }
9240 lits.add$1(this.makeStringLiteral(text, token.get$span())); 9243 lits.add$1(this.makeStringLiteral(text, token.get$span()));
9241 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 9244 if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
9242 lits.add$1(this.expression()); 9245 lits.add$1(this.expression());
9243 this._eat(7/*TokenKind.RBRACE*/); 9246 this._eat(7/*TokenKind.RBRACE*/);
9244 } 9247 }
9245 else if (this._maybeEat(109/*TokenKind.THIS*/)) { 9248 else if (this._maybeEat(109/*TokenKind.THIS*/)) {
9246 lits.add$1(new ThisExpression(this._previousToken.get$span())); 9249 lits.add$1(new ThisExpression(this._previousToken.get$span()));
9247 } 9250 }
9248 else { 9251 else {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
9302 Parser.prototype._atClosureParameters = function() { 9305 Parser.prototype._atClosureParameters = function() {
9303 if (this._inhibitLambda) return false; 9306 if (this._inhibitLambda) return false;
9304 var after = this._peekAfterCloseParen(); 9307 var after = this._peekAfterCloseParen();
9305 return after.kind == 9/*TokenKind.ARROW*/ || after.kind == 6/*TokenKind.LBRACE */; 9308 return after.kind == 9/*TokenKind.ARROW*/ || after.kind == 6/*TokenKind.LBRACE */;
9306 } 9309 }
9307 Parser.prototype._eatLeftParen = function() { 9310 Parser.prototype._eatLeftParen = function() {
9308 this._eat(2/*TokenKind.LPAREN*/); 9311 this._eat(2/*TokenKind.LPAREN*/);
9309 this._afterParensIndex++; 9312 this._afterParensIndex++;
9310 } 9313 }
9311 Parser.prototype._peekAfterCloseParen = function() { 9314 Parser.prototype._peekAfterCloseParen = function() {
9312 if (this._afterParensIndex < this._afterParens.length) { 9315 if (this._afterParensIndex < this._afterParens.get$length()) {
9313 return this._afterParens.$index(this._afterParensIndex); 9316 return this._afterParens.$index(this._afterParensIndex);
9314 } 9317 }
9315 this._afterParensIndex = 0; 9318 this._afterParensIndex = 0;
9316 this._afterParens.clear(); 9319 this._afterParens.clear();
9317 var tokens = [this._next()]; 9320 var tokens = [this._next()];
9318 this._lookaheadAfterParens(tokens); 9321 this._lookaheadAfterParens(tokens);
9319 var after = this._peekToken; 9322 var after = this._peekToken;
9320 tokens.add$1(after); 9323 tokens.add$1(after);
9321 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer); 9324 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer);
9322 this._next(); 9325 this._next();
9323 return after; 9326 return after;
9324 } 9327 }
9325 Parser.prototype._lookaheadAfterParens = function(tokens) { 9328 Parser.prototype._lookaheadAfterParens = function(tokens) {
9326 var saved = this._afterParens.length; 9329 var saved = this._afterParens.get$length();
9327 this._afterParens.add(null); 9330 this._afterParens.add(null);
9328 while (true) { 9331 while (true) {
9329 var token = this._next(); 9332 var token = this._next();
9330 tokens.add(token); 9333 tokens.add(token);
9331 var kind = token.kind; 9334 var kind = token.kind;
9332 if (kind == 3/*TokenKind.RPAREN*/ || kind == 1/*TokenKind.END_OF_FILE*/) { 9335 if (kind == 3/*TokenKind.RPAREN*/ || kind == 1/*TokenKind.END_OF_FILE*/) {
9333 this._afterParens.$setindex(saved, this._peekToken); 9336 this._afterParens.$setindex(saved, this._peekToken);
9334 return; 9337 return;
9335 } 9338 }
9336 else if (kind == 2/*TokenKind.LPAREN*/) { 9339 else if (kind == 2/*TokenKind.LPAREN*/) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
9498 var span = this._makeSpan(start); 9501 var span = this._makeSpan(start);
9499 var typeToBeNamedLater = new NameTypeReference(false, null, null, span); 9502 var typeToBeNamedLater = new NameTypeReference(false, null, null, span);
9500 var genericType = this.addTypeArguments(typeToBeNamedLater, 0); 9503 var genericType = this.addTypeArguments(typeToBeNamedLater, 0);
9501 if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind.INDE X*/)) { 9504 if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind.INDE X*/)) {
9502 genericType.set$baseType(new TypeReference(span, $globals.world.listType)); 9505 genericType.set$baseType(new TypeReference(span, $globals.world.listType));
9503 return this.finishListLiteral(start, isConst, genericType); 9506 return this.finishListLiteral(start, isConst, genericType);
9504 } 9507 }
9505 else if (this._peekKind(6/*TokenKind.LBRACE*/)) { 9508 else if (this._peekKind(6/*TokenKind.LBRACE*/)) {
9506 genericType.set$baseType(new TypeReference(span, $globals.world.mapType)); 9509 genericType.set$baseType(new TypeReference(span, $globals.world.mapType));
9507 var typeArgs = genericType.get$typeArguments(); 9510 var typeArgs = genericType.get$typeArguments();
9508 if ($eq(typeArgs.length, 1)) { 9511 if ($eq(typeArgs.get$length(), 1)) {
9509 genericType.set$typeArguments([new TypeReference(span, $globals.world.stri ngType), typeArgs.$index(0)]); 9512 genericType.set$typeArguments([new TypeReference(span, $globals.world.stri ngType), typeArgs.$index(0)]);
9510 } 9513 }
9511 else if ($eq(typeArgs.length, 2)) { 9514 else if ($eq(typeArgs.get$length(), 2)) {
9512 var keyType = typeArgs.$index(0); 9515 var keyType = typeArgs.$index(0);
9513 if (!(keyType instanceof NameTypeReference) || $ne(keyType.get$name().get$ name(), "String")) { 9516 if (!(keyType instanceof NameTypeReference) || $ne(keyType.get$name().get$ name(), "String")) {
9514 $globals.world.error('the key type of a map literal is implicitly "Strin g"', keyType.get$span()); 9517 $globals.world.error('the key type of a map literal is implicitly "Strin g"', keyType.get$span());
9515 } 9518 }
9516 else { 9519 else {
9517 $globals.world.warning('a map literal takes one type argument specifying the value type', keyType.get$span()); 9520 $globals.world.warning('a map literal takes one type argument specifying the value type', keyType.get$span());
9518 } 9521 }
9519 } 9522 }
9520 return this.finishMapLiteral(start, isConst, genericType); 9523 return this.finishMapLiteral(start, isConst, genericType);
9521 } 9524 }
(...skipping 27 matching lines...) Expand all
9549 var start = this._peekToken.start; 9552 var start = this._peekToken.start;
9550 var name = this.identifier(); 9553 var name = this.identifier();
9551 var myType = null; 9554 var myType = null;
9552 if (this._maybeEat(74/*TokenKind.EXTENDS*/)) { 9555 if (this._maybeEat(74/*TokenKind.EXTENDS*/)) {
9553 myType = this.type(1); 9556 myType = this.type(1);
9554 } 9557 }
9555 var tp = new TypeParameter(name, myType, this._makeSpan(start)); 9558 var tp = new TypeParameter(name, myType, this._makeSpan(start));
9556 return new ParameterType(name.get$name(), tp); 9559 return new ParameterType(name.get$name(), tp);
9557 } 9560 }
9558 Parser.prototype.get$typeParameter = function() { 9561 Parser.prototype.get$typeParameter = function() {
9559 return Parser.prototype.typeParameter.bind(this); 9562 return Parser.prototype.typeParameter.bind(this)
9560 } 9563 }
9561 Parser.prototype.typeParameters = function() { 9564 Parser.prototype.typeParameters = function() {
9562 this._eat(52/*TokenKind.LT*/); 9565 this._eat(52/*TokenKind.LT*/);
9563 var closed = false; 9566 var closed = false;
9564 var ret = []; 9567 var ret = [];
9565 do { 9568 do {
9566 var tp = this.typeParameter(); 9569 var tp = this.typeParameter();
9567 ret.add$1(tp); 9570 ret.add$1(tp);
9568 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc e) && $eq(tp.get$typeParameter().get$extendsType().get$depth(), 0)) { 9571 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc e) && $eq(tp.get$typeParameter().get$extendsType().get$depth(), 0)) {
9569 closed = true; 9572 closed = true;
9570 break; 9573 break;
9571 } 9574 }
9572 } 9575 }
9573 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9576 while (this._maybeEat(11/*TokenKind.COMMA*/))
9574 if (!closed) { 9577 if (!closed) {
9575 this._eat(53/*TokenKind.GT*/); 9578 this._eat(53/*TokenKind.GT*/);
9576 } 9579 }
9577 return ret; 9580 return ret;
9578 } 9581 }
9579 Parser.prototype.get$typeParameters = function() { 9582 Parser.prototype.get$typeParameters = function() {
9580 return Parser.prototype.typeParameters.bind(this); 9583 return Parser.prototype.typeParameters.bind(this)
9581 } 9584 }
9582 Parser.prototype._eatClosingAngle = function(depth) { 9585 Parser.prototype._eatClosingAngle = function(depth) {
9583 if (this._maybeEat(53/*TokenKind.GT*/)) { 9586 if (this._maybeEat(53/*TokenKind.GT*/)) {
9584 return depth; 9587 return depth;
9585 } 9588 }
9586 else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) { 9589 else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) {
9587 return depth - 1; 9590 return depth - 1;
9588 } 9591 }
9589 else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) { 9592 else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) {
9590 return depth - 2; 9593 return depth - 2;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
9662 } 9665 }
9663 Parser.prototype.type = function(depth) { 9666 Parser.prototype.type = function(depth) {
9664 var typeRef = this.nameTypeReference(); 9667 var typeRef = this.nameTypeReference();
9665 if (this._peekKind(52/*TokenKind.LT*/)) { 9668 if (this._peekKind(52/*TokenKind.LT*/)) {
9666 return this.addTypeArguments(typeRef, depth); 9669 return this.addTypeArguments(typeRef, depth);
9667 } 9670 }
9668 else { 9671 else {
9669 return typeRef; 9672 return typeRef;
9670 } 9673 }
9671 } 9674 }
9675 Parser.prototype.type.$optional = ['depth', '0']
9672 Parser.prototype.get$type = function() { 9676 Parser.prototype.get$type = function() {
9673 return Parser.prototype.type.bind(this); 9677 return Parser.prototype.type.bind(this)
9674 } 9678 }
9675 Parser.prototype.formalParameter = function(inOptionalBlock) { 9679 Parser.prototype.formalParameter = function(inOptionalBlock) {
9676 var start = this._peekToken.start; 9680 var start = this._peekToken.start;
9677 var isThis = false; 9681 var isThis = false;
9678 var isRest = false; 9682 var isRest = false;
9679 var di = this.declaredIdentifier(false); 9683 var di = this.declaredIdentifier(false);
9680 var type = di.get$type(); 9684 var type = di.get$type();
9681 var name = di.get$name(); 9685 var name = di.get$name();
9682 var value = null; 9686 var value = null;
9683 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 9687 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
9781 function DivertedTokenSource(tokens, parser, previousTokenizer) { 9785 function DivertedTokenSource(tokens, parser, previousTokenizer) {
9782 this._pos = 0 9786 this._pos = 0
9783 this.tokens = tokens; 9787 this.tokens = tokens;
9784 this.parser = parser; 9788 this.parser = parser;
9785 this.previousTokenizer = previousTokenizer; 9789 this.previousTokenizer = previousTokenizer;
9786 // Initializers done 9790 // Initializers done
9787 } 9791 }
9788 DivertedTokenSource.prototype.next = function() { 9792 DivertedTokenSource.prototype.next = function() {
9789 var token = this.tokens.$index(this._pos); 9793 var token = this.tokens.$index(this._pos);
9790 ++this._pos; 9794 ++this._pos;
9791 if (this._pos == this.tokens.length) { 9795 if (this._pos == this.tokens.get$length()) {
9792 this.parser.tokenizer = this.previousTokenizer; 9796 this.parser.tokenizer = this.previousTokenizer;
9793 } 9797 }
9794 return token; 9798 return token;
9795 } 9799 }
9796 DivertedTokenSource.prototype.next$0 = DivertedTokenSource.prototype.next; 9800 DivertedTokenSource.prototype.next$0 = DivertedTokenSource.prototype.next;
9797 // ********** Code for Node ************** 9801 // ********** Code for Node **************
9798 function Node(span) { 9802 function Node(span) {
9799 this.span = span; 9803 this.span = span;
9800 // Initializers done 9804 // Initializers done
9801 } 9805 }
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
10775 while (args.hasNext$0() && params.hasNext$0()) { 10779 while (args.hasNext$0() && params.hasNext$0()) {
10776 var typeParam = params.next$0(); 10780 var typeParam = params.next$0();
10777 var typeArg = args.next$0(); 10781 var typeArg = args.next$0();
10778 if (typeParam.get$extendsType() != null && typeArg != null) { 10782 if (typeParam.get$extendsType() != null && typeArg != null) {
10779 typeArg.ensureSubtypeOf$3(typeParam.get$extendsType(), typeParam.get$spa n(), true); 10783 typeArg.ensureSubtypeOf$3(typeParam.get$extendsType(), typeParam.get$spa n(), true);
10780 } 10784 }
10781 } 10785 }
10782 } 10786 }
10783 if (this.get$interfaces() != null) { 10787 if (this.get$interfaces() != null) {
10784 var $$list = this.get$interfaces(); 10788 var $$list = this.get$interfaces();
10785 for (var $$i = 0;$$i < $$list.length; $$i++) { 10789 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
10786 var i = $$list.$index($$i); 10790 var i = $$list.$index($$i);
10787 i._checkExtends$0(); 10791 i._checkExtends$0();
10788 } 10792 }
10789 } 10793 }
10790 } 10794 }
10791 Type.prototype._checkOverride = function(member) { 10795 Type.prototype._checkOverride = function(member) {
10792 var parentMember = this._getMemberInParents(member.name); 10796 var parentMember = this._getMemberInParents(member.name);
10793 if (parentMember != null) { 10797 if (parentMember != null) {
10794 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li brary())) { 10798 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li brary())) {
10795 member.override(parentMember); 10799 member.override(parentMember);
(...skipping 16 matching lines...) Expand all
10812 Type.prototype._getMemberInParents = function(memberName) { 10816 Type.prototype._getMemberInParents = function(memberName) {
10813 if (this.get$isClass()) { 10817 if (this.get$isClass()) {
10814 if (this.get$parent() != null) { 10818 if (this.get$parent() != null) {
10815 return this.get$parent().getMember(memberName); 10819 return this.get$parent().getMember(memberName);
10816 } 10820 }
10817 else { 10821 else {
10818 return null; 10822 return null;
10819 } 10823 }
10820 } 10824 }
10821 else { 10825 else {
10822 if (this.get$interfaces() != null && this.get$interfaces().length > 0) { 10826 if (this.get$interfaces() != null && this.get$interfaces().get$length() > 0) {
10823 var $$list = this.get$interfaces(); 10827 var $$list = this.get$interfaces();
10824 for (var $$i = 0;$$i < $$list.length; $$i++) { 10828 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
10825 var i = $$list.$index($$i); 10829 var i = $$list.$index($$i);
10826 var ret = i.getMember$1(memberName); 10830 var ret = i.getMember$1(memberName);
10827 if (ret != null) { 10831 if (ret != null) {
10828 return ret; 10832 return ret;
10829 } 10833 }
10830 } 10834 }
10831 } 10835 }
10832 return $globals.world.objectType.getMember(memberName); 10836 return $globals.world.objectType.getMember(memberName);
10833 } 10837 }
10834 } 10838 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
10872 $globals.world.warning(msg, span); 10876 $globals.world.warning(msg, span);
10873 } 10877 }
10874 } 10878 }
10875 } 10879 }
10876 Type.prototype.needsVarCall = function(args) { 10880 Type.prototype.needsVarCall = function(args) {
10877 if (this.get$isVarOrFunction()) { 10881 if (this.get$isVarOrFunction()) {
10878 return true; 10882 return true;
10879 } 10883 }
10880 var call = this.getCallMethod(); 10884 var call = this.getCallMethod();
10881 if (call != null) { 10885 if (call != null) {
10882 if (args.get$length() != call.get$parameters().length || !call.namesInOrder$ 1(args)) { 10886 if (args.get$length() != call.get$parameters().get$length() || !call.namesIn Order$1(args)) {
10883 return true; 10887 return true;
10884 } 10888 }
10885 } 10889 }
10886 return false; 10890 return false;
10887 } 10891 }
10888 Type.union = function(x, y) { 10892 Type.union = function(x, y) {
10889 if ($eq(x, y)) return x; 10893 if ($eq(x, y)) return x;
10890 if (x.get$isNum() && y.get$isNum()) return $globals.world.numType; 10894 if (x.get$isNum() && y.get$isNum()) return $globals.world.numType;
10891 if (x.get$isString() && y.get$isString()) return $globals.world.stringType; 10895 if (x.get$isString() && y.get$isString()) return $globals.world.stringType;
10892 return $globals.world.varType; 10896 return $globals.world.varType;
(...skipping 24 matching lines...) Expand all
10917 } 10921 }
10918 if ($eq(this, other)) return true; 10922 if ($eq(this, other)) return true;
10919 if (this.get$isVar()) return true; 10923 if (this.get$isVar()) return true;
10920 if (other.get$isVar()) return true; 10924 if (other.get$isVar()) return true;
10921 if (other._isDirectSupertypeOf(this)) return true; 10925 if (other._isDirectSupertypeOf(this)) return true;
10922 var call = this.getCallMethod(); 10926 var call = this.getCallMethod();
10923 var otherCall = other.getCallMethod(); 10927 var otherCall = other.getCallMethod();
10924 if (call != null && otherCall != null) { 10928 if (call != null && otherCall != null) {
10925 return Type._isFunctionSubtypeOf(call, otherCall); 10929 return Type._isFunctionSubtypeOf(call, otherCall);
10926 } 10930 }
10927 if ($eq(this.get$genericType(), other.get$genericType()) && this.get$typeArgsI nOrder() != null && other.get$typeArgsInOrder() != null && $eq(this.get$typeArgs InOrder().length, other.get$typeArgsInOrder().length)) { 10931 if ($eq(this.get$genericType(), other.get$genericType()) && this.get$typeArgsI nOrder() != null && other.get$typeArgsInOrder() != null && $eq(this.get$typeArgs InOrder().get$length(), other.get$typeArgsInOrder().get$length())) {
10928 var t = this.get$typeArgsInOrder().iterator$0(); 10932 var t = this.get$typeArgsInOrder().iterator$0();
10929 var s = other.get$typeArgsInOrder().iterator$0(); 10933 var s = other.get$typeArgsInOrder().iterator$0();
10930 while (t.hasNext$0()) { 10934 while (t.hasNext$0()) {
10931 if (!t.next$0().isSubtypeOf$1(s.next$0())) return false; 10935 if (!t.next$0().isSubtypeOf$1(s.next$0())) return false;
10932 } 10936 }
10933 return true; 10937 return true;
10934 } 10938 }
10935 if (this.get$parent() != null && this.get$parent().isSubtypeOf(other)) { 10939 if (this.get$parent() != null && this.get$parent().isSubtypeOf(other)) {
10936 return true; 10940 return true;
10937 } 10941 }
(...skipping 12 matching lines...) Expand all
10950 } 10954 }
10951 Type.prototype.$eq = function(other) { 10955 Type.prototype.$eq = function(other) {
10952 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this .get$library(), other.get$library()); 10956 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this .get$library(), other.get$library());
10953 } 10957 }
10954 Type._isFunctionSubtypeOf = function(t, s) { 10958 Type._isFunctionSubtypeOf = function(t, s) {
10955 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) { 10959 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) {
10956 return false; 10960 return false;
10957 } 10961 }
10958 var tp = t.parameters; 10962 var tp = t.parameters;
10959 var sp = s.parameters; 10963 var sp = s.parameters;
10960 if (tp.length < sp.length) return false; 10964 if (tp.get$length() < sp.get$length()) return false;
10961 for (var i = 0; 10965 for (var i = 0;
10962 i < sp.length; i++) { 10966 i < sp.get$length(); i++) {
10963 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur n false; 10967 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur n false;
10964 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index( i).get$name())) return false; 10968 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index( i).get$name())) return false;
10965 if (!tp.$index(i).get$type().isAssignable$1(sp.$index(i).get$type())) return false; 10969 if (!tp.$index(i).get$type().isAssignable$1(sp.$index(i).get$type())) return false;
10966 } 10970 }
10967 if (tp.length > sp.length && !tp.$index(sp.length).get$isOptional()) return fa lse; 10971 if (tp.get$length() > sp.get$length() && !tp.$index(sp.get$length()).get$isOpt ional()) return false;
10968 return true; 10972 return true;
10969 } 10973 }
10970 Type.prototype._checkExtends$0 = Type.prototype._checkExtends; 10974 Type.prototype._checkExtends$0 = Type.prototype._checkExtends;
10971 Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype; 10975 Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype;
10972 Type.prototype.ensureSubtypeOf$3 = Type.prototype.ensureSubtypeOf; 10976 Type.prototype.ensureSubtypeOf$3 = Type.prototype.ensureSubtypeOf;
10973 Type.prototype.getConstructor$1 = Type.prototype.getConstructor; 10977 Type.prototype.getConstructor$1 = Type.prototype.getConstructor;
10974 Type.prototype.getFactory$2 = Type.prototype.getFactory; 10978 Type.prototype.getFactory$2 = Type.prototype.getFactory;
10975 Type.prototype.getMember$1 = Type.prototype.getMember; 10979 Type.prototype.getMember$1 = Type.prototype.getMember;
10976 Type.prototype.getOrMakeConcreteType$1 = Type.prototype.getOrMakeConcreteType; 10980 Type.prototype.getOrMakeConcreteType$1 = Type.prototype.getOrMakeConcreteType;
10977 Type.prototype.hashCode$0 = Type.prototype.hashCode; 10981 Type.prototype.hashCode$0 = Type.prototype.hashCode;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
11195 ConcreteType.prototype.get$members = function() { return this.members; }; 11199 ConcreteType.prototype.get$members = function() { return this.members; };
11196 ConcreteType.prototype.set$members = function(value) { return this.members = val ue; }; 11200 ConcreteType.prototype.set$members = function(value) { return this.members = val ue; };
11197 ConcreteType.prototype.get$constructors = function() { return this.constructors; }; 11201 ConcreteType.prototype.get$constructors = function() { return this.constructors; };
11198 ConcreteType.prototype.set$constructors = function(value) { return this.construc tors = value; }; 11202 ConcreteType.prototype.set$constructors = function(value) { return this.construc tors = value; };
11199 ConcreteType.prototype.get$factories = function() { return this.factories; }; 11203 ConcreteType.prototype.get$factories = function() { return this.factories; };
11200 ConcreteType.prototype.set$factories = function(value) { return this.factories = value; }; 11204 ConcreteType.prototype.set$factories = function(value) { return this.factories = value; };
11201 ConcreteType.prototype.resolveTypeParams = function(inType) { 11205 ConcreteType.prototype.resolveTypeParams = function(inType) {
11202 var newTypeArgs = []; 11206 var newTypeArgs = [];
11203 var needsNewType = false; 11207 var needsNewType = false;
11204 var $$list = this.typeArgsInOrder; 11208 var $$list = this.typeArgsInOrder;
11205 for (var $$i = 0;$$i < $$list.length; $$i++) { 11209 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
11206 var t = $$list.$index($$i); 11210 var t = $$list.$index($$i);
11207 var newType = t.resolveTypeParams$1(inType); 11211 var newType = t.resolveTypeParams$1(inType);
11208 if ($ne(newType, t)) needsNewType = true; 11212 if ($ne(newType, t)) needsNewType = true;
11209 newTypeArgs.add$1(newType); 11213 newTypeArgs.add$1(newType);
11210 } 11214 }
11211 if (!needsNewType) return this; 11215 if (!needsNewType) return this;
11212 return this.genericType.getOrMakeConcreteType(newTypeArgs); 11216 return this.genericType.getOrMakeConcreteType(newTypeArgs);
11213 } 11217 }
11214 ConcreteType.prototype.getOrMakeConcreteType = function(typeArgs) { 11218 ConcreteType.prototype.getOrMakeConcreteType = function(typeArgs) {
11215 return this.genericType.getOrMakeConcreteType(typeArgs); 11219 return this.genericType.getOrMakeConcreteType(typeArgs);
11216 } 11220 }
11217 ConcreteType.prototype.get$parent = function() { 11221 ConcreteType.prototype.get$parent = function() {
11218 if (this._parent == null && this.genericType.get$parent() != null) { 11222 if (this._parent == null && this.genericType.get$parent() != null) {
11219 this._parent = this.genericType.get$parent().resolveTypeParams(this); 11223 this._parent = this.genericType.get$parent().resolveTypeParams(this);
11220 } 11224 }
11221 return this._parent; 11225 return this._parent;
11222 } 11226 }
11223 ConcreteType.prototype.get$interfaces = function() { 11227 ConcreteType.prototype.get$interfaces = function() {
11224 if (this._interfaces == null && this.genericType.interfaces != null) { 11228 if (this._interfaces == null && this.genericType.interfaces != null) {
11225 this._interfaces = []; 11229 this._interfaces = [];
11226 var $$list = this.genericType.interfaces; 11230 var $$list = this.genericType.interfaces;
11227 for (var $$i = 0;$$i < $$list.length; $$i++) { 11231 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
11228 var i = $$list.$index($$i); 11232 var i = $$list.$index($$i);
11229 this._interfaces.add(i.resolveTypeParams$1(this)); 11233 this._interfaces.add(i.resolveTypeParams$1(this));
11230 } 11234 }
11231 } 11235 }
11232 return this._interfaces; 11236 return this._interfaces;
11233 } 11237 }
11234 ConcreteType.prototype.get$subtypes = function() { 11238 ConcreteType.prototype.get$subtypes = function() {
11235 if (this._subtypes == null) { 11239 if (this._subtypes == null) {
11236 this._subtypes = new HashSetImplementation(); 11240 this._subtypes = new HashSetImplementation();
11237 var $$list = this.genericType.get$subtypes(); 11241 var $$list = this.genericType.get$subtypes();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
11373 this._concreteTypes = new HashMapImplementation(); 11377 this._concreteTypes = new HashMapImplementation();
11374 this.typeParameters = this.definition.get$typeParameters(); 11378 this.typeParameters = this.definition.get$typeParameters();
11375 } 11379 }
11376 } 11380 }
11377 DefinedType.prototype.get$nativeType = function() { 11381 DefinedType.prototype.get$nativeType = function() {
11378 return (this.definition != null ? this.definition.get$nativeType() : null); 11382 return (this.definition != null ? this.definition.get$nativeType() : null);
11379 } 11383 }
11380 DefinedType.prototype.get$typeArgsInOrder = function() { 11384 DefinedType.prototype.get$typeArgsInOrder = function() {
11381 if (this.typeParameters == null) return null; 11385 if (this.typeParameters == null) return null;
11382 if (this._typeArgsInOrder == null) { 11386 if (this._typeArgsInOrder == null) {
11383 this._typeArgsInOrder = new FixedCollection_Type($globals.world.varType, thi s.typeParameters.length); 11387 this._typeArgsInOrder = new FixedCollection_Type($globals.world.varType, thi s.typeParameters.get$length());
11384 } 11388 }
11385 return this._typeArgsInOrder; 11389 return this._typeArgsInOrder;
11386 } 11390 }
11387 DefinedType.prototype.get$isVar = function() { 11391 DefinedType.prototype.get$isVar = function() {
11388 return $eq(this, $globals.world.varType); 11392 return $eq(this, $globals.world.varType);
11389 } 11393 }
11390 DefinedType.prototype.get$isVoid = function() { 11394 DefinedType.prototype.get$isVoid = function() {
11391 return $eq(this, $globals.world.voidType); 11395 return $eq(this, $globals.world.voidType);
11392 } 11396 }
11393 DefinedType.prototype.get$isTop = function() { 11397 DefinedType.prototype.get$isTop = function() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
11430 } 11434 }
11431 DefinedType.prototype.getAllMembers = function() { 11435 DefinedType.prototype.getAllMembers = function() {
11432 return HashMapImplementation.HashMapImplementation$from$factory(this.members); 11436 return HashMapImplementation.HashMapImplementation$from$factory(this.members);
11433 } 11437 }
11434 DefinedType.prototype.markUsed = function() { 11438 DefinedType.prototype.markUsed = function() {
11435 if (this.isUsed) return; 11439 if (this.isUsed) return;
11436 this.isUsed = true; 11440 this.isUsed = true;
11437 this._checkExtends(); 11441 this._checkExtends();
11438 if (this._lazyGenMethods != null) { 11442 if (this._lazyGenMethods != null) {
11439 var $$list = orderValuesByKeys(this._lazyGenMethods); 11443 var $$list = orderValuesByKeys(this._lazyGenMethods);
11440 for (var $$i = 0;$$i < $$list.length; $$i++) { 11444 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
11441 var method = $$list.$index($$i); 11445 var method = $$list.$index($$i);
11442 $globals.world.gen.genMethod(method); 11446 $globals.world.gen.genMethod(method);
11443 } 11447 }
11444 this._lazyGenMethods = null; 11448 this._lazyGenMethods = null;
11445 } 11449 }
11446 if (this.get$parent() != null) this.get$parent().markUsed(); 11450 if (this.get$parent() != null) this.get$parent().markUsed();
11447 } 11451 }
11448 DefinedType.prototype.genMethod = function(method) { 11452 DefinedType.prototype.genMethod = function(method) {
11449 if (this.isUsed) { 11453 if (this.isUsed) {
11450 $globals.world.gen.genMethod(method); 11454 $globals.world.gen.genMethod(method);
11451 } 11455 }
11452 else if (this.isClass) { 11456 else if (this.isClass) {
11453 if (this._lazyGenMethods == null) this._lazyGenMethods = new HashMapImplemen tation(); 11457 if (this._lazyGenMethods == null) this._lazyGenMethods = new HashMapImplemen tation();
11454 this._lazyGenMethods.$setindex(method.name, method); 11458 this._lazyGenMethods.$setindex(method.name, method);
11455 } 11459 }
11456 } 11460 }
11457 DefinedType.prototype._resolveInterfaces = function(types) { 11461 DefinedType.prototype._resolveInterfaces = function(types) {
11458 if (types == null) return []; 11462 if (types == null) return [];
11459 var interfaces = []; 11463 var interfaces = [];
11460 for (var $$i = 0;$$i < types.length; $$i++) { 11464 for (var $$i = 0;$$i < types.get$length(); $$i++) {
11461 var type = types.$index($$i); 11465 var type = types.$index($$i);
11462 var resolvedInterface = this.resolveType(type, true); 11466 var resolvedInterface = this.resolveType(type, true);
11463 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this. library.get$isCoreImpl())) { 11467 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this. library.get$isCoreImpl())) {
11464 $globals.world.error(('can not implement "' + resolvedInterface.get$name() + '": ') + 'only native implementation allowed', type.get$span()); 11468 $globals.world.error(('can not implement "' + resolvedInterface.get$name() + '": ') + 'only native implementation allowed', type.get$span());
11465 } 11469 }
11466 resolvedInterface.addDirectSubtype$1(this); 11470 resolvedInterface.addDirectSubtype$1(this);
11467 interfaces.add$1(resolvedInterface); 11471 interfaces.add$1(resolvedInterface);
11468 } 11472 }
11469 return interfaces; 11473 return interfaces;
11470 } 11474 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
11513 if (ancestor.get$interfaces() != null) { 11517 if (ancestor.get$interfaces() != null) {
11514 var $$list = ancestor.get$interfaces(); 11518 var $$list = ancestor.get$interfaces();
11515 for (var $$i = ancestor.get$interfaces().iterator$0(); $$i.hasNext$0(); ) { 11519 for (var $$i = ancestor.get$interfaces().iterator$0(); $$i.hasNext$0(); ) {
11516 var parent = $$i.next$0(); 11520 var parent = $$i.next$0();
11517 if (_helper(parent)) return true; 11521 if (_helper(parent)) return true;
11518 } 11522 }
11519 } 11523 }
11520 return false; 11524 return false;
11521 } 11525 }
11522 for (var i = 0; 11526 for (var i = 0;
11523 i < this.interfaces.length; i++) { 11527 i < this.interfaces.get$length(); i++) {
11524 if (_helper(this.interfaces.$index(i))) return i; 11528 if (_helper(this.interfaces.$index(i))) return i;
11525 } 11529 }
11526 return -1; 11530 return -1;
11527 } 11531 }
11528 DefinedType.prototype.resolve = function() { 11532 DefinedType.prototype.resolve = function() {
11529 if ((this.definition instanceof TypeDefinition)) { 11533 if ((this.definition instanceof TypeDefinition)) {
11530 var typeDef = this.definition; 11534 var typeDef = this.definition;
11531 if (this.isClass) { 11535 if (this.isClass) {
11532 if (typeDef.extendsTypes != null && typeDef.extendsTypes.length > 0) { 11536 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > 0) {
11533 if (typeDef.extendsTypes.length > 1) { 11537 if (typeDef.extendsTypes.get$length() > 1) {
11534 $globals.world.error('more than one base class', typeDef.extendsTypes. $index(1).get$span()); 11538 $globals.world.error('more than one base class', typeDef.extendsTypes. $index(1).get$span());
11535 } 11539 }
11536 var extendsTypeRef = typeDef.extendsTypes.$index(0); 11540 var extendsTypeRef = typeDef.extendsTypes.$index(0);
11537 if ((extendsTypeRef instanceof GenericTypeReference)) { 11541 if ((extendsTypeRef instanceof GenericTypeReference)) {
11538 var g = extendsTypeRef; 11542 var g = extendsTypeRef;
11539 this.set$parent(this.resolveType(g.baseType, true)); 11543 this.set$parent(this.resolveType(g.baseType, true));
11540 } 11544 }
11541 this.set$parent(this.resolveType(extendsTypeRef, true)); 11545 this.set$parent(this.resolveType(extendsTypeRef, true));
11542 if (!this.get$parent().get$isClass()) { 11546 if (!this.get$parent().get$isClass()) {
11543 $globals.world.error('class may not extend an interface - use implemen ts', typeDef.extendsTypes.$index(0).get$span()); 11547 $globals.world.error('class may not extend an interface - use implemen ts', typeDef.extendsTypes.$index(0).get$span());
11544 } 11548 }
11545 this.get$parent().addDirectSubtype(this); 11549 this.get$parent().addDirectSubtype(this);
11546 if (this._cycleInClassExtends()) { 11550 if (this._cycleInClassExtends()) {
11547 $globals.world.error(('class "' + this.name + '" has a cycle in its in heritance chain'), extendsTypeRef.get$span()); 11551 $globals.world.error(('class "' + this.name + '" has a cycle in its in heritance chain'), extendsTypeRef.get$span());
11548 } 11552 }
11549 } 11553 }
11550 else { 11554 else {
11551 if (!this.get$isObject()) { 11555 if (!this.get$isObject()) {
11552 this.set$parent($globals.world.objectType); 11556 this.set$parent($globals.world.objectType);
11553 this.get$parent().addDirectSubtype(this); 11557 this.get$parent().addDirectSubtype(this);
11554 } 11558 }
11555 } 11559 }
11556 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes); 11560 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes);
11557 if (typeDef.factoryType != null) { 11561 if (typeDef.factoryType != null) {
11558 $globals.world.error('factory not allowed on classes', typeDef.factoryTy pe.span); 11562 $globals.world.error('factory not allowed on classes', typeDef.factoryTy pe.span);
11559 } 11563 }
11560 } 11564 }
11561 else { 11565 else {
11562 if (typeDef.implementsTypes != null && typeDef.implementsTypes.length > 0) { 11566 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length( ) > 0) {
11563 $globals.world.error('implements not allowed on interfaces (use extends) ', typeDef.implementsTypes.$index(0).get$span()); 11567 $globals.world.error('implements not allowed on interfaces (use extends) ', typeDef.implementsTypes.$index(0).get$span());
11564 } 11568 }
11565 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes); 11569 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes);
11566 var res = this._cycleInInterfaceExtends(); 11570 var res = this._cycleInInterfaceExtends();
11567 if (res >= 0) { 11571 if (res >= 0) {
11568 $globals.world.error(('interface "' + this.name + '" has a cycle in its inheritance chain'), typeDef.extendsTypes.$index(res).get$span()); 11572 $globals.world.error(('interface "' + this.name + '" has a cycle in its inheritance chain'), typeDef.extendsTypes.$index(res).get$span());
11569 } 11573 }
11570 if (typeDef.factoryType != null) { 11574 if (typeDef.factoryType != null) {
11571 this.factory_ = this.resolveType(typeDef.factoryType, true); 11575 this.factory_ = this.resolveType(typeDef.factoryType, true);
11572 if (this.factory_ == null) { 11576 if (this.factory_ == null) {
11573 $globals.world.warning('unresolved factory', typeDef.factoryType.span) ; 11577 $globals.world.warning('unresolved factory', typeDef.factoryType.span) ;
11574 } 11578 }
11575 } 11579 }
11576 } 11580 }
11577 } 11581 }
11578 else if ((this.definition instanceof FunctionTypeDefinition)) { 11582 else if ((this.definition instanceof FunctionTypeDefinition)) {
11579 this.interfaces = [$globals.world.functionType]; 11583 this.interfaces = [$globals.world.functionType];
11580 } 11584 }
11581 if (this.typeParameters != null) { 11585 if (this.typeParameters != null) {
11582 var $$list = this.typeParameters; 11586 var $$list = this.typeParameters;
11583 for (var $$i = 0;$$i < $$list.length; $$i++) { 11587 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
11584 var tp = $$list.$index($$i); 11588 var tp = $$list.$index($$i);
11585 tp.set$enclosingElement(this); 11589 tp.set$enclosingElement(this);
11586 tp.resolve$0(); 11590 tp.resolve$0();
11587 } 11591 }
11588 } 11592 }
11589 if (this.get$isObject()) this._createNotEqualMember(); 11593 if (this.get$isObject()) this._createNotEqualMember();
11590 $globals.world._addType(this); 11594 $globals.world._addType(this);
11591 var $$list = this.constructors.getValues(); 11595 var $$list = this.constructors.getValues();
11592 for (var $$i = this.constructors.getValues().iterator$0(); $$i.hasNext$0(); ) { 11596 for (var $$i = this.constructors.getValues().iterator$0(); $$i.hasNext$0(); ) {
11593 var c = $$i.next$0(); 11597 var c = $$i.next$0();
(...skipping 20 matching lines...) Expand all
11614 if (methodName == null) methodName = definition.name.name; 11618 if (methodName == null) methodName = definition.name.name;
11615 var method = new MethodMember(methodName, this, definition); 11619 var method = new MethodMember(methodName, this, definition);
11616 if (method.get$isConstructor()) { 11620 if (method.get$isConstructor()) {
11617 if (this.constructors.containsKey(method.get$constructorName())) { 11621 if (this.constructors.containsKey(method.get$constructorName())) {
11618 $globals.world.error(('duplicate constructor definition of ' + method.get$ name()), definition.span); 11622 $globals.world.error(('duplicate constructor definition of ' + method.get$ name()), definition.span);
11619 return; 11623 return;
11620 } 11624 }
11621 this.constructors.$setindex(method.get$constructorName(), method); 11625 this.constructors.$setindex(method.get$constructorName(), method);
11622 return; 11626 return;
11623 } 11627 }
11624 if (definition.modifiers != null && definition.modifiers.length == 1 && $eq(de finition.modifiers.$index(0).get$kind(), 75/*TokenKind.FACTORY*/)) { 11628 if (definition.modifiers != null && definition.modifiers.get$length() == 1 && $eq(definition.modifiers.$index(0).get$kind(), 75/*TokenKind.FACTORY*/)) {
11625 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) { 11629 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) {
11626 $globals.world.error(('duplicate factory definition of "' + method.get$nam e() + '"'), definition.span); 11630 $globals.world.error(('duplicate factory definition of "' + method.get$nam e() + '"'), definition.span);
11627 return; 11631 return;
11628 } 11632 }
11629 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod); 11633 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod);
11630 return; 11634 return;
11631 } 11635 }
11632 if (methodName.startsWith('get:') || methodName.startsWith('set:')) { 11636 if (methodName.startsWith('get:') || methodName.startsWith('set:')) {
11633 var propName = methodName.substring(4); 11637 var propName = methodName.substring(4);
11634 var prop = this.members.$index(propName); 11638 var prop = this.members.$index(propName);
(...skipping 20 matching lines...) Expand all
11655 return; 11659 return;
11656 } 11660 }
11657 if (this.members.containsKey(methodName)) { 11661 if (this.members.containsKey(methodName)) {
11658 $globals.world.error(('duplicate method definition of "' + method.get$name() + '"'), definition.span); 11662 $globals.world.error(('duplicate method definition of "' + method.get$name() + '"'), definition.span);
11659 return; 11663 return;
11660 } 11664 }
11661 this.members.$setindex(methodName, method); 11665 this.members.$setindex(methodName, method);
11662 } 11666 }
11663 DefinedType.prototype.addField = function(definition) { 11667 DefinedType.prototype.addField = function(definition) {
11664 for (var i = 0; 11668 for (var i = 0;
11665 i < definition.names.length; i++) { 11669 i < definition.names.get$length(); i++) {
11666 var name = definition.names.$index(i).get$name(); 11670 var name = definition.names.$index(i).get$name();
11667 if (this.members.containsKey(name)) { 11671 if (this.members.containsKey(name)) {
11668 $globals.world.error(('duplicate field definition of "' + name + '"'), def inition.span); 11672 $globals.world.error(('duplicate field definition of "' + name + '"'), def inition.span);
11669 return; 11673 return;
11670 } 11674 }
11671 var value = null; 11675 var value = null;
11672 if (definition.values != null) { 11676 if (definition.values != null) {
11673 value = definition.values.$index(i); 11677 value = definition.values.$index(i);
11674 } 11678 }
11675 var field = new FieldMember(name, this, definition, value); 11679 var field = new FieldMember(name, this, definition, value);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
11735 return this._getMemberInParents(memberName); 11739 return this._getMemberInParents(memberName);
11736 } 11740 }
11737 DefinedType.prototype.resolveTypeParams = function(inType) { 11741 DefinedType.prototype.resolveTypeParams = function(inType) {
11738 return this; 11742 return this;
11739 } 11743 }
11740 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) { 11744 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) {
11741 var jsnames = []; 11745 var jsnames = [];
11742 var names = []; 11746 var names = [];
11743 var typeMap = new HashMapImplementation(); 11747 var typeMap = new HashMapImplementation();
11744 for (var i = 0; 11748 for (var i = 0;
11745 i < typeArgs.length; i++) { 11749 i < typeArgs.get$length(); i++) {
11746 var paramName = this.typeParameters.$index(i).get$name(); 11750 var paramName = this.typeParameters.$index(i).get$name();
11747 typeMap.$setindex(paramName, typeArgs.$index(i)); 11751 typeMap.$setindex(paramName, typeArgs.$index(i));
11748 names.add$1(typeArgs.$index(i).get$name()); 11752 names.add$1(typeArgs.$index(i).get$name());
11749 jsnames.add$1(typeArgs.$index(i).get$jsname()); 11753 jsnames.add$1(typeArgs.$index(i).get$jsname());
11750 } 11754 }
11751 var jsname = ('' + this.get$jsname() + '_' + Strings.join(jsnames, '\$')); 11755 var jsname = ('' + this.get$jsname() + '_' + Strings.join(jsnames, '\$'));
11752 var simpleName = ('' + this.name + '<' + Strings.join(names, ', ') + '>'); 11756 var simpleName = ('' + this.name + '<' + Strings.join(names, ', ') + '>');
11753 var key = Strings.join(names, '\$'); 11757 var key = Strings.join(names, '\$');
11754 var ret = this._concreteTypes.$index(key); 11758 var ret = this._concreteTypes.$index(key);
11755 if (ret == null) { 11759 if (ret == null) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
11805 } 11809 }
11806 NativeType.prototype.get$name = function() { return this.name; }; 11810 NativeType.prototype.get$name = function() { return this.name; };
11807 NativeType.prototype.set$name = function(value) { return this.name = value; }; 11811 NativeType.prototype.set$name = function(value) { return this.name = value; };
11808 // ********** Code for FixedCollection ************** 11812 // ********** Code for FixedCollection **************
11809 function FixedCollection(value, length) { 11813 function FixedCollection(value, length) {
11810 this.value = value; 11814 this.value = value;
11811 this.length = length; 11815 this.length = length;
11812 // Initializers done 11816 // Initializers done
11813 } 11817 }
11814 FixedCollection.prototype.get$value = function() { return this.value; }; 11818 FixedCollection.prototype.get$value = function() { return this.value; };
11819 FixedCollection.prototype.get$length = function() { return this.length; };
11815 FixedCollection.prototype.iterator = function() { 11820 FixedCollection.prototype.iterator = function() {
11816 return new FixedIterator_E(this.value, this.length); 11821 return new FixedIterator_E(this.value, this.length);
11817 } 11822 }
11818 FixedCollection.prototype.forEach = function(f) { 11823 FixedCollection.prototype.forEach = function(f) {
11819 Collections.forEach(this, f); 11824 Collections.forEach(this, f);
11820 } 11825 }
11821 FixedCollection.prototype.filter = function(f) { 11826 FixedCollection.prototype.filter = function(f) {
11822 return Collections.filter(this, new ListFactory(), f); 11827 return Collections.filter(this, new ListFactory(), f);
11823 } 11828 }
11824 FixedCollection.prototype.every = function(f) { 11829 FixedCollection.prototype.every = function(f) {
(...skipping 27 matching lines...) Expand all
11852 // Initializers done 11857 // Initializers done
11853 } 11858 }
11854 // ********** Code for FixedIterator ************** 11859 // ********** Code for FixedIterator **************
11855 function FixedIterator(value, length) { 11860 function FixedIterator(value, length) {
11856 this._index = 0 11861 this._index = 0
11857 this.value = value; 11862 this.value = value;
11858 this.length = length; 11863 this.length = length;
11859 // Initializers done 11864 // Initializers done
11860 } 11865 }
11861 FixedIterator.prototype.get$value = function() { return this.value; }; 11866 FixedIterator.prototype.get$value = function() { return this.value; };
11867 FixedIterator.prototype.get$length = function() { return this.length; };
11862 FixedIterator.prototype.hasNext = function() { 11868 FixedIterator.prototype.hasNext = function() {
11863 return this._index < this.length; 11869 return this._index < this.length;
11864 } 11870 }
11865 FixedIterator.prototype.next = function() { 11871 FixedIterator.prototype.next = function() {
11866 this._index++; 11872 this._index++;
11867 return this.value; 11873 return this.value;
11868 } 11874 }
11869 FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext; 11875 FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext;
11870 FixedIterator.prototype.next$0 = FixedIterator.prototype.next; 11876 FixedIterator.prototype.next$0 = FixedIterator.prototype.next;
11871 // ********** Code for FixedIterator_E ************** 11877 // ********** Code for FixedIterator_E **************
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
11976 var member = this._resolveMember(context, name, null, true); 11982 var member = this._resolveMember(context, name, null, true);
11977 return member != null && member.canInvoke$2(context, args); 11983 return member != null && member.canInvoke$2(context, args);
11978 } 11984 }
11979 Value.prototype._hasOverriddenNoSuchMethod = function() { 11985 Value.prototype._hasOverriddenNoSuchMethod = function() {
11980 if (this.isSuper) { 11986 if (this.isSuper) {
11981 var m = this.get$type().getMember('noSuchMethod'); 11987 var m = this.get$type().getMember('noSuchMethod');
11982 return m != null && !m.get$declaringType().get$isObject(); 11988 return m != null && !m.get$declaringType().get$isObject();
11983 } 11989 }
11984 else { 11990 else {
11985 var m = this.get$type().resolveMember('noSuchMethod'); 11991 var m = this.get$type().resolveMember('noSuchMethod');
11986 return m != null && m.get$members().length > 1; 11992 return m != null && m.get$members().get$length() > 1;
11987 } 11993 }
11988 } 11994 }
11989 Value.prototype._tryResolveMember = function(context, name) { 11995 Value.prototype._tryResolveMember = function(context, name) {
11990 if (this.isSuper) { 11996 if (this.isSuper) {
11991 return this.get$type().getMember(name); 11997 return this.get$type().getMember(name);
11992 } 11998 }
11993 else { 11999 else {
11994 return this.get$type().resolveMember(name); 12000 return this.get$type().resolveMember(name);
11995 } 12001 }
11996 } 12002 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
12032 $globals.world.error('Types are not first class', span); 12038 $globals.world.error('Types are not first class', span);
12033 } 12039 }
12034 } 12040 }
12035 Value.prototype._varCall = function(context, args) { 12041 Value.prototype._varCall = function(context, args) {
12036 var stub = $globals.world.functionType.getCallStub(args); 12042 var stub = $globals.world.functionType.getCallStub(args);
12037 return new Value($globals.world.varType, ('' + this.code + '.' + stub.get$name () + '(' + args.getCode() + ')'), this.span, true); 12043 return new Value($globals.world.varType, ('' + this.code + '.' + stub.get$name () + '(' + args.getCode() + ')'), this.span, true);
12038 } 12044 }
12039 Value.prototype.needsConversion = function(toType) { 12045 Value.prototype.needsConversion = function(toType) {
12040 var callMethod = toType.getCallMethod(); 12046 var callMethod = toType.getCallMethod();
12041 if (callMethod != null) { 12047 if (callMethod != null) {
12042 var arity = callMethod.get$parameters().length; 12048 var arity = callMethod.get$parameters().get$length();
12043 var myCall = this.get$type().getCallMethod(); 12049 var myCall = this.get$type().getCallMethod();
12044 if (myCall == null || $ne(myCall.get$parameters().length, arity)) { 12050 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) {
12045 return true; 12051 return true;
12046 } 12052 }
12047 } 12053 }
12048 if ($globals.options.enableTypeChecks) { 12054 if ($globals.options.enableTypeChecks) {
12049 var fromType = this.get$type(); 12055 var fromType = this.get$type();
12050 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNul lable())) { 12056 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNul lable())) {
12051 fromType = $globals.world.objectType; 12057 fromType = $globals.world.objectType;
12052 } 12058 }
12053 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); 12059 var bothNum = this.get$type().get$isNum() && toType.get$isNum();
12054 return !(fromType.isSubtypeOf(toType) || bothNum); 12060 return !(fromType.isSubtypeOf(toType) || bothNum);
12055 } 12061 }
12056 return false; 12062 return false;
12057 } 12063 }
12058 Value.prototype.convertTo = function(context, toType, node, isDynamic) { 12064 Value.prototype.convertTo = function(context, toType, node, isDynamic) {
12059 var checked = !isDynamic; 12065 var checked = !isDynamic;
12060 var callMethod = toType.getCallMethod(); 12066 var callMethod = toType.getCallMethod();
12061 if (callMethod != null) { 12067 if (callMethod != null) {
12062 if (checked && !toType.isAssignable(this.get$type())) { 12068 if (checked && !toType.isAssignable(this.get$type())) {
12063 this.convertWarning(toType, node); 12069 this.convertWarning(toType, node);
12064 } 12070 }
12065 var arity = callMethod.get$parameters().length; 12071 var arity = callMethod.get$parameters().get$length();
12066 var myCall = this.get$type().getCallMethod(); 12072 var myCall = this.get$type().getCallMethod();
12067 if (myCall == null || $ne(myCall.get$parameters().length, arity)) { 12073 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) {
12068 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bar e$factory(arity)); 12074 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bar e$factory(arity));
12069 var val = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'), node.span, true); 12075 var val = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'), node.span, true);
12070 return this._isDomCallback(toType) && !this._isDomCallback(this.get$type() ) ? val._wrapDomCallback$2(toType, arity) : val; 12076 return this._isDomCallback(toType) && !this._isDomCallback(this.get$type() ) ? val._wrapDomCallback$2(toType, arity) : val;
12071 } 12077 }
12072 else if (this._isDomCallback(toType) && !this._isDomCallback(this.get$type() )) { 12078 else if (this._isDomCallback(toType) && !this._isDomCallback(this.get$type() )) {
12073 return this._wrapDomCallback(toType, arity); 12079 return this._wrapDomCallback(toType, arity);
12074 } 12080 }
12075 } 12081 }
12076 var fromType = this.get$type(); 12082 var fromType = this.get$type();
12077 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNulla ble())) { 12083 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNulla ble())) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
12276 function ConstMapValue() {} 12282 function ConstMapValue() {}
12277 ConstMapValue._internal$ctor = function(type, values, actualValue, canonicalCode , span, code) { 12283 ConstMapValue._internal$ctor = function(type, values, actualValue, canonicalCode , span, code) {
12278 this.values = values; 12284 this.values = values;
12279 // Initializers done 12285 // Initializers done
12280 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12286 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code);
12281 } 12287 }
12282 ConstMapValue._internal$ctor.prototype = ConstMapValue.prototype; 12288 ConstMapValue._internal$ctor.prototype = ConstMapValue.prototype;
12283 ConstMapValue.ConstMapValue$factory = function(type, keyValuePairs, actualValue, canonicalCode, span) { 12289 ConstMapValue.ConstMapValue$factory = function(type, keyValuePairs, actualValue, canonicalCode, span) {
12284 var values = new HashMapImplementation(); 12290 var values = new HashMapImplementation();
12285 for (var i = 0; 12291 for (var i = 0;
12286 i < keyValuePairs.length; i += 2) { 12292 i < keyValuePairs.get$length(); i += 2) {
12287 values.$setindex(keyValuePairs.$index(i).get$actualValue(), keyValuePairs.$i ndex(i + 1)); 12293 values.$setindex(keyValuePairs.$index(i).get$actualValue(), keyValuePairs.$i ndex(i + 1));
12288 } 12294 }
12289 return new ConstMapValue._internal$ctor(type, values, actualValue, canonicalCo de, span, EvaluatedValue.codeWithComments(canonicalCode, span)); 12295 return new ConstMapValue._internal$ctor(type, values, actualValue, canonicalCo de, span, EvaluatedValue.codeWithComments(canonicalCode, span));
12290 } 12296 }
12291 ConstMapValue.prototype.get$values = function() { return this.values; }; 12297 ConstMapValue.prototype.get$values = function() { return this.values; };
12292 ConstMapValue.prototype.set$values = function(value) { return this.values = valu e; }; 12298 ConstMapValue.prototype.set$values = function(value) { return this.values = valu e; };
12293 // ********** Code for ConstObjectValue ************** 12299 // ********** Code for ConstObjectValue **************
12294 $inherits(ConstObjectValue, EvaluatedValue); 12300 $inherits(ConstObjectValue, EvaluatedValue);
12295 function ConstObjectValue() {} 12301 function ConstObjectValue() {}
12296 ConstObjectValue._internal$ctor = function(type, fields, actualValue, canonicalC ode, span, code) { 12302 ConstObjectValue._internal$ctor = function(type, fields, actualValue, canonicalC ode, span, code) {
(...skipping 21 matching lines...) Expand all
12318 // ********** Code for GlobalValue ************** 12324 // ********** Code for GlobalValue **************
12319 $inherits(GlobalValue, Value); 12325 $inherits(GlobalValue, Value);
12320 function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) { 12326 function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) {
12321 this.field = field; 12327 this.field = field;
12322 this.name = name; 12328 this.name = name;
12323 this.exp = exp; 12329 this.exp = exp;
12324 this.canonicalCode = canonicalCode; 12330 this.canonicalCode = canonicalCode;
12325 this.dependencies = []; 12331 this.dependencies = [];
12326 // Initializers done 12332 // Initializers done
12327 Value.call(this, type, code, span, !isConst); 12333 Value.call(this, type, code, span, !isConst);
12328 for (var $$i = 0;$$i < _dependencies.length; $$i++) { 12334 for (var $$i = 0;$$i < _dependencies.get$length(); $$i++) {
12329 var dep = _dependencies.$index($$i); 12335 var dep = _dependencies.$index($$i);
12330 this.dependencies.add(dep); 12336 this.dependencies.add(dep);
12331 this.dependencies.addAll(dep.get$dependencies()); 12337 this.dependencies.addAll(dep.get$dependencies());
12332 } 12338 }
12333 } 12339 }
12334 GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) { 12340 GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) {
12335 var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code); 12341 var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code);
12336 var codeWithComment = ('' + code + '/*' + field.get$declaringType().get$name() + '.' + field.get$name() + '*/'); 12342 var codeWithComment = ('' + code + '/*' + field.get$declaringType().get$name() + '.' + field.get$name() + '*/');
12337 return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), f ield, null, exp, code, exp.span, dependencies.filter$1((function (d) { 12343 return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), f ield, null, exp, code, exp.span, dependencies.filter$1((function (d) {
12338 return (d instanceof GlobalValue); 12344 return (d instanceof GlobalValue);
(...skipping 27 matching lines...) Expand all
12366 GlobalValue.prototype.compareTo = function(other) { 12372 GlobalValue.prototype.compareTo = function(other) {
12367 if ($eq(other, this)) { 12373 if ($eq(other, this)) {
12368 return 0; 12374 return 0;
12369 } 12375 }
12370 else if (this.dependencies.indexOf(other) >= 0) { 12376 else if (this.dependencies.indexOf(other) >= 0) {
12371 return 1; 12377 return 1;
12372 } 12378 }
12373 else if (other.dependencies.indexOf(this) >= 0) { 12379 else if (other.dependencies.indexOf(this) >= 0) {
12374 return -1; 12380 return -1;
12375 } 12381 }
12376 else if (this.dependencies.length > other.dependencies.length) { 12382 else if (this.dependencies.get$length() > other.dependencies.get$length()) {
12377 return 1; 12383 return 1;
12378 } 12384 }
12379 else if (this.dependencies.length < other.dependencies.length) { 12385 else if (this.dependencies.get$length() < other.dependencies.get$length()) {
12380 return -1; 12386 return -1;
12381 } 12387 }
12382 else if (this.name == null && other.name != null) { 12388 else if (this.name == null && other.name != null) {
12383 return 1; 12389 return 1;
12384 } 12390 }
12385 else if (this.name != null && other.name == null) { 12391 else if (this.name != null && other.name == null) {
12386 return -1; 12392 return -1;
12387 } 12393 }
12388 else if (this.name != null) { 12394 else if (this.name != null) {
12389 return this.name.compareTo(other.name); 12395 return this.name.compareTo(other.name);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
12638 }) 12644 })
12639 )) { 12645 )) {
12640 library.imports.add(new LibraryImport(this.corelib)); 12646 library.imports.add(new LibraryImport(this.corelib));
12641 } 12647 }
12642 this.libraries.$setindex(filename, library); 12648 this.libraries.$setindex(filename, library);
12643 this._todo.add(library); 12649 this._todo.add(library);
12644 } 12650 }
12645 return library; 12651 return library;
12646 } 12652 }
12647 World.prototype.process = function() { 12653 World.prototype.process = function() {
12648 while (this._todo.length > 0) { 12654 while (this._todo.get$length() > 0) {
12649 var todo = this._todo; 12655 var todo = this._todo;
12650 this._todo = []; 12656 this._todo = [];
12651 for (var $$i = 0;$$i < todo.length; $$i++) { 12657 for (var $$i = 0;$$i < todo.get$length(); $$i++) {
12652 var lib = todo.$index($$i); 12658 var lib = todo.$index($$i);
12653 lib.visitSources$0(); 12659 lib.visitSources$0();
12654 } 12660 }
12655 } 12661 }
12656 } 12662 }
12657 World.prototype.processDartScript = function(script) { 12663 World.prototype.processDartScript = function(script) {
12658 if (script == null) script = $globals.options.dartScript; 12664 if (script == null) script = $globals.options.dartScript;
12659 var library = this.getOrAddLibrary(script); 12665 var library = this.getOrAddLibrary(script);
12660 this.process(); 12666 this.process();
12661 return library; 12667 return library;
12662 } 12668 }
12663 World.prototype.resolveAll = function() { 12669 World.prototype.resolveAll = function() {
12664 var $$list = this.libraries.getValues(); 12670 var $$list = this.libraries.getValues();
12665 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) { 12671 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) {
12666 var lib = $$i.next$0(); 12672 var lib = $$i.next$0();
12667 lib.resolve$0(); 12673 lib.resolve$0();
12668 } 12674 }
12669 } 12675 }
12670 World.prototype.get$resolveAll = function() { 12676 World.prototype.get$resolveAll = function() {
12671 return World.prototype.resolveAll.bind(this); 12677 return World.prototype.resolveAll.bind(this)
12672 } 12678 }
12673 World.prototype.generateCode = function(lib) { 12679 World.prototype.generateCode = function(lib) {
12674 var mainMembers = lib.topType.resolveMember('main'); 12680 var mainMembers = lib.topType.resolveMember('main');
12675 var main = null; 12681 var main = null;
12676 if (mainMembers == null || $eq(mainMembers.get$members().length, 0)) { 12682 if (mainMembers == null || $eq(mainMembers.get$members().get$length(), 0)) {
12677 this.fatal('no main method specified'); 12683 this.fatal('no main method specified');
12678 } 12684 }
12679 else if (mainMembers.get$members().length > 1) { 12685 else if (mainMembers.get$members().get$length() > 1) {
12680 var $$list = mainMembers.get$members(); 12686 var $$list = mainMembers.get$members();
12681 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) { 12687 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) {
12682 var m = $$i.next$0(); 12688 var m = $$i.next$0();
12683 main = m; 12689 main = m;
12684 this.error('more than one main member (using last?)', main.get$span()); 12690 this.error('more than one main member (using last?)', main.get$span());
12685 } 12691 }
12686 } 12692 }
12687 else { 12693 else {
12688 main = mainMembers.get$members().$index(0); 12694 main = mainMembers.get$members().$index(0);
12689 } 12695 }
12690 var codeWriter = new CodeWriter(); 12696 var codeWriter = new CodeWriter();
12691 this.gen = new WorldGenerator(main, codeWriter); 12697 this.gen = new WorldGenerator(main, codeWriter);
12692 this.gen.run(); 12698 this.gen.run();
12693 this.jsBytesWritten = codeWriter.get$text().length; 12699 this.jsBytesWritten = codeWriter.get$text().get$length();
12694 } 12700 }
12695 World.prototype._message = function(color, prefix, message, span, span1, span2, throwing) { 12701 World.prototype._message = function(color, prefix, message, span, span1, span2, throwing) {
12696 if (this.messageHandler != null) { 12702 if (this.messageHandler != null) {
12697 this.messageHandler(prefix, message, span); 12703 this.messageHandler(prefix, message, span);
12698 if (span1 != null) { 12704 if (span1 != null) {
12699 this.messageHandler(prefix, message, span1); 12705 this.messageHandler(prefix, message, span1);
12700 } 12706 }
12701 if (span2 != null) { 12707 if (span2 != null) {
12702 this.messageHandler(prefix, message, span2); 12708 this.messageHandler(prefix, message, span2);
12703 } 12709 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
12807 } 12813 }
12808 else { 12814 else {
12809 $globals.world.error(('Invalid configuration ' + this.config)); 12815 $globals.world.error(('Invalid configuration ' + this.config));
12810 $throw(('Invalid configuration')); 12816 $throw(('Invalid configuration'));
12811 } 12817 }
12812 var ignoreUnrecognizedFlags = false; 12818 var ignoreUnrecognizedFlags = false;
12813 var passedLibDir = false; 12819 var passedLibDir = false;
12814 this.childArgs = []; 12820 this.childArgs = [];
12815 loop: 12821 loop:
12816 for (var i = 2; 12822 for (var i = 2;
12817 i < args.length; i++) { 12823 i < args.get$length(); i++) {
12818 var arg = args.$index(i); 12824 var arg = args.$index(i);
12819 switch (arg) { 12825 switch (arg) {
12820 case '--enable_leg': 12826 case '--enable_leg':
12821 12827
12822 this.enableLeg = true; 12828 this.enableLeg = true;
12823 break; 12829 break;
12824 12830
12825 case '--leg_only': 12831 case '--leg_only':
12826 12832
12827 this.enableLeg = true; 12833 this.enableLeg = true;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
12896 12902
12897 case '--no_colors': 12903 case '--no_colors':
12898 12904
12899 this.useColors = false; 12905 this.useColors = false;
12900 break; 12906 break;
12901 12907
12902 default: 12908 default:
12903 12909
12904 if (arg.endsWith$1('.dart')) { 12910 if (arg.endsWith$1('.dart')) {
12905 this.dartScript = arg; 12911 this.dartScript = arg;
12906 this.childArgs = args.getRange(i + 1, args.length - i - 1); 12912 this.childArgs = args.getRange(i + 1, args.get$length() - i - 1);
12907 break loop; 12913 break loop;
12908 } 12914 }
12909 else if (arg.startsWith$1('--out=')) { 12915 else if (arg.startsWith$1('--out=')) {
12910 this.outfile = arg.substring$1('--out='.length); 12916 this.outfile = arg.substring$1('--out='.length);
12911 } 12917 }
12912 else if (arg.startsWith$1('--libdir=')) { 12918 else if (arg.startsWith$1('--libdir=')) {
12913 this.libDir = arg.substring$1('--libdir='.length); 12919 this.libDir = arg.substring$1('--libdir='.length);
12914 passedLibDir = true; 12920 passedLibDir = true;
12915 } 12921 }
12916 else { 12922 else {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
13054 code.exitBlock('};'); 13060 code.exitBlock('};');
13055 } 13061 }
13056 } 13062 }
13057 VarMethodStub.prototype._needsExactTypeCheck = function() { 13063 VarMethodStub.prototype._needsExactTypeCheck = function() {
13058 var $this = this; // closure support 13064 var $this = this; // closure support
13059 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse; 13065 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse;
13060 var members = this.member.declaringType.resolveMember(this.member.name).member s; 13066 var members = this.member.declaringType.resolveMember(this.member.name).member s;
13061 return members.filter$1((function (m) { 13067 return members.filter$1((function (m) {
13062 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( ); 13068 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( );
13063 }) 13069 })
13064 ).length >= 1; 13070 ).get$length() >= 1;
13065 } 13071 }
13066 VarMethodStub.prototype._useDirectCall = function(args) { 13072 VarMethodStub.prototype._useDirectCall = function(args) {
13067 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) { 13073 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) {
13068 var method = this.member; 13074 var method = this.member;
13069 if (method.needsArgumentConversion(args)) { 13075 if (method.needsArgumentConversion(args)) {
13070 return false; 13076 return false;
13071 } 13077 }
13072 for (var i = args.get$length(); 13078 for (var i = args.get$length();
13073 i < method.parameters.length; i++) { 13079 i < method.parameters.get$length(); i++) {
13074 if ($ne(method.parameters.$index(i).get$value().get$code(), 'null')) { 13080 if ($ne(method.parameters.$index(i).get$value().get$code(), 'null')) {
13075 return false; 13081 return false;
13076 } 13082 }
13077 } 13083 }
13078 return method.namesInOrder(args); 13084 return method.namesInOrder(args);
13079 } 13085 }
13080 else { 13086 else {
13081 return false; 13087 return false;
13082 } 13088 }
13083 } 13089 }
(...skipping 13 matching lines...) Expand all
13097 VarMethodSet.prototype.get$returnType = function() { return this.returnType; }; 13103 VarMethodSet.prototype.get$returnType = function() { return this.returnType; };
13098 VarMethodSet.prototype.invoke = function(context, node, target, args) { 13104 VarMethodSet.prototype.invoke = function(context, node, target, args) {
13099 this._invokeMembers(context, node); 13105 this._invokeMembers(context, node);
13100 return VarMember.prototype.invoke.call(this, context, node, target, args); 13106 return VarMember.prototype.invoke.call(this, context, node, target, args);
13101 } 13107 }
13102 VarMethodSet.prototype._invokeMembers = function(context, node) { 13108 VarMethodSet.prototype._invokeMembers = function(context, node) {
13103 if (this.invoked) return; 13109 if (this.invoked) return;
13104 this.invoked = true; 13110 this.invoked = true;
13105 var hasObjectType = false; 13111 var hasObjectType = false;
13106 var $$list = this.members; 13112 var $$list = this.members;
13107 for (var $$i = 0;$$i < $$list.length; $$i++) { 13113 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
13108 var member = $$list.$index($$i); 13114 var member = $$list.$index($$i);
13109 var type = member.get$declaringType(); 13115 var type = member.get$declaringType();
13110 var target = new Value(type, 'this', node.span, true); 13116 var target = new Value(type, 'this', node.span, true);
13111 var result = member.invoke$4$isDynamic(context, node, target, this.args, tru e); 13117 var result = member.invoke$4$isDynamic(context, node, target, this.args, tru e);
13112 var stub = new VarMethodStub(this.name, member, this.args, 'return ' + resul t.get$code()); 13118 var stub = new VarMethodStub(this.name, member, this.args, 'return ' + resul t.get$code());
13113 type.get$varStubs().$setindex(stub.get$name(), stub); 13119 type.get$varStubs().$setindex(stub.get$name(), stub);
13114 if (type.get$isObject()) hasObjectType = true; 13120 if (type.get$isObject()) hasObjectType = true;
13115 } 13121 }
13116 if (!hasObjectType) { 13122 if (!hasObjectType) {
13117 var target = new Value($globals.world.objectType, 'this', node.span, true); 13123 var target = new Value($globals.world.objectType, 'this', node.span, true);
13118 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs); 13124 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs);
13119 var stub = new VarMethodStub(this.name, null, this.args, 'return ' + result. get$code()); 13125 var stub = new VarMethodStub(this.name, null, this.args, 'return ' + result. get$code());
13120 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub); 13126 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub);
13121 } 13127 }
13122 } 13128 }
13123 VarMethodSet.prototype.generate = function(code) { 13129 VarMethodSet.prototype.generate = function(code) {
13124 13130
13125 } 13131 }
13126 VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate; 13132 VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate;
13127 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke; 13133 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke;
13128 // ********** Code for top level ************** 13134 // ********** Code for top level **************
13129 function _otherOperator(jsname, op) { 13135 function _otherOperator(jsname, op) {
13130 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}"); 13136 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}");
13131 } 13137 }
13132 function map(source, mapper) { 13138 function map(source, mapper) {
13133 var result = new ListFactory(); 13139 var result = new ListFactory();
13134 if (!!(source && source.is$List())) { 13140 if (!!(source && source.is$List())) {
13135 var list = source; 13141 var list = source;
13136 result.length = list.length; 13142 result.set$length(list.get$length());
13137 for (var i = 0; 13143 for (var i = 0;
13138 i < list.length; i++) { 13144 i < list.get$length(); i++) {
13139 result.$setindex(i, mapper(list.$index(i))); 13145 result.$setindex(i, mapper(list.$index(i)));
13140 } 13146 }
13141 } 13147 }
13142 else { 13148 else {
13143 for (var $$i = source.iterator(); $$i.hasNext$0(); ) { 13149 for (var $$i = source.iterator(); $$i.hasNext$0(); ) {
13144 var item = $$i.next$0(); 13150 var item = $$i.next$0();
13145 result.add(mapper(item)); 13151 result.add(mapper(item));
13146 } 13152 }
13147 } 13153 }
13148 return result; 13154 return result;
13149 } 13155 }
13150 function reduce(source, callback, initialValue) { 13156 function reduce(source, callback, initialValue) {
13151 var i = source.iterator(); 13157 var i = source.iterator();
13152 var current = initialValue; 13158 var current = initialValue;
13153 if (current == null && i.hasNext$0()) { 13159 if (current == null && i.hasNext$0()) {
13154 current = i.next$0(); 13160 current = i.next$0();
13155 } 13161 }
13156 while (i.hasNext$0()) { 13162 while (i.hasNext$0()) {
13157 current = callback.call$2(current, i.next$0()); 13163 current = callback.call$2(current, i.next$0());
13158 } 13164 }
13159 return current; 13165 return current;
13160 } 13166 }
13161 function orderValuesByKeys(map) { 13167 function orderValuesByKeys(map) {
13162 var keys = map.getKeys(); 13168 var keys = map.getKeys();
13163 keys.sort((function (x, y) { 13169 keys.sort((function (x, y) {
13164 return x.compareTo$1(y); 13170 return x.compareTo$1(y);
13165 }) 13171 })
13166 ); 13172 );
13167 var values = []; 13173 var values = [];
13168 for (var $$i = 0;$$i < keys.length; $$i++) { 13174 for (var $$i = 0;$$i < keys.get$length(); $$i++) {
13169 var k = keys.$index($$i); 13175 var k = keys.$index($$i);
13170 values.add(map.$index(k)); 13176 values.add(map.$index(k));
13171 } 13177 }
13172 return values; 13178 return values;
13173 } 13179 }
13174 function isMultilineString(text) { 13180 function isMultilineString(text) {
13175 return text.startsWith('"""') || text.startsWith("'''"); 13181 return text.startsWith('"""') || text.startsWith("'''");
13176 } 13182 }
13177 function isRawMultilineString(text) { 13183 function isRawMultilineString(text) {
13178 return text.startsWith('@"""') || text.startsWith("@'''"); 13184 return text.startsWith('@"""') || text.startsWith("@'''");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
13252 nameBuilder.add('\$').add(args.getName(i)); 13258 nameBuilder.add('\$').add(args.getName(i));
13253 } 13259 }
13254 return nameBuilder.toString(); 13260 return nameBuilder.toString();
13255 } 13261 }
13256 // ********** Library minfrog ************** 13262 // ********** Library minfrog **************
13257 // ********** Code for top level ************** 13263 // ********** Code for top level **************
13258 function main() { 13264 function main() {
13259 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1))); 13265 var homedir = path.dirname(fs.realpathSync(process.argv.$index(1)));
13260 var argv = []; 13266 var argv = [];
13261 for (var i = 0; 13267 for (var i = 0;
13262 i < process.argv.length; i++) { 13268 i < process.argv.get$length(); i++) {
13263 argv.add$1(process.argv.$index(i)); 13269 argv.add$1(process.argv.$index(i));
13264 if (i == 1) { 13270 if (i == 1) {
13265 var terminal = process.get$env().$index('TERM'); 13271 var terminal = process.get$env().$index('TERM');
13266 if (terminal == null || !terminal.startsWith$1('xterm')) { 13272 if (terminal == null || !terminal.startsWith$1('xterm')) {
13267 argv.add$1('--no_colors'); 13273 argv.add$1('--no_colors');
13268 } 13274 }
13269 } 13275 }
13270 } 13276 }
13271 if (compile(homedir, argv, new NodeFileSystem())) { 13277 if (compile(homedir, argv, new NodeFileSystem())) {
13272 var code = $globals.world.getGeneratedCode(); 13278 var code = $globals.world.getGeneratedCode();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
13306 $globals._NO_COLOR = '\u001b[0m'; 13312 $globals._NO_COLOR = '\u001b[0m';
13307 $globals._RED_COLOR = '\u001b[31m'; 13313 $globals._RED_COLOR = '\u001b[31m';
13308 } 13314 }
13309 var const$0 = new EnvMap()/*const EnvMap()*/; 13315 var const$0 = new EnvMap()/*const EnvMap()*/;
13310 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; 13316 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;
13311 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 13317 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
13312 var const$8 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 13318 var const$8 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
13313 var $globals = {}; 13319 var $globals = {};
13314 $static_init(); 13320 $static_init();
13315 main(); 13321 main();
OLDNEW
« no previous file with comments | « frog/member.dart ('k') | frog/tests/frog/frog.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698