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

Side by Side Diff: frog/minfrog

Issue 9143001: Fixes 2 tests and a crash (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/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 function $throw(e) { 4 function $throw(e) {
5 // If e is not a value, we can use V8's captureStackTrace utility method. 5 // If e is not a value, we can use V8's captureStackTrace utility method.
6 // TODO(jmesserly): capture the stack trace on other JS engines. 6 // TODO(jmesserly): capture the stack trace on other JS engines.
7 if (e && (typeof e == 'object') && Error.captureStackTrace) { 7 if (e && (typeof e == 'object') && Error.captureStackTrace) {
8 // TODO(jmesserly): this will clobber the e.stack property 8 // TODO(jmesserly): this will clobber the e.stack property
9 Error.captureStackTrace(e, $throw); 9 Error.captureStackTrace(e, $throw);
10 } 10 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }; 108 };
109 Object.prototype.addDirectSubtype$1 = function($0) { 109 Object.prototype.addDirectSubtype$1 = function($0) {
110 return this.noSuchMethod("addDirectSubtype", [$0]); 110 return this.noSuchMethod("addDirectSubtype", [$0]);
111 }; 111 };
112 Object.prototype.addMethod$2 = function($0, $1) { 112 Object.prototype.addMethod$2 = function($0, $1) {
113 return this.noSuchMethod("addMethod", [$0, $1]); 113 return this.noSuchMethod("addMethod", [$0, $1]);
114 }; 114 };
115 Object.prototype.addSource$1 = function($0) { 115 Object.prototype.addSource$1 = function($0) {
116 return this.noSuchMethod("addSource", [$0]); 116 return this.noSuchMethod("addSource", [$0]);
117 }; 117 };
118 Object.prototype.binop$4 = function($0, $1, $2, $3) {
119 return this.noSuchMethod("binop", [$0, $1, $2, $3]);
120 };
118 Object.prototype.block$0 = function() { 121 Object.prototype.block$0 = function() {
119 return this.noSuchMethod("block", []); 122 return this.noSuchMethod("block", []);
120 }; 123 };
121 Object.prototype.canInvoke$2 = function($0, $1) { 124 Object.prototype.canInvoke$2 = function($0, $1) {
122 return this.noSuchMethod("canInvoke", [$0, $1]); 125 return this.noSuchMethod("canInvoke", [$0, $1]);
123 }; 126 };
124 Object.prototype.checkFirstClass$1 = function($0) { 127 Object.prototype.checkFirstClass$1 = function($0) {
125 return this.noSuchMethod("checkFirstClass", [$0]); 128 return this.noSuchMethod("checkFirstClass", [$0]);
126 }; 129 };
127 Object.prototype.compareTo$1 = function($0) { 130 Object.prototype.compareTo$1 = function($0) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 }; 177 };
175 Object.prototype.getColumn$2 = function($0, $1) { 178 Object.prototype.getColumn$2 = function($0, $1) {
176 return this.noSuchMethod("getColumn", [$0, $1]); 179 return this.noSuchMethod("getColumn", [$0, $1]);
177 }; 180 };
178 Object.prototype.getConstructor$1 = function($0) { 181 Object.prototype.getConstructor$1 = function($0) {
179 return this.noSuchMethod("getConstructor", [$0]); 182 return this.noSuchMethod("getConstructor", [$0]);
180 }; 183 };
181 Object.prototype.getFactory$2 = function($0, $1) { 184 Object.prototype.getFactory$2 = function($0, $1) {
182 return this.noSuchMethod("getFactory", [$0, $1]); 185 return this.noSuchMethod("getFactory", [$0, $1]);
183 }; 186 };
187 Object.prototype.getGlobalValue$0 = function() {
188 return this.noSuchMethod("getGlobalValue", []);
189 };
184 Object.prototype.getKeys$0 = function() { 190 Object.prototype.getKeys$0 = function() {
185 return this.noSuchMethod("getKeys", []); 191 return this.noSuchMethod("getKeys", []);
186 }; 192 };
187 Object.prototype.getLine$1 = function($0) { 193 Object.prototype.getLine$1 = function($0) {
188 return this.noSuchMethod("getLine", [$0]); 194 return this.noSuchMethod("getLine", [$0]);
189 }; 195 };
190 Object.prototype.getMember$1 = function($0) { 196 Object.prototype.getMember$1 = function($0) {
191 return this.noSuchMethod("getMember", [$0]); 197 return this.noSuchMethod("getMember", [$0]);
192 }; 198 };
193 Object.prototype.getOrMakeConcreteType$1 = function($0) { 199 Object.prototype.getOrMakeConcreteType$1 = function($0) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 }; 297 };
292 Object.prototype.startsWith$1 = function($0) { 298 Object.prototype.startsWith$1 = function($0) {
293 return this.noSuchMethod("startsWith", [$0]); 299 return this.noSuchMethod("startsWith", [$0]);
294 }; 300 };
295 Object.prototype.substring$1 = function($0) { 301 Object.prototype.substring$1 = function($0) {
296 return this.noSuchMethod("substring", [$0]); 302 return this.noSuchMethod("substring", [$0]);
297 }; 303 };
298 Object.prototype.substring$2 = function($0, $1) { 304 Object.prototype.substring$2 = function($0, $1) {
299 return this.noSuchMethod("substring", [$0, $1]); 305 return this.noSuchMethod("substring", [$0, $1]);
300 }; 306 };
307 Object.prototype.toDouble$0 = function() {
308 return this.noSuchMethod("toDouble", []);
309 };
310 Object.prototype.toInt$0 = function() {
311 return this.noSuchMethod("toInt", []);
312 };
301 Object.prototype.toRadixString$1 = function($0) { 313 Object.prototype.toRadixString$1 = function($0) {
302 return this.noSuchMethod("toRadixString", [$0]); 314 return this.noSuchMethod("toRadixString", [$0]);
303 }; 315 };
304 Object.prototype.toString$0 = function() { 316 Object.prototype.toString$0 = function() {
305 return this.toString(); 317 return this.toString();
306 }; 318 };
307 Object.prototype.visit$1 = function($0) { 319 Object.prototype.visit$1 = function($0) {
308 return this.noSuchMethod("visit", [$0]); 320 return this.noSuchMethod("visit", [$0]);
309 }; 321 };
310 Object.prototype.visitBinaryExpression$1 = function($0) { 322 Object.prototype.visitBinaryExpression$1 = function($0) {
311 return this.noSuchMethod("visitBinaryExpression", [$0]); 323 return this.noSuchMethod("visitBinaryExpression", [$0]);
312 }; 324 };
313 Object.prototype.visitPostfixExpression$1 = function($0) { 325 Object.prototype.visitPostfixExpression$1 = function($0) {
314 return this.noSuchMethod("visitPostfixExpression", [$0]); 326 return this.noSuchMethod("visitPostfixExpression", [$0]);
315 }; 327 };
316 Object.prototype.visitSources$0 = function() { 328 Object.prototype.visitSources$0 = function() {
317 return this.noSuchMethod("visitSources", []); 329 return this.noSuchMethod("visitSources", []);
318 }; 330 };
319 Object.prototype.writeDefinition$2 = function($0, $1) { 331 Object.prototype.writeDefinition$2 = function($0, $1) {
320 return this.noSuchMethod("writeDefinition", [$0, $1]); 332 return this.noSuchMethod("writeDefinition", [$0, $1]);
321 }; 333 };
322 // ********** Code for Clock ************** 334 // ********** Code for Clock **************
323 function Clock() {} 335 function Clock() {}
324 Clock.now = function() { 336 Clock.now = function() {
325 return new Date().getTime(); 337 return new Date().getTime();
326 } 338 }
327 Clock.frequency = function() { 339 Clock.frequency = function() {
328 return 1000; 340 return (1000);
329 } 341 }
330 // ********** Code for IllegalAccessException ************** 342 // ********** Code for IllegalAccessException **************
331 function IllegalAccessException() { 343 function IllegalAccessException() {
332 // Initializers done 344 // Initializers done
333 } 345 }
334 IllegalAccessException.prototype.toString = function() { 346 IllegalAccessException.prototype.toString = function() {
335 return "Attempt to modify an immutable object"; 347 return "Attempt to modify an immutable object";
336 } 348 }
337 IllegalAccessException.prototype.toString$0 = IllegalAccessException.prototype.t oString; 349 IllegalAccessException.prototype.toString$0 = IllegalAccessException.prototype.t oString;
338 // ********** Code for NoSuchMethodException ************** 350 // ********** Code for NoSuchMethodException **************
339 function NoSuchMethodException(_receiver, _functionName, _arguments) { 351 function NoSuchMethodException(_receiver, _functionName, _arguments) {
340 this._receiver = _receiver; 352 this._receiver = _receiver;
341 this._functionName = _functionName; 353 this._functionName = _functionName;
342 this._arguments = _arguments; 354 this._arguments = _arguments;
343 // Initializers done 355 // Initializers done
344 } 356 }
345 NoSuchMethodException.prototype.toString = function() { 357 NoSuchMethodException.prototype.toString = function() {
346 var sb = new StringBufferImpl(""); 358 var sb = new StringBufferImpl("");
347 for (var i = 0; 359 for (var i = (0);
348 i < this._arguments.get$length(); i++) { 360 i < this._arguments.get$length(); i++) {
349 if (i > 0) { 361 if (i > (0)) {
350 sb.add(", "); 362 sb.add(", ");
351 } 363 }
352 sb.add(this._arguments.$index(i)); 364 sb.add(this._arguments.$index(i));
353 } 365 }
354 sb.add("]"); 366 sb.add("]");
355 return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("fun ction name: '" + this._functionName + "' arguments: [" + sb + "]"); 367 return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("fun ction name: '" + this._functionName + "' arguments: [" + sb + "]");
356 } 368 }
357 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS tring; 369 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS tring;
358 // ********** Code for ClosureArgumentMismatchException ************** 370 // ********** Code for ClosureArgumentMismatchException **************
359 function ClosureArgumentMismatchException() { 371 function ClosureArgumentMismatchException() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (typeof console == 'object') { 488 if (typeof console == 'object') {
477 if (obj) obj = obj.toString(); 489 if (obj) obj = obj.toString();
478 console.log(obj); 490 console.log(obj);
479 } else { 491 } else {
480 write(obj); 492 write(obj);
481 write('\n'); 493 write('\n');
482 } 494 }
483 } 495 }
484 function _map(itemsAndKeys) { 496 function _map(itemsAndKeys) {
485 var ret = new LinkedHashMapImplementation(); 497 var ret = new LinkedHashMapImplementation();
486 for (var i = 0; 498 for (var i = (0);
487 i < itemsAndKeys.get$length(); ) { 499 i < itemsAndKeys.get$length(); ) {
488 ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++)); 500 ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++));
489 } 501 }
490 return ret; 502 return ret;
491 } 503 }
492 function _toDartException(e) { 504 function _toDartException(e) {
493 function attachStack(dartEx) { 505 function attachStack(dartEx) {
494 // TODO(jmesserly): setting the stack property is not a long term solution. 506 // TODO(jmesserly): setting the stack property is not a long term solution.
495 var stack = e.stack; 507 var stack = e.stack;
496 // The stack contains the error message, and the stack is all that is 508 // The stack contains the error message, and the stack is all that is
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 ListFactory.prototype.addLast = function(value) { 573 ListFactory.prototype.addLast = function(value) {
562 this.push(value); 574 this.push(value);
563 } 575 }
564 ListFactory.prototype.addAll = function(collection) { 576 ListFactory.prototype.addAll = function(collection) {
565 for (var $$i = collection.iterator(); $$i.hasNext$0(); ) { 577 for (var $$i = collection.iterator(); $$i.hasNext$0(); ) {
566 var item = $$i.next$0(); 578 var item = $$i.next$0();
567 this.add(item); 579 this.add(item);
568 } 580 }
569 } 581 }
570 ListFactory.prototype.clear = function() { 582 ListFactory.prototype.clear = function() {
571 this.set$length(0); 583 this.set$length((0));
572 } 584 }
573 ListFactory.prototype.removeLast = function() { 585 ListFactory.prototype.removeLast = function() {
574 return this.pop(); 586 return this.pop();
575 } 587 }
576 ListFactory.prototype.last = function() { 588 ListFactory.prototype.last = function() {
577 return this[this.get$length() - 1]; 589 return this[this.get$length() - (1)];
578 } 590 }
579 ListFactory.prototype.getRange = function(start, length) { 591 ListFactory.prototype.getRange = function(start, length) {
580 return this.slice(start, start + length); 592 return this.slice(start, start + length);
581 } 593 }
582 ListFactory.prototype.isEmpty = function() { 594 ListFactory.prototype.isEmpty = function() {
583 return this.get$length() == 0; 595 return this.get$length() == (0);
584 } 596 }
585 ListFactory.prototype.iterator = function() { 597 ListFactory.prototype.iterator = function() {
586 return new ListIterator(this); 598 return new ListIterator(this);
587 } 599 }
588 ListFactory.prototype.add$1 = ListFactory.prototype.add; 600 ListFactory.prototype.add$1 = ListFactory.prototype.add;
589 ListFactory.prototype.addAll$1 = ListFactory.prototype.addAll; 601 ListFactory.prototype.addAll$1 = ListFactory.prototype.addAll;
590 ListFactory.prototype.every$1 = function($0) { 602 ListFactory.prototype.every$1 = function($0) {
591 return this.every(to$call$1($0)); 603 return this.every(to$call$1($0));
592 }; 604 };
593 ListFactory.prototype.filter$1 = function($0) { 605 ListFactory.prototype.filter$1 = function($0) {
(...skipping 11 matching lines...) Expand all
605 return this.some(to$call$1($0)); 617 return this.some(to$call$1($0));
606 }; 618 };
607 ListFactory.prototype.sort$1 = function($0) { 619 ListFactory.prototype.sort$1 = function($0) {
608 return this.sort(to$call$2($0)); 620 return this.sort(to$call$2($0));
609 }; 621 };
610 ListFactory_E = ListFactory; 622 ListFactory_E = ListFactory;
611 ListFactory_Expression = ListFactory; 623 ListFactory_Expression = ListFactory;
612 ListFactory_K = ListFactory; 624 ListFactory_K = ListFactory;
613 ListFactory_dart_core_String = ListFactory; 625 ListFactory_dart_core_String = ListFactory;
614 ListFactory_V = ListFactory; 626 ListFactory_V = ListFactory;
627 ListFactory_Value = ListFactory;
615 ListFactory_int = ListFactory; 628 ListFactory_int = ListFactory;
616 // ********** Code for ListIterator ************** 629 // ********** Code for ListIterator **************
617 function ListIterator(array) { 630 function ListIterator(array) {
618 this._array = array; 631 this._array = array;
619 this._pos = 0; 632 this._pos = (0);
620 // Initializers done 633 // Initializers done
621 } 634 }
622 ListIterator.prototype.hasNext = function() { 635 ListIterator.prototype.hasNext = function() {
623 return this._array.get$length() > this._pos; 636 return this._array.get$length() > this._pos;
624 } 637 }
625 ListIterator.prototype.next = function() { 638 ListIterator.prototype.next = function() {
626 if (!this.hasNext()) { 639 if (!this.hasNext()) {
627 $throw(const$7/*const NoMoreElementsException()*/); 640 $throw(const$7);
628 } 641 }
629 return this._array.$index(this._pos++); 642 return this._array.$index(this._pos++);
630 } 643 }
631 ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext; 644 ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext;
632 ListIterator.prototype.next$0 = ListIterator.prototype.next; 645 ListIterator.prototype.next$0 = ListIterator.prototype.next;
633 // ********** Code for ImmutableList ************** 646 // ********** Code for ImmutableList **************
634 /** Implements extends for Dart classes on JavaScript prototypes. */ 647 /** Implements extends for Dart classes on JavaScript prototypes. */
635 function $inherits(child, parent) { 648 function $inherits(child, parent) {
636 if (child.prototype.__proto__) { 649 if (child.prototype.__proto__) {
637 child.prototype.__proto__ = parent.prototype; 650 child.prototype.__proto__ = parent.prototype;
638 } else { 651 } else {
639 function tmp() {}; 652 function tmp() {};
640 tmp.prototype = parent.prototype; 653 tmp.prototype = parent.prototype;
641 child.prototype = new tmp(); 654 child.prototype = new tmp();
642 child.prototype.constructor = child; 655 child.prototype.constructor = child;
643 } 656 }
644 } 657 }
645 $inherits(ImmutableList, ListFactory_E); 658 $inherits(ImmutableList, ListFactory_E);
646 function ImmutableList(length) { 659 function ImmutableList(length) {
647 this._length = length; 660 this._length = length;
648 // Initializers done 661 // Initializers done
649 Array.call(this, length); 662 Array.call(this, length);
650 } 663 }
651 ImmutableList.ImmutableList$from$factory = function(other) { 664 ImmutableList.ImmutableList$from$factory = function(other) {
652 var list = new ImmutableList(other.get$length()); 665 var list = new ImmutableList(other.get$length());
653 for (var i = 0; 666 for (var i = (0);
654 i < other.get$length(); i++) { 667 i < other.get$length(); i++) {
655 list._setindex(i, other.$index(i)); 668 list._setindex(i, other.$index(i));
656 } 669 }
657 return list; 670 return list;
658 } 671 }
659 ImmutableList.prototype.get$length = function() { 672 ImmutableList.prototype.get$length = function() {
660 return this._length; 673 return this._length;
661 } 674 }
662 ImmutableList.prototype.set$length = function(length) { 675 ImmutableList.prototype.set$length = function(length) {
663 $throw(const$126/*const IllegalAccessException()*/); 676 $throw(const$126);
664 } 677 }
665 Object.defineProperty(ImmutableList.prototype, "length", { 678 Object.defineProperty(ImmutableList.prototype, "length", {
666 get: ImmutableList.prototype.get$length, 679 get: ImmutableList.prototype.get$length,
667 set: ImmutableList.prototype.set$length 680 set: ImmutableList.prototype.set$length
668 }); 681 });
669 ImmutableList.prototype._setindex = function(index, value) { 682 ImmutableList.prototype._setindex = function(index, value) {
670 return this[index] = value; 683 return this[index] = value;
671 } 684 }
672 ImmutableList.prototype.$setindex = function(index, value) { 685 ImmutableList.prototype.$setindex = function(index, value) {
673 $throw(const$126/*const IllegalAccessException()*/); 686 $throw(const$126);
674 } 687 }
675 ImmutableList.prototype.sort = function(compare) { 688 ImmutableList.prototype.sort = function(compare) {
676 $throw(const$126/*const IllegalAccessException()*/); 689 $throw(const$126);
677 } 690 }
678 ImmutableList.prototype.add = function(element) { 691 ImmutableList.prototype.add = function(element) {
679 $throw(const$126/*const IllegalAccessException()*/); 692 $throw(const$126);
680 } 693 }
681 ImmutableList.prototype.addLast = function(element) { 694 ImmutableList.prototype.addLast = function(element) {
682 $throw(const$126/*const IllegalAccessException()*/); 695 $throw(const$126);
683 } 696 }
684 ImmutableList.prototype.addAll = function(elements) { 697 ImmutableList.prototype.addAll = function(elements) {
685 $throw(const$126/*const IllegalAccessException()*/); 698 $throw(const$126);
686 } 699 }
687 ImmutableList.prototype.clear = function() { 700 ImmutableList.prototype.clear = function() {
688 $throw(const$126/*const IllegalAccessException()*/); 701 $throw(const$126);
689 } 702 }
690 ImmutableList.prototype.removeLast = function() { 703 ImmutableList.prototype.removeLast = function() {
691 $throw(const$126/*const IllegalAccessException()*/); 704 $throw(const$126);
692 } 705 }
693 ImmutableList.prototype.toString = function() { 706 ImmutableList.prototype.toString = function() {
694 return ListFactory.ListFactory$from$factory(this).toString(); 707 return ListFactory.ListFactory$from$factory(this).toString();
695 } 708 }
696 ImmutableList.prototype.add$1 = ImmutableList.prototype.add; 709 ImmutableList.prototype.add$1 = ImmutableList.prototype.add;
697 ImmutableList.prototype.addAll$1 = ImmutableList.prototype.addAll; 710 ImmutableList.prototype.addAll$1 = ImmutableList.prototype.addAll;
698 ImmutableList.prototype.removeLast$0 = ImmutableList.prototype.removeLast; 711 ImmutableList.prototype.removeLast$0 = ImmutableList.prototype.removeLast;
699 ImmutableList.prototype.sort$1 = function($0) { 712 ImmutableList.prototype.sort$1 = function($0) {
700 return this.sort(to$call$2($0)); 713 return this.sort(to$call$2($0));
701 }; 714 };
(...skipping 21 matching lines...) Expand all
723 } 736 }
724 NumImplementation.prototype.toDouble = function() { 737 NumImplementation.prototype.toDouble = function() {
725 'use strict'; return this + 0; 738 'use strict'; return this + 0;
726 } 739 }
727 NumImplementation.prototype.toRadixString = function(radix) { 740 NumImplementation.prototype.toRadixString = function(radix) {
728 'use strict'; return this.toString(radix) 741 'use strict'; return this.toString(radix)
729 } 742 }
730 NumImplementation.prototype.compareTo = function(other) { 743 NumImplementation.prototype.compareTo = function(other) {
731 var thisValue = this.toDouble(); 744 var thisValue = this.toDouble();
732 if (thisValue < other) { 745 if (thisValue < other) {
733 return -1; 746 return (-1);
734 } 747 }
735 else if (thisValue > other) { 748 else if (thisValue > other) {
736 return 1; 749 return (1);
737 } 750 }
738 else if (thisValue == other) { 751 else if (thisValue == other) {
739 if (thisValue == 0) { 752 if (thisValue == (0)) {
740 var thisIsNegative = this.isNegative(); 753 var thisIsNegative = this.isNegative();
741 var otherIsNegative = other.isNegative(); 754 var otherIsNegative = other.isNegative();
742 if ($eq(thisIsNegative, otherIsNegative)) return 0; 755 if ($eq(thisIsNegative, otherIsNegative)) return (0);
743 if (thisIsNegative) return -1; 756 if (thisIsNegative) return (-1);
744 return 1; 757 return (1);
745 } 758 }
746 return 0; 759 return (0);
747 } 760 }
748 else if (this.isNaN()) { 761 else if (this.isNaN()) {
749 if (other.isNaN()) { 762 if (other.isNaN()) {
750 return 0; 763 return (0);
751 } 764 }
752 return 1; 765 return (1);
753 } 766 }
754 else { 767 else {
755 return -1; 768 return (-1);
756 } 769 }
757 } 770 }
758 NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo; 771 NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo;
759 NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode; 772 NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode;
773 NumImplementation.prototype.toDouble$0 = NumImplementation.prototype.toDouble;
774 NumImplementation.prototype.toInt$0 = NumImplementation.prototype.toInt;
760 NumImplementation.prototype.toRadixString$1 = NumImplementation.prototype.toRadi xString; 775 NumImplementation.prototype.toRadixString$1 = NumImplementation.prototype.toRadi xString;
761 // ********** Code for HashMapImplementation ************** 776 // ********** Code for HashMapImplementation **************
762 function HashMapImplementation() { 777 function HashMapImplementation() {
763 // Initializers done 778 // Initializers done
764 this._numberOfEntries = 0; 779 this._numberOfEntries = (0);
765 this._numberOfDeleted = 0; 780 this._numberOfDeleted = (0);
766 this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementa tion._INITIAL_CAPACITY*/); 781 this._loadLimit = HashMapImplementation._computeLoadLimit((8));
767 this._keys = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 782 this._keys = new Array((8));
768 this._values = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 783 this._values = new Array((8));
769 } 784 }
770 HashMapImplementation.HashMapImplementation$from$factory = function(other) { 785 HashMapImplementation.HashMapImplementation$from$factory = function(other) {
771 var result = new HashMapImplementation_K$V(); 786 var result = new HashMapImplementation_K$V();
772 other.forEach((function (key, value) { 787 other.forEach((function (key, value) {
773 result.$setindex(key, value); 788 result.$setindex(key, value);
774 }) 789 })
775 ); 790 );
776 return result; 791 return result;
777 } 792 }
778 HashMapImplementation._computeLoadLimit = function(capacity) { 793 HashMapImplementation._computeLoadLimit = function(capacity) {
779 return $truncdiv((capacity * 3), 4); 794 return $truncdiv((capacity * (3)), (4));
780 } 795 }
781 HashMapImplementation._firstProbe = function(hashCode, length) { 796 HashMapImplementation._firstProbe = function(hashCode, length) {
782 return hashCode & (length - 1); 797 return hashCode & (length - (1));
783 } 798 }
784 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length ) { 799 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length ) {
785 return (currentProbe + numberOfProbes) & (length - 1); 800 return (currentProbe + numberOfProbes) & (length - (1));
786 } 801 }
787 HashMapImplementation.prototype._probeForAdding = function(key) { 802 HashMapImplementation.prototype._probeForAdding = function(key) {
788 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length()); 803 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
789 var numberOfProbes = 1; 804 var numberOfProbes = (1);
790 var initialHash = hash; 805 var initialHash = hash;
791 var insertionIndex = -1; 806 var insertionIndex = (-1);
792 while (true) { 807 while (true) {
793 var existingKey = this._keys.$index(hash); 808 var existingKey = this._keys.$index(hash);
794 if (existingKey == null) { 809 if (existingKey == null) {
795 if (insertionIndex < 0) return hash; 810 if (insertionIndex < (0)) return hash;
796 return insertionIndex; 811 return insertionIndex;
797 } 812 }
798 else if ($eq(existingKey, key)) { 813 else if ($eq(existingKey, key)) {
799 return hash; 814 return hash;
800 } 815 }
801 else if ((insertionIndex < 0) && (const$2/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) { 816 else if ((insertionIndex < (0)) && (const$2 == existingKey)) {
802 insertionIndex = hash; 817 insertionIndex = hash;
803 } 818 }
804 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length()); 819 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
805 } 820 }
806 } 821 }
807 HashMapImplementation.prototype._probeForLookup = function(key) { 822 HashMapImplementation.prototype._probeForLookup = function(key) {
808 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length()); 823 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
809 var numberOfProbes = 1; 824 var numberOfProbes = (1);
810 var initialHash = hash; 825 var initialHash = hash;
811 while (true) { 826 while (true) {
812 var existingKey = this._keys.$index(hash); 827 var existingKey = this._keys.$index(hash);
813 if (existingKey == null) return -1; 828 if (existingKey == null) return (-1);
814 if ($eq(existingKey, key)) return hash; 829 if ($eq(existingKey, key)) return hash;
815 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length()); 830 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
816 } 831 }
817 } 832 }
818 HashMapImplementation.prototype._ensureCapacity = function() { 833 HashMapImplementation.prototype._ensureCapacity = function() {
819 var newNumberOfEntries = this._numberOfEntries + 1; 834 var newNumberOfEntries = this._numberOfEntries + (1);
820 if (newNumberOfEntries >= this._loadLimit) { 835 if (newNumberOfEntries >= this._loadLimit) {
821 this._grow(this._keys.get$length() * 2); 836 this._grow(this._keys.get$length() * (2));
822 return; 837 return;
823 } 838 }
824 var capacity = this._keys.get$length(); 839 var capacity = this._keys.get$length();
825 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; 840 var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
826 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; 841 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
827 if (this._numberOfDeleted > numberOfFree) { 842 if (this._numberOfDeleted > numberOfFree) {
828 this._grow(this._keys.get$length()); 843 this._grow(this._keys.get$length());
829 } 844 }
830 } 845 }
831 HashMapImplementation._isPowerOfTwo = function(x) { 846 HashMapImplementation._isPowerOfTwo = function(x) {
832 return ((x & (x - 1)) == 0); 847 return ((x & (x - (1))) == (0));
833 } 848 }
834 HashMapImplementation.prototype._grow = function(newCapacity) { 849 HashMapImplementation.prototype._grow = function(newCapacity) {
835 var capacity = this._keys.get$length(); 850 var capacity = this._keys.get$length();
836 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); 851 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
837 var oldKeys = this._keys; 852 var oldKeys = this._keys;
838 var oldValues = this._values; 853 var oldValues = this._values;
839 this._keys = new Array(newCapacity); 854 this._keys = new Array(newCapacity);
840 this._values = new Array(newCapacity); 855 this._values = new Array(newCapacity);
841 for (var i = 0; 856 for (var i = (0);
842 i < capacity; i++) { 857 i < capacity; i++) {
843 var key = oldKeys.$index(i); 858 var key = oldKeys.$index(i);
844 if (key == null || key === const$2/*HashMapImplementation._DELETED_KEY*/) { 859 if (key == null || key == const$2) {
845 continue; 860 continue;
846 } 861 }
847 var value = oldValues.$index(i); 862 var value = oldValues.$index(i);
848 var newIndex = this._probeForAdding(key); 863 var newIndex = this._probeForAdding(key);
849 this._keys.$setindex(newIndex, key); 864 this._keys.$setindex(newIndex, key);
850 this._values.$setindex(newIndex, value); 865 this._values.$setindex(newIndex, value);
851 } 866 }
852 this._numberOfDeleted = 0; 867 this._numberOfDeleted = (0);
853 } 868 }
854 HashMapImplementation.prototype.$setindex = function(key, value) { 869 HashMapImplementation.prototype.$setindex = function(key, value) {
855 this._ensureCapacity(); 870 this._ensureCapacity();
856 var index = this._probeForAdding(key); 871 var index = this._probeForAdding(key);
857 if ((this._keys.$index(index) == null) || (this._keys.$index(index) === const$ 2/*HashMapImplementation._DELETED_KEY*/)) { 872 if ((this._keys.$index(index) == null) || (this._keys.$index(index) == const$2 )) {
858 this._numberOfEntries++; 873 this._numberOfEntries++;
859 } 874 }
860 this._keys.$setindex(index, key); 875 this._keys.$setindex(index, key);
861 this._values.$setindex(index, value); 876 this._values.$setindex(index, value);
862 } 877 }
863 HashMapImplementation.prototype.$index = function(key) { 878 HashMapImplementation.prototype.$index = function(key) {
864 var index = this._probeForLookup(key); 879 var index = this._probeForLookup(key);
865 if (index < 0) return null; 880 if (index < (0)) return null;
866 return this._values.$index(index); 881 return this._values.$index(index);
867 } 882 }
868 HashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { 883 HashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) {
869 var index = this._probeForLookup(key); 884 var index = this._probeForLookup(key);
870 if (index >= 0) return this._values.$index(index); 885 if (index >= (0)) return this._values.$index(index);
871 var value = ifAbsent(); 886 var value = ifAbsent();
872 this.$setindex(key, value); 887 this.$setindex(key, value);
873 return value; 888 return value;
874 } 889 }
875 HashMapImplementation.prototype.remove = function(key) { 890 HashMapImplementation.prototype.remove = function(key) {
876 var index = this._probeForLookup(key); 891 var index = this._probeForLookup(key);
877 if (index >= 0) { 892 if (index >= (0)) {
878 this._numberOfEntries--; 893 this._numberOfEntries--;
879 var value = this._values.$index(index); 894 var value = this._values.$index(index);
880 this._values.$setindex(index); 895 this._values.$setindex(index);
881 this._keys.$setindex(index, const$2/*HashMapImplementation._DELETED_KEY*/); 896 this._keys.$setindex(index, const$2);
882 this._numberOfDeleted++; 897 this._numberOfDeleted++;
883 return value; 898 return value;
884 } 899 }
885 return null; 900 return null;
886 } 901 }
887 HashMapImplementation.prototype.isEmpty = function() { 902 HashMapImplementation.prototype.isEmpty = function() {
888 return this._numberOfEntries == 0; 903 return this._numberOfEntries == (0);
889 } 904 }
890 HashMapImplementation.prototype.get$length = function() { 905 HashMapImplementation.prototype.get$length = function() {
891 return this._numberOfEntries; 906 return this._numberOfEntries;
892 } 907 }
893 HashMapImplementation.prototype.forEach = function(f) { 908 HashMapImplementation.prototype.forEach = function(f) {
894 var length = this._keys.get$length(); 909 var length = this._keys.get$length();
895 for (var i = 0; 910 for (var i = (0);
896 i < length; i++) { 911 i < length; i++) {
897 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$2/*Has hMapImplementation._DELETED_KEY*/)) { 912 if ((this._keys.$index(i) != null) && (this._keys.$index(i) != const$2)) {
898 f(this._keys.$index(i), this._values.$index(i)); 913 f(this._keys.$index(i), this._values.$index(i));
899 } 914 }
900 } 915 }
901 } 916 }
902 HashMapImplementation.prototype.getKeys = function() { 917 HashMapImplementation.prototype.getKeys = function() {
903 var list = new Array(this.get$length()); 918 var list = new Array(this.get$length());
904 var i = 0; 919 var i = (0);
905 this.forEach(function _(key, value) { 920 this.forEach(function _(key, value) {
906 list.$setindex(i++, key); 921 list.$setindex(i++, key);
907 } 922 }
908 ); 923 );
909 return list; 924 return list;
910 } 925 }
911 HashMapImplementation.prototype.getValues = function() { 926 HashMapImplementation.prototype.getValues = function() {
912 var list = new Array(this.get$length()); 927 var list = new Array(this.get$length());
913 var i = 0; 928 var i = (0);
914 this.forEach(function _(key, value) { 929 this.forEach(function _(key, value) {
915 list.$setindex(i++, value); 930 list.$setindex(i++, value);
916 } 931 }
917 ); 932 );
918 return list; 933 return list;
919 } 934 }
920 HashMapImplementation.prototype.containsKey = function(key) { 935 HashMapImplementation.prototype.containsKey = function(key) {
921 return (this._probeForLookup(key) != -1); 936 return (this._probeForLookup(key) != (-1));
922 } 937 }
923 HashMapImplementation.prototype.containsKey$1 = HashMapImplementation.prototype. containsKey; 938 HashMapImplementation.prototype.containsKey$1 = HashMapImplementation.prototype. containsKey;
924 HashMapImplementation.prototype.forEach$1 = function($0) { 939 HashMapImplementation.prototype.forEach$1 = function($0) {
925 return this.forEach(to$call$2($0)); 940 return this.forEach(to$call$2($0));
926 }; 941 };
927 HashMapImplementation.prototype.getKeys$0 = HashMapImplementation.prototype.getK eys; 942 HashMapImplementation.prototype.getKeys$0 = HashMapImplementation.prototype.getK eys;
928 HashMapImplementation.prototype.getValues$0 = HashMapImplementation.prototype.ge tValues; 943 HashMapImplementation.prototype.getValues$0 = HashMapImplementation.prototype.ge tValues;
929 HashMapImplementation.prototype.isEmpty$0 = HashMapImplementation.prototype.isEm pty; 944 HashMapImplementation.prototype.isEmpty$0 = HashMapImplementation.prototype.isEm pty;
930 // ********** Code for HashMapImplementation_E$E ************** 945 // ********** Code for HashMapImplementation_E$E **************
931 $inherits(HashMapImplementation_E$E, HashMapImplementation); 946 $inherits(HashMapImplementation_E$E, HashMapImplementation);
932 function HashMapImplementation_E$E() { 947 function HashMapImplementation_E$E() {
933 // Initializers done 948 // Initializers done
934 this._numberOfEntries = 0; 949 this._numberOfEntries = (0);
935 this._numberOfDeleted = 0; 950 this._numberOfDeleted = (0);
936 this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementa tion._INITIAL_CAPACITY*/); 951 this._loadLimit = HashMapImplementation._computeLoadLimit((8));
937 this._keys = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 952 this._keys = new Array((8));
938 this._values = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 953 this._values = new Array((8));
939 } 954 }
940 HashMapImplementation_E$E._computeLoadLimit = function(capacity) { 955 HashMapImplementation_E$E._computeLoadLimit = function(capacity) {
941 return $truncdiv((capacity * 3), 4); 956 return $truncdiv((capacity * (3)), (4));
942 } 957 }
943 HashMapImplementation_E$E._firstProbe = function(hashCode, length) { 958 HashMapImplementation_E$E._firstProbe = function(hashCode, length) {
944 return hashCode & (length - 1); 959 return hashCode & (length - (1));
945 } 960 }
946 HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, le ngth) { 961 HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, le ngth) {
947 return (currentProbe + numberOfProbes) & (length - 1); 962 return (currentProbe + numberOfProbes) & (length - (1));
948 } 963 }
949 HashMapImplementation_E$E.prototype._probeForAdding = function(key) { 964 HashMapImplementation_E$E.prototype._probeForAdding = function(key) {
950 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length()); 965 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
951 var numberOfProbes = 1; 966 var numberOfProbes = (1);
952 var initialHash = hash; 967 var initialHash = hash;
953 var insertionIndex = -1; 968 var insertionIndex = (-1);
954 while (true) { 969 while (true) {
955 var existingKey = this._keys.$index(hash); 970 var existingKey = this._keys.$index(hash);
956 if (existingKey == null) { 971 if (existingKey == null) {
957 if (insertionIndex < 0) return hash; 972 if (insertionIndex < (0)) return hash;
958 return insertionIndex; 973 return insertionIndex;
959 } 974 }
960 else if ($eq(existingKey, key)) { 975 else if ($eq(existingKey, key)) {
961 return hash; 976 return hash;
962 } 977 }
963 else if ((insertionIndex < 0) && (const$2/*HashMapImplementation._DELETED_KE Y*/ === existingKey)) { 978 else if ((insertionIndex < (0)) && (const$2 == existingKey)) {
964 insertionIndex = hash; 979 insertionIndex = hash;
965 } 980 }
966 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length()); 981 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
967 } 982 }
968 } 983 }
969 HashMapImplementation_E$E.prototype._probeForLookup = function(key) { 984 HashMapImplementation_E$E.prototype._probeForLookup = function(key) {
970 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length()); 985 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$ length());
971 var numberOfProbes = 1; 986 var numberOfProbes = (1);
972 var initialHash = hash; 987 var initialHash = hash;
973 while (true) { 988 while (true) {
974 var existingKey = this._keys.$index(hash); 989 var existingKey = this._keys.$index(hash);
975 if (existingKey == null) return -1; 990 if (existingKey == null) return (-1);
976 if ($eq(existingKey, key)) return hash; 991 if ($eq(existingKey, key)) return hash;
977 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length()); 992 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g et$length());
978 } 993 }
979 } 994 }
980 HashMapImplementation_E$E.prototype._ensureCapacity = function() { 995 HashMapImplementation_E$E.prototype._ensureCapacity = function() {
981 var newNumberOfEntries = this._numberOfEntries + 1; 996 var newNumberOfEntries = this._numberOfEntries + (1);
982 if (newNumberOfEntries >= this._loadLimit) { 997 if (newNumberOfEntries >= this._loadLimit) {
983 this._grow(this._keys.get$length() * 2); 998 this._grow(this._keys.get$length() * (2));
984 return; 999 return;
985 } 1000 }
986 var capacity = this._keys.get$length(); 1001 var capacity = this._keys.get$length();
987 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; 1002 var numberOfFreeOrDeleted = capacity - newNumberOfEntries;
988 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; 1003 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted;
989 if (this._numberOfDeleted > numberOfFree) { 1004 if (this._numberOfDeleted > numberOfFree) {
990 this._grow(this._keys.get$length()); 1005 this._grow(this._keys.get$length());
991 } 1006 }
992 } 1007 }
993 HashMapImplementation_E$E._isPowerOfTwo = function(x) { 1008 HashMapImplementation_E$E._isPowerOfTwo = function(x) {
994 return ((x & (x - 1)) == 0); 1009 return ((x & (x - (1))) == (0));
995 } 1010 }
996 HashMapImplementation_E$E.prototype._grow = function(newCapacity) { 1011 HashMapImplementation_E$E.prototype._grow = function(newCapacity) {
997 var capacity = this._keys.get$length(); 1012 var capacity = this._keys.get$length();
998 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); 1013 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity);
999 var oldKeys = this._keys; 1014 var oldKeys = this._keys;
1000 var oldValues = this._values; 1015 var oldValues = this._values;
1001 this._keys = new Array(newCapacity); 1016 this._keys = new Array(newCapacity);
1002 this._values = new Array(newCapacity); 1017 this._values = new Array(newCapacity);
1003 for (var i = 0; 1018 for (var i = (0);
1004 i < capacity; i++) { 1019 i < capacity; i++) {
1005 var key = oldKeys.$index(i); 1020 var key = oldKeys.$index(i);
1006 if (key == null || key === const$2/*HashMapImplementation._DELETED_KEY*/) { 1021 if (key == null || key == const$2) {
1007 continue; 1022 continue;
1008 } 1023 }
1009 var value = oldValues.$index(i); 1024 var value = oldValues.$index(i);
1010 var newIndex = this._probeForAdding(key); 1025 var newIndex = this._probeForAdding(key);
1011 this._keys.$setindex(newIndex, key); 1026 this._keys.$setindex(newIndex, key);
1012 this._values.$setindex(newIndex, value); 1027 this._values.$setindex(newIndex, value);
1013 } 1028 }
1014 this._numberOfDeleted = 0; 1029 this._numberOfDeleted = (0);
1015 } 1030 }
1016 HashMapImplementation_E$E.prototype.$setindex = function(key, value) { 1031 HashMapImplementation_E$E.prototype.$setindex = function(key, value) {
1017 this._ensureCapacity(); 1032 this._ensureCapacity();
1018 var index = this._probeForAdding(key); 1033 var index = this._probeForAdding(key);
1019 if ((this._keys.$index(index) == null) || (this._keys.$index(index) === const$ 2/*HashMapImplementation._DELETED_KEY*/)) { 1034 if ((this._keys.$index(index) == null) || (this._keys.$index(index) == const$2 )) {
1020 this._numberOfEntries++; 1035 this._numberOfEntries++;
1021 } 1036 }
1022 this._keys.$setindex(index, key); 1037 this._keys.$setindex(index, key);
1023 this._values.$setindex(index, value); 1038 this._values.$setindex(index, value);
1024 } 1039 }
1025 HashMapImplementation_E$E.prototype.remove = function(key) { 1040 HashMapImplementation_E$E.prototype.remove = function(key) {
1026 var index = this._probeForLookup(key); 1041 var index = this._probeForLookup(key);
1027 if (index >= 0) { 1042 if (index >= (0)) {
1028 this._numberOfEntries--; 1043 this._numberOfEntries--;
1029 var value = this._values.$index(index); 1044 var value = this._values.$index(index);
1030 this._values.$setindex(index); 1045 this._values.$setindex(index);
1031 this._keys.$setindex(index, const$2/*HashMapImplementation._DELETED_KEY*/); 1046 this._keys.$setindex(index, const$2);
1032 this._numberOfDeleted++; 1047 this._numberOfDeleted++;
1033 return value; 1048 return value;
1034 } 1049 }
1035 return null; 1050 return null;
1036 } 1051 }
1037 HashMapImplementation_E$E.prototype.isEmpty = function() { 1052 HashMapImplementation_E$E.prototype.isEmpty = function() {
1038 return this._numberOfEntries == 0; 1053 return this._numberOfEntries == (0);
1039 } 1054 }
1040 HashMapImplementation_E$E.prototype.forEach = function(f) { 1055 HashMapImplementation_E$E.prototype.forEach = function(f) {
1041 var length = this._keys.get$length(); 1056 var length = this._keys.get$length();
1042 for (var i = 0; 1057 for (var i = (0);
1043 i < length; i++) { 1058 i < length; i++) {
1044 if ((this._keys.$index(i) != null) && (this._keys.$index(i) !== const$2/*Has hMapImplementation._DELETED_KEY*/)) { 1059 if ((this._keys.$index(i) != null) && (this._keys.$index(i) != const$2)) {
1045 f(this._keys.$index(i), this._values.$index(i)); 1060 f(this._keys.$index(i), this._values.$index(i));
1046 } 1061 }
1047 } 1062 }
1048 } 1063 }
1049 HashMapImplementation_E$E.prototype.getKeys = function() { 1064 HashMapImplementation_E$E.prototype.getKeys = function() {
1050 var list = new Array(this.get$length()); 1065 var list = new Array(this.get$length());
1051 var i = 0; 1066 var i = (0);
1052 this.forEach(function _(key, value) { 1067 this.forEach(function _(key, value) {
1053 list.$setindex(i++, key); 1068 list.$setindex(i++, key);
1054 } 1069 }
1055 ); 1070 );
1056 return list; 1071 return list;
1057 } 1072 }
1058 HashMapImplementation_E$E.prototype.containsKey = function(key) { 1073 HashMapImplementation_E$E.prototype.containsKey = function(key) {
1059 return (this._probeForLookup(key) != -1); 1074 return (this._probeForLookup(key) != (-1));
1060 } 1075 }
1061 // ********** Code for HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePa ir_K$V ************** 1076 // ********** Code for HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePa ir_K$V **************
1062 $inherits(HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V, HashM apImplementation); 1077 $inherits(HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V, HashM apImplementation);
1063 function HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V() {} 1078 function HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V() {}
1064 // ********** Code for HashMapImplementation_K$V ************** 1079 // ********** Code for HashMapImplementation_K$V **************
1065 $inherits(HashMapImplementation_K$V, HashMapImplementation); 1080 $inherits(HashMapImplementation_K$V, HashMapImplementation);
1066 function HashMapImplementation_K$V() { 1081 function HashMapImplementation_K$V() {
1067 // Initializers done 1082 // Initializers done
1068 this._numberOfEntries = 0; 1083 this._numberOfEntries = (0);
1069 this._numberOfDeleted = 0; 1084 this._numberOfDeleted = (0);
1070 this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementa tion._INITIAL_CAPACITY*/); 1085 this._loadLimit = HashMapImplementation._computeLoadLimit((8));
1071 this._keys = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 1086 this._keys = new Array((8));
1072 this._values = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 1087 this._values = new Array((8));
1073 } 1088 }
1074 HashMapImplementation_K$V._computeLoadLimit = function(capacity) { 1089 HashMapImplementation_K$V._computeLoadLimit = function(capacity) {
1075 return $truncdiv((capacity * 3), 4); 1090 return $truncdiv((capacity * (3)), (4));
1076 } 1091 }
1077 // ********** Code for HashMapImplementation_dart_core_String$EvaluatedValue *** *********** 1092 // ********** Code for HashMapImplementation_dart_core_String$Value ************ **
1078 $inherits(HashMapImplementation_dart_core_String$EvaluatedValue, HashMapImplemen tation); 1093 $inherits(HashMapImplementation_dart_core_String$Value, HashMapImplementation);
1079 function HashMapImplementation_dart_core_String$EvaluatedValue() {} 1094 function HashMapImplementation_dart_core_String$Value() {}
1080 // ********** Code for HashSetImplementation ************** 1095 // ********** Code for HashSetImplementation **************
1081 function HashSetImplementation() { 1096 function HashSetImplementation() {
1082 // Initializers done 1097 // Initializers done
1083 this._backingMap = new HashMapImplementation_E$E(); 1098 this._backingMap = new HashMapImplementation_E$E();
1084 } 1099 }
1085 HashSetImplementation.HashSetImplementation$from$factory = function(other) { 1100 HashSetImplementation.HashSetImplementation$from$factory = function(other) {
1086 var set = new HashSetImplementation_E(); 1101 var set = new HashSetImplementation_E();
1087 for (var $$i = other.iterator(); $$i.hasNext$0(); ) { 1102 for (var $$i = other.iterator(); $$i.hasNext$0(); ) {
1088 var e = $$i.next$0(); 1103 var e = $$i.next$0();
1089 set.add(e); 1104 set.add(e);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 $inherits(HashSetImplementation_Library, HashSetImplementation); 1181 $inherits(HashSetImplementation_Library, HashSetImplementation);
1167 function HashSetImplementation_Library() {} 1182 function HashSetImplementation_Library() {}
1168 // ********** Code for HashSetImplementation_dart_core_String ************** 1183 // ********** Code for HashSetImplementation_dart_core_String **************
1169 $inherits(HashSetImplementation_dart_core_String, HashSetImplementation); 1184 $inherits(HashSetImplementation_dart_core_String, HashSetImplementation);
1170 function HashSetImplementation_dart_core_String() {} 1185 function HashSetImplementation_dart_core_String() {}
1171 // ********** Code for HashSetImplementation_Type ************** 1186 // ********** Code for HashSetImplementation_Type **************
1172 $inherits(HashSetImplementation_Type, HashSetImplementation); 1187 $inherits(HashSetImplementation_Type, HashSetImplementation);
1173 function HashSetImplementation_Type() {} 1188 function HashSetImplementation_Type() {}
1174 // ********** Code for HashSetIterator ************** 1189 // ********** Code for HashSetIterator **************
1175 function HashSetIterator(set_) { 1190 function HashSetIterator(set_) {
1176 this._nextValidIndex = -1; 1191 this._nextValidIndex = (-1);
1177 this._entries = set_._backingMap._keys; 1192 this._entries = set_._backingMap._keys;
1178 // Initializers done 1193 // Initializers done
1179 this._advance(); 1194 this._advance();
1180 } 1195 }
1181 HashSetIterator.prototype.hasNext = function() { 1196 HashSetIterator.prototype.hasNext = function() {
1182 if (this._nextValidIndex >= this._entries.get$length()) return false; 1197 if (this._nextValidIndex >= this._entries.get$length()) return false;
1183 if (this._entries.$index(this._nextValidIndex) === const$2/*HashMapImplementat ion._DELETED_KEY*/) { 1198 if (this._entries.$index(this._nextValidIndex) == const$2) {
Jennifer Messerly 2012/01/09 19:06:54 Nice. I think this actually improves readability.
1184 this._advance(); 1199 this._advance();
1185 } 1200 }
1186 return this._nextValidIndex < this._entries.get$length(); 1201 return this._nextValidIndex < this._entries.get$length();
1187 } 1202 }
1188 HashSetIterator.prototype.next = function() { 1203 HashSetIterator.prototype.next = function() {
1189 if (!this.hasNext()) { 1204 if (!this.hasNext()) {
1190 $throw(const$7/*const NoMoreElementsException()*/); 1205 $throw(const$7);
1191 } 1206 }
1192 var res = this._entries.$index(this._nextValidIndex); 1207 var res = this._entries.$index(this._nextValidIndex);
1193 this._advance(); 1208 this._advance();
1194 return res; 1209 return res;
1195 } 1210 }
1196 HashSetIterator.prototype._advance = function() { 1211 HashSetIterator.prototype._advance = function() {
1197 var length = this._entries.get$length(); 1212 var length = this._entries.get$length();
1198 var entry; 1213 var entry;
1199 var deletedKey = const$2/*HashMapImplementation._DELETED_KEY*/; 1214 var deletedKey = const$2;
1200 do { 1215 do {
1201 if (++this._nextValidIndex >= length) break; 1216 if (++this._nextValidIndex >= length) break;
1202 entry = this._entries.$index(this._nextValidIndex); 1217 entry = this._entries.$index(this._nextValidIndex);
1203 } 1218 }
1204 while ((entry == null) || (entry === deletedKey)) 1219 while ((entry == null) || (entry == deletedKey))
1205 } 1220 }
1206 HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext; 1221 HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext;
1207 HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next; 1222 HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next;
1208 // ********** Code for HashSetIterator_E ************** 1223 // ********** Code for HashSetIterator_E **************
1209 $inherits(HashSetIterator_E, HashSetIterator); 1224 $inherits(HashSetIterator_E, HashSetIterator);
1210 function HashSetIterator_E(set_) { 1225 function HashSetIterator_E(set_) {
1211 this._nextValidIndex = -1; 1226 this._nextValidIndex = (-1);
1212 this._entries = set_._backingMap._keys; 1227 this._entries = set_._backingMap._keys;
1213 // Initializers done 1228 // Initializers done
1214 this._advance(); 1229 this._advance();
1215 } 1230 }
1216 HashSetIterator_E.prototype._advance = function() { 1231 HashSetIterator_E.prototype._advance = function() {
1217 var length = this._entries.get$length(); 1232 var length = this._entries.get$length();
1218 var entry; 1233 var entry;
1219 var deletedKey = const$2/*HashMapImplementation._DELETED_KEY*/; 1234 var deletedKey = const$2;
1220 do { 1235 do {
1221 if (++this._nextValidIndex >= length) break; 1236 if (++this._nextValidIndex >= length) break;
1222 entry = this._entries.$index(this._nextValidIndex); 1237 entry = this._entries.$index(this._nextValidIndex);
1223 } 1238 }
1224 while ((entry == null) || (entry === deletedKey)) 1239 while ((entry == null) || (entry == deletedKey))
1225 } 1240 }
1226 // ********** Code for _DeletedKeySentinel ************** 1241 // ********** Code for _DeletedKeySentinel **************
1227 function _DeletedKeySentinel() { 1242 function _DeletedKeySentinel() {
1228 // Initializers done 1243 // Initializers done
1229 } 1244 }
1230 // ********** Code for KeyValuePair ************** 1245 // ********** Code for KeyValuePair **************
1231 function KeyValuePair(key, value) { 1246 function KeyValuePair(key, value) {
1232 this.key = key; 1247 this.key = key;
1233 this.value = value; 1248 this.value = value;
1234 // Initializers done 1249 // Initializers done
(...skipping 30 matching lines...) Expand all
1265 LinkedHashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { 1280 LinkedHashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) {
1266 var value = this.$index(key); 1281 var value = this.$index(key);
1267 if ((this.$index(key) == null) && !(this.containsKey(key))) { 1282 if ((this.$index(key) == null) && !(this.containsKey(key))) {
1268 value = ifAbsent(); 1283 value = ifAbsent();
1269 this.$setindex(key, value); 1284 this.$setindex(key, value);
1270 } 1285 }
1271 return value; 1286 return value;
1272 } 1287 }
1273 LinkedHashMapImplementation.prototype.getKeys = function() { 1288 LinkedHashMapImplementation.prototype.getKeys = function() {
1274 var list = new Array(this.get$length()); 1289 var list = new Array(this.get$length());
1275 var index = 0; 1290 var index = (0);
1276 this._list.forEach(function _(entry) { 1291 this._list.forEach(function _(entry) {
1277 list.$setindex(index++, entry.key); 1292 list.$setindex(index++, entry.key);
1278 } 1293 }
1279 ); 1294 );
1280 return list; 1295 return list;
1281 } 1296 }
1282 LinkedHashMapImplementation.prototype.getValues = function() { 1297 LinkedHashMapImplementation.prototype.getValues = function() {
1283 var list = new Array(this.get$length()); 1298 var list = new Array(this.get$length());
1284 var index = 0; 1299 var index = (0);
1285 this._list.forEach(function _(entry) { 1300 this._list.forEach(function _(entry) {
1286 list.$setindex(index++, entry.value); 1301 list.$setindex(index++, entry.value);
1287 } 1302 }
1288 ); 1303 );
1289 return list; 1304 return list;
1290 } 1305 }
1291 LinkedHashMapImplementation.prototype.forEach = function(f) { 1306 LinkedHashMapImplementation.prototype.forEach = function(f) {
1292 this._list.forEach(function _(entry) { 1307 this._list.forEach(function _(entry) {
1293 f(entry.key, entry.value); 1308 f(entry.key, entry.value);
1294 } 1309 }
1295 ); 1310 );
1296 } 1311 }
1297 LinkedHashMapImplementation.prototype.containsKey = function(key) { 1312 LinkedHashMapImplementation.prototype.containsKey = function(key) {
1298 return this._map.containsKey(key); 1313 return this._map.containsKey(key);
1299 } 1314 }
1300 LinkedHashMapImplementation.prototype.get$length = function() { 1315 LinkedHashMapImplementation.prototype.get$length = function() {
1301 return this._map.get$length(); 1316 return this._map.get$length();
1302 } 1317 }
1303 LinkedHashMapImplementation.prototype.isEmpty = function() { 1318 LinkedHashMapImplementation.prototype.isEmpty = function() {
1304 return this.get$length() == 0; 1319 return this.get$length() == (0);
1305 } 1320 }
1306 LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementatio n.prototype.containsKey; 1321 LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementatio n.prototype.containsKey;
1307 LinkedHashMapImplementation.prototype.forEach$1 = function($0) { 1322 LinkedHashMapImplementation.prototype.forEach$1 = function($0) {
1308 return this.forEach(to$call$2($0)); 1323 return this.forEach(to$call$2($0));
1309 }; 1324 };
1310 LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.pr ototype.getKeys; 1325 LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.pr ototype.getKeys;
1311 LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation. prototype.getValues; 1326 LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation. prototype.getValues;
1312 LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.pr ototype.isEmpty; 1327 LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.pr ototype.isEmpty;
1313 // ********** Code for DoubleLinkedQueueEntry ************** 1328 // ********** Code for DoubleLinkedQueueEntry **************
1314 function DoubleLinkedQueueEntry(e) { 1329 function DoubleLinkedQueueEntry(e) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 return this._previous._asNonSentinelEntry(); 1405 return this._previous._asNonSentinelEntry();
1391 } 1406 }
1392 // ********** Code for _DoubleLinkedQueueEntrySentinel ************** 1407 // ********** Code for _DoubleLinkedQueueEntrySentinel **************
1393 $inherits(_DoubleLinkedQueueEntrySentinel, DoubleLinkedQueueEntry_E); 1408 $inherits(_DoubleLinkedQueueEntrySentinel, DoubleLinkedQueueEntry_E);
1394 function _DoubleLinkedQueueEntrySentinel() { 1409 function _DoubleLinkedQueueEntrySentinel() {
1395 // Initializers done 1410 // Initializers done
1396 DoubleLinkedQueueEntry_E.call(this, null); 1411 DoubleLinkedQueueEntry_E.call(this, null);
1397 this._link(this, this); 1412 this._link(this, this);
1398 } 1413 }
1399 _DoubleLinkedQueueEntrySentinel.prototype.remove = function() { 1414 _DoubleLinkedQueueEntrySentinel.prototype.remove = function() {
1400 $throw(const$1/*const EmptyQueueException()*/); 1415 $throw(const$1);
1401 } 1416 }
1402 _DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry = function() { 1417 _DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry = function() {
1403 return null; 1418 return null;
1404 } 1419 }
1405 _DoubleLinkedQueueEntrySentinel.prototype.get$element = function() { 1420 _DoubleLinkedQueueEntrySentinel.prototype.get$element = function() {
1406 $throw(const$1/*const EmptyQueueException()*/); 1421 $throw(const$1);
1407 } 1422 }
1408 // ********** Code for _DoubleLinkedQueueEntrySentinel_E ************** 1423 // ********** Code for _DoubleLinkedQueueEntrySentinel_E **************
1409 $inherits(_DoubleLinkedQueueEntrySentinel_E, _DoubleLinkedQueueEntrySentinel); 1424 $inherits(_DoubleLinkedQueueEntrySentinel_E, _DoubleLinkedQueueEntrySentinel);
1410 function _DoubleLinkedQueueEntrySentinel_E() { 1425 function _DoubleLinkedQueueEntrySentinel_E() {
1411 // Initializers done 1426 // Initializers done
1412 DoubleLinkedQueueEntry_E.call(this, null); 1427 DoubleLinkedQueueEntry_E.call(this, null);
1413 this._link(this, this); 1428 this._link(this, this);
1414 } 1429 }
1415 // ********** Code for _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V ******** ****** 1430 // ********** Code for _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V ******** ******
1416 $inherits(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, _DoubleLinkedQueueEn trySentinel); 1431 $inherits(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, _DoubleLinkedQueueEn trySentinel);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 DoubleLinkedQueue.prototype.removeFirst = function() { 1465 DoubleLinkedQueue.prototype.removeFirst = function() {
1451 return this._sentinel._next.remove(); 1466 return this._sentinel._next.remove();
1452 } 1467 }
1453 DoubleLinkedQueue.prototype.last = function() { 1468 DoubleLinkedQueue.prototype.last = function() {
1454 return this._sentinel._previous.get$element(); 1469 return this._sentinel._previous.get$element();
1455 } 1470 }
1456 DoubleLinkedQueue.prototype.lastEntry = function() { 1471 DoubleLinkedQueue.prototype.lastEntry = function() {
1457 return this._sentinel.previousEntry(); 1472 return this._sentinel.previousEntry();
1458 } 1473 }
1459 DoubleLinkedQueue.prototype.get$length = function() { 1474 DoubleLinkedQueue.prototype.get$length = function() {
1460 var counter = 0; 1475 var counter = (0);
1461 this.forEach(function _(element) { 1476 this.forEach(function _(element) {
1462 counter++; 1477 counter++;
1463 } 1478 }
1464 ); 1479 );
1465 return counter; 1480 return counter;
1466 } 1481 }
1467 DoubleLinkedQueue.prototype.isEmpty = function() { 1482 DoubleLinkedQueue.prototype.isEmpty = function() {
1468 return (this._sentinel._next === this._sentinel); 1483 return (this._sentinel._next == this._sentinel);
1469 } 1484 }
1470 DoubleLinkedQueue.prototype.forEach = function(f) { 1485 DoubleLinkedQueue.prototype.forEach = function(f) {
1471 var entry = this._sentinel._next; 1486 var entry = this._sentinel._next;
1472 while (entry !== this._sentinel) { 1487 while (entry != this._sentinel) {
1473 var nextEntry = entry._next; 1488 var nextEntry = entry._next;
1474 f(entry._element); 1489 f(entry._element);
1475 entry = nextEntry; 1490 entry = nextEntry;
1476 } 1491 }
1477 } 1492 }
1478 DoubleLinkedQueue.prototype.every = function(f) { 1493 DoubleLinkedQueue.prototype.every = function(f) {
1479 var entry = this._sentinel._next; 1494 var entry = this._sentinel._next;
1480 while (entry !== this._sentinel) { 1495 while (entry != this._sentinel) {
1481 var nextEntry = entry._next; 1496 var nextEntry = entry._next;
1482 if (!f(entry._element)) return false; 1497 if (!f(entry._element)) return false;
1483 entry = nextEntry; 1498 entry = nextEntry;
1484 } 1499 }
1485 return true; 1500 return true;
1486 } 1501 }
1487 DoubleLinkedQueue.prototype.some = function(f) { 1502 DoubleLinkedQueue.prototype.some = function(f) {
1488 var entry = this._sentinel._next; 1503 var entry = this._sentinel._next;
1489 while (entry !== this._sentinel) { 1504 while (entry != this._sentinel) {
1490 var nextEntry = entry._next; 1505 var nextEntry = entry._next;
1491 if (f(entry._element)) return true; 1506 if (f(entry._element)) return true;
1492 entry = nextEntry; 1507 entry = nextEntry;
1493 } 1508 }
1494 return false; 1509 return false;
1495 } 1510 }
1496 DoubleLinkedQueue.prototype.filter = function(f) { 1511 DoubleLinkedQueue.prototype.filter = function(f) {
1497 var other = new DoubleLinkedQueue(); 1512 var other = new DoubleLinkedQueue();
1498 var entry = this._sentinel._next; 1513 var entry = this._sentinel._next;
1499 while (entry !== this._sentinel) { 1514 while (entry != this._sentinel) {
1500 var nextEntry = entry._next; 1515 var nextEntry = entry._next;
1501 if (f(entry._element)) other.addLast(entry._element); 1516 if (f(entry._element)) other.addLast(entry._element);
1502 entry = nextEntry; 1517 entry = nextEntry;
1503 } 1518 }
1504 return other; 1519 return other;
1505 } 1520 }
1506 DoubleLinkedQueue.prototype.iterator = function() { 1521 DoubleLinkedQueue.prototype.iterator = function() {
1507 return new _DoubleLinkedQueueIterator_E(this._sentinel); 1522 return new _DoubleLinkedQueueIterator_E(this._sentinel);
1508 } 1523 }
1509 DoubleLinkedQueue.prototype.add$1 = DoubleLinkedQueue.prototype.add; 1524 DoubleLinkedQueue.prototype.add$1 = DoubleLinkedQueue.prototype.add;
(...skipping 24 matching lines...) Expand all
1534 this._sentinel = new _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V(); 1549 this._sentinel = new _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V();
1535 } 1550 }
1536 DoubleLinkedQueue_KeyValuePair_K$V.prototype.addLast = function(value) { 1551 DoubleLinkedQueue_KeyValuePair_K$V.prototype.addLast = function(value) {
1537 this._sentinel.prepend(value); 1552 this._sentinel.prepend(value);
1538 } 1553 }
1539 DoubleLinkedQueue_KeyValuePair_K$V.prototype.lastEntry = function() { 1554 DoubleLinkedQueue_KeyValuePair_K$V.prototype.lastEntry = function() {
1540 return this._sentinel.previousEntry(); 1555 return this._sentinel.previousEntry();
1541 } 1556 }
1542 DoubleLinkedQueue_KeyValuePair_K$V.prototype.forEach = function(f) { 1557 DoubleLinkedQueue_KeyValuePair_K$V.prototype.forEach = function(f) {
1543 var entry = this._sentinel._next; 1558 var entry = this._sentinel._next;
1544 while (entry !== this._sentinel) { 1559 while (entry != this._sentinel) {
1545 var nextEntry = entry._next; 1560 var nextEntry = entry._next;
1546 f(entry._element); 1561 f(entry._element);
1547 entry = nextEntry; 1562 entry = nextEntry;
1548 } 1563 }
1549 } 1564 }
1550 // ********** Code for _DoubleLinkedQueueIterator ************** 1565 // ********** Code for _DoubleLinkedQueueIterator **************
1551 function _DoubleLinkedQueueIterator(_sentinel) { 1566 function _DoubleLinkedQueueIterator(_sentinel) {
1552 this._sentinel = _sentinel; 1567 this._sentinel = _sentinel;
1553 // Initializers done 1568 // Initializers done
1554 this._currentEntry = this._sentinel; 1569 this._currentEntry = this._sentinel;
1555 } 1570 }
1556 _DoubleLinkedQueueIterator.prototype.hasNext = function() { 1571 _DoubleLinkedQueueIterator.prototype.hasNext = function() {
1557 return this._currentEntry._next !== this._sentinel; 1572 return this._currentEntry._next != this._sentinel;
1558 } 1573 }
1559 _DoubleLinkedQueueIterator.prototype.next = function() { 1574 _DoubleLinkedQueueIterator.prototype.next = function() {
1560 if (!this.hasNext()) { 1575 if (!this.hasNext()) {
1561 $throw(const$7/*const NoMoreElementsException()*/); 1576 $throw(const$7);
1562 } 1577 }
1563 this._currentEntry = this._currentEntry._next; 1578 this._currentEntry = this._currentEntry._next;
1564 return this._currentEntry.get$element(); 1579 return this._currentEntry.get$element();
1565 } 1580 }
1566 _DoubleLinkedQueueIterator.prototype.hasNext$0 = _DoubleLinkedQueueIterator.prot otype.hasNext; 1581 _DoubleLinkedQueueIterator.prototype.hasNext$0 = _DoubleLinkedQueueIterator.prot otype.hasNext;
1567 _DoubleLinkedQueueIterator.prototype.next$0 = _DoubleLinkedQueueIterator.prototy pe.next; 1582 _DoubleLinkedQueueIterator.prototype.next$0 = _DoubleLinkedQueueIterator.prototy pe.next;
1568 // ********** Code for _DoubleLinkedQueueIterator_E ************** 1583 // ********** Code for _DoubleLinkedQueueIterator_E **************
1569 $inherits(_DoubleLinkedQueueIterator_E, _DoubleLinkedQueueIterator); 1584 $inherits(_DoubleLinkedQueueIterator_E, _DoubleLinkedQueueIterator);
1570 function _DoubleLinkedQueueIterator_E(_sentinel) { 1585 function _DoubleLinkedQueueIterator_E(_sentinel) {
1571 this._sentinel = _sentinel; 1586 this._sentinel = _sentinel;
(...skipping 21 matching lines...) Expand all
1593 return this.start.bind(this); 1608 return this.start.bind(this);
1594 } 1609 }
1595 StopwatchImplementation.prototype.stop = function() { 1610 StopwatchImplementation.prototype.stop = function() {
1596 if (this._start == null) { 1611 if (this._start == null) {
1597 return; 1612 return;
1598 } 1613 }
1599 this._stop = Clock.now(); 1614 this._stop = Clock.now();
1600 } 1615 }
1601 StopwatchImplementation.prototype.elapsed = function() { 1616 StopwatchImplementation.prototype.elapsed = function() {
1602 if (this._start == null) { 1617 if (this._start == null) {
1603 return 0; 1618 return (0);
1604 } 1619 }
1605 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this ._start); 1620 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this ._start);
1606 } 1621 }
1607 StopwatchImplementation.prototype.elapsedInMs = function() { 1622 StopwatchImplementation.prototype.elapsedInMs = function() {
1608 return $truncdiv((this.elapsed() * 1000), this.frequency()); 1623 return $truncdiv((this.elapsed() * (1000)), this.frequency());
1609 } 1624 }
1610 StopwatchImplementation.prototype.frequency = function() { 1625 StopwatchImplementation.prototype.frequency = function() {
1611 return Clock.frequency(); 1626 return Clock.frequency();
1612 } 1627 }
1613 StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.st art; 1628 StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.st art;
1614 // ********** Code for StringBufferImpl ************** 1629 // ********** Code for StringBufferImpl **************
1615 function StringBufferImpl(content) { 1630 function StringBufferImpl(content) {
1616 // Initializers done 1631 // Initializers done
1617 this.clear(); 1632 this.clear();
1618 this.add(content); 1633 this.add(content);
1619 } 1634 }
1620 StringBufferImpl.prototype.get$length = function() { 1635 StringBufferImpl.prototype.get$length = function() {
1621 return this._length; 1636 return this._length;
1622 } 1637 }
1623 StringBufferImpl.prototype.isEmpty = function() { 1638 StringBufferImpl.prototype.isEmpty = function() {
1624 return this._length == 0; 1639 return this._length == (0);
1625 } 1640 }
1626 StringBufferImpl.prototype.add = function(obj) { 1641 StringBufferImpl.prototype.add = function(obj) {
1627 var str = obj.toString(); 1642 var str = obj.toString();
1628 if (str == null || str.isEmpty()) return this; 1643 if (str == null || str.isEmpty()) return this;
1629 this._buffer.add(str); 1644 this._buffer.add(str);
1630 this._length += str.length; 1645 this._length += str.length;
1631 return this; 1646 return this;
1632 } 1647 }
1633 StringBufferImpl.prototype.addAll = function(objects) { 1648 StringBufferImpl.prototype.addAll = function(objects) {
1634 for (var $$i = objects.iterator(); $$i.hasNext$0(); ) { 1649 for (var $$i = objects.iterator(); $$i.hasNext$0(); ) {
1635 var obj = $$i.next$0(); 1650 var obj = $$i.next$0();
1636 this.add(obj); 1651 this.add(obj);
1637 } 1652 }
1638 return this; 1653 return this;
1639 } 1654 }
1640 StringBufferImpl.prototype.clear = function() { 1655 StringBufferImpl.prototype.clear = function() {
1641 this._buffer = new Array(); 1656 this._buffer = new Array();
1642 this._length = 0; 1657 this._length = (0);
1643 return this; 1658 return this;
1644 } 1659 }
1645 StringBufferImpl.prototype.toString = function() { 1660 StringBufferImpl.prototype.toString = function() {
1646 if (this._buffer.get$length() == 0) return ""; 1661 if (this._buffer.get$length() == (0)) return "";
1647 if (this._buffer.get$length() == 1) return this._buffer.$index(0); 1662 if (this._buffer.get$length() == (1)) return this._buffer.$index((0));
1648 var result = StringBase.concatAll(this._buffer); 1663 var result = StringBase.concatAll(this._buffer);
1649 this._buffer.clear(); 1664 this._buffer.clear();
1650 this._buffer.add(result); 1665 this._buffer.add(result);
1651 return result; 1666 return result;
1652 } 1667 }
1653 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add; 1668 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add;
1654 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll; 1669 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll;
1655 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty; 1670 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty;
1656 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString; 1671 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString;
1657 // ********** Code for StringBase ************** 1672 // ********** Code for StringBase **************
1658 function StringBase() {} 1673 function StringBase() {}
1659 StringBase.createFromCharCodes = function(charCodes) { 1674 StringBase.createFromCharCodes = function(charCodes) {
1660 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { 1675 if (Object.getPrototypeOf(charCodes) !== Array.prototype) {
1661 charCodes = new ListFactory.ListFactory$from$factory(charCodes); 1676 charCodes = new ListFactory.ListFactory$from$factory(charCodes);
1662 } 1677 }
1663 return String.fromCharCode.apply(null, charCodes); 1678 return String.fromCharCode.apply(null, charCodes);
1664 } 1679 }
1665 StringBase.join = function(strings, separator) { 1680 StringBase.join = function(strings, separator) {
1666 if (strings.get$length() == 0) return ""; 1681 if (strings.get$length() == (0)) return "";
1667 var s = strings.$index(0); 1682 var s = strings.$index((0));
1668 for (var i = 1; 1683 for (var i = (1);
1669 i < strings.get$length(); i++) { 1684 i < strings.get$length(); i++) {
1670 s = s + separator + strings.$index(i); 1685 s = s + separator + strings.$index(i);
1671 } 1686 }
1672 return s; 1687 return s;
1673 } 1688 }
1674 StringBase.concatAll = function(strings) { 1689 StringBase.concatAll = function(strings) {
1675 return StringBase.join(strings, ""); 1690 return StringBase.join(strings, "");
1676 } 1691 }
1677 // ********** Code for StringImplementation ************** 1692 // ********** Code for StringImplementation **************
1678 StringImplementation = String; 1693 StringImplementation = String;
1679 StringImplementation.prototype.get$length = function() { return this.length; }; 1694 StringImplementation.prototype.get$length = function() { return this.length; };
1680 StringImplementation.prototype.endsWith = function(other) { 1695 StringImplementation.prototype.endsWith = function(other) {
1681 'use strict'; 1696 'use strict';
1682 if (other.length > this.length) return false; 1697 if (other.length > this.length) return false;
1683 return other == this.substring(this.length - other.length); 1698 return other == this.substring(this.length - other.length);
1684 } 1699 }
1685 StringImplementation.prototype.startsWith = function(other) { 1700 StringImplementation.prototype.startsWith = function(other) {
1686 'use strict'; 1701 'use strict';
1687 if (other.length > this.length) return false; 1702 if (other.length > this.length) return false;
1688 return other == this.substring(0, other.length); 1703 return other == this.substring(0, other.length);
1689 } 1704 }
1690 StringImplementation.prototype.isEmpty = function() { 1705 StringImplementation.prototype.isEmpty = function() {
1691 return this.length == 0; 1706 return this.length == (0);
1692 } 1707 }
1693 StringImplementation.prototype.contains = function(pattern, startIndex) { 1708 StringImplementation.prototype.contains = function(pattern, startIndex) {
1694 'use strict'; return this.indexOf(pattern, startIndex) >= 0; 1709 'use strict'; return this.indexOf(pattern, startIndex) >= 0;
1695 } 1710 }
1696 StringImplementation.prototype._replaceFirst = function(from, to) { 1711 StringImplementation.prototype._replaceFirst = function(from, to) {
1697 'use strict';return this.replace(from, to); 1712 'use strict';return this.replace(from, to);
1698 } 1713 }
1699 StringImplementation.prototype._replaceRegExp = function(from, to) { 1714 StringImplementation.prototype._replaceRegExp = function(from, to) {
1700 'use strict';return this.replace(from.re, to); 1715 'use strict';return this.replace(from.re, to);
1701 } 1716 }
1702 StringImplementation.prototype.replaceFirst = function(from, to) { 1717 StringImplementation.prototype.replaceFirst = function(from, to) {
1703 if ((typeof(from) == 'string')) return this._replaceFirst(from, to); 1718 if ((typeof(from) == 'string')) return this._replaceFirst(from, to);
1704 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from, to); 1719 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from, to);
1705 var $$list = from.allMatches(this); 1720 var $$list = from.allMatches(this);
1706 for (var $$i = from.allMatches(this).iterator(); $$i.hasNext$0(); ) { 1721 for (var $$i = from.allMatches(this).iterator(); $$i.hasNext$0(); ) {
1707 var match = $$i.next$0(); 1722 var match = $$i.next$0();
1708 return this.substring(0, match.start$0()) + to + this.substring(match.end$0( )); 1723 return this.substring((0), match.start$0()) + to + this.substring(match.end$ 0());
1709 } 1724 }
1710 } 1725 }
1711 StringImplementation.prototype._replaceAll = function(from, to) { 1726 StringImplementation.prototype._replaceAll = function(from, to) {
1712 'use strict'; 1727 'use strict';
1713 from = new RegExp(from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'g'); 1728 from = new RegExp(from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'g');
1714 to = to.replace(/\$/g, '$$$$'); // Escape sequences are fun! 1729 to = to.replace(/\$/g, '$$$$'); // Escape sequences are fun!
1715 return this.replace(from, to); 1730 return this.replace(from, to);
1716 } 1731 }
1717 StringImplementation.prototype.replaceAll = function(from, to) { 1732 StringImplementation.prototype.replaceAll = function(from, to) {
1718 if ((typeof(from) == 'string')) return this._replaceAll(from, to); 1733 if ((typeof(from) == 'string')) return this._replaceAll(from, to);
1719 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from.get$dynamic( ).get$_global(), to); 1734 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from.get$dynamic( ).get$_global(), to);
1720 var buffer = new StringBufferImpl(""); 1735 var buffer = new StringBufferImpl("");
1721 var lastMatchEnd = 0; 1736 var lastMatchEnd = (0);
1722 var $$list = from.allMatches(this); 1737 var $$list = from.allMatches(this);
1723 for (var $$i = from.allMatches(this).iterator(); $$i.hasNext$0(); ) { 1738 for (var $$i = from.allMatches(this).iterator(); $$i.hasNext$0(); ) {
1724 var match = $$i.next$0(); 1739 var match = $$i.next$0();
1725 buffer.add$1(this.substring(lastMatchEnd, match.start$0())); 1740 buffer.add$1(this.substring(lastMatchEnd, match.start$0()));
1726 buffer.add$1(to); 1741 buffer.add$1(to);
1727 lastMatchEnd = match.end$0(); 1742 lastMatchEnd = match.end$0();
1728 } 1743 }
1729 buffer.add$1(this.substring(lastMatchEnd)); 1744 buffer.add$1(this.substring(lastMatchEnd));
1730 } 1745 }
1731 StringImplementation.prototype.hashCode = function() { 1746 StringImplementation.prototype.hashCode = function() {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 function get$process() { 2024 function get$process() {
2010 return new Process(get$_process()); 2025 return new Process(get$_process());
2011 } 2026 }
2012 // ********** Library file_system ************** 2027 // ********** Library file_system **************
2013 // ********** Code for top level ************** 2028 // ********** Code for top level **************
2014 function joinPaths(path1, path2) { 2029 function joinPaths(path1, path2) {
2015 var pieces = path1.split("/"); 2030 var pieces = path1.split("/");
2016 var $$list = path2.split("/"); 2031 var $$list = path2.split("/");
2017 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2032 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2018 var piece = $$list.$index($$i); 2033 var piece = $$list.$index($$i);
2019 if ($eq(piece, "..") && pieces.get$length() > 0 && $ne(pieces.last$0(), ".") && $ne(pieces.last$0(), "..")) { 2034 if ($eq(piece, "..") && pieces.get$length() > (0) && $ne(pieces.last$0(), ". ") && $ne(pieces.last$0(), "..")) {
2020 pieces.removeLast$0(); 2035 pieces.removeLast$0();
2021 } 2036 }
2022 else if ($ne(piece, "")) { 2037 else if ($ne(piece, "")) {
2023 if (pieces.get$length() > 0 && $eq(pieces.last$0(), ".")) { 2038 if (pieces.get$length() > (0) && $eq(pieces.last$0(), ".")) {
2024 pieces.removeLast$0(); 2039 pieces.removeLast$0();
2025 } 2040 }
2026 pieces.add$1(piece); 2041 pieces.add$1(piece);
2027 } 2042 }
2028 } 2043 }
2029 return Strings.join(pieces, "/"); 2044 return Strings.join(pieces, "/");
2030 } 2045 }
2031 function dirname(path) { 2046 function dirname(path) {
2032 var lastSlash = path.lastIndexOf("/", path.length); 2047 var lastSlash = path.lastIndexOf("/", path.length);
2033 if (lastSlash == -1) { 2048 if (lastSlash == (-1)) {
2034 return "."; 2049 return ".";
2035 } 2050 }
2036 else { 2051 else {
2037 return path.substring(0, lastSlash); 2052 return path.substring((0), lastSlash);
2038 } 2053 }
2039 } 2054 }
2040 function basename(path) { 2055 function basename(path) {
2041 var lastSlash = path.lastIndexOf("/", path.length); 2056 var lastSlash = path.lastIndexOf("/", path.length);
2042 if (lastSlash == -1) { 2057 if (lastSlash == (-1)) {
2043 return path; 2058 return path;
2044 } 2059 }
2045 else { 2060 else {
2046 return path.substring(lastSlash + 1); 2061 return path.substring(lastSlash + (1));
2047 } 2062 }
2048 } 2063 }
2049 // ********** Library file_system_node ************** 2064 // ********** Library file_system_node **************
2050 // ********** Code for NodeFileSystem ************** 2065 // ********** Code for NodeFileSystem **************
2051 function NodeFileSystem() { 2066 function NodeFileSystem() {
2052 // Initializers done 2067 // Initializers done
2053 } 2068 }
2054 NodeFileSystem.prototype.writeString = function(outfile, text) { 2069 NodeFileSystem.prototype.writeString = function(outfile, text) {
2055 fs.writeFileSync(outfile, text); 2070 fs.writeFileSync(outfile, text);
2056 } 2071 }
2057 NodeFileSystem.prototype.readAll = function(filename) { 2072 NodeFileSystem.prototype.readAll = function(filename) {
2058 return fs.readFileSync(filename, "utf8"); 2073 return fs.readFileSync(filename, "utf8");
2059 } 2074 }
2060 NodeFileSystem.prototype.fileExists = function(filename) { 2075 NodeFileSystem.prototype.fileExists = function(filename) {
2061 return path.existsSync(filename); 2076 return path.existsSync(filename);
2062 } 2077 }
2063 // ********** Code for top level ************** 2078 // ********** Code for top level **************
2064 // ********** Library lang ************** 2079 // ********** Library lang **************
2065 // ********** Code for CodeWriter ************** 2080 // ********** Code for CodeWriter **************
2066 function CodeWriter() { 2081 function CodeWriter() {
2067 this._indentation = 0 2082 this._indentation = (0)
2068 this._pendingIndent = false 2083 this._pendingIndent = false
2069 this.writeComments = true 2084 this.writeComments = true
2070 this._buf = new StringBufferImpl(""); 2085 this._buf = new StringBufferImpl("");
2071 // Initializers done 2086 // Initializers done
2072 } 2087 }
2073 CodeWriter.prototype.get$text = function() { 2088 CodeWriter.prototype.get$text = function() {
2074 return this._buf.toString(); 2089 return this._buf.toString();
2075 } 2090 }
2076 CodeWriter.prototype._indent = function() { 2091 CodeWriter.prototype._indent = function() {
2077 this._pendingIndent = false; 2092 this._pendingIndent = false;
2078 for (var i = 0; 2093 for (var i = (0);
2079 i < this._indentation; i++) { 2094 i < this._indentation; i++) {
2080 this._buf.add(" "/*CodeWriter.INDENTATION*/); 2095 this._buf.add(" ");
2081 } 2096 }
2082 } 2097 }
2083 CodeWriter.prototype.comment = function(text) { 2098 CodeWriter.prototype.comment = function(text) {
2084 if (this.writeComments) { 2099 if (this.writeComments) {
2085 this.writeln(text); 2100 this.writeln(text);
2086 } 2101 }
2087 } 2102 }
2088 CodeWriter.prototype.write = function(text) { 2103 CodeWriter.prototype.write = function(text) {
2089 if (text.length == 0) return; 2104 if (text.length == (0)) return;
2090 if (this._pendingIndent) this._indent(); 2105 if (this._pendingIndent) this._indent();
2091 if (text.indexOf("\n") != -1) { 2106 if (text.indexOf("\n") != (-1)) {
2092 var lines = text.split("\n"); 2107 var lines = text.split("\n");
2093 for (var i = 0; 2108 for (var i = (0);
2094 i < lines.get$length() - 1; i++) { 2109 i < lines.get$length() - (1); i++) {
2095 this.writeln(lines.$index(i)); 2110 this.writeln(lines.$index(i));
2096 } 2111 }
2097 this.write(lines.$index(lines.get$length() - 1)); 2112 this.write(lines.$index(lines.get$length() - (1)));
2098 } 2113 }
2099 else { 2114 else {
2100 this._buf.add(text); 2115 this._buf.add(text);
2101 } 2116 }
2102 } 2117 }
2103 CodeWriter.prototype.writeln = function(text) { 2118 CodeWriter.prototype.writeln = function(text) {
2104 if (text != null) { 2119 if (text != null) {
2105 this.write(text); 2120 this.write(text);
2106 } 2121 }
2107 if (!text.endsWith("\n")) this._buf.add("\n"/*CodeWriter.NEWLINE*/); 2122 if (!text.endsWith("\n")) this._buf.add("\n");
2108 this._pendingIndent = true; 2123 this._pendingIndent = true;
2109 } 2124 }
2110 CodeWriter.prototype.enterBlock = function(text) { 2125 CodeWriter.prototype.enterBlock = function(text) {
2111 this.writeln(text); 2126 this.writeln(text);
2112 this._indentation++; 2127 this._indentation++;
2113 } 2128 }
2114 CodeWriter.prototype.exitBlock = function(text) { 2129 CodeWriter.prototype.exitBlock = function(text) {
2115 this._indentation--; 2130 this._indentation--;
2116 this.writeln(text); 2131 this.writeln(text);
2117 } 2132 }
(...skipping 18 matching lines...) Expand all
2136 this._usedOperators = new HashMapImplementation(); 2151 this._usedOperators = new HashMapImplementation();
2137 this.writer = new CodeWriter(); 2152 this.writer = new CodeWriter();
2138 // Initializers done 2153 // Initializers done
2139 } 2154 }
2140 CoreJs.prototype.useOperator = function(name) { 2155 CoreJs.prototype.useOperator = function(name) {
2141 if (this._usedOperators.$index(name) != null) return; 2156 if (this._usedOperators.$index(name) != null) return;
2142 var code; 2157 var code;
2143 switch (name) { 2158 switch (name) {
2144 case ":ne": 2159 case ":ne":
2145 2160
2146 code = "function $ne(x, y) {\n if (x == null) return y != null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof( y) == 'string')\n ? x != y : !x.$eq(y);\n}"/*null._NE_FUNCTION*/; 2161 code = "function $ne(x, y) {\n if (x == null) return y != null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof( y) == 'string')\n ? x != y : !x.$eq(y);\n}";
2147 break; 2162 break;
2148 2163
2149 case ":eq": 2164 case ":eq":
2150 2165
2151 code = "function $eq(x, y) {\n if (x == null) return y == null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof( y) == 'string')\n ? x == y : x.$eq(y);\n}\n// TODO(jimhug): Should this or sh ould it not match equals?\nObject.prototype.$eq = function(other) { return this === other; }"/*null._EQ_FUNCTION*/; 2166 code = "function $eq(x, y) {\n if (x == null) return y == null;\n return (typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof( y) == 'string')\n ? x == y : x.$eq(y);\n}\n// TODO(jimhug): Should this or sh ould it not match equals?\nObject.prototype.$eq = function(other) { return this === other; }";
2152 break; 2167 break;
2153 2168
2154 case ":bit_not": 2169 case ":bit_not":
2155 2170
2156 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x. $bit_not();\n}"/*null._BIT_NOT_FUNCTION*/; 2171 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x. $bit_not();\n}";
2157 break; 2172 break;
2158 2173
2159 case ":negate": 2174 case ":negate":
2160 2175
2161 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$ negate();\n}"/*null._NEGATE_FUNCTION*/; 2176 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$ negate();\n}";
2162 break; 2177 break;
2163 2178
2164 case ":add": 2179 case ":add":
2165 2180
2166 code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof( y) == 'number') ||\n (typeof(x) == 'string'))\n ? x + y : x.$add(y); \n}"/*null._ADD_FUNCTION*/; 2181 code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof( y) == 'number') ||\n (typeof(x) == 'string'))\n ? x + y : x.$add(y); \n}";
2167 break; 2182 break;
2168 2183
2169 case ":truncdiv": 2184 case ":truncdiv":
2170 2185
2171 this.useThrow = true; 2186 this.useThrow = true;
2172 code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number' && typeof( y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroException()); \n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp); \n } else {\n return x.$truncdiv(y);\n }\n}"/*null._TRUNCDIV_FUNCTION*/; 2187 code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number' && typeof( y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroException()); \n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp); \n } else {\n return x.$truncdiv(y);\n }\n}";
2173 break; 2188 break;
2174 2189
2175 case ":mod": 2190 case ":mod":
2176 2191
2177 code = "function $mod(x, y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') {\n var result = x % y;\n if (result == 0) {\n return 0; // Make sure we don't return -0.0.\n } else if (result < 0) {\n if (y < 0) {\n return result - y;\n } else {\n return result + y;\n }\n }\n return result;\n } else {\n return x.$mod(y);\n }\n}"/*nu ll._MOD_FUNCTION*/; 2192 code = "function $mod(x, y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') {\n var result = x % y;\n if (result == 0) {\n return 0; // Make sure we don't return -0.0.\n } else if (result < 0) {\n if (y < 0) {\n return result - y;\n } else {\n return result + y;\n }\n }\n return result;\n } else {\n return x.$mod(y);\n }\n}";
2178 break; 2193 break;
2179 2194
2180 default: 2195 default:
2181 2196
2182 var op = TokenKind.rawOperatorFromMethod(name); 2197 var op = TokenKind.rawOperatorFromMethod(name);
2183 var jsname = $globals.world.toJsIdentifier(name); 2198 var jsname = $globals.world.toJsIdentifier(name);
2184 code = _otherOperator(jsname, op); 2199 code = _otherOperator(jsname, op);
2185 break; 2200 break;
2186 2201
2187 } 2202 }
2188 this._usedOperators.$setindex(name, code); 2203 this._usedOperators.$setindex(name, code);
2189 } 2204 }
2190 CoreJs.prototype.ensureDynamicProto = function() { 2205 CoreJs.prototype.ensureDynamicProto = function() {
2191 if (this._generatedDynamicProto) return; 2206 if (this._generatedDynamicProto) return;
2192 this._generatedDynamicProto = true; 2207 this._generatedDynamicProto = true;
2193 this.ensureTypeNameOf(); 2208 this.ensureTypeNameOf();
2194 this.writer.writeln("function $dynamic(name) {\n var f = Object.prototype[nam e];\n if (f && f.methods) return f.methods;\n\n var methods = {};\n if (f) me thods.Object = f;\n function $dynamicBind() {\n // Find the target method\n var obj = this;\n var tag = obj.$typeNameOf();\n var method = methods[t ag];\n if (!method) {\n var table = $dynamicMetadata;\n for (var i = 0; i < table.length; i++) {\n var entry = table[i];\n if (entry. map.hasOwnProperty(tag)) {\n method = methods[entry.tag];\n if (method) break;\n }\n }\n }\n method = method || methods.Obje ct;\n // Patch the prototype, but don't overwrite an existing stub, like\n // the one on Object.prototype.\n var proto = Object.getPrototypeOf(obj);\n if (!proto.hasOwnProperty(name)) proto[name] = method;\n\n return method.a pply(this, Array.prototype.slice.call(arguments));\n };\n $dynamicBind.methods = methods;\n Object.prototype[name] = $dynamicBind;\n return methods;\n}\nif (typeof $dynamicMetadata == 'undefined') $dynamicMetadata = [];\n\nfunction $dyn amicSetMetadata(inputTable) {\n // TODO: Deal with light isolates.\n var table = [];\n for (var i = 0; i < inputTable.length; i++) {\n var tag = inputTabl e[i][0];\n var tags = inputTable[i][1];\n var map = {};\n var tagNames = tags.split('|');\n for (var j = 0; j < tagNames.length; j++) {\n map[t agNames[j]] = true;\n }\n table.push({tag: tag, tags: tags, map: map});\n }\n $dynamicMetadata = table;\n}\n"/*null._DYNAMIC_FUNCTION*/); 2209 this.writer.writeln("function $dynamic(name) {\n var f = Object.prototype[nam e];\n if (f && f.methods) return f.methods;\n\n var methods = {};\n if (f) me thods.Object = f;\n function $dynamicBind() {\n // Find the target method\n var obj = this;\n var tag = obj.$typeNameOf();\n var method = methods[t ag];\n if (!method) {\n var table = $dynamicMetadata;\n for (var i = 0; i < table.length; i++) {\n var entry = table[i];\n if (entry. map.hasOwnProperty(tag)) {\n method = methods[entry.tag];\n if (method) break;\n }\n }\n }\n method = method || methods.Obje ct;\n // Patch the prototype, but don't overwrite an existing stub, like\n // the one on Object.prototype.\n var proto = Object.getPrototypeOf(obj);\n if (!proto.hasOwnProperty(name)) proto[name] = method;\n\n return method.a pply(this, Array.prototype.slice.call(arguments));\n };\n $dynamicBind.methods = methods;\n Object.prototype[name] = $dynamicBind;\n return methods;\n}\nif (typeof $dynamicMetadata == 'undefined') $dynamicMetadata = [];\n\nfunction $dyn amicSetMetadata(inputTable) {\n // TODO: Deal with light isolates.\n var table = [];\n for (var i = 0; i < inputTable.length; i++) {\n var tag = inputTabl e[i][0];\n var tags = inputTable[i][1];\n var map = {};\n var tagNames = tags.split('|');\n for (var j = 0; j < tagNames.length; j++) {\n map[t agNames[j]] = true;\n }\n table.push({tag: tag, tags: tags, map: map});\n }\n $dynamicMetadata = table;\n}\n");
2195 } 2210 }
2196 CoreJs.prototype.ensureTypeNameOf = function() { 2211 CoreJs.prototype.ensureTypeNameOf = function() {
2197 if (this._generatedTypeNameOf) return; 2212 if (this._generatedTypeNameOf) return;
2198 this._generatedTypeNameOf = true; 2213 this._generatedTypeNameOf = true;
2199 this.writer.writeln("Object.prototype.$typeNameOf = function() {\n if ((typeo f(window) != 'undefined' && window.constructor.name == 'DOMWindow')\n || ty peof(process) != 'undefined') { // fast-path for Chrome and Node\n return thi s.constructor.name;\n }\n var str = Object.prototype.toString.call(this);\n s tr = str.substring(8, str.length - 1);\n if (str == 'Window') {\n str = 'DOM Window';\n } else if (str == 'Document') {\n str = 'HTMLDocument';\n }\n r eturn str;\n}"/*null._TYPE_NAME_OF_FUNCTION*/); 2214 this.writer.writeln("Object.prototype.$typeNameOf = function() {\n if ((typeo f(window) != 'undefined' && window.constructor.name == 'DOMWindow')\n || ty peof(process) != 'undefined') { // fast-path for Chrome and Node\n return thi s.constructor.name;\n }\n var str = Object.prototype.toString.call(this);\n s tr = str.substring(8, str.length - 1);\n if (str == 'Window') {\n str = 'DOM Window';\n } else if (str == 'Document') {\n str = 'HTMLDocument';\n }\n r eturn str;\n}");
2200 } 2215 }
2201 CoreJs.prototype.ensureInheritsHelper = function() { 2216 CoreJs.prototype.ensureInheritsHelper = function() {
2202 if (this._generatedInherits) return; 2217 if (this._generatedInherits) return;
2203 this._generatedInherits = true; 2218 this._generatedInherits = true;
2204 this.writer.writeln("/** Implements extends for Dart classes on JavaScript pro totypes. */\nfunction $inherits(child, parent) {\n if (child.prototype.__proto_ _) {\n child.prototype.__proto__ = parent.prototype;\n } else {\n functio n tmp() {};\n tmp.prototype = parent.prototype;\n child.prototype = new tm p();\n child.prototype.constructor = child;\n }\n}"/*null._INHERITS_FUNCTION */); 2219 this.writer.writeln("/** Implements extends for Dart classes on JavaScript pro totypes. */\nfunction $inherits(child, parent) {\n if (child.prototype.__proto_ _) {\n child.prototype.__proto__ = parent.prototype;\n } else {\n functio n tmp() {};\n tmp.prototype = parent.prototype;\n child.prototype = new tm p();\n child.prototype.constructor = child;\n }\n}");
2205 } 2220 }
2206 CoreJs.prototype.generate = function(w) { 2221 CoreJs.prototype.generate = function(w) {
2207 w.write(this.writer.get$text()); 2222 w.write(this.writer.get$text());
2208 this.writer = w; 2223 this.writer = w;
2209 if (this.useNotNullBool) { 2224 if (this.useNotNullBool) {
2210 this.useThrow = true; 2225 this.useThrow = true;
2211 w.writeln("function $notnull_bool(test) {\n if (test === true || test === f alse) return test;\n $throw(new TypeError(test, 'bool'));\n}"/*null._NOTNULL_BO OL_FUNCTION*/); 2226 w.writeln("function $notnull_bool(test) {\n if (test === true || test === f alse) return test;\n $throw(new TypeError(test, 'bool'));\n}");
2212 } 2227 }
2213 if (this.useThrow) { 2228 if (this.useThrow) {
2214 w.writeln("function $throw(e) {\n // If e is not a value, we can use V8's c aptureStackTrace utility method.\n // TODO(jmesserly): capture the stack trace on other JS engines.\n if (e && (typeof e == 'object') && Error.captureStackTra ce) {\n // TODO(jmesserly): this will clobber the e.stack property\n Error .captureStackTrace(e, $throw);\n }\n throw e;\n}"/*null._THROW_FUNCTION*/); 2229 w.writeln("function $throw(e) {\n // If e is not a value, we can use V8's c aptureStackTrace utility method.\n // TODO(jmesserly): capture the stack trace on other JS engines.\n if (e && (typeof e == 'object') && Error.captureStackTra ce) {\n // TODO(jmesserly): this will clobber the e.stack property\n Error .captureStackTrace(e, $throw);\n }\n throw e;\n}");
2215 } 2230 }
2216 if (this.useIndex) { 2231 if (this.useIndex) {
2217 w.writeln("Object.prototype.$index = function(i) {\n var proto = Object.get PrototypeOf(this);\n if (proto !== Object) {\n proto.$index = function(i) { return this[i]; }\n }\n return this[i];\n}\nArray.prototype.$index = function( i) { return this[i]; }\nString.prototype.$index = function(i) { return this[i]; }"/*null._INDEX_OPERATORS*/); 2232 w.writeln("Object.prototype.$index = function(i) {\n var proto = Object.get PrototypeOf(this);\n if (proto !== Object) {\n proto.$index = function(i) { return this[i]; }\n }\n return this[i];\n}\nArray.prototype.$index = function( i) { return this[i]; }\nString.prototype.$index = function(i) { return this[i]; }");
2218 } 2233 }
2219 if (this.useSetIndex) { 2234 if (this.useSetIndex) {
2220 w.writeln("Object.prototype.$setindex = function(i, value) {\n var proto = Object.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$setindex = f unction(i, value) { return this[i] = value; }\n }\n return this[i] = value;\n} \nArray.prototype.$setindex = function(i, value) { return this[i] = value; }"/*n ull._SETINDEX_OPERATORS*/); 2235 w.writeln("Object.prototype.$setindex = function(i, value) {\n var proto = Object.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$setindex = f unction(i, value) { return this[i] = value; }\n }\n return this[i] = value;\n} \nArray.prototype.$setindex = function(i, value) { return this[i] = value; }");
2221 } 2236 }
2222 if (this.useIsolates) { 2237 if (this.useIsolates) {
2223 if (this.useWrap0) { 2238 if (this.useWrap0) {
2224 w.writeln("// Wrap a 0-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }\nFunction.proto type.wrap$call$0 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$0 = function() {\n isolateContext.eval( self);\n $globalState.topEventLoop.run();\n };\n this.wrap$call$0 = functio n() { return this.wrap$0; };\n return this.wrap$0;\n}"/*null._WRAP_CALL0_FUNCTI ON*/); 2239 w.writeln("// Wrap a 0-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }\nFunction.proto type.wrap$call$0 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$0 = function() {\n isolateContext.eval( self);\n $globalState.topEventLoop.run();\n };\n this.wrap$call$0 = functio n() { return this.wrap$0; };\n return this.wrap$0;\n}");
2225 } 2240 }
2226 if (this.useWrap1) { 2241 if (this.useWrap1) {
2227 w.writeln("// Wrap a 1-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }\nFunction.proto type.wrap$call$1 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$1 = function(arg) {\n isolateContext.ev al(function() { self(arg); });\n $globalState.topEventLoop.run();\n };\n th is.wrap$call$1 = function() { return this.wrap$1; };\n return this.wrap$1;\n}"/ *null._WRAP_CALL1_FUNCTION*/); 2242 w.writeln("// Wrap a 1-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }\nFunction.proto type.wrap$call$1 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$1 = function(arg) {\n isolateContext.ev al(function() { self(arg); });\n $globalState.topEventLoop.run();\n };\n th is.wrap$call$1 = function() { return this.wrap$1; };\n return this.wrap$1;\n}") ;
2228 } 2243 }
2229 w.writeln("var $globalThis = this;\nvar $globals = null;\nvar $globalState = null;"/*null._ISOLATE_INIT_CODE*/); 2244 w.writeln("var $globalThis = this;\nvar $globals = null;\nvar $globalState = null;");
2230 } 2245 }
2231 else { 2246 else {
2232 if (this.useWrap0) { 2247 if (this.useWrap0) {
2233 w.writeln("function $wrap_call$0(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L0_FUNCTION*/); 2248 w.writeln("function $wrap_call$0(fn) { return fn; }");
2234 } 2249 }
2235 if (this.useWrap1) { 2250 if (this.useWrap1) {
2236 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L1_FUNCTION*/); 2251 w.writeln("function $wrap_call$1(fn) { return fn; }");
2237 } 2252 }
2238 } 2253 }
2239 var $$list = orderValuesByKeys(this._usedOperators); 2254 var $$list = orderValuesByKeys(this._usedOperators);
2240 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2255 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2241 var opImpl = $$list.$index($$i); 2256 var opImpl = $$list.$index($$i);
2242 w.writeln(opImpl); 2257 w.writeln(opImpl);
2243 } 2258 }
2244 if ($globals.world.dom != null) { 2259 if ($globals.world.dom != null) {
2245 this.ensureTypeNameOf(); 2260 this.ensureTypeNameOf();
2246 w.writeln("Object.prototype.get$typeName = Object.prototype.$typeNameOf;"); 2261 w.writeln("Object.prototype.get$typeName = Object.prototype.$typeNameOf;");
(...skipping 26 matching lines...) Expand all
2273 Element.prototype.get$jsname = function() { 2288 Element.prototype.get$jsname = function() {
2274 return this._jsname; 2289 return this._jsname;
2275 } 2290 }
2276 Element.prototype.get$nativeName = function() { 2291 Element.prototype.get$nativeName = function() {
2277 return this._jsname; 2292 return this._jsname;
2278 } 2293 }
2279 Element.prototype.get$avoidNativeName = function() { 2294 Element.prototype.get$avoidNativeName = function() {
2280 return false; 2295 return false;
2281 } 2296 }
2282 Element.prototype.get$jsnamePriority = function() { 2297 Element.prototype.get$jsnamePriority = function() {
2283 return this.get$isNative() ? 2 : (this.get$library().get$isCore() ? 1 : 0); 2298 return this.get$isNative() ? (2) : (this.get$library().get$isCore() ? (1) : (0 ));
2284 } 2299 }
2285 Element.prototype.resolve = function() { 2300 Element.prototype.resolve = function() {
2286 2301
2287 } 2302 }
2288 Element.prototype.get$typeParameters = function() { 2303 Element.prototype.get$typeParameters = function() {
2289 return null; 2304 return null;
2290 } 2305 }
2291 Element.prototype.get$enclosingElement = function() { 2306 Element.prototype.get$enclosingElement = function() {
2292 return this._enclosingElement == null ? this.get$library() : this._enclosingEl ement; 2307 return this._enclosingElement == null ? this.get$library() : this._enclosingEl ement;
2293 } 2308 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 var baseType = this.resolveType(typeRef.baseType, typeErrors); 2340 var baseType = this.resolveType(typeRef.baseType, typeErrors);
2326 if (!baseType.get$isGeneric()) { 2341 if (!baseType.get$isGeneric()) {
2327 $globals.world.error(("" + baseType.get$name() + " is not generic"), typeR ef.span); 2342 $globals.world.error(("" + baseType.get$name() + " is not generic"), typeR ef.span);
2328 return null; 2343 return null;
2329 } 2344 }
2330 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$ length()) { 2345 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$ length()) {
2331 $globals.world.error("wrong number of type arguments", typeRef.span); 2346 $globals.world.error("wrong number of type arguments", typeRef.span);
2332 return null; 2347 return null;
2333 } 2348 }
2334 var typeArgs = []; 2349 var typeArgs = [];
2335 for (var i = 0; 2350 for (var i = (0);
2336 i < typeRef.typeArguments.get$length(); i++) { 2351 i < typeRef.typeArguments.get$length(); i++) {
2337 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s)); 2352 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s));
2338 } 2353 }
2339 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs); 2354 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs);
2340 } 2355 }
2341 else if ((node instanceof FunctionTypeReference)) { 2356 else if ((node instanceof FunctionTypeReference)) {
2342 var typeRef = node; 2357 var typeRef = node;
2343 var name = ""; 2358 var name = "";
2344 if (typeRef.func.name != null) { 2359 if (typeRef.func.name != null) {
2345 name = typeRef.func.name.name; 2360 name = typeRef.func.name.name;
(...skipping 25 matching lines...) Expand all
2371 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]); 2386 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]);
2372 } 2387 }
2373 $globals.world.numImplType.markUsed(); 2388 $globals.world.numImplType.markUsed();
2374 $globals.world.stringImplType.markUsed(); 2389 $globals.world.stringImplType.markUsed();
2375 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) { 2390 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) {
2376 if (this.corejs.useWrap0 || this.corejs.useWrap1) { 2391 if (this.corejs.useWrap0 || this.corejs.useWrap1) {
2377 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM ember$1("eval")); 2392 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM ember$1("eval"));
2378 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember $1("run")); 2393 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember $1("run"));
2379 } 2394 }
2380 this.corejs.useIsolates = true; 2395 this.corejs.useIsolates = true;
2381 var isolateMain = $globals.world.coreimpl.topType.resolveMember("startRootIs olate").members.$index(0); 2396 var isolateMain = $globals.world.coreimpl.topType.resolveMember("startRootIs olate").members.$index((0));
2382 var isolateMainTarget = new Value.type$ctor($globals.world.coreimpl.topType, this.main.get$span()); 2397 var isolateMainTarget = new Value.type$ctor($globals.world.coreimpl.topType, this.main.get$span());
2383 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); 2398 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false);
2384 } 2399 }
2385 this.writeTypes($globals.world.coreimpl); 2400 this.writeTypes($globals.world.coreimpl);
2386 this.writeTypes($globals.world.corelib); 2401 this.writeTypes($globals.world.corelib);
2387 this.writeTypes(this.main.declaringType.get$library()); 2402 this.writeTypes(this.main.declaringType.get$library());
2388 if (this._mixins != null) this.writer.write(this._mixins.get$text()); 2403 if (this._mixins != null) this.writer.write(this._mixins.get$text());
2389 this.writeDynamicDispatchMetadata(); 2404 this.writeDynamicDispatchMetadata();
2390 this.writeGlobals(); 2405 this.writeGlobals();
2391 this.writer.writeln(("" + mainCall.get$code() + ";")); 2406 this.writer.writeln(("" + mainCall.get$code() + ";"));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 }).bind(null, lib, toCheck) 2449 }).bind(null, lib, toCheck)
2435 ); 2450 );
2436 lib.get$types().getValues$0().forEach$1((function (t) { 2451 lib.get$types().getValues$0().forEach$1((function (t) {
2437 return types.add(t); 2452 return types.add(t);
2438 }) 2453 })
2439 ); 2454 );
2440 } 2455 }
2441 } 2456 }
2442 return types; 2457 return types;
2443 } 2458 }
2444 WorldGenerator.prototype.globalForStaticField = function(field, fieldValue, depe ndencies) { 2459 WorldGenerator.prototype.globalForStaticField = function(field, exp, dependencie s) {
2445 this.hasStatics = true; 2460 this.hasStatics = true;
2446 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ()); 2461 var key = ("" + field.declaringType.get$jsname() + "." + field.get$jsname());
2447 if (!this.globals.containsKey(fullname)) { 2462 var ret = this.globals.$index(key);
2448 this.globals.$setindex(fullname, GlobalValue.GlobalValue$fromStatic$factory( field, fieldValue, dependencies)); 2463 if (ret == null) {
2464 ret = new GlobalValue(exp.get$type(), exp.get$code(), field.isFinal, field, null, exp, exp.span, dependencies);
2465 this.globals.$setindex(key, ret);
2449 } 2466 }
2450 return this.globals.$index(fullname); 2467 return ret;
2451 } 2468 }
2452 WorldGenerator.prototype.globalForConst = function(exp, dependencies) { 2469 WorldGenerator.prototype.globalForConst = function(exp, dependencies) {
2453 var key = exp.get$type().get$jsname() + ":" + exp.canonicalCode; 2470 var key = exp.get$type().get$jsname() + ":" + exp.get$code();
2454 if (!this.globals.containsKey(key)) { 2471 var ret = this.globals.$index(key);
2455 this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.g lobals.get$length(), exp, dependencies)); 2472 if (ret == null) {
2473 var name = ("const$" + this.globals.get$length());
2474 ret = new GlobalValue(exp.get$type(), name, true, null, name, exp, exp.span, dependencies);
2475 this.globals.$setindex(key, ret);
2456 } 2476 }
2457 return this.globals.$index(key); 2477 return ret;
2458 } 2478 }
2459 WorldGenerator.prototype.writeTypes = function(lib) { 2479 WorldGenerator.prototype.writeTypes = function(lib) {
2460 if (lib.isWritten) return; 2480 if (lib.isWritten) return;
2461 lib.isWritten = true; 2481 lib.isWritten = true;
2462 var $$list = lib.imports; 2482 var $$list = lib.imports;
2463 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2483 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2464 var import_ = $$list.$index($$i); 2484 var import_ = $$list.$index($$i);
2465 this.writeTypes(import_.get$library()); 2485 this.writeTypes(import_.get$library());
2466 } 2486 }
2467 for (var i = 0; 2487 for (var i = (0);
2468 i < lib.sources.get$length(); i++) { 2488 i < lib.sources.get$length(); i++) {
2469 lib.sources.$index(i).set$orderInLibrary(i); 2489 lib.sources.$index(i).set$orderInLibrary(i);
2470 } 2490 }
2471 this.writer.comment(("// ********** Library " + lib.name + " **************") ); 2491 this.writer.comment(("// ********** Library " + lib.name + " **************") );
2472 if (lib.get$isCore()) { 2492 if (lib.get$isCore()) {
2473 this.writer.comment("// ********** Natives dart:core **************"); 2493 this.writer.comment("// ********** Natives dart:core **************");
2474 this.corejs.generate(this.writer); 2494 this.corejs.generate(this.writer);
2475 } 2495 }
2476 var $$list = lib.natives; 2496 var $$list = lib.natives;
2477 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2497 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2478 var file = $$list.$index($$i); 2498 var file = $$list.$index($$i);
2479 var filename = basename(file.get$filename()); 2499 var filename = basename(file.get$filename());
2480 this.writer.comment(("// ********** Natives " + filename + " ************** ")); 2500 this.writer.comment(("// ********** Natives " + filename + " ************** "));
2481 this.writer.writeln(file.get$text()); 2501 this.writer.writeln(file.get$text());
2482 } 2502 }
2483 lib.topType.markUsed(); 2503 lib.topType.markUsed();
2484 var $$list = this._orderValues(lib.types); 2504 var $$list = this._orderValues(lib.types);
2485 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2505 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2486 var type = $$list.$index($$i); 2506 var type = $$list.$index($$i);
2487 if ((type.get$isUsed() || type.get$library().get$isDom() || type.get$isHidde nNativeType()) && type.get$isClass()) { 2507 if ((type.get$isUsed() || type.get$library().get$isDom() || type.get$isHidde nNativeType()) && type.get$isClass()) {
2488 this.writeType(type); 2508 this.writeType(type);
2489 if (type.get$isGeneric()) { 2509 if (type.get$isGeneric()) {
2490 var $list0 = this._orderValues(type.get$_concreteTypes()); 2510 var $list0 = this._orderValues(type.get$_concreteTypes());
2491 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) { 2511 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) {
2492 var ct = $list0.$index($i0); 2512 var ct = $list0.$index($i0);
2493 this.writeType(ct); 2513 this.writeType(ct);
2494 } 2514 }
2495 } 2515 }
2496 } 2516 }
2497 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) { 2517 else if (type.get$isFunction() && type.get$varStubs().get$length() > (0)) {
2498 this.writer.comment(("// ********** Code for " + type.get$jsname() + " *** ***********")); 2518 this.writer.comment(("// ********** Code for " + type.get$jsname() + " *** ***********"));
2499 this._writeDynamicStubs(type); 2519 this._writeDynamicStubs(type);
2500 } 2520 }
2501 if (type.get$typeCheckCode() != null) { 2521 if (type.get$typeCheckCode() != null) {
2502 this.writer.writeln(type.get$typeCheckCode()); 2522 this.writer.writeln(type.get$typeCheckCode());
2503 } 2523 }
2504 } 2524 }
2505 } 2525 }
2506 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) { 2526 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) {
2507 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) { 2527 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 } 2599 }
2580 else if (!type.get$isNative()) { 2600 else if (!type.get$isNative()) {
2581 if (type.get$parent() != null && !type.get$parent().get$isObject()) { 2601 if (type.get$parent() != null && !type.get$parent().get$isObject()) {
2582 this.corejs.ensureInheritsHelper(); 2602 this.corejs.ensureInheritsHelper();
2583 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$ parent().get$jsname() + ");")); 2603 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$ parent().get$jsname() + ");"));
2584 } 2604 }
2585 } 2605 }
2586 } 2606 }
2587 if (type.get$isTop()) { 2607 if (type.get$isTop()) {
2588 } 2608 }
2589 else if (type.get$constructors().get$length() == 0) { 2609 else if (type.get$constructors().get$length() == (0)) {
2590 if (!type.get$isNative()) { 2610 if (!type.get$isNative()) {
2591 this.writer.writeln(("function " + type.get$jsname() + "() {}")); 2611 this.writer.writeln(("function " + type.get$jsname() + "() {}"));
2592 } 2612 }
2593 } 2613 }
2594 else { 2614 else {
2595 var standardConstructor = type.get$constructors().$index(""); 2615 var standardConstructor = type.get$constructors().$index("");
2596 if (standardConstructor == null || standardConstructor.generator == null) { 2616 if (standardConstructor == null || standardConstructor.generator == null) {
2597 if (!type.get$isNative()) { 2617 if (!type.get$isNative()) {
2598 this.writer.writeln(("function " + type.get$jsname() + "() {}")); 2618 this.writer.writeln(("function " + type.get$jsname() + "() {}"));
2599 } 2619 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 m.generator.writeDefinition(this.writer, null); 2751 m.generator.writeDefinition(this.writer, null);
2732 } 2752 }
2733 else if ((m instanceof MethodMember) && m.get$isNative() && m._provideProperty Syntax && !m._provideFieldSyntax) { 2753 else if ((m instanceof MethodMember) && m.get$isNative() && m._provideProperty Syntax && !m._provideFieldSyntax) {
2734 MethodGenerator._maybeGenerateBoundGetter(m, this.writer); 2754 MethodGenerator._maybeGenerateBoundGetter(m, this.writer);
2735 } 2755 }
2736 } 2756 }
2737 WorldGenerator.prototype.get$_writeMethod = function() { 2757 WorldGenerator.prototype.get$_writeMethod = function() {
2738 return this._writeMethod.bind(this); 2758 return this._writeMethod.bind(this);
2739 } 2759 }
2740 WorldGenerator.prototype.writeGlobals = function() { 2760 WorldGenerator.prototype.writeGlobals = function() {
2741 if (this.globals.get$length() > 0) { 2761 if (this.globals.get$length() > (0)) {
2742 this.writer.comment("// ********** Globals **************"); 2762 this.writer.comment("// ********** Globals **************");
2743 var list = this.globals.getValues(); 2763 var list = this.globals.getValues();
2744 list.sort$1((function (a, b) { 2764 list.sort$1((function (a, b) {
2745 return a.compareTo$1(b); 2765 return a.compareTo$1(b);
2746 }) 2766 })
2747 ); 2767 );
2748 this.writer.enterBlock("function $static_init(){"); 2768 this.writer.enterBlock("function $static_init(){");
2749 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { 2769 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
2750 var global = $$i.next$0(); 2770 var global = $$i.next$0();
2751 if (global.get$field() != null) { 2771 if (global.get$field() != null) {
2752 this._writeStaticField(global.get$field()); 2772 this._writeStaticField(global.get$field());
2753 } 2773 }
2754 } 2774 }
2755 this.writer.exitBlock("}"); 2775 this.writer.exitBlock("}");
2756 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { 2776 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
2757 var global = $$i.next$0(); 2777 var global = $$i.next$0();
2758 if (global.get$field() == null) { 2778 if (global.get$field() == null) {
2759 this.writer.writeln(("var " + global.get$name() + " = " + global.get$exp ().get$code() + ";")); 2779 this.writer.writeln(("var " + global.get$name() + " = " + global.get$exp ().get$code() + ";"));
2760 } 2780 }
2761 } 2781 }
2762 } 2782 }
2763 if (!this.corejs.useIsolates) { 2783 if (!this.corejs.useIsolates) {
2764 if (this.hasStatics) { 2784 if (this.hasStatics) {
2765 this.writer.writeln("var $globals = {};"); 2785 this.writer.writeln("var $globals = {};");
2766 } 2786 }
2767 if (this.globals.get$length() > 0) { 2787 if (this.globals.get$length() > (0)) {
2768 this.writer.writeln("$static_init();"); 2788 this.writer.writeln("$static_init();");
2769 } 2789 }
2770 } 2790 }
2771 } 2791 }
2772 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { 2792 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) {
2773 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new HashSetImplementation(); 2793 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new HashSetImplementation();
2774 this.typesWithDynamicDispatch.add(type); 2794 this.typesWithDynamicDispatch.add(type);
2775 } 2795 }
2776 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { 2796 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() {
2777 var $this = this; // closure support 2797 var $this = this; // closure support
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 tagDefns.$setindex(tag, varName); 2850 tagDefns.$setindex(tag, varName);
2831 expressions.add$1(varName); 2851 expressions.add$1(varName);
2832 } 2852 }
2833 } 2853 }
2834 } 2854 }
2835 } 2855 }
2836 walk(type); 2856 walk(type);
2837 var constantPart = ("'" + Strings.join(subtags, "|") + "'"); 2857 var constantPart = ("'" + Strings.join(subtags, "|") + "'");
2838 if ($ne(constantPart, "''")) expressions.add$1(constantPart); 2858 if ($ne(constantPart, "''")) expressions.add$1(constantPart);
2839 var expression; 2859 var expression;
2840 if ($eq(expressions.get$length(), 1)) { 2860 if ($eq(expressions.get$length(), (1))) {
2841 expression = expressions.$index(0); 2861 expression = expressions.$index((0));
2842 } 2862 }
2843 else { 2863 else {
2844 expression = ("[" + Strings.join(expressions, ",") + "].join('|')"); 2864 expression = ("[" + Strings.join(expressions, ",") + "].join('|')");
2845 } 2865 }
2846 return expression; 2866 return expression;
2847 } 2867 }
2848 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { 2868 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) {
2849 var type = $$i.next$0(); 2869 var type = $$i.next$0();
2850 tagDefns.$setindex(type.get$nativeName(), makeExpression(type)); 2870 tagDefns.$setindex(type.get$nativeName(), makeExpression(type));
2851 } 2871 }
(...skipping 20 matching lines...) Expand all
2872 return values; 2892 return values;
2873 } 2893 }
2874 WorldGenerator.prototype._orderCollectionValues = function(collection) { 2894 WorldGenerator.prototype._orderCollectionValues = function(collection) {
2875 var values = ListFactory.ListFactory$from$factory(collection); 2895 var values = ListFactory.ListFactory$from$factory(collection);
2876 values.sort(this.get$_compareMembers()); 2896 values.sort(this.get$_compareMembers());
2877 return values; 2897 return values;
2878 } 2898 }
2879 WorldGenerator.prototype._compareMembers = function(x, y) { 2899 WorldGenerator.prototype._compareMembers = function(x, y) {
2880 if (x.get$span() != null && y.get$span() != null) { 2900 if (x.get$span() != null && y.get$span() != null) {
2881 var spans = x.get$span().compareTo$1(y.get$span()); 2901 var spans = x.get$span().compareTo$1(y.get$span());
2882 if (spans != 0) return spans; 2902 if (spans != (0)) return spans;
2883 } 2903 }
2884 if (x.get$span() == null) return 1; 2904 if (x.get$span() == null) return (1);
2885 if (y.get$span() == null) return -1; 2905 if (y.get$span() == null) return (-1);
2886 return x.get$name().compareTo$1(y.get$name()); 2906 return x.get$name().compareTo$1(y.get$name());
2887 } 2907 }
2888 WorldGenerator.prototype.get$_compareMembers = function() { 2908 WorldGenerator.prototype.get$_compareMembers = function() {
2889 return this._compareMembers.bind(this); 2909 return this._compareMembers.bind(this);
2890 } 2910 }
2891 // ********** Code for BlockScope ************** 2911 // ********** Code for BlockScope **************
2892 function BlockScope(enclosingMethod, parent, reentrant) { 2912 function BlockScope(enclosingMethod, parent, reentrant) {
2893 this.enclosingMethod = enclosingMethod; 2913 this.enclosingMethod = enclosingMethod;
2894 this.parent = parent; 2914 this.parent = parent;
2895 this.reentrant = reentrant; 2915 this.reentrant = reentrant;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 var type = this.enclosingMethod.method.declaringType; 2973 var type = this.enclosingMethod.method.declaringType;
2954 if (type.get$library().lookup(name, null) != null) return true; 2974 if (type.get$library().lookup(name, null) != null) return true;
2955 return false; 2975 return false;
2956 } 2976 }
2957 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) { 2977 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) {
2958 var jsName = $globals.world.toJsIdentifier(name); 2978 var jsName = $globals.world.toJsIdentifier(name);
2959 if (this._vars.containsKey(name)) { 2979 if (this._vars.containsKey(name)) {
2960 $globals.world.error(("duplicate name \"" + name + "\""), span); 2980 $globals.world.error(("duplicate name \"" + name + "\""), span);
2961 } 2981 }
2962 if (!isParameter) { 2982 if (!isParameter) {
2963 var index = 0; 2983 var index = (0);
2964 while (this._isDefinedInParent(jsName)) { 2984 while (this._isDefinedInParent(jsName)) {
2965 jsName = ("" + name + (index++)); 2985 jsName = ("" + name + (index++));
2966 } 2986 }
2967 } 2987 }
2968 var ret = new Value(type, jsName, span, false); 2988 var ret = new Value(type, jsName, span, false);
2969 ret.set$isFinal(isFinal); 2989 ret.set$isFinal(isFinal);
2970 this._vars.$setindex(name, ret); 2990 this._vars.$setindex(name, ret);
2971 if (name != jsName) this._jsNames.add(jsName); 2991 if (name != jsName) this._jsNames.add(jsName);
2972 return ret; 2992 return ret;
2973 } 2993 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 return (this.enclosingMethod != null); 3038 return (this.enclosingMethod != null);
3019 } 3039 }
3020 MethodGenerator.prototype.get$isStatic = function() { 3040 MethodGenerator.prototype.get$isStatic = function() {
3021 return this.method.get$isStatic(); 3041 return this.method.get$isStatic();
3022 } 3042 }
3023 MethodGenerator.prototype.getTemp = function(value) { 3043 MethodGenerator.prototype.getTemp = function(value) {
3024 return value.needsTemp ? this.forceTemp(value) : value; 3044 return value.needsTemp ? this.forceTemp(value) : value;
3025 } 3045 }
3026 MethodGenerator.prototype.forceTemp = function(value) { 3046 MethodGenerator.prototype.forceTemp = function(value) {
3027 var name; 3047 var name;
3028 if (this._freeTemps.get$length() > 0) { 3048 if (this._freeTemps.get$length() > (0)) {
3029 name = this._freeTemps.removeLast(); 3049 name = this._freeTemps.removeLast();
3030 } 3050 }
3031 else { 3051 else {
3032 name = "$" + this._usedTemps.get$length(); 3052 name = "$" + this._usedTemps.get$length();
3033 } 3053 }
3034 this._usedTemps.add(name); 3054 this._usedTemps.add(name);
3035 return new Value(value.get$type(), name, value.span, false); 3055 return new Value(value.get$type(), name, value.span, false);
3036 } 3056 }
3037 MethodGenerator.prototype.assignTemp = function(tmp, v) { 3057 MethodGenerator.prototype.assignTemp = function(tmp, v) {
3038 if ($eq(tmp, v)) { 3058 if ($eq(tmp, v)) {
3039 return v; 3059 return v;
3040 } 3060 }
3041 else { 3061 else {
3042 return new Value(v.get$type(), ("(" + tmp.code + " = " + v.code + ")"), v.sp an, true); 3062 return new Value(v.get$type(), ("(" + tmp.get$code() + " = " + v.get$code() + ")"), v.span, true);
3043 } 3063 }
3044 } 3064 }
3045 MethodGenerator.prototype.freeTemp = function(value) { 3065 MethodGenerator.prototype.freeTemp = function(value) {
3046 if (this._usedTemps.remove(value.code)) { 3066 if (this._usedTemps.remove(value.get$code())) {
3047 this._freeTemps.add(value.code); 3067 this._freeTemps.add(value.get$code());
3048 } 3068 }
3049 else { 3069 else {
3050 $globals.world.internalError(("tried to free unused value or non-temp \"" + value.code + "\"")); 3070 $globals.world.internalError(("tried to free unused value or non-temp \"" + value.get$code() + "\""));
3051 } 3071 }
3052 } 3072 }
3053 MethodGenerator.prototype.run = function() { 3073 MethodGenerator.prototype.run = function() {
3054 if (this.method.isGenerated) return; 3074 if (this.method.isGenerated) return;
3055 this.method.isGenerated = true; 3075 this.method.isGenerated = true;
3056 this.method.generator = this; 3076 this.method.generator = this;
3057 this.writeBody(); 3077 this.writeBody();
3058 if (this.method.get$definition().get$nativeBody() != null) { 3078 if (this.method.get$definition().get$nativeBody() != null) {
3059 this.writer = new CodeWriter(); 3079 this.writer = new CodeWriter();
3060 if ($eq(this.method.get$definition().get$nativeBody(), "")) { 3080 if ($eq(this.method.get$definition().get$nativeBody(), "")) {
3061 this.method.generator = null; 3081 this.method.generator = null;
3062 } 3082 }
3063 else { 3083 else {
3064 this._paramCode = map(this.method.get$parameters(), (function (p) { 3084 this._paramCode = map(this.method.get$parameters(), (function (p) {
3065 return p.get$name(); 3085 return p.get$name();
3066 }) 3086 })
3067 ); 3087 );
3068 this.writer.write(this.method.get$definition().get$nativeBody()); 3088 this.writer.write(this.method.get$definition().get$nativeBody());
3069 } 3089 }
3070 } 3090 }
3071 } 3091 }
3072 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) { 3092 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) {
3073 var paramCode = this._paramCode; 3093 var paramCode = this._paramCode;
3074 var names = null; 3094 var names = null;
3075 if (this.captures != null && this.captures.get$length() > 0) { 3095 if (this.captures != null && this.captures.get$length() > (0)) {
3076 names = ListFactory.ListFactory$from$factory(this.captures); 3096 names = ListFactory.ListFactory$from$factory(this.captures);
3077 names.sort$1((function (x, y) { 3097 names.sort$1((function (x, y) {
3078 return x.compareTo$1(y); 3098 return x.compareTo$1(y);
3079 }) 3099 })
3080 ); 3100 );
3081 paramCode = ListFactory.ListFactory$from$factory(names); 3101 paramCode = ListFactory.ListFactory$from$factory(names);
3082 paramCode.addAll$1(this._paramCode); 3102 paramCode.addAll$1(this._paramCode);
3083 } 3103 }
3084 var _params = ("(" + Strings.join(this._paramCode, ", ") + ")"); 3104 var _params = ("(" + Strings.join(this._paramCode, ", ") + ")");
3085 var params = ("(" + Strings.join(paramCode, ", ") + ")"); 3105 var params = ("(" + Strings.join(paramCode, ", ") + ")");
(...skipping 29 matching lines...) Expand all
3115 } 3135 }
3116 else if (this.method.get$isStatic()) { 3136 else if (this.method.get$isStatic()) {
3117 defWriter.enterBlock(("" + this.method.declaringType.get$jsname() + "." + th is.method.get$jsname() + " = function" + _params + " {")); 3137 defWriter.enterBlock(("" + this.method.declaringType.get$jsname() + "." + th is.method.get$jsname() + " = function" + _params + " {"));
3118 } 3138 }
3119 else { 3139 else {
3120 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (" = function" + _params + " {")); 3140 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (" = function" + _params + " {"));
3121 } 3141 }
3122 if (this.needsThis) { 3142 if (this.needsThis) {
3123 defWriter.writeln("var $this = this; // closure support"); 3143 defWriter.writeln("var $this = this; // closure support");
3124 } 3144 }
3125 if (this._usedTemps.get$length() > 0 || this._freeTemps.get$length() > 0) { 3145 if (this._usedTemps.get$length() > (0) || this._freeTemps.get$length() > (0)) {
3126 this._freeTemps.addAll(this._usedTemps); 3146 this._freeTemps.addAll(this._usedTemps);
3127 this._freeTemps.sort((function (x, y) { 3147 this._freeTemps.sort((function (x, y) {
3128 return x.compareTo$1(y); 3148 return x.compareTo$1(y);
3129 }) 3149 })
3130 ); 3150 );
3131 defWriter.writeln(("var " + Strings.join(this._freeTemps, ", ") + ";")); 3151 defWriter.writeln(("var " + Strings.join(this._freeTemps, ", ") + ";"));
3132 } 3152 }
3133 defWriter.writeln(this.writer.get$text()); 3153 defWriter.writeln(this.writer.get$text());
3134 if (names != null) { 3154 if (names != null) {
3135 defWriter.exitBlock(("}).bind(null, " + Strings.join(names, ", ") + ")")); 3155 defWriter.exitBlock(("}).bind(null, " + Strings.join(names, ", ") + ")"));
(...skipping 30 matching lines...) Expand all
3166 var optValues = []; 3186 var optValues = [];
3167 meth.genParameterValues(); 3187 meth.genParameterValues();
3168 var $$list = meth.parameters; 3188 var $$list = meth.parameters;
3169 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3189 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3170 var param = $$list.$index($$i); 3190 var param = $$list.$index($$i);
3171 if (param.get$isOptional()) { 3191 if (param.get$isOptional()) {
3172 optNames.add$1(param.get$name()); 3192 optNames.add$1(param.get$name());
3173 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de())); 3193 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de()));
3174 } 3194 }
3175 } 3195 }
3176 if (optNames.get$length() > 0) { 3196 if (optNames.get$length() > (0)) {
3177 var start = ""; 3197 var start = "";
3178 if (meth.isStatic) { 3198 if (meth.isStatic) {
3179 if (!meth.declaringType.get$isTop()) { 3199 if (!meth.declaringType.get$isTop()) {
3180 start = meth.declaringType.get$jsname() + "."; 3200 start = meth.declaringType.get$jsname() + ".";
3181 } 3201 }
3182 } 3202 }
3183 else { 3203 else {
3184 start = meth.declaringType.get$jsname() + ".prototype."; 3204 start = meth.declaringType.get$jsname() + ".prototype.";
3185 } 3205 }
3186 optNames.addAll$1(optValues); 3206 optNames.addAll$1(optValues);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 } 3264 }
3245 if (declaredInitializers != null) { 3265 if (declaredInitializers != null) {
3246 for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) { 3266 for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) {
3247 var init = $$i.next$0(); 3267 var init = $$i.next$0();
3248 if ((init instanceof CallExpression)) { 3268 if ((init instanceof CallExpression)) {
3249 if (initializerCall != null) { 3269 if (initializerCall != null) {
3250 $globals.world.error("only one initializer redirecting call is allow ed", init.get$span()); 3270 $globals.world.error("only one initializer redirecting call is allow ed", init.get$span());
3251 } 3271 }
3252 initializerCall = init; 3272 initializerCall = init;
3253 } 3273 }
3254 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign( init.get$op().get$kind()) == 0) { 3274 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign( init.get$op().get$kind()) == (0)) {
3255 var left = init.get$x(); 3275 var left = init.get$x();
3256 if (!((left instanceof DotExpression) && (left.get$self() instanceof T hisExpression) || (left instanceof VarExpression))) { 3276 if (!((left instanceof DotExpression) && (left.get$self() instanceof T hisExpression) || (left instanceof VarExpression))) {
3257 $globals.world.error("invalid left side of initializer", left.get$sp an()); 3277 $globals.world.error("invalid left side of initializer", left.get$sp an());
3258 continue; 3278 continue;
3259 } 3279 }
3260 var f = this.method.declaringType.getMember(left.get$name().get$name() ); 3280 var f = this.method.declaringType.getMember(left.get$name().get$name() );
3261 if (f == null) { 3281 if (f == null) {
3262 $globals.world.error("bad initializer - no matching field", left.get $span()); 3282 $globals.world.error("bad initializer - no matching field", left.get $span());
3263 continue; 3283 continue;
3264 } 3284 }
(...skipping 13 matching lines...) Expand all
3278 } 3298 }
3279 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) { 3299 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) {
3280 var parentType = this.method.declaringType.get$parent(); 3300 var parentType = this.method.declaringType.get$parent();
3281 if (parentType != null && !parentType.get$isObject()) { 3301 if (parentType != null && !parentType.get$isObject()) {
3282 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span()); 3302 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span());
3283 } 3303 }
3284 } 3304 }
3285 if (initializerCall != null) { 3305 if (initializerCall != null) {
3286 var target = this._writeInitializerCall(initializerCall); 3306 var target = this._writeInitializerCall(initializerCall);
3287 if (!target.get$isSuper()) { 3307 if (!target.get$isSuper()) {
3288 if (initializers.get$length() > 0) { 3308 if (initializers.get$length() > (0)) {
3289 var $$list = this.method.get$parameters(); 3309 var $$list = this.method.get$parameters();
3290 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3310 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3291 var p = $$list.$index($$i); 3311 var p = $$list.$index($$i);
3292 if (p.get$isInitializer()) { 3312 if (p.get$isInitializer()) {
3293 $globals.world.error("no initialization allowed on redirecting const ructors", p.get$definition().get$span()); 3313 $globals.world.error("no initialization allowed on redirecting const ructors", p.get$definition().get$span());
3294 break; 3314 break;
3295 } 3315 }
3296 } 3316 }
3297 } 3317 }
3298 if (declaredInitializers != null && declaredInitializers.get$length() > 1) { 3318 if (declaredInitializers != null && declaredInitializers.get$length() > (1 )) {
3299 var init = $eq(declaredInitializers.$index(0), initializerCall) ? declar edInitializers.$index(1) : declaredInitializers.$index(0); 3319 var init = $eq(declaredInitializers.$index((0)), initializerCall) ? decl aredInitializers.$index((1)) : declaredInitializers.$index((0));
3300 $globals.world.error("no initialization allowed on redirecting construct ors", init.get$span()); 3320 $globals.world.error("no initialization allowed on redirecting construct ors", init.get$span());
3301 } 3321 }
3302 initializedFields = null; 3322 initializedFields = null;
3303 } 3323 }
3304 } 3324 }
3305 if (initializedFields != null) { 3325 if (initializedFields != null) {
3306 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) { 3326 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
3307 var member = $$i.next$0(); 3327 var member = $$i.next$0();
3308 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) { 3328 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) {
3309 $globals.world.error(("Field \"" + member.get$name() + "\" is final and was not initialized"), this.method.get$definition().get$span()); 3329 $globals.world.error(("Field \"" + member.get$name() + "\" is final and was not initialized"), this.method.get$definition().get$span());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3361 } 3381 }
3362 else if (seenLabel) { 3382 else if (seenLabel) {
3363 $globals.world.error("bare argument can not follow named arguments", arg.g et$span()); 3383 $globals.world.error("bare argument can not follow named arguments", arg.g et$span());
3364 } 3384 }
3365 args.add$1(this.visitValue(arg.get$value())); 3385 args.add$1(this.visitValue(arg.get$value()));
3366 } 3386 }
3367 return new Arguments(arguments, args); 3387 return new Arguments(arguments, args);
3368 } 3388 }
3369 MethodGenerator.prototype._invokeNative = function(name, arguments) { 3389 MethodGenerator.prototype._invokeNative = function(name, arguments) {
3370 var args = Arguments.get$EMPTY(); 3390 var args = Arguments.get$EMPTY();
3371 if (arguments.get$length() > 0) { 3391 if (arguments.get$length() > (0)) {
3372 args = new Arguments(null, arguments); 3392 args = new Arguments(null, arguments);
3373 } 3393 }
3374 var method = $globals.world.corelib.topType.members.$index(name); 3394 var method = $globals.world.corelib.topType.members.$index(name);
3375 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args); 3395 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args);
3376 } 3396 }
3377 MethodGenerator._escapeString = function(text) { 3397 MethodGenerator._escapeString = function(text) {
3378 return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n").replaceAll("\r", "\\r"); 3398 return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n").replaceAll("\r", "\\r");
3379 } 3399 }
3380 MethodGenerator.prototype.visitStatementsInBlock = function(body) { 3400 MethodGenerator.prototype.visitStatementsInBlock = function(body) {
3381 if ((body instanceof BlockStatement)) { 3401 if ((body instanceof BlockStatement)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 } 3450 }
3431 return this.visitValue(node); 3451 return this.visitValue(node);
3432 } 3452 }
3433 MethodGenerator.prototype.visitDietStatement = function(node) { 3453 MethodGenerator.prototype.visitDietStatement = function(node) {
3434 var parser = new Parser(node.span.file, false, false, false, node.span.start); 3454 var parser = new Parser(node.span.file, false, false, false, node.span.start);
3435 this.visitStatementsInBlock(parser.block$0()); 3455 this.visitStatementsInBlock(parser.block$0());
3436 return false; 3456 return false;
3437 } 3457 }
3438 MethodGenerator.prototype.visitVariableDefinition = function(node) { 3458 MethodGenerator.prototype.visitVariableDefinition = function(node) {
3439 var isFinal = false; 3459 var isFinal = false;
3440 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) { 3460 if (node.modifiers != null && $eq(node.modifiers.$index((0)).get$kind(), (98)) ) {
3441 isFinal = true; 3461 isFinal = true;
3442 } 3462 }
3443 this.writer.write("var "); 3463 this.writer.write("var ");
3444 var type = this.method.resolveType(node.type, false); 3464 var type = this.method.resolveType(node.type, false);
3445 for (var i = 0; 3465 for (var i = (0);
3446 i < node.names.get$length(); i++) { 3466 i < node.names.get$length(); i++) {
3447 var thisType = type; 3467 var thisType = type;
3448 if (i > 0) { 3468 if (i > (0)) {
3449 this.writer.write(", "); 3469 this.writer.write(", ");
3450 } 3470 }
3451 var name = node.names.$index(i).get$name(); 3471 var name = node.names.$index(i).get$name();
3452 var value = this.visitValue(node.values.$index(i)); 3472 var value = this.visitValue(node.values.$index(i));
3453 if (isFinal) { 3473 if (isFinal) {
3454 if (value == null) { 3474 if (value == null) {
3455 $globals.world.error("no value specified for final variable", node.span) ; 3475 $globals.world.error("no value specified for final variable", node.span) ;
3456 } 3476 }
3457 else { 3477 else {
3458 if (thisType.get$isVar()) thisType = value.get$type(); 3478 if (thisType.get$isVar()) thisType = value.get$type();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 else { 3530 else {
3511 this.writer.writeln(("throw " + rethrow.get$code() + ";")); 3531 this.writer.writeln(("throw " + rethrow.get$code() + ";"));
3512 } 3532 }
3513 } 3533 }
3514 return true; 3534 return true;
3515 } 3535 }
3516 MethodGenerator.prototype.visitAssertStatement = function(node) { 3536 MethodGenerator.prototype.visitAssertStatement = function(node) {
3517 var test = this.visitValue(node.test); 3537 var test = this.visitValue(node.test);
3518 if ($globals.options.enableAsserts) { 3538 if ($globals.options.enableAsserts) {
3519 var span = node.test.span; 3539 var span = node.test.span;
3520 var line = span.get$file().getLine$1(span.get$start()) + 1; 3540 var line = span.get$file().getLine$1(span.get$start()) + (1);
3521 var column = span.get$file().getColumn$2(line - 1, span.get$start()) + 1; 3541 var column = span.get$file().getColumn$2(line - (1), span.get$start()) + (1) ;
3522 var args = [test, Value.fromString(span.get$text(), node.span), Value.fromSt ring(span.get$file().get$filename(), node.span), Value.fromInt(line, node.span), Value.fromInt(column, node.span)]; 3542 var args = [test, Value.fromString(span.get$text(), node.span), Value.fromSt ring(span.get$file().get$filename(), node.span), Value.fromInt(line, node.span), Value.fromInt(column, node.span)];
3523 var tp = $globals.world.corelib.topType; 3543 var tp = $globals.world.corelib.topType;
3524 var f = tp.getMember$1("_assert"); 3544 var f = tp.getMember$1("_assert");
3525 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Argument s(null, args), false); 3545 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Argument s(null, args), false);
3526 this.writer.writeln(("" + value.get$code() + ";")); 3546 this.writer.writeln(("" + value.get$code() + ";"));
3527 } 3547 }
3528 return false; 3548 return false;
3529 } 3549 }
3530 MethodGenerator.prototype.visitBreakStatement = function(node) { 3550 MethodGenerator.prototype.visitBreakStatement = function(node) {
3531 if (node.label == null) { 3551 if (node.label == null) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 MethodGenerator.prototype.visitForInStatement = function(node) { 3631 MethodGenerator.prototype.visitForInStatement = function(node) {
3612 var itemType = this.method.resolveType(node.item.type, false); 3632 var itemType = this.method.resolveType(node.item.type, false);
3613 var itemName = node.item.name.name; 3633 var itemName = node.item.name.name;
3614 var list = node.list.visit(this); 3634 var list = node.list.visit(this);
3615 this._pushBlock(true); 3635 this._pushBlock(true);
3616 var isFinal = this._isFinal(node.item.type); 3636 var isFinal = this._isFinal(node.item.type);
3617 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false); 3637 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false);
3618 var listVar = list; 3638 var listVar = list;
3619 if (list.get$needsTemp()) { 3639 if (list.get$needsTemp()) {
3620 listVar = this._scope.create("$list", list.get$type(), null, false, false); 3640 listVar = this._scope.create("$list", list.get$type(), null, false, false);
3621 this.writer.writeln(("var " + listVar.code + " = " + list.get$code() + ";")) ; 3641 this.writer.writeln(("var " + listVar.get$code() + " = " + list.get$code() + ";"));
3622 } 3642 }
3623 if (list.get$type().get$isList()) { 3643 if (list.get$type().get$isList()) {
3624 var tmpi = this._scope.create("$i", $globals.world.numType, null, false, fal se); 3644 var tmpi = this._scope.create("$i", $globals.world.numType, null, false, fal se);
3625 var listLength = listVar.get_(this, "length", node.list); 3645 var listLength = listVar.get_(this, "length", node.list);
3626 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = 0;") + ("" + tmp i.get$code() + " < " + listLength.get$code() + "; " + tmpi.get$code() + "++) {") ); 3646 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = 0;") + ("" + tmp i.get$code() + " < " + listLength.get$code() + "; " + tmpi.get$code() + "++) {") );
3627 var value = listVar.invoke(this, ":index", node.list, new Arguments(null, [t mpi]), false); 3647 var value = listVar.invoke(this, ":index", node.list, new Arguments(null, [t mpi]), false);
3628 this.writer.writeln(("var " + item.get$code() + " = " + value.get$code() + " ;")); 3648 this.writer.writeln(("var " + item.get$code() + " = " + value.get$code() + " ;"));
3629 } 3649 }
3630 else { 3650 else {
3631 var iterator = list.invoke$4(this, "iterator", node.list, Arguments.get$EMPT Y()); 3651 var iterator = list.invoke$4(this, "iterator", node.list, Arguments.get$EMPT Y());
3632 var tmpi = this._scope.create("$i", iterator.get$type(), null, false, false) ; 3652 var tmpi = this._scope.create("$i", iterator.get$type(), null, false, false) ;
3633 var hasNext = tmpi.invoke$4(this, "hasNext", node.list, Arguments.get$EMPTY( )); 3653 var hasNext = tmpi.invoke$4(this, "hasNext", node.list, Arguments.get$EMPTY( ));
3634 var next = tmpi.invoke$4(this, "next", node.list, Arguments.get$EMPTY()); 3654 var next = tmpi.invoke$4(this, "next", node.list, Arguments.get$EMPTY());
3635 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = " + iterator.get $code() + "; " + hasNext.get$code() + "; ) {")); 3655 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = " + iterator.get $code() + "; " + hasNext.get$code() + "; ) {"));
3636 this.writer.writeln(("var " + item.get$code() + " = " + next.get$code() + "; ")); 3656 this.writer.writeln(("var " + item.get$code() + " = " + next.get$code() + "; "));
3637 } 3657 }
3638 this.visitStatementsInBlock(node.body); 3658 this.visitStatementsInBlock(node.body);
3639 this.writer.exitBlock("}"); 3659 this.writer.exitBlock("}");
3640 this._popBlock(); 3660 this._popBlock();
3641 return false; 3661 return false;
3642 } 3662 }
3643 MethodGenerator.prototype._genToDartException = function(ex) { 3663 MethodGenerator.prototype._genToDartException = function(ex) {
3644 var result = this._invokeNative("_toDartException", [ex]); 3664 var result = this._invokeNative("_toDartException", [ex]);
3645 this.writer.writeln(("" + ex.code + " = " + result.get$code() + ";")); 3665 this.writer.writeln(("" + ex.get$code() + " = " + result.get$code() + ";"));
3646 } 3666 }
3647 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) { 3667 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) {
3648 var result = this._invokeNative("_stackTraceOf", [ex]); 3668 var result = this._invokeNative("_stackTraceOf", [ex]);
3649 this.writer.writeln(("var " + trace.code + " = " + result.get$code() + ";")); 3669 this.writer.writeln(("var " + trace.get$code() + " = " + result.get$code() + " ;"));
3650 } 3670 }
3651 MethodGenerator.prototype.visitTryStatement = function(node) { 3671 MethodGenerator.prototype.visitTryStatement = function(node) {
3652 this.writer.enterBlock("try {"); 3672 this.writer.enterBlock("try {");
3653 this._pushBlock(false); 3673 this._pushBlock(false);
3654 this.visitStatementsInBlock(node.body); 3674 this.visitStatementsInBlock(node.body);
3655 this._popBlock(); 3675 this._popBlock();
3656 if (node.catches.get$length() == 1) { 3676 if (node.catches.get$length() == (1)) {
3657 var catch_ = node.catches.$index(0); 3677 var catch_ = node.catches.$index((0));
3658 this._pushBlock(false); 3678 this._pushBlock(false);
3659 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e); 3679 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e);
3660 var ex = this._scope.declare(catch_.get$exception()); 3680 var ex = this._scope.declare(catch_.get$exception());
3661 this._scope.rethrow = ex; 3681 this._scope.rethrow = ex;
3662 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); 3682 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {"));
3663 if (catch_.get$trace() != null) { 3683 if (catch_.get$trace() != null) {
3664 var trace = this._scope.declare(catch_.get$trace()); 3684 var trace = this._scope.declare(catch_.get$trace());
3665 this._genStackTraceOf(trace, ex); 3685 this._genStackTraceOf(trace, ex);
3666 } 3686 }
3667 this._genToDartException(ex); 3687 this._genToDartException(ex);
3668 if (!exType.get$isVarOrObject()) { 3688 if (!exType.get$isVarOrObject()) {
3669 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true); 3689 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true);
3670 this.writer.writeln(("if (" + test.get$code() + ") throw " + ex.get$code() + ";")); 3690 this.writer.writeln(("if (" + test.get$code() + ") throw " + ex.get$code() + ";"));
3671 } 3691 }
3672 this.visitStatementsInBlock(node.catches.$index(0).get$body()); 3692 this.visitStatementsInBlock(node.catches.$index((0)).get$body());
3673 this._popBlock(); 3693 this._popBlock();
3674 } 3694 }
3675 else if (node.catches.get$length() > 0) { 3695 else if (node.catches.get$length() > (0)) {
3676 this._pushBlock(false); 3696 this._pushBlock(false);
3677 var ex = this._scope.create("$ex", $globals.world.varType, null, false, fals e); 3697 var ex = this._scope.create("$ex", $globals.world.varType, null, false, fals e);
3678 this._scope.rethrow = ex; 3698 this._scope.rethrow = ex;
3679 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); 3699 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {"));
3680 var trace = null; 3700 var trace = null;
3681 if (node.catches.some((function (c) { 3701 if (node.catches.some((function (c) {
3682 return c.get$trace() != null; 3702 return c.get$trace() != null;
3683 }) 3703 })
3684 )) { 3704 )) {
3685 trace = this._scope.create("$trace", $globals.world.varType, null, false, false); 3705 trace = this._scope.create("$trace", $globals.world.varType, null, false, false);
3686 this._genStackTraceOf(trace, ex); 3706 this._genStackTraceOf(trace, ex);
3687 } 3707 }
3688 this._genToDartException(ex); 3708 this._genToDartException(ex);
3689 var needsRethrow = true; 3709 var needsRethrow = true;
3690 for (var i = 0; 3710 for (var i = (0);
3691 i < node.catches.get$length(); i++) { 3711 i < node.catches.get$length(); i++) {
3692 var catch_ = node.catches.$index(i); 3712 var catch_ = node.catches.$index(i);
3693 this._pushBlock(false); 3713 this._pushBlock(false);
3694 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse); 3714 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse);
3695 var tmp = this._scope.declare(catch_.get$exception()); 3715 var tmp = this._scope.declare(catch_.get$exception());
3696 if (!tmpType.get$isVarOrObject()) { 3716 if (!tmpType.get$isVarOrObject()) {
3697 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true); 3717 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true);
3698 if (i == 0) { 3718 if (i == (0)) {
3699 this.writer.enterBlock(("if (" + test.get$code() + ") {")); 3719 this.writer.enterBlock(("if (" + test.get$code() + ") {"));
3700 } 3720 }
3701 else { 3721 else {
3702 this.writer.nextBlock(("} else if (" + test.get$code() + ") {")); 3722 this.writer.nextBlock(("} else if (" + test.get$code() + ") {"));
3703 } 3723 }
3704 } 3724 }
3705 else if (i > 0) { 3725 else if (i > (0)) {
3706 this.writer.nextBlock("} else {"); 3726 this.writer.nextBlock("} else {");
3707 } 3727 }
3708 this.writer.writeln(("var " + tmp.get$code() + " = " + ex.get$code() + ";" )); 3728 this.writer.writeln(("var " + tmp.get$code() + " = " + ex.get$code() + ";" ));
3709 if (catch_.get$trace() != null) { 3729 if (catch_.get$trace() != null) {
3710 var tmptrace = this._scope.declare(catch_.get$trace()); 3730 var tmptrace = this._scope.declare(catch_.get$trace());
3711 this.writer.writeln(("var " + tmptrace.get$code() + " = " + trace.get$co de() + ";")); 3731 this.writer.writeln(("var " + tmptrace.get$code() + " = " + trace.get$co de() + ";"));
3712 } 3732 }
3713 this.visitStatementsInBlock(catch_.get$body()); 3733 this.visitStatementsInBlock(catch_.get$body());
3714 this._popBlock(); 3734 this._popBlock();
3715 if (tmpType.get$isVarOrObject()) { 3735 if (tmpType.get$isVarOrObject()) {
3716 if (i + 1 < node.catches.get$length()) { 3736 if (i + (1) < node.catches.get$length()) {
3717 $globals.world.error("Unreachable catch clause", node.catches.$index(i + 1).get$span()); 3737 $globals.world.error("Unreachable catch clause", node.catches.$index(i + (1)).get$span());
3718 } 3738 }
3719 if (i > 0) { 3739 if (i > (0)) {
3720 this.writer.exitBlock("}"); 3740 this.writer.exitBlock("}");
3721 } 3741 }
3722 needsRethrow = false; 3742 needsRethrow = false;
3723 break; 3743 break;
3724 } 3744 }
3725 } 3745 }
3726 if (needsRethrow) { 3746 if (needsRethrow) {
3727 this.writer.nextBlock("} else {"); 3747 this.writer.nextBlock("} else {");
3728 this.writer.writeln(("throw " + ex.get$code() + ";")); 3748 this.writer.writeln(("throw " + ex.get$code() + ";"));
3729 this.writer.exitBlock("}"); 3749 this.writer.exitBlock("}");
(...skipping 12 matching lines...) Expand all
3742 MethodGenerator.prototype.visitSwitchStatement = function(node) { 3762 MethodGenerator.prototype.visitSwitchStatement = function(node) {
3743 var test = this.visitValue(node.test); 3763 var test = this.visitValue(node.test);
3744 this.writer.enterBlock(("switch (" + test.get$code() + ") {")); 3764 this.writer.enterBlock(("switch (" + test.get$code() + ") {"));
3745 var $$list = node.cases; 3765 var $$list = node.cases;
3746 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3766 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3747 var case_ = $$list.$index($$i); 3767 var case_ = $$list.$index($$i);
3748 if (case_.get$label() != null) { 3768 if (case_.get$label() != null) {
3749 $globals.world.error("unimplemented: labeled case statement", case_.get$sp an()); 3769 $globals.world.error("unimplemented: labeled case statement", case_.get$sp an());
3750 } 3770 }
3751 this._pushBlock(false); 3771 this._pushBlock(false);
3752 for (var i = 0; 3772 for (var i = (0);
3753 i < case_.get$cases().get$length(); i++) { 3773 i < case_.get$cases().get$length(); i++) {
3754 var expr = case_.get$cases().$index(i); 3774 var expr = case_.get$cases().$index(i);
3755 if (expr == null) { 3775 if (expr == null) {
3756 if (i < case_.get$cases().get$length() - 1) { 3776 if (i < case_.get$cases().get$length() - (1)) {
3757 $globals.world.error("default clause must be the last case", case_.get $span()); 3777 $globals.world.error("default clause must be the last case", case_.get $span());
3758 } 3778 }
3759 this.writer.writeln("default:"); 3779 this.writer.writeln("default:");
3760 } 3780 }
3761 else { 3781 else {
3762 var value = this.visitValue(expr); 3782 var value = this.visitValue(expr);
3763 this.writer.writeln(("case " + value.get$code() + ":")); 3783 this.writer.writeln(("case " + value.get$code() + ":"));
3764 } 3784 }
3765 } 3785 }
3766 this.writer.enterBlock(""); 3786 this.writer.enterBlock("");
3767 var caseExits = this._visitAllStatements(case_.get$statements(), false); 3787 var caseExits = this._visitAllStatements(case_.get$statements(), false);
3768 if ($ne(case_, node.cases.$index(node.cases.get$length() - 1)) && !caseExits ) { 3788 if ($ne(case_, node.cases.$index(node.cases.get$length() - (1))) && !caseExi ts) {
3769 var span = case_.get$statements().$index(case_.get$statements().get$length () - 1).get$span(); 3789 var span = case_.get$statements().$index(case_.get$statements().get$length () - (1)).get$span();
3770 this.writer.writeln("$throw(new FallThroughError());"); 3790 this.writer.writeln("$throw(new FallThroughError());");
3771 $globals.world.gen.corejs.useThrow = true; 3791 $globals.world.gen.corejs.useThrow = true;
3772 } 3792 }
3773 this.writer.exitBlock(""); 3793 this.writer.exitBlock("");
3774 this._popBlock(); 3794 this._popBlock();
3775 } 3795 }
3776 this.writer.exitBlock("}"); 3796 this.writer.exitBlock("}");
3777 return false; 3797 return false;
3778 } 3798 }
3779 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) { 3799 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) {
3780 for (var i = 0; 3800 for (var i = (0);
3781 i < statementList.get$length(); i++) { 3801 i < statementList.get$length(); i++) {
3782 var stmt = statementList.$index(i); 3802 var stmt = statementList.$index(i);
3783 exits = stmt.visit$1(this); 3803 exits = stmt.visit$1(this);
3784 if ($ne(stmt, statementList.$index(statementList.get$length() - 1)) && exits ) { 3804 if ($ne(stmt, statementList.$index(statementList.get$length() - (1))) && exi ts) {
3785 $globals.world.warning("unreachable code", statementList.$index(i + 1).get $span()); 3805 $globals.world.warning("unreachable code", statementList.$index(i + (1)).g et$span());
3786 } 3806 }
3787 } 3807 }
3788 return exits; 3808 return exits;
3789 } 3809 }
3790 MethodGenerator.prototype.visitBlockStatement = function(node) { 3810 MethodGenerator.prototype.visitBlockStatement = function(node) {
3791 this._pushBlock(false); 3811 this._pushBlock(false);
3792 this.writer.enterBlock("{"); 3812 this.writer.enterBlock("{");
3793 var exits = this._visitAllStatements(node.body, false); 3813 var exits = this._visitAllStatements(node.body, false);
3794 this.writer.exitBlock("}"); 3814 this.writer.exitBlock("}");
3795 this._popBlock(); 3815 this._popBlock();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3867 var w = new CodeWriter(); 3887 var w = new CodeWriter();
3868 meth.generator.writeDefinition(w, node); 3888 meth.generator.writeDefinition(w, node);
3869 return new Value(meth.get$functionType(), w.get$text(), node.span, true); 3889 return new Value(meth.get$functionType(), w.get$text(), node.span, true);
3870 } 3890 }
3871 MethodGenerator.prototype.visitCallExpression = function(node) { 3891 MethodGenerator.prototype.visitCallExpression = function(node) {
3872 var target; 3892 var target;
3873 var position = node.target; 3893 var position = node.target;
3874 var name = ":call"; 3894 var name = ":call";
3875 if ((node.target instanceof DotExpression)) { 3895 if ((node.target instanceof DotExpression)) {
3876 var dot = node.target; 3896 var dot = node.target;
3877 if ((dot.self instanceof LiteralExpression)) { 3897 target = dot.self.visit(this);
3878 target = (new ParenExpression(dot.self, dot.self.span)).visit(this);
3879 }
3880 else {
3881 target = dot.self.visit(this);
3882 }
3883 name = dot.name.name; 3898 name = dot.name.name;
3884 position = dot.name; 3899 position = dot.name;
3885 } 3900 }
3886 else if ((node.target instanceof VarExpression)) { 3901 else if ((node.target instanceof VarExpression)) {
3887 var varExpr = node.target; 3902 var varExpr = node.target;
3888 name = varExpr.name.name; 3903 name = varExpr.name.name;
3889 target = this._scope.lookup(name); 3904 target = this._scope.lookup(name);
3890 if (target != null) { 3905 if (target != null) {
3891 return target.invoke$4(this, ":call", node, this._makeArgs(node.arguments) ); 3906 return target.invoke$4(this, ":call", node, this._makeArgs(node.arguments) );
3892 } 3907 }
3893 target = this._makeThisOrType(varExpr.span); 3908 target = this._makeThisOrType(varExpr.span);
3894 return target.invoke$4(this, name, node, this._makeArgs(node.arguments)); 3909 return target.invoke$4(this, name, node, this._makeArgs(node.arguments));
3895 } 3910 }
3896 else { 3911 else {
3897 target = node.target.visit(this); 3912 target = node.target.visit(this);
3898 } 3913 }
3899 return target.invoke$4(this, name, position, this._makeArgs(node.arguments)); 3914 return target.invoke$4(this, name, position, this._makeArgs(node.arguments));
3900 } 3915 }
3901 MethodGenerator.prototype.visitIndexExpression = function(node) { 3916 MethodGenerator.prototype.visitIndexExpression = function(node) {
3902 var target = this.visitValue(node.target); 3917 var target = this.visitValue(node.target);
3903 var index = this.visitValue(node.index); 3918 var index = this.visitValue(node.index);
3904 return target.invoke$4(this, ":index", node, new Arguments(null, [index])); 3919 return target.invoke$4(this, ":index", node, new Arguments(null, [index]));
3905 } 3920 }
3906 MethodGenerator.prototype._expressionNeedsParens = function(e) { 3921 MethodGenerator.prototype._expressionNeedsParens = function(e) {
3907 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression ) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e)); 3922 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression ) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e));
3908 } 3923 }
3909 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) { 3924 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
3910 var kind = node.op.kind; 3925 var kind = node.op.kind;
3911 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) { 3926 if (kind == (35) || kind == (34)) {
3912 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); 3927 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool);
3913 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); 3928 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool);
3914 var code = ("" + x.get$code() + " " + node.op + " " + y.get$code()); 3929 return x.binop$4(kind, y, this, node);
3915 if (x.get$isConst() && y.get$isConst()) {
3916 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue();
3917 return Value.fromBool(value, node.span);
3918 }
3919 return new Value($globals.world.nonNullBool, code, node.span, true);
3920 } 3930 }
3921 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT* /) { 3931 else if (kind == (50) || kind == (51)) {
3922 var x = this.visitValue(node.x); 3932 var x = this.visitValue(node.x);
3923 var y = this.visitValue(node.y); 3933 var y = this.visitValue(node.y);
3924 if (x.get$isConst() && y.get$isConst()) { 3934 return x.binop$4(kind, y, this, node);
3925 var xVal = x.get$actualValue();
3926 var yVal = y.get$actualValue();
3927 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal , yVal);
3928 return Value.fromBool(value, node.span);
3929 }
3930 if ($eq(x.get$code(), "null") || $eq(y.get$code(), "null")) {
3931 var op = node.op.toString().substring(0, 2);
3932 return new Value($globals.world.nonNullBool, ("" + x.get$code() + " " + op + " " + y.get$code()), node.span, true);
3933 }
3934 else {
3935 return new Value($globals.world.nonNullBool, ("" + x.get$code() + " " + no de.op + " " + y.get$code()), node.span, true);
3936 }
3937 } 3935 }
3938 var assignKind = TokenKind.kindFromAssign(node.op.kind); 3936 var assignKind = TokenKind.kindFromAssign(node.op.kind);
3939 if (assignKind == -1) { 3937 if (assignKind == (-1)) {
3940 var x = this.visitValue(node.x); 3938 var x = this.visitValue(node.x);
3941 var y = this.visitValue(node.y); 3939 var y = this.visitValue(node.y);
3942 var name = TokenKind.binaryMethodName(node.op.kind); 3940 return x.binop$4(kind, y, this, node);
3943 if (node.op.kind == 49/*TokenKind.NE*/) {
3944 name = ":ne";
3945 }
3946 if (name == null) {
3947 $globals.world.internalError(("unimplemented binary op " + node.op), node. span);
3948 return;
3949 }
3950 return x.invoke$4(this, name, node, new Arguments(null, [y]));
3951 } 3941 }
3952 else if ((assignKind != 0) && this._expressionNeedsParens(node.y)) { 3942 else if ((assignKind != (0)) && this._expressionNeedsParens(node.y)) {
3953 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod e.y.span), node, to$call$1(null), isVoid); 3943 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod e.y.span), node, to$call$1(null), isVoid);
3954 } 3944 }
3955 else { 3945 else {
3956 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid); 3946 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
3957 } 3947 }
3958 } 3948 }
3959 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) { 3949 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) {
3960 if (captureOriginal == null) { 3950 if (captureOriginal == null) {
3961 captureOriginal = (function (x) { 3951 captureOriginal = (function (x) {
3962 return x; 3952 return x;
(...skipping 17 matching lines...) Expand all
3980 var name = xn.name.name; 3970 var name = xn.name.name;
3981 var x = this._scope.lookup(name); 3971 var x = this._scope.lookup(name);
3982 var y = this.visitValue(yn); 3972 var y = this.visitValue(yn);
3983 if (x == null) { 3973 if (x == null) {
3984 var members = this.method.declaringType.resolveMember(name); 3974 var members = this.method.declaringType.resolveMember(name);
3985 x = this._makeThisOrType(position.span); 3975 x = this._makeThisOrType(position.span);
3986 if (members != null) { 3976 if (members != null) {
3987 if ($globals.options.forceDynamic && !members.get$isStatic()) { 3977 if ($globals.options.forceDynamic && !members.get$isStatic()) {
3988 members = this.findMembers(xn.name.name); 3978 members = this.findMembers(xn.name.name);
3989 } 3979 }
3990 if (kind == 0) { 3980 if (kind == (0)) {
3991 return x.set_$4(this, name, position, y); 3981 return x.set_$4(this, name, position, y);
3992 } 3982 }
3993 else if (!members.get$treatAsField() || members.get$containsMethods()) { 3983 else if (!members.get$treatAsField() || members.get$containsMethods()) {
3994 var right = x.get_$3(this, name, position); 3984 var right = x.get_$3(this, name, position);
3995 right = captureOriginal(right); 3985 right = captureOriginal(right);
3996 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y])); 3986 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
3997 return x.set_$4(this, name, position, y); 3987 return x.set_$4(this, name, position, y);
3998 } 3988 }
3999 else { 3989 else {
4000 x = x.get_$3(this, name, position); 3990 x = x.get_$3(this, name, position);
4001 } 3991 }
4002 } 3992 }
4003 else { 3993 else {
4004 var member = this.get$library().lookup(name, xn.name.span); 3994 var member = this.get$library().lookup(name, xn.name.span);
4005 if (member == null) { 3995 if (member == null) {
4006 $globals.world.warning(("can not resolve " + name), xn.span); 3996 $globals.world.warning(("can not resolve " + name), xn.span);
4007 return this._makeMissingValue(name); 3997 return this._makeMissingValue(name);
4008 } 3998 }
4009 members = new MemberSet(member, false); 3999 members = new MemberSet(member, false);
4010 if (!members.get$treatAsField() || members.get$containsMethods()) { 4000 if (!members.get$treatAsField() || members.get$containsMethods()) {
4011 if (kind != 0) { 4001 if (kind != (0)) {
4012 var right = members._get$3(this, position, x); 4002 var right = members._get$3(this, position, x);
4013 right = captureOriginal(right); 4003 right = captureOriginal(right);
4014 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, n ew Arguments(null, [y])); 4004 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, n ew Arguments(null, [y]));
4015 } 4005 }
4016 return members._set$4(this, position, x, y); 4006 return members._set$4(this, position, x, y);
4017 } 4007 }
4018 else { 4008 else {
4019 x = members._get$3(this, position, x); 4009 x = members._get$3(this, position, x);
4020 } 4010 }
4021 } 4011 }
4022 } 4012 }
4023 if (x.get$isFinal()) { 4013 if (x.get$isFinal()) {
4024 $globals.world.error(("final variable \"" + x.get$code() + "\" is not assign able"), position.span); 4014 $globals.world.error(("final variable \"" + x.get$code() + "\" is not assign able"), position.span);
4025 } 4015 }
4026 y = y.convertTo$2(this, x.get$type()); 4016 y = y.convertTo$2(this, x.get$type());
4027 if (kind == 0) { 4017 if (kind == (0)) {
4028 x = captureOriginal(x); 4018 x = captureOriginal(x);
4029 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true); 4019 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true);
4030 } 4020 }
4031 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != 46/* TokenKind.TRUNCDIV*/)) { 4021 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != (46) )) {
4032 x = captureOriginal(x); 4022 x = captureOriginal(x);
4033 var op = TokenKind.kindToString(kind); 4023 var op = TokenKind.kindToString(kind);
4034 return new Value(y.get$type(), ("" + x.get$code() + " " + op + "= " + y.get$ code()), position.span, true); 4024 return new Value(y.get$type(), ("" + x.get$code() + " " + op + "= " + y.get$ code()), position.span, true);
4035 } 4025 }
4036 else { 4026 else {
4037 var right = x; 4027 var right = x;
4038 right = captureOriginal(right); 4028 right = captureOriginal(right);
4039 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4029 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4040 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true); 4030 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true);
4041 } 4031 }
4042 } 4032 }
4043 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal, isVoid) { 4033 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal, isVoid) {
4044 var target = this.visitValue(xn.target); 4034 var target = this.visitValue(xn.target);
4045 var index = this.visitValue(xn.index); 4035 var index = this.visitValue(xn.index);
4046 var y = this.visitValue(yn); 4036 var y = this.visitValue(yn);
4047 var tmptarget = target; 4037 var tmptarget = target;
4048 var tmpindex = index; 4038 var tmpindex = index;
4049 if (kind != 0) { 4039 if (kind != (0)) {
4050 tmptarget = this.getTemp(target); 4040 tmptarget = this.getTemp(target);
4051 tmpindex = this.getTemp(index); 4041 tmpindex = this.getTemp(index);
4052 index = this.assignTemp(tmpindex, index); 4042 index = this.assignTemp(tmpindex, index);
4053 var right = tmptarget.invoke$4(this, ":index", position, new Arguments(null, [tmpindex])); 4043 var right = tmptarget.invoke$4(this, ":index", position, new Arguments(null, [tmpindex]));
4054 right = captureOriginal(right); 4044 right = captureOriginal(right);
4055 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4045 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4056 } 4046 }
4057 var tmpy = null; 4047 var tmpy = null;
4058 if (!isVoid) { 4048 if (!isVoid) {
4059 tmpy = this.getTemp(y); 4049 tmpy = this.getTemp(y);
4060 y = this.assignTemp(tmpy, y); 4050 y = this.assignTemp(tmpy, y);
4061 } 4051 }
4062 var ret = this.assignTemp(tmptarget, target).invoke(this, ":setindex", positio n, new Arguments(null, [index, y]), false); 4052 var ret = this.assignTemp(tmptarget, target).invoke(this, ":setindex", positio n, new Arguments(null, [index, y]), false);
4063 if (tmpy != null) { 4053 if (tmpy != null) {
4064 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpy.get$code () + ")"), ret.get$span(), true); 4054 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpy.get$code () + ")"), ret.get$span(), true);
4065 if ($ne(tmpy, y)) this.freeTemp(tmpy); 4055 if ($ne(tmpy, y)) this.freeTemp(tmpy);
4066 } 4056 }
4067 if ($ne(tmptarget, target)) this.freeTemp(tmptarget); 4057 if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
4068 if ($ne(tmpindex, index)) this.freeTemp(tmpindex); 4058 if ($ne(tmpindex, index)) this.freeTemp(tmpindex);
4069 return ret; 4059 return ret;
4070 } 4060 }
4071 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) { 4061 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) {
4072 var target = xn.self.visit(this); 4062 var target = xn.self.visit(this);
4073 var y = this.visitValue(yn); 4063 var y = this.visitValue(yn);
4074 var tmptarget = target; 4064 var tmptarget = target;
4075 if (kind != 0) { 4065 if (kind != (0)) {
4076 tmptarget = this.getTemp(target); 4066 tmptarget = this.getTemp(target);
4077 var right = tmptarget.get_$3(this, xn.name.name, xn.name); 4067 var right = tmptarget.get_$3(this, xn.name.name, xn.name);
4078 right = captureOriginal(right); 4068 right = captureOriginal(right);
4079 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4069 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4080 } 4070 }
4081 var ret = this.assignTemp(tmptarget, target).set_(this, xn.name.name, xn.name, y, false); 4071 var ret = this.assignTemp(tmptarget, target).set_(this, xn.name.name, xn.name, y, false);
4082 if ($ne(tmptarget, target)) this.freeTemp(tmptarget); 4072 if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
4083 return ret; 4073 return ret;
4084 } 4074 }
4085 MethodGenerator.prototype.visitUnaryExpression = function(node) { 4075 MethodGenerator.prototype.visitUnaryExpression = function(node) {
4086 var value = this.visitValue(node.self); 4076 var value = this.visitValue(node.self);
4087 switch (node.op.kind) { 4077 switch (node.op.kind) {
4088 case 16/*TokenKind.INCR*/: 4078 case (16):
4089 case 17/*TokenKind.DECR*/: 4079 case (17):
4090 4080
4091 if (value.get$type().get$isNum()) { 4081 if (value.get$type().get$isNum()) {
4092 return new Value(value.get$type(), ("" + node.op + value.get$code()), no de.span, true); 4082 return new Value(value.get$type(), ("" + node.op + value.get$code()), no de.span, true);
4093 } 4083 }
4094 else { 4084 else {
4095 var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/); 4085 var kind = ((16) == node.op.kind ? (42) : (43));
4096 var operand = new LiteralExpression(Value.fromInt(1, node.span), node.sp an); 4086 var operand = new LiteralExpression(Value.fromInt((1), node.span), node. span);
4097 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null), false); 4087 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null), false);
4098 return new Value(assignValue.get$type(), ("(" + assignValue.get$code() + ")"), node.span, true); 4088 return new Value(assignValue.get$type(), ("(" + assignValue.get$code() + ")"), node.span, true);
4099 } 4089 }
4100 4090
4101 case 19/*TokenKind.NOT*/: 4091 case (19):
4102 4092
4103 if (value.get$type().get$isBool() && value.get$isConst()) { 4093 if (value.get$type().get$isBool() && value.get$isConst()) {
4104 var newVal = !value.get$actualValue(); 4094 var newVal = !value.get$actualValue();
4105 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, ( "" + newVal), node.span); 4095 return Value.fromBool(newVal, node.span);
4106 } 4096 }
4107 else { 4097 else {
4108 var newVal = value.convertTo$2(this, $globals.world.nonNullBool); 4098 var newVal = value.convertTo$2(this, $globals.world.nonNullBool);
4109 return new Value(newVal.get$type(), ("!" + newVal.get$code()), node.span , true); 4099 return new Value(newVal.get$type(), ("!" + newVal.get$code()), node.span , true);
4110 } 4100 }
4111 4101
4112 case 42/*TokenKind.ADD*/: 4102 case (42):
4113 4103
4114 return value.convertTo$2(this, $globals.world.numType); 4104 return value.convertTo$2(this, $globals.world.numType);
4115 4105
4116 case 43/*TokenKind.SUB*/: 4106 case (43):
4117 case 18/*TokenKind.BIT_NOT*/: 4107 case (18):
4118 4108
4119 if (node.op.kind == 18/*TokenKind.BIT_NOT*/) { 4109 if (node.op.kind == (18)) {
4120 return value.invoke$4(this, ":bit_not", node, Arguments.get$EMPTY()); 4110 return value.invoke$4(this, ":bit_not", node, Arguments.get$EMPTY());
4121 } 4111 }
4122 else if (node.op.kind == 43/*TokenKind.SUB*/) { 4112 else if (node.op.kind == (43)) {
4123 return value.invoke$4(this, ":negate", node, Arguments.get$EMPTY()); 4113 return value.invoke$4(this, ":negate", node, Arguments.get$EMPTY());
4124 } 4114 }
4125 else { 4115 else {
4126 $globals.world.internalError(("unimplemented: unary " + node.op), node.s pan); 4116 $globals.world.internalError(("unimplemented: unary " + node.op), node.s pan);
4127 } 4117 }
4128 $throw(new FallThroughError()); 4118 $throw(new FallThroughError());
4129 4119
4130 default: 4120 default:
4131 4121
4132 $globals.world.internalError(("unimplemented: " + node.op), node.span); 4122 $globals.world.internalError(("unimplemented: " + node.op), node.span);
4133 4123
4134 } 4124 }
4135 } 4125 }
4136 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) { 4126 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) {
4137 $globals.world.error("Expected expression", node.span); 4127 $globals.world.error("Expected expression", node.span);
4138 } 4128 }
4139 MethodGenerator.prototype.visitAwaitExpression = function(node) { 4129 MethodGenerator.prototype.visitAwaitExpression = function(node) {
4140 $globals.world.internalError("Await expressions should have been eliminated be fore code generation", node.span); 4130 $globals.world.internalError("Await expressions should have been eliminated be fore code generation", node.span);
4141 } 4131 }
4142 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) { 4132 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) {
4143 var $this = this; // closure support 4133 var $this = this; // closure support
4144 var value = this.visitValue(node.body); 4134 var value = this.visitValue(node.body);
4145 if (value.get$type().get$isNum() && !value.get$isFinal()) { 4135 if (value.get$type().get$isNum() && !value.get$isFinal()) {
4146 return new Value(value.get$type(), ("" + value.get$code() + node.op), node.s pan, true); 4136 return new Value(value.get$type(), ("" + value.get$code() + node.op), node.s pan, true);
4147 } 4137 }
4148 var kind = (16/*TokenKind.INCR*/ == node.op.kind) ? 42/*TokenKind.ADD*/ : 43/* TokenKind.SUB*/; 4138 var kind = ((16) == node.op.kind) ? (42) : (43);
4149 var operand = new LiteralExpression(Value.fromInt(1, node.span), node.span); 4139 var operand = new LiteralExpression(Value.fromInt((1), node.span), node.span);
4150 var tmpleft = null, left = null; 4140 var tmpleft = null, left = null;
4151 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) { 4141 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) {
4152 if (isVoid) { 4142 if (isVoid) {
4153 return l; 4143 return l;
4154 } 4144 }
4155 else { 4145 else {
4156 left = l; 4146 left = l;
4157 tmpleft = $this.forceTemp(l); 4147 tmpleft = $this.forceTemp(l);
4158 return $this.assignTemp(tmpleft, left); 4148 return $this.assignTemp(tmpleft, left);
4159 } 4149 }
4160 }) 4150 })
4161 , false); 4151 , false);
4162 if (tmpleft != null) { 4152 if (tmpleft != null) {
4163 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true); 4153 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true);
4164 } 4154 }
4165 if ($ne(tmpleft, left)) { 4155 if ($ne(tmpleft, left)) {
4166 this.freeTemp(tmpleft); 4156 this.freeTemp(tmpleft);
4167 } 4157 }
4168 return ret; 4158 return ret;
4169 } 4159 }
4170 MethodGenerator.prototype.visitNewExpression = function(node) { 4160 MethodGenerator.prototype.visitNewExpression = function(node) {
4171 var typeRef = node.type; 4161 var typeRef = node.type;
4172 var constructorName = ""; 4162 var constructorName = "";
4173 if (node.name != null) { 4163 if (node.name != null) {
4174 constructorName = node.name.name; 4164 constructorName = node.name.name;
4175 } 4165 }
4176 if ($eq(constructorName, "") && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) { 4166 if ($eq(constructorName, "") && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) {
4177 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); 4167 var names = ListFactory.ListFactory$from$factory(typeRef.get$names());
4178 constructorName = names.removeLast$0().get$name(); 4168 constructorName = names.removeLast$0().get$name();
4179 if ($eq(names.get$length(), 0)) names = null; 4169 if ($eq(names.get$length(), (0))) names = null;
4180 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span()); 4170 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span());
4181 } 4171 }
4182 var type = this.method.resolveType(typeRef, true); 4172 var type = this.method.resolveType(typeRef, true);
4183 if (type.get$isTop()) { 4173 if (type.get$isTop()) {
4184 type = type.get$library().findTypeByName$1(constructorName); 4174 type = type.get$library().findTypeByName$1(constructorName);
4185 constructorName = ""; 4175 constructorName = "";
4186 } 4176 }
4187 if ((type instanceof ParameterType)) { 4177 if ((type instanceof ParameterType)) {
4188 $globals.world.error("cannot instantiate a type parameter", node.span); 4178 $globals.world.error("cannot instantiate a type parameter", node.span);
4189 return this._makeMissingValue(constructorName); 4179 return this._makeMissingValue(constructorName);
(...skipping 16 matching lines...) Expand all
4206 var arg = $$list.$index($$i); 4196 var arg = $$list.$index($$i);
4207 if (!this.visitValue(arg.get$value()).get$isConst()) { 4197 if (!this.visitValue(arg.get$value()).get$isConst()) {
4208 $globals.world.error("const constructor expects const arguments", arg.ge t$span()); 4198 $globals.world.error("const constructor expects const arguments", arg.ge t$span());
4209 } 4199 }
4210 } 4200 }
4211 } 4201 }
4212 var target = new Value.type$ctor(type, typeRef.get$span()); 4202 var target = new Value.type$ctor(type, typeRef.get$span());
4213 return m.invoke$4(this, node, target, this._makeArgs(node.arguments)); 4203 return m.invoke$4(this, node, target, this._makeArgs(node.arguments));
4214 } 4204 }
4215 MethodGenerator.prototype.visitListExpression = function(node) { 4205 MethodGenerator.prototype.visitListExpression = function(node) {
4216 var argsCode = [];
4217 var argValues = []; 4206 var argValues = [];
4218 var type = null; 4207 var listType = $globals.world.listType;
4219 if (node.type != null) { 4208 var type = $globals.world.varType;
4220 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (0); 4209 if (node.itemType != null) {
4210 type = this.method.resolveType(node.itemType, true);
4221 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 4211 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) {
4222 $globals.world.error("type parameter cannot be used in const list literals "); 4212 $globals.world.error("type parameter cannot be used in const list literals ");
4223 } 4213 }
4214 listType = listType.getOrMakeConcreteType$1([type]);
4224 } 4215 }
4225 var $$list = node.values; 4216 var $$list = node.values;
4226 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4217 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4227 var item = $$list.$index($$i); 4218 var item = $$list.$index($$i);
4228 var arg = this.visitTypedValue(item, type); 4219 var arg = this.visitTypedValue(item, type);
4229 argValues.add$1(arg); 4220 argValues.add$1(arg);
4230 if (node.isConst) { 4221 if (node.isConst && !arg.get$isConst()) {
4231 if (!arg.get$isConst()) { 4222 $globals.world.error("const list can only contain const values", arg.get$s pan());
4232 $globals.world.error("const list can only contain const values", item.ge t$span());
4233 argsCode.add$1(arg.get$code());
4234 }
4235 else {
4236 argsCode.add$1(arg.get$canonicalCode());
4237 }
4238 }
4239 else {
4240 argsCode.add$1(arg.get$code());
4241 } 4223 }
4242 } 4224 }
4243 $globals.world.listFactoryType.markUsed(); 4225 $globals.world.listFactoryType.markUsed();
4244 var code = ("[" + Strings.join(argsCode, ", ") + "]"); 4226 var ret = new ListValue(argValues, node.isConst, listType, node.span);
4245 var value = new Value($globals.world.listType, code, node.span, true); 4227 if (ret.get$isConst()) return ret.getGlobalValue$0();
4246 if (node.isConst) { 4228 return ret;
4247 var immutableList = $globals.world.immutableListType;
4248 var immutableListCtor = immutableList.getConstructor("from");
4249 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu e.get$type(), node.span), new Arguments(null, [value]));
4250 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact ory(immutableList, argValues, ("const " + code), result.get$code(), node.span), argValues);
4251 }
4252 return value;
4253 } 4229 }
4254 MethodGenerator.prototype.visitMapExpression = function(node) { 4230 MethodGenerator.prototype.visitMapExpression = function(node) {
4255 if (node.items.get$length() == 0 && !node.isConst) { 4231 if (node.items.get$length() == (0) && !node.isConst) {
4256 return $globals.world.mapType.getConstructor("").invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY()); 4232 return $globals.world.mapType.getConstructor("").invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY());
4257 } 4233 }
4258 var argValues = []; 4234 var values = new Array();
4259 var argsCode = []; 4235 var valueType = $globals.world.varType, keyType = $globals.world.stringType;
4260 var type = null; 4236 var mapType = $globals.world.mapType;
4261 if (node.type != null) { 4237 if (node.valueType != null) {
4262 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (1); 4238 if (node.keyType != null) {
4263 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 4239 keyType = this.method.resolveType(node.keyType, true);
4240 if (!keyType.get$isString()) {
4241 $globals.world.error("the key type of a map literal must be \"String\"", keyType.get$span());
4242 }
4243 if (node.isConst && ((keyType instanceof ParameterType) || keyType.get$has TypeParams())) {
4244 $globals.world.error("type parameter cannot be used in const map literal s");
4245 }
4246 }
4247 valueType = this.method.resolveType(node.valueType, true);
4248 if (node.isConst && ((valueType instanceof ParameterType) || valueType.get$h asTypeParams())) {
4264 $globals.world.error("type parameter cannot be used in const map literals" ); 4249 $globals.world.error("type parameter cannot be used in const map literals" );
4265 } 4250 }
4251 mapType = mapType.getOrMakeConcreteType$1([keyType, valueType]);
4266 } 4252 }
4267 for (var i = 0; 4253 for (var i = (0);
4268 i < node.items.get$length(); i += 2) { 4254 i < node.items.get$length(); i += (2)) {
4269 var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringTy pe); 4255 var key = this.visitTypedValue(node.items.$index(i), keyType);
4270 var valueItem = node.items.$index(i + 1); 4256 if (node.isConst && !key.get$isConst()) {
4271 var value = this.visitTypedValue(valueItem, type); 4257 $globals.world.error("const map can only contain const keys", key.get$span ());
4272 argValues.add$1(key);
4273 argValues.add$1(value);
4274 if (node.isConst) {
4275 if (!key.get$isConst() || !value.get$isConst()) {
4276 $globals.world.error("const map can only contain const values", valueIte m.get$span());
4277 argsCode.add$1(key.get$code());
4278 argsCode.add$1(value.get$code());
4279 }
4280 else {
4281 argsCode.add$1(key.get$canonicalCode());
4282 argsCode.add$1(value.get$canonicalCode());
4283 }
4284 } 4258 }
4285 else { 4259 values.add$1(key);
4286 argsCode.add$1(key.get$code()); 4260 var value = this.visitTypedValue(node.items.$index(i + (1)), valueType);
4287 argsCode.add$1(value.get$code()); 4261 if (node.isConst && !value.get$isConst()) {
4262 $globals.world.error("const map can only contain const values", value.get$ span());
4288 } 4263 }
4264 values.add$1(value);
4289 } 4265 }
4290 var argList = ("[" + Strings.join(argsCode, ", ") + "]"); 4266 var ret = new MapValue(values, node.isConst, mapType, node.span);
4291 var items = new Value($globals.world.listType, argList, node.span, true); 4267 if (ret.get$isConst()) return ret.getGlobalValue$0();
4292 var tp = $globals.world.corelib.topType; 4268 return ret;
4293 var f = node.isConst ? tp.getMember$1("_constMap") : tp.getMember$1("_map");
4294 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Arguments( null, [items]), false);
4295 if (node.isConst) {
4296 value = ConstMapValue.ConstMapValue$factory(value.get$type(), argValues, val ue.get$code(), value.get$code(), value.get$span());
4297 return $globals.world.gen.globalForConst(value, argValues);
4298 }
4299 else {
4300 return value;
4301 }
4302 } 4269 }
4303 MethodGenerator.prototype.visitConditionalExpression = function(node) { 4270 MethodGenerator.prototype.visitConditionalExpression = function(node) {
4304 var test = this.visitBool(node.test); 4271 var test = this.visitBool(node.test);
4305 var trueBranch = this.visitValue(node.trueBranch); 4272 var trueBranch = this.visitValue(node.trueBranch);
4306 var falseBranch = this.visitValue(node.falseBranch); 4273 var falseBranch = this.visitValue(node.falseBranch);
4307 var code = ("" + test.get$code() + " ? " + trueBranch.get$code() + " : " + fal seBranch.get$code()); 4274 var code = ("" + test.get$code() + " ? " + trueBranch.get$code() + " : " + fal seBranch.get$code());
4308 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), co de, node.span, true); 4275 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), co de, node.span, true);
4309 } 4276 }
4310 MethodGenerator.prototype.visitIsExpression = function(node) { 4277 MethodGenerator.prototype.visitIsExpression = function(node) {
4311 var value = this.visitValue(node.x); 4278 var value = this.visitValue(node.x);
4312 var type = this.method.resolveType(node.type, false); 4279 var type = this.method.resolveType(node.type, false);
4313 return value.instanceOf$4(this, type, node.span, node.isTrue); 4280 return value.instanceOf$4(this, type, node.span, node.isTrue);
4314 } 4281 }
4315 MethodGenerator.prototype.visitParenExpression = function(node) { 4282 MethodGenerator.prototype.visitParenExpression = function(node) {
4316 var body = this.visitValue(node.body); 4283 var body = this.visitValue(node.body);
4317 if (body.get$isConst()) { 4284 if (body.get$isConst()) return body;
4318 return EvaluatedValue.EvaluatedValue$factory(body.get$type(), body.get$actua lValue(), ("(" + body.get$canonicalCode() + ")"), node.span);
4319 }
4320 return new Value(body.get$type(), ("(" + body.get$code() + ")"), node.span, tr ue); 4285 return new Value(body.get$type(), ("(" + body.get$code() + ")"), node.span, tr ue);
4321 } 4286 }
4322 MethodGenerator.prototype.visitDotExpression = function(node) { 4287 MethodGenerator.prototype.visitDotExpression = function(node) {
4323 var target = node.self.visit(this); 4288 var target = node.self.visit(this);
4324 return target.get_$3(this, node.name.name, node.name); 4289 return target.get_$3(this, node.name.name, node.name);
4325 } 4290 }
4326 MethodGenerator.prototype.visitVarExpression = function(node) { 4291 MethodGenerator.prototype.visitVarExpression = function(node) {
4327 var name = node.name.name; 4292 var name = node.name.name;
4328 var ret = this._scope.lookup(name); 4293 var ret = this._scope.lookup(name);
4329 if (ret != null) return ret; 4294 if (ret != null) return ret;
(...skipping 10 matching lines...) Expand all
4340 } 4305 }
4341 MethodGenerator.prototype.visitSuperExpression = function(node) { 4306 MethodGenerator.prototype.visitSuperExpression = function(node) {
4342 return this._makeSuperValue(node); 4307 return this._makeSuperValue(node);
4343 } 4308 }
4344 MethodGenerator.prototype.visitLiteralExpression = function(node) { 4309 MethodGenerator.prototype.visitLiteralExpression = function(node) {
4345 return node.value; 4310 return node.value;
4346 } 4311 }
4347 MethodGenerator.prototype._isUnaryIncrement = function(item) { 4312 MethodGenerator.prototype._isUnaryIncrement = function(item) {
4348 if ((item instanceof UnaryExpression)) { 4313 if ((item instanceof UnaryExpression)) {
4349 var u = item; 4314 var u = item;
4350 return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR* /; 4315 return u.op.kind == (16) || u.op.kind == (17);
4351 } 4316 }
4352 else { 4317 else {
4353 return false; 4318 return false;
4354 } 4319 }
4355 } 4320 }
4356 MethodGenerator.prototype.visitStringInterpExpression = function(node) { 4321 MethodGenerator.prototype.visitStringInterpExpression = function(node) {
4357 var items = []; 4322 var items = [];
4358 var $$list = node.pieces; 4323 var $$list = node.pieces;
4359 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4324 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4360 var item = $$list.$index($$i); 4325 var item = $$list.$index($$i);
4361 var val = this.visitValue(item); 4326 var val = this.visitValue(item);
4362 val.invoke$4(this, "toString", item, Arguments.get$EMPTY()); 4327 val.invoke$4(this, "toString", item, Arguments.get$EMPTY());
4363 var code = val.get$code(); 4328 var code = val.get$code();
4364 if (this._expressionNeedsParens(item)) { 4329 if (this._expressionNeedsParens(item)) {
4365 code = ("(" + code + ")"); 4330 code = ("(" + code + ")");
4366 } 4331 }
4367 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, "\"\""))) { 4332 if ($eq(items.get$length(), (0)) || ($ne(code, "''") && $ne(code, "\"\""))) {
4368 items.add$1(code); 4333 items.add$1(code);
4369 } 4334 }
4370 } 4335 }
4371 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ") + ")"), node.span, true); 4336 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ") + ")"), node.span, true);
4372 } 4337 }
4373 MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNo nStatic; 4338 MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNo nStatic;
4374 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) { 4339 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) {
4375 return this.visitBinaryExpression($0, false); 4340 return this.visitBinaryExpression($0, false);
4376 }; 4341 };
4377 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { 4342 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) {
4378 return this.visitPostfixExpression($0, false); 4343 return this.visitPostfixExpression($0, false);
4379 }; 4344 };
4380 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition; 4345 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition;
4381 // ********** Code for Arguments ************** 4346 // ********** Code for Arguments **************
4382 function Arguments(nodes, values) { 4347 function Arguments(nodes, values) {
4383 this.nodes = nodes; 4348 this.nodes = nodes;
4384 this.values = values; 4349 this.values = values;
4385 // Initializers done 4350 // Initializers done
4386 } 4351 }
4387 Arguments.Arguments$bare$factory = function(arity) { 4352 Arguments.Arguments$bare$factory = function(arity) {
4388 var values = []; 4353 var values = [];
4389 for (var i = 0; 4354 for (var i = (0);
4390 i < arity; i++) { 4355 i < arity; i++) {
4391 values.add$1(new Value($globals.world.varType, ("$" + i), null, false)); 4356 values.add$1(new Value($globals.world.varType, ("$" + i), null, false));
4392 } 4357 }
4393 return new Arguments(null, values); 4358 return new Arguments(null, values);
4394 } 4359 }
4395 Arguments.get$EMPTY = function() { 4360 Arguments.get$EMPTY = function() {
4396 if ($globals.Arguments__empty == null) { 4361 if ($globals.Arguments__empty == null) {
4397 $globals.Arguments__empty = new Arguments(null, []); 4362 $globals.Arguments__empty = new Arguments(null, []);
4398 } 4363 }
4399 return $globals.Arguments__empty; 4364 return $globals.Arguments__empty;
4400 } 4365 }
4401 Arguments.prototype.get$values = function() { return this.values; };
4402 Arguments.prototype.set$values = function(value) { return this.values = value; } ;
4403 Arguments.prototype.get$nameCount = function() { 4366 Arguments.prototype.get$nameCount = function() {
4404 return this.get$length() - this.get$bareCount(); 4367 return this.get$length() - this.get$bareCount();
4405 } 4368 }
4406 Arguments.prototype.get$hasNames = function() { 4369 Arguments.prototype.get$hasNames = function() {
4407 return this.get$bareCount() < this.get$length(); 4370 return this.get$bareCount() < this.get$length();
4408 } 4371 }
4409 Arguments.prototype.get$length = function() { 4372 Arguments.prototype.get$length = function() {
4410 return this.values.get$length(); 4373 return this.values.get$length();
4411 } 4374 }
4412 Arguments.prototype.getName = function(i) { 4375 Arguments.prototype.getName = function(i) {
4413 return this.nodes.$index(i).get$label().get$name(); 4376 return this.nodes.$index(i).get$label().get$name();
4414 } 4377 }
4415 Arguments.prototype.getIndexOfName = function(name) { 4378 Arguments.prototype.getIndexOfName = function(name) {
4416 for (var i = this.get$bareCount(); 4379 for (var i = this.get$bareCount();
4417 i < this.get$length(); i++) { 4380 i < this.get$length(); i++) {
4418 if (this.getName(i) == name) { 4381 if (this.getName(i) == name) {
4419 return i; 4382 return i;
4420 } 4383 }
4421 } 4384 }
4422 return -1; 4385 return (-1);
4423 } 4386 }
4424 Arguments.prototype.getValue = function(name) { 4387 Arguments.prototype.getValue = function(name) {
4425 var i = this.getIndexOfName(name); 4388 var i = this.getIndexOfName(name);
4426 return i >= 0 ? this.values.$index(i) : null; 4389 return i >= (0) ? this.values.$index(i) : null;
4427 } 4390 }
4428 Arguments.prototype.get$bareCount = function() { 4391 Arguments.prototype.get$bareCount = function() {
4429 if (this._bareCount == null) { 4392 if (this._bareCount == null) {
4430 this._bareCount = this.get$length(); 4393 this._bareCount = this.get$length();
4431 if (this.nodes != null) { 4394 if (this.nodes != null) {
4432 for (var i = 0; 4395 for (var i = (0);
4433 i < this.nodes.get$length(); i++) { 4396 i < this.nodes.get$length(); i++) {
4434 if (this.nodes.$index(i).get$label() != null) { 4397 if (this.nodes.$index(i).get$label() != null) {
4435 this._bareCount = i; 4398 this._bareCount = i;
4436 break; 4399 break;
4437 } 4400 }
4438 } 4401 }
4439 } 4402 }
4440 } 4403 }
4441 return this._bareCount; 4404 return this._bareCount;
4442 } 4405 }
4443 Arguments.prototype.getCode = function() { 4406 Arguments.prototype.getCode = function() {
4444 var argsCode = []; 4407 var argsCode = [];
4445 for (var i = 0; 4408 for (var i = (0);
4446 i < this.get$length(); i++) { 4409 i < this.get$length(); i++) {
4447 argsCode.add$1(this.values.$index(i).get$code()); 4410 argsCode.add$1(this.values.$index(i).get$code());
4448 } 4411 }
4449 Arguments.removeTrailingNulls(argsCode); 4412 Arguments.removeTrailingNulls(argsCode);
4450 return Strings.join(argsCode, ", "); 4413 return Strings.join(argsCode, ", ");
4451 } 4414 }
4452 Arguments.removeTrailingNulls = function(argsCode) { 4415 Arguments.removeTrailingNulls = function(argsCode) {
4453 while (argsCode.get$length() > 0 && $eq(argsCode.last(), "null")) { 4416 while (argsCode.get$length() > (0) && $eq(argsCode.last(), "null")) {
4454 argsCode.removeLast(); 4417 argsCode.removeLast();
4455 } 4418 }
4456 } 4419 }
4457 Arguments.prototype.getNames = function() { 4420 Arguments.prototype.getNames = function() {
4458 var names = []; 4421 var names = [];
4459 for (var i = this.get$bareCount(); 4422 for (var i = this.get$bareCount();
4460 i < this.get$length(); i++) { 4423 i < this.get$length(); i++) {
4461 names.add$1(this.getName(i)); 4424 names.add$1(this.getName(i));
4462 } 4425 }
4463 return names; 4426 return names;
4464 } 4427 }
4465 Arguments.prototype.toCallStubArgs = function() { 4428 Arguments.prototype.toCallStubArgs = function() {
4466 var result = []; 4429 var result = [];
4467 for (var i = 0; 4430 for (var i = (0);
4468 i < this.get$bareCount(); i++) { 4431 i < this.get$bareCount(); i++) {
4469 result.add$1(new Value($globals.world.varType, ("$" + i), null, false)); 4432 result.add$1(new Value($globals.world.varType, ("$" + i), null, false));
4470 } 4433 }
4471 for (var i = this.get$bareCount(); 4434 for (var i = this.get$bareCount();
4472 i < this.get$length(); i++) { 4435 i < this.get$length(); i++) {
4473 var name = this.getName(i); 4436 var name = this.getName(i);
4474 if (name == null) name = ("$" + i); 4437 if (name == null) name = ("$" + i);
4475 result.add$1(new Value($globals.world.varType, name, null, false)); 4438 result.add$1(new Value($globals.world.varType, name, null, false));
4476 } 4439 }
4477 return new Arguments(this.nodes, result); 4440 return new Arguments(this.nodes, result);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 Library.prototype.get$isCore = function() { 4485 Library.prototype.get$isCore = function() {
4523 return $eq(this, $globals.world.corelib); 4486 return $eq(this, $globals.world.corelib);
4524 } 4487 }
4525 Library.prototype.get$isCoreImpl = function() { 4488 Library.prototype.get$isCoreImpl = function() {
4526 return $eq(this, $globals.world.coreimpl); 4489 return $eq(this, $globals.world.coreimpl);
4527 } 4490 }
4528 Library.prototype.get$isDom = function() { 4491 Library.prototype.get$isDom = function() {
4529 return $eq(this, $globals.world.dom); 4492 return $eq(this, $globals.world.dom);
4530 } 4493 }
4531 Library.prototype.get$span = function() { 4494 Library.prototype.get$span = function() {
4532 return new SourceSpan(this.baseSource, 0, 0); 4495 return new SourceSpan(this.baseSource, (0), (0));
4533 } 4496 }
4534 Library.prototype.makeFullPath = function(filename) { 4497 Library.prototype.makeFullPath = function(filename) {
4535 if (filename.startsWith("dart:")) return filename; 4498 if (filename.startsWith("dart:")) return filename;
4536 if (filename.startsWith("/")) return filename; 4499 if (filename.startsWith("/")) return filename;
4537 if (filename.startsWith("file:///")) return filename; 4500 if (filename.startsWith("file:///")) return filename;
4538 if (filename.startsWith("http://")) return filename; 4501 if (filename.startsWith("http://")) return filename;
4539 return joinPaths(this.sourceDir, filename); 4502 return joinPaths(this.sourceDir, filename);
4540 } 4503 }
4541 Library.prototype.addImport = function(fullname, prefix) { 4504 Library.prototype.addImport = function(fullname, prefix) {
4542 var newLib = $globals.world.getOrAddLibrary(fullname); 4505 var newLib = $globals.world.getOrAddLibrary(fullname);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4605 } 4568 }
4606 else { 4569 else {
4607 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ; 4570 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ;
4608 } 4571 }
4609 return this.types.$index(name); 4572 return this.types.$index(name);
4610 } 4573 }
4611 Library.prototype.findType = function(type) { 4574 Library.prototype.findType = function(type) {
4612 var result = this.findTypeByName(type.name.name); 4575 var result = this.findTypeByName(type.name.name);
4613 if (result == null) return null; 4576 if (result == null) return null;
4614 if (type.names != null) { 4577 if (type.names != null) {
4615 if (type.names.get$length() > 1) { 4578 if (type.names.get$length() > (1)) {
4616 return null; 4579 return null;
4617 } 4580 }
4618 if (!result.get$isTop()) { 4581 if (!result.get$isTop()) {
4619 return null; 4582 return null;
4620 } 4583 }
4621 return result.get$library().findTypeByName(type.names.$index(0).get$name()); 4584 return result.get$library().findTypeByName(type.names.$index((0)).get$name() );
4622 } 4585 }
4623 return result; 4586 return result;
4624 } 4587 }
4625 Library.prototype.findTypeByName = function(name) { 4588 Library.prototype.findTypeByName = function(name) {
4626 var ret = this.types.$index(name); 4589 var ret = this.types.$index(name);
4627 var $$list = this.imports; 4590 var $$list = this.imports;
4628 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4591 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4629 var imported = $$list.$index($$i); 4592 var imported = $$list.$index($$i);
4630 var newRet = null; 4593 var newRet = null;
4631 if (imported.get$prefix() == null) { 4594 if (imported.get$prefix() == null) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 } 4666 }
4704 } 4667 }
4705 } 4668 }
4706 } 4669 }
4707 return ret; 4670 return ret;
4708 } 4671 }
4709 Library.prototype.resolve = function() { 4672 Library.prototype.resolve = function() {
4710 if (this.name == null) { 4673 if (this.name == null) {
4711 this.name = this.baseSource.filename; 4674 this.name = this.baseSource.filename;
4712 var index = this.name.lastIndexOf("/", this.name.length); 4675 var index = this.name.lastIndexOf("/", this.name.length);
4713 if (index >= 0) { 4676 if (index >= (0)) {
4714 this.name = this.name.substring(index + 1); 4677 this.name = this.name.substring(index + (1));
4715 } 4678 }
4716 index = this.name.indexOf("."); 4679 index = this.name.indexOf(".");
4717 if (index > 0) { 4680 if (index > (0)) {
4718 this.name = this.name.substring(0, index); 4681 this.name = this.name.substring((0), index);
4719 } 4682 }
4720 } 4683 }
4721 this._jsname = this.name.replaceAll(".", "_").replaceAll(":", "_").replaceAll( " ", "_"); 4684 this._jsname = this.name.replaceAll(".", "_").replaceAll(":", "_").replaceAll( " ", "_");
4722 var $$list = this.types.getValues(); 4685 var $$list = this.types.getValues();
4723 for (var $$i = this.types.getValues().iterator$0(); $$i.hasNext$0(); ) { 4686 for (var $$i = this.types.getValues().iterator$0(); $$i.hasNext$0(); ) {
4724 var type = $$i.next$0(); 4687 var type = $$i.next$0();
4725 type.resolve$0(); 4688 type.resolve$0();
4726 } 4689 }
4727 } 4690 }
4728 Library.prototype.visitSources = function() { 4691 Library.prototype.visitSources = function() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4776 _LibraryVisitor.prototype.addSource = function(source) { 4739 _LibraryVisitor.prototype.addSource = function(source) {
4777 var $this = this; // closure support 4740 var $this = this; // closure support
4778 if (this.library.sources.some((function (s) { 4741 if (this.library.sources.some((function (s) {
4779 return $eq(s.get$filename(), source.filename); 4742 return $eq(s.get$filename(), source.filename);
4780 }) 4743 })
4781 )) { 4744 )) {
4782 $globals.world.error(("duplicate source file \"" + source.filename + "\"")); 4745 $globals.world.error(("duplicate source file \"" + source.filename + "\""));
4783 return; 4746 return;
4784 } 4747 }
4785 this.library.sources.add(source); 4748 this.library.sources.add(source);
4786 var parser = new Parser(source, $globals.options.dietParse, false, false, 0); 4749 var parser = new Parser(source, $globals.options.dietParse, false, false, (0)) ;
4787 var unit = parser.compilationUnit(); 4750 var unit = parser.compilationUnit();
4788 unit.forEach((function (def) { 4751 unit.forEach((function (def) {
4789 return def.visit$1($this); 4752 return def.visit$1($this);
4790 }) 4753 })
4791 ); 4754 );
4792 this.isTop = false; 4755 this.isTop = false;
4793 var newSources = this.sources; 4756 var newSources = this.sources;
4794 this.sources = []; 4757 this.sources = [];
4795 for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) { 4758 for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) {
4796 var source0 = $$i.next$0(); 4759 var source0 = $$i.next$0();
(...skipping 22 matching lines...) Expand all
4819 else { 4782 else {
4820 $globals.world.error("already specified library name", node.span); 4783 $globals.world.error("already specified library name", node.span);
4821 } 4784 }
4822 break; 4785 break;
4823 4786
4824 case "import": 4787 case "import":
4825 4788
4826 this.seenImport = true; 4789 this.seenImport = true;
4827 name = this.getFirstStringArg(node); 4790 name = this.getFirstStringArg(node);
4828 var prefix = this.tryGetNamedStringArg(node, "prefix"); 4791 var prefix = this.tryGetNamedStringArg(node, "prefix");
4829 if (node.arguments.get$length() > 2 || node.arguments.get$length() == 2 && prefix == null) { 4792 if (node.arguments.get$length() > (2) || node.arguments.get$length() == (2 ) && prefix == null) {
4830 $globals.world.error("expected at most one \"name\" argument and one opt ional \"prefix\"" + (" but found " + node.arguments.get$length()), node.span); 4793 $globals.world.error("expected at most one \"name\" argument and one opt ional \"prefix\"" + (" but found " + node.arguments.get$length()), node.span);
4831 } 4794 }
4832 else if (prefix != null && prefix.indexOf$1(".") >= 0) { 4795 else if (prefix != null && prefix.indexOf$1(".") >= (0)) {
4833 $globals.world.error("library prefix canot contain \".\"", node.span); 4796 $globals.world.error("library prefix canot contain \".\"", node.span);
4834 } 4797 }
4835 else if (this.seenSource || this.seenResource) { 4798 else if (this.seenSource || this.seenResource) {
4836 $globals.world.error("#imports must come before any #source or #resource ", node.span); 4799 $globals.world.error("#imports must come before any #source or #resource ", node.span);
4837 } 4800 }
4838 if ($eq(prefix, "")) prefix = null; 4801 if ($eq(prefix, "")) prefix = null;
4839 var filename = this.library.makeFullPath(name); 4802 var filename = this.library.makeFullPath(name);
4840 if (this.library.imports.some((function (li) { 4803 if (this.library.imports.some((function (li) {
4841 return $eq(li.get$library().get$baseSource(), filename); 4804 return $eq(li.get$library().get$baseSource(), filename);
4842 }) 4805 })
(...skipping 26 matching lines...) Expand all
4869 this.getFirstStringArg(node); 4832 this.getFirstStringArg(node);
4870 break; 4833 break;
4871 4834
4872 default: 4835 default:
4873 4836
4874 $globals.world.error(("unknown directive: " + node.name.name), node.span); 4837 $globals.world.error(("unknown directive: " + node.name.name), node.span);
4875 4838
4876 } 4839 }
4877 } 4840 }
4878 _LibraryVisitor.prototype.getSingleStringArg = function(node) { 4841 _LibraryVisitor.prototype.getSingleStringArg = function(node) {
4879 if (node.arguments.get$length() != 1) { 4842 if (node.arguments.get$length() != (1)) {
4880 $globals.world.error(("expected exactly one argument but found " + node.argu ments.get$length()), node.span); 4843 $globals.world.error(("expected exactly one argument but found " + node.argu ments.get$length()), node.span);
4881 } 4844 }
4882 return this.getFirstStringArg(node); 4845 return this.getFirstStringArg(node);
4883 } 4846 }
4884 _LibraryVisitor.prototype.getFirstStringArg = function(node) { 4847 _LibraryVisitor.prototype.getFirstStringArg = function(node) {
4885 if (node.arguments.get$length() < 1) { 4848 if (node.arguments.get$length() < (1)) {
4886 $globals.world.error(("expected at least one argument but found " + node.arg uments.get$length()), node.span); 4849 $globals.world.error(("expected at least one argument but found " + node.arg uments.get$length()), node.span);
4887 } 4850 }
4888 var arg = node.arguments.$index(0); 4851 var arg = node.arguments.$index((0));
4889 if (arg.get$label() != null) { 4852 if (arg.get$label() != null) {
4890 $globals.world.error("label not allowed for directive", node.span); 4853 $globals.world.error("label not allowed for directive", node.span);
4891 } 4854 }
4892 return this._parseStringArgument(arg); 4855 return this._parseStringArgument(arg);
4893 } 4856 }
4894 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { 4857 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) {
4895 var args = node.arguments.filter((function (a) { 4858 var args = node.arguments.filter((function (a) {
4896 return a.get$label() != null && $eq(a.get$label().get$name(), argName); 4859 return a.get$label() != null && $eq(a.get$label().get$name(), argName);
4897 }) 4860 })
4898 ); 4861 );
4899 if ($eq(args.get$length(), 0)) { 4862 if ($eq(args.get$length(), (0))) {
4900 return null; 4863 return null;
4901 } 4864 }
4902 if (args.get$length() > 1) { 4865 if (args.get$length() > (1)) {
4903 $globals.world.error(("expected at most one \"" + argName + "\" argument but found ") + node.arguments.get$length(), node.span); 4866 $globals.world.error(("expected at most one \"" + argName + "\" argument but found ") + node.arguments.get$length(), node.span);
4904 } 4867 }
4905 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) { 4868 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) {
4906 var arg = $$i.next$0(); 4869 var arg = $$i.next$0();
4907 return this._parseStringArgument(arg); 4870 return this._parseStringArgument(arg);
4908 } 4871 }
4909 } 4872 }
4910 _LibraryVisitor.prototype._parseStringArgument = function(arg) { 4873 _LibraryVisitor.prototype._parseStringArgument = function(arg) {
4911 var expr = arg.value; 4874 var expr = arg.value;
4912 if (!(expr instanceof LiteralExpression) || !expr.get$value().get$type().get$i sString()) { 4875 if (!(expr instanceof LiteralExpression) || !expr.get$value().get$type().get$i sString()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4950 Parameter.prototype.set$name = function(value) { return this.name = value; }; 4913 Parameter.prototype.set$name = function(value) { return this.name = value; };
4951 Parameter.prototype.get$type = function() { return this.type; }; 4914 Parameter.prototype.get$type = function() { return this.type; };
4952 Parameter.prototype.set$type = function(value) { return this.type = value; }; 4915 Parameter.prototype.set$type = function(value) { return this.type = value; };
4953 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; }; 4916 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; };
4954 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; }; 4917 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; };
4955 Parameter.prototype.get$value = function() { return this.value; }; 4918 Parameter.prototype.get$value = function() { return this.value; };
4956 Parameter.prototype.set$value = function(value) { return this.value = value; }; 4919 Parameter.prototype.set$value = function(value) { return this.value = value; };
4957 Parameter.prototype.resolve = function() { 4920 Parameter.prototype.resolve = function() {
4958 this.name = this.definition.name.name; 4921 this.name = this.definition.name.name;
4959 if (this.name.startsWith("this.")) { 4922 if (this.name.startsWith("this.")) {
4960 this.name = this.name.substring(5); 4923 this.name = this.name.substring((5));
4961 this.isInitializer = true; 4924 this.isInitializer = true;
4962 } 4925 }
4963 this.type = this.method.resolveType(this.definition.type, false); 4926 this.type = this.method.resolveType(this.definition.type, false);
4964 if (this.definition.value != null) { 4927 if (this.definition.value != null) {
4965 if (this.definition.value.span.start == this.definition.span.start) { 4928 if (this.definition.value.span.start == this.definition.span.start) {
4966 return; 4929 return;
4967 } 4930 }
4968 if (this.method.name == ":call") { 4931 if (this.method.name == ":call") {
4969 if (this.method.get$definition().get$body() == null && !this.method.get$is Native()) { 4932 if (this.method.get$definition().get$body() == null && !this.method.get$is Native()) {
4970 $globals.world.error("default value not allowed on function type", this. definition.span); 4933 $globals.world.error("default value not allowed on function type", this. definition.span);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 Member.prototype.get$generatedFactoryName = function() { 5077 Member.prototype.get$generatedFactoryName = function() {
5115 var prefix = ("" + this.declaringType.get$jsname() + "." + this.get$constructo rName() + "$"); 5078 var prefix = ("" + this.declaringType.get$jsname() + "." + this.get$constructo rName() + "$");
5116 if (this.name == "") { 5079 if (this.name == "") {
5117 return ("" + prefix + "factory"); 5080 return ("" + prefix + "factory");
5118 } 5081 }
5119 else { 5082 else {
5120 return ("" + prefix + this.name + "$factory"); 5083 return ("" + prefix + this.name + "$factory");
5121 } 5084 }
5122 } 5085 }
5123 Member.prototype.hashCode = function() { 5086 Member.prototype.hashCode = function() {
5124 var typeCode = this.declaringType == null ? 1 : this.declaringType.hashCode(); 5087 var typeCode = this.declaringType == null ? (1) : this.declaringType.hashCode( );
5125 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode( ) : this.name.hashCode(); 5088 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode( ) : this.name.hashCode();
5126 return (typeCode << 4) ^ nameCode; 5089 return (typeCode << (4)) ^ nameCode;
5127 } 5090 }
5128 Member.prototype.$eq = function(other) { 5091 Member.prototype.$eq = function(other) {
5129 return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$is Constructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.ge t$isConstructor() ? this.get$constructorName() == other.get$constructorName() : this.name == other.get$name()); 5092 return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$is Constructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.ge t$isConstructor() ? this.get$constructorName() == other.get$constructorName() : this.name == other.get$name());
5130 } 5093 }
5131 Member.prototype._get$3 = Member.prototype._get; 5094 Member.prototype._get$3 = Member.prototype._get;
5132 Member.prototype._get$3$isDynamic = Member.prototype._get; 5095 Member.prototype._get$3$isDynamic = Member.prototype._get;
5133 Member.prototype._get$4 = Member.prototype._get; 5096 Member.prototype._get$4 = Member.prototype._get;
5134 Member.prototype._set$4 = Member.prototype._set; 5097 Member.prototype._set$4 = Member.prototype._set;
5135 Member.prototype._set$4$isDynamic = Member.prototype._set; 5098 Member.prototype._set$4$isDynamic = Member.prototype._set;
5136 Member.prototype._set$5 = Member.prototype._set; 5099 Member.prototype._set$5 = Member.prototype._set;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
5249 FieldMember.prototype.get$isField = function() { 5212 FieldMember.prototype.get$isField = function() {
5250 return true; 5213 return true;
5251 } 5214 }
5252 FieldMember.prototype.resolve = function() { 5215 FieldMember.prototype.resolve = function() {
5253 this.isStatic = this.declaringType.get$isTop(); 5216 this.isStatic = this.declaringType.get$isTop();
5254 this.isFinal = false; 5217 this.isFinal = false;
5255 if (this.definition.modifiers != null) { 5218 if (this.definition.modifiers != null) {
5256 var $$list = this.definition.modifiers; 5219 var $$list = this.definition.modifiers;
5257 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 5220 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5258 var mod = $$list.$index($$i); 5221 var mod = $$list.$index($$i);
5259 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) { 5222 if ($eq(mod.get$kind(), (84))) {
5260 if (this.isStatic) { 5223 if (this.isStatic) {
5261 $globals.world.error("duplicate static modifier", mod.get$span()); 5224 $globals.world.error("duplicate static modifier", mod.get$span());
5262 } 5225 }
5263 this.isStatic = true; 5226 this.isStatic = true;
5264 } 5227 }
5265 else if ($eq(mod.get$kind(), 98/*TokenKind.FINAL*/)) { 5228 else if ($eq(mod.get$kind(), (98))) {
5266 if (this.isFinal) { 5229 if (this.isFinal) {
5267 $globals.world.error("duplicate final modifier", mod.get$span()); 5230 $globals.world.error("duplicate final modifier", mod.get$span());
5268 } 5231 }
5269 this.isFinal = true; 5232 this.isFinal = true;
5270 } 5233 }
5271 else { 5234 else {
5272 $globals.world.error(("" + mod + " modifier not allowed on field"), mod. get$span()); 5235 $globals.world.error(("" + mod + " modifier not allowed on field"), mod. get$span());
5273 } 5236 }
5274 } 5237 }
5275 } 5238 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
5337 else if (this.declaringType.get$isNative()) { 5300 else if (this.declaringType.get$isNative()) {
5338 if (this.declaringType.get$isHiddenNativeType()) { 5301 if (this.declaringType.get$isHiddenNativeType()) {
5339 $globals.world.error("static field of hidden native type is inaccessible ", node.span); 5302 $globals.world.error("static field of hidden native type is inaccessible ", node.span);
5340 } 5303 }
5341 return new Value(this.type, ("" + this.declaringType.get$jsname() + "." + this.get$jsname()), node.span, true); 5304 return new Value(this.type, ("" + this.declaringType.get$jsname() + "." + this.get$jsname()), node.span, true);
5342 } 5305 }
5343 else { 5306 else {
5344 return new Value(this.type, ("$globals." + this.declaringType.get$jsname() + "_" + this.get$jsname()), node.span, true); 5307 return new Value(this.type, ("$globals." + this.declaringType.get$jsname() + "_" + this.get$jsname()), node.span, true);
5345 } 5308 }
5346 } 5309 }
5347 else if (target.get$isConst() && this.isFinal) { 5310 return new Value(this.type, ("" + target.get$code() + "." + this.get$jsname()) , node.span, true);
5348 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get $exp() : target;
5349 if ((constTarget instanceof ConstObjectValue)) {
5350 return constTarget.get$fields().$index(this.name);
5351 }
5352 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name == "length") {
5353 return new Value(this.type, ("" + constTarget.get$actualValue().get$length ()), node.span, true);
5354 }
5355 }
5356 return new Value(this.type, ("" + target.code + "." + this.get$jsname()), node .span, true);
5357 } 5311 }
5358 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { 5312 FieldMember.prototype._set = function(context, node, target, value, isDynamic) {
5359 var lhs = this._get(context, node, target, isDynamic); 5313 var lhs = this._get(context, node, target, isDynamic);
5360 value = value.convertTo(context, this.type, isDynamic); 5314 value = value.convertTo(context, this.type, isDynamic);
5361 return new Value(this.type, ("" + lhs.get$code() + " = " + value.code), node.s pan, true); 5315 return new Value(this.type, ("" + lhs.get$code() + " = " + value.get$code()), node.span, true);
5362 } 5316 }
5363 FieldMember.prototype._get$3 = function($0, $1, $2) { 5317 FieldMember.prototype._get$3 = function($0, $1, $2) {
5364 return this._get($0, $1, $2, false); 5318 return this._get($0, $1, $2, false);
5365 }; 5319 };
5366 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get; 5320 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get;
5367 FieldMember.prototype._get$4 = FieldMember.prototype._get; 5321 FieldMember.prototype._get$4 = FieldMember.prototype._get;
5368 FieldMember.prototype._set$4 = function($0, $1, $2, $3) { 5322 FieldMember.prototype._set$4 = function($0, $1, $2, $3) {
5369 return this._set($0, $1, $2, $3, false); 5323 return this._set($0, $1, $2, $3, false);
5370 }; 5324 };
5371 FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set; 5325 FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5451 } 5405 }
5452 else { 5406 else {
5453 parent = parentMember; 5407 parent = parentMember;
5454 } 5408 }
5455 if (this.getter == null) this.getter = parent.getter; 5409 if (this.getter == null) this.getter = parent.getter;
5456 if (this.setter == null) this.setter = parent.setter; 5410 if (this.setter == null) this.setter = parent.setter;
5457 } 5411 }
5458 PropertyMember.prototype.resolve = function() { 5412 PropertyMember.prototype.resolve = function() {
5459 if (this.getter != null) { 5413 if (this.getter != null) {
5460 this.getter.resolve(); 5414 this.getter.resolve();
5461 if (this.getter.parameters.get$length() != 0) { 5415 if (this.getter.parameters.get$length() != (0)) {
5462 $globals.world.error("getter methods should take no arguments", this.gette r.definition.span); 5416 $globals.world.error("getter methods should take no arguments", this.gette r.definition.span);
5463 } 5417 }
5464 if (this.getter.returnType.get$isVoid()) { 5418 if (this.getter.returnType.get$isVoid()) {
5465 $globals.world.warning("getter methods should not be void", this.getter.de finition.returnType.span); 5419 $globals.world.warning("getter methods should not be void", this.getter.de finition.returnType.span);
5466 } 5420 }
5467 } 5421 }
5468 if (this.setter != null) { 5422 if (this.setter != null) {
5469 this.setter.resolve(); 5423 this.setter.resolve();
5470 if (this.setter.parameters.get$length() != 1) { 5424 if (this.setter.parameters.get$length() != (1)) {
5471 $globals.world.error("setter methods should take a single argument", this. setter.definition.span); 5425 $globals.world.error("setter methods should take a single argument", this. setter.definition.span);
5472 } 5426 }
5473 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) { 5427 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) {
5474 $globals.world.warning("setter methods should be void", this.setter.defini tion.returnType.span); 5428 $globals.world.warning("setter methods should be void", this.setter.defini tion.returnType.span);
5475 } 5429 }
5476 } 5430 }
5477 this.get$library()._addMember(this); 5431 this.get$library()._addMember(this);
5478 } 5432 }
5479 PropertyMember.prototype._get$3 = function($0, $1, $2) { 5433 PropertyMember.prototype._get$3 = function($0, $1, $2) {
5480 return this._get($0, $1, $2, false); 5434 return this._get($0, $1, $2, false);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5587 return type.resolveTypeParams$1(this.declaringType); 5541 return type.resolveTypeParams$1(this.declaringType);
5588 } 5542 }
5589 ConcreteMember.prototype.computeValue = function() { 5543 ConcreteMember.prototype.computeValue = function() {
5590 return this.baseMember.computeValue(); 5544 return this.baseMember.computeValue();
5591 } 5545 }
5592 ConcreteMember.prototype.override = function(other) { 5546 ConcreteMember.prototype.override = function(other) {
5593 return this.baseMember.override(other); 5547 return this.baseMember.override(other);
5594 } 5548 }
5595 ConcreteMember.prototype._get = function(context, node, target, isDynamic) { 5549 ConcreteMember.prototype._get = function(context, node, target, isDynamic) {
5596 var ret = this.baseMember._get(context, node, target, isDynamic); 5550 var ret = this.baseMember._get(context, node, target, isDynamic);
5597 return new Value(this.get$inferredResult(), ret.code, node.span, true); 5551 return new Value(this.get$inferredResult(), ret.get$code(), node.span, true);
5598 } 5552 }
5599 ConcreteMember.prototype._set = function(context, node, target, value, isDynamic ) { 5553 ConcreteMember.prototype._set = function(context, node, target, value, isDynamic ) {
5600 var ret = this.baseMember._set(context, node, target, value, isDynamic); 5554 var ret = this.baseMember._set(context, node, target, value, isDynamic);
5601 return new Value(this.returnType, ret.code, node.span, true); 5555 return new Value(this.returnType, ret.get$code(), node.span, true);
5602 } 5556 }
5603 ConcreteMember.prototype.invoke = function(context, node, target, args, isDynami c) { 5557 ConcreteMember.prototype.invoke = function(context, node, target, args, isDynami c) {
5604 var ret = this.baseMember.invoke(context, node, target, args, isDynamic); 5558 var ret = this.baseMember.invoke(context, node, target, args, isDynamic);
5605 var code = ret.code; 5559 var code = ret.get$code();
5606 if (this.get$isConstructor()) { 5560 if (this.get$isConstructor()) {
5607 code = code.replaceFirst$2(this.declaringType.get$genericType().get$jsname() , this.declaringType.get$jsname()); 5561 code = code.replaceFirst$2(this.declaringType.get$genericType().get$jsname() , this.declaringType.get$jsname());
5608 } 5562 }
5609 if ((this.baseMember instanceof MethodMember)) { 5563 if ((this.baseMember instanceof MethodMember)) {
5610 this.declaringType.genMethod(this); 5564 this.declaringType.genMethod(this);
5611 } 5565 }
5612 return new Value(this.get$inferredResult(), code, node.span, true); 5566 return new Value(this.get$inferredResult(), code, node.span, true);
5613 } 5567 }
5614 ConcreteMember.prototype._get$3 = function($0, $1, $2) { 5568 ConcreteMember.prototype._get$3 = function($0, $1, $2) {
5615 return this._get($0, $1, $2, false); 5569 return this._get($0, $1, $2, false);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5682 MethodMember.prototype.get$span = function() { 5636 MethodMember.prototype.get$span = function() {
5683 return this.definition == null ? null : this.definition.span; 5637 return this.definition == null ? null : this.definition.span;
5684 } 5638 }
5685 MethodMember.prototype.get$constructorName = function() { 5639 MethodMember.prototype.get$constructorName = function() {
5686 var returnType = this.definition.returnType; 5640 var returnType = this.definition.returnType;
5687 if (returnType == null) return ""; 5641 if (returnType == null) return "";
5688 if ((returnType instanceof GenericTypeReference)) { 5642 if ((returnType instanceof GenericTypeReference)) {
5689 return ""; 5643 return "";
5690 } 5644 }
5691 if (returnType.get$names() != null) { 5645 if (returnType.get$names() != null) {
5692 return returnType.get$names().$index(0).get$name(); 5646 return returnType.get$names().$index((0)).get$name();
5693 } 5647 }
5694 else if (returnType.get$name() != null) { 5648 else if (returnType.get$name() != null) {
5695 return returnType.get$name().get$name(); 5649 return returnType.get$name().get$name();
5696 } 5650 }
5697 $globals.world.internalError("no valid constructor name", this.definition.span ); 5651 $globals.world.internalError("no valid constructor name", this.definition.span );
5698 } 5652 }
5699 MethodMember.prototype.get$functionType = function() { 5653 MethodMember.prototype.get$functionType = function() {
5700 if (this._functionType == null) { 5654 if (this._functionType == null) {
5701 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT ype, this.name, this.definition); 5655 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT ype, this.name, this.definition);
5702 if (this.parameters == null) { 5656 if (this.parameters == null) {
(...skipping 15 matching lines...) Expand all
5718 MethodMember.prototype.canInvoke = function(context, args) { 5672 MethodMember.prototype.canInvoke = function(context, args) {
5719 var bareCount = args.get$bareCount(); 5673 var bareCount = args.get$bareCount();
5720 if (bareCount > this.parameters.get$length()) return false; 5674 if (bareCount > this.parameters.get$length()) return false;
5721 if (bareCount == this.parameters.get$length()) { 5675 if (bareCount == this.parameters.get$length()) {
5722 if (bareCount != args.get$length()) return false; 5676 if (bareCount != args.get$length()) return false;
5723 } 5677 }
5724 else { 5678 else {
5725 if (!this.parameters.$index(bareCount).get$isOptional()) return false; 5679 if (!this.parameters.$index(bareCount).get$isOptional()) return false;
5726 for (var i = bareCount; 5680 for (var i = bareCount;
5727 i < args.get$length(); i++) { 5681 i < args.get$length(); i++) {
5728 if (this.indexOfParameter(args.getName(i)) < 0) { 5682 if (this.indexOfParameter(args.getName(i)) < (0)) {
5729 return false; 5683 return false;
5730 } 5684 }
5731 } 5685 }
5732 } 5686 }
5733 return true; 5687 return true;
5734 } 5688 }
5735 MethodMember.prototype.indexOfParameter = function(name) { 5689 MethodMember.prototype.indexOfParameter = function(name) {
5736 for (var i = 0; 5690 for (var i = (0);
5737 i < this.parameters.get$length(); i++) { 5691 i < this.parameters.get$length(); i++) {
5738 var p = this.parameters.$index(i); 5692 var p = this.parameters.$index(i);
5739 if (p.get$isOptional() && $eq(p.get$name(), name)) { 5693 if (p.get$isOptional() && $eq(p.get$name(), name)) {
5740 return i; 5694 return i;
5741 } 5695 }
5742 } 5696 }
5743 return -1; 5697 return (-1);
5744 } 5698 }
5745 MethodMember.prototype.provideFieldSyntax = function() { 5699 MethodMember.prototype.provideFieldSyntax = function() {
5746 this._provideFieldSyntax = true; 5700 this._provideFieldSyntax = true;
5747 } 5701 }
5748 MethodMember.prototype.providePropertySyntax = function() { 5702 MethodMember.prototype.providePropertySyntax = function() {
5749 this._providePropertySyntax = true; 5703 this._providePropertySyntax = true;
5750 } 5704 }
5751 MethodMember.prototype._set = function(context, node, target, value, isDynamic) { 5705 MethodMember.prototype._set = function(context, node, target, value, isDynamic) {
5752 $globals.world.error("cannot set method", node.span); 5706 $globals.world.error("cannot set method", node.span);
5753 } 5707 }
5754 MethodMember.prototype._get = function(context, node, target, isDynamic) { 5708 MethodMember.prototype._get = function(context, node, target, isDynamic) {
5755 this.declaringType.genMethod(this); 5709 this.declaringType.genMethod(this);
5756 this._provideOptionalParamInfo = true; 5710 this._provideOptionalParamInfo = true;
5757 if (this.isStatic) { 5711 if (this.isStatic) {
5758 this.declaringType.markUsed(); 5712 this.declaringType.markUsed();
5759 var type = this.declaringType.get$isTop() ? "" : ("" + this.declaringType.ge t$jsname() + "."); 5713 var type = this.declaringType.get$isTop() ? "" : ("" + this.declaringType.ge t$jsname() + ".");
5760 return new Value(this.get$functionType(), ("" + type + this.get$jsname()), n ode.span, true); 5714 return new Value(this.get$functionType(), ("" + type + this.get$jsname()), n ode.span, true);
5761 } 5715 }
5762 this._providePropertySyntax = true; 5716 this._providePropertySyntax = true;
5763 return new Value(this.get$functionType(), ("" + target.code + ".get$" + this.g et$jsname() + "()"), node.span, true); 5717 return new Value(this.get$functionType(), ("" + target.get$code() + ".get$" + this.get$jsname() + "()"), node.span, true);
5764 } 5718 }
5765 MethodMember.prototype.namesInHomePositions = function(args) { 5719 MethodMember.prototype.namesInHomePositions = function(args) {
5766 if (!args.get$hasNames()) return true; 5720 if (!args.get$hasNames()) return true;
5767 for (var i = args.get$bareCount(); 5721 for (var i = args.get$bareCount();
5768 i < args.values.get$length(); i++) { 5722 i < args.values.get$length(); i++) {
5769 if (i >= this.parameters.get$length()) { 5723 if (i >= this.parameters.get$length()) {
5770 return false; 5724 return false;
5771 } 5725 }
5772 if (args.getName(i) != this.parameters.$index(i).get$name()) { 5726 if (args.getName(i) != this.parameters.$index(i).get$name()) {
5773 return false; 5727 return false;
5774 } 5728 }
5775 } 5729 }
5776 return true; 5730 return true;
5777 } 5731 }
5778 MethodMember.prototype.namesInOrder = function(args) { 5732 MethodMember.prototype.namesInOrder = function(args) {
5779 if (!args.get$hasNames()) return true; 5733 if (!args.get$hasNames()) return true;
5780 var lastParameter = null; 5734 var lastParameter = null;
5781 for (var i = args.get$bareCount(); 5735 for (var i = args.get$bareCount();
5782 i < this.parameters.get$length(); i++) { 5736 i < this.parameters.get$length(); i++) {
5783 var p = args.getIndexOfName(this.parameters.$index(i).get$name()); 5737 var p = args.getIndexOfName(this.parameters.$index(i).get$name());
5784 if (p >= 0 && args.values.$index(p).get$needsTemp()) { 5738 if (p >= (0) && args.values.$index(p).get$needsTemp()) {
5785 if (lastParameter != null && lastParameter > p) { 5739 if (lastParameter != null && lastParameter > p) {
5786 return false; 5740 return false;
5787 } 5741 }
5788 lastParameter = p; 5742 lastParameter = p;
5789 } 5743 }
5790 } 5744 }
5791 return true; 5745 return true;
5792 } 5746 }
5793 MethodMember.prototype.needsArgumentConversion = function(args) { 5747 MethodMember.prototype.needsArgumentConversion = function(args) {
5794 var bareCount = args.get$bareCount(); 5748 var bareCount = args.get$bareCount();
5795 for (var i = 0; 5749 for (var i = (0);
5796 i < bareCount; i++) { 5750 i < bareCount; i++) {
5797 var arg = args.values.$index(i); 5751 var arg = args.values.$index(i);
5798 if (arg.needsConversion$1(this.parameters.$index(i).get$type())) { 5752 if (arg.needsConversion$1(this.parameters.$index(i).get$type())) {
5799 return true; 5753 return true;
5800 } 5754 }
5801 } 5755 }
5802 if (bareCount < this.parameters.get$length()) { 5756 if (bareCount < this.parameters.get$length()) {
5803 this.genParameterValues(); 5757 this.genParameterValues();
5804 for (var i = bareCount; 5758 for (var i = bareCount;
5805 i < this.parameters.get$length(); i++) { 5759 i < this.parameters.get$length(); i++) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5848 } 5802 }
5849 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ; 5803 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ;
5850 if (!this.namesInOrder(args)) { 5804 if (!this.namesInOrder(args)) {
5851 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s); 5805 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s);
5852 } 5806 }
5853 var argsCode = []; 5807 var argsCode = [];
5854 if (!target.isType && (this.get$isConstructor() || target.isSuper)) { 5808 if (!target.isType && (this.get$isConstructor() || target.isSuper)) {
5855 argsCode.add$1("this"); 5809 argsCode.add$1("this");
5856 } 5810 }
5857 var bareCount = args.get$bareCount(); 5811 var bareCount = args.get$bareCount();
5858 for (var i = 0; 5812 for (var i = (0);
5859 i < bareCount; i++) { 5813 i < bareCount; i++) {
5860 var arg = args.values.$index(i); 5814 var arg = args.values.$index(i);
5861 if (i >= this.parameters.get$length()) { 5815 if (i >= this.parameters.get$length()) {
5862 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get $length(), false); 5816 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get $length(), false);
5863 return this._argError(context, node, target, args, msg, i); 5817 return this._argError(context, node, target, args, msg, i);
5864 } 5818 }
5865 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isDynam ic); 5819 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isDynam ic);
5866 if (this.isConst && arg.get$isConst()) { 5820 argsCode.add$1(arg.get$code());
5867 argsCode.add$1(arg.get$canonicalCode());
5868 }
5869 else {
5870 argsCode.add$1(arg.get$code());
5871 }
5872 } 5821 }
5873 var namedArgsUsed = 0; 5822 var namedArgsUsed = (0);
5874 if (bareCount < this.parameters.get$length()) { 5823 if (bareCount < this.parameters.get$length()) {
5875 this.genParameterValues(); 5824 this.genParameterValues();
5876 for (var i = bareCount; 5825 for (var i = bareCount;
5877 i < this.parameters.get$length(); i++) { 5826 i < this.parameters.get$length(); i++) {
5878 var arg = args.getValue(this.parameters.$index(i).get$name()); 5827 var arg = args.getValue(this.parameters.$index(i).get$name());
5879 if (arg == null) { 5828 if (arg == null) {
5880 arg = this.parameters.$index(i).get$value(); 5829 arg = this.parameters.$index(i).get$value();
5881 } 5830 }
5882 else { 5831 else {
5883 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isD ynamic); 5832 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isD ynamic);
5884 namedArgsUsed++; 5833 namedArgsUsed++;
5885 } 5834 }
5886 if (arg == null || !this.parameters.$index(i).get$isOptional()) { 5835 if (arg == null || !this.parameters.$index(i).get$isOptional()) {
5887 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + 1, true); 5836 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + (1), true);
5888 return this._argError(context, node, target, args, msg, i); 5837 return this._argError(context, node, target, args, msg, i);
5889 } 5838 }
5890 else { 5839 else {
5891 argsCode.add$1(this.isConst && arg.get$isConst() ? arg.get$canonicalCode () : arg.get$code()); 5840 argsCode.add$1(arg.get$code());
5892 } 5841 }
5893 } 5842 }
5894 Arguments.removeTrailingNulls(argsCode); 5843 Arguments.removeTrailingNulls(argsCode);
5895 } 5844 }
5896 if (namedArgsUsed < args.get$nameCount()) { 5845 if (namedArgsUsed < args.get$nameCount()) {
5897 var seen = new HashSetImplementation(); 5846 var seen = new HashSetImplementation();
5898 for (var i = bareCount; 5847 for (var i = bareCount;
5899 i < args.get$length(); i++) { 5848 i < args.get$length(); i++) {
5900 var name = args.getName(i); 5849 var name = args.getName(i);
5901 if (seen.contains$1(name)) { 5850 if (seen.contains$1(name)) {
5902 return this._argError(context, node, target, args, ("duplicate argument \"" + name + "\""), i); 5851 return this._argError(context, node, target, args, ("duplicate argument \"" + name + "\""), i);
5903 } 5852 }
5904 seen.add$1(name); 5853 seen.add$1(name);
5905 var p = this.indexOfParameter(name); 5854 var p = this.indexOfParameter(name);
5906 if (p < 0) { 5855 if (p < (0)) {
5907 return this._argError(context, node, target, args, ("method does not hav e optional parameter \"" + name + "\""), i); 5856 return this._argError(context, node, target, args, ("method does not hav e optional parameter \"" + name + "\""), i);
5908 } 5857 }
5909 else if (p < bareCount) { 5858 else if (p < bareCount) {
5910 return this._argError(context, node, target, args, ("argument \"" + name + "\" passed as positional and named"), p); 5859 return this._argError(context, node, target, args, ("argument \"" + name + "\" passed as positional and named"), p);
5911 } 5860 }
5912 } 5861 }
5913 $globals.world.internalError(("wrong named arguments calling " + this.name), node.span); 5862 $globals.world.internalError(("wrong named arguments calling " + this.name), node.span);
5914 } 5863 }
5915 var argsString = Strings.join(argsCode, ", "); 5864 var argsString = Strings.join(argsCode, ", ");
5916 if (this.get$isConstructor()) { 5865 if (this.get$isConstructor()) {
5917 return this._invokeConstructor(context, node, target, args, argsString); 5866 return this._invokeConstructor(context, node, target, args, argsString);
5918 } 5867 }
5919 if (target.isSuper) { 5868 if (target.isSuper) {
5920 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + ".prototype." + this.get$jsname() + ".call(" + argsString + ")"), node.s pan, true); 5869 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + ".prototype." + this.get$jsname() + ".call(" + argsString + ")"), node.s pan, true);
5921 } 5870 }
5922 if (this.get$isOperator()) { 5871 if (this.get$isOperator()) {
5923 return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic) ; 5872 return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic) ;
5924 } 5873 }
5925 if (this.isFactory) { 5874 if (this.isFactory) {
5926 return new Value(target.get$type(), ("" + this.get$generatedFactoryName() + "(" + argsString + ")"), node.span, true); 5875 return new Value(target.get$type(), ("" + this.get$generatedFactoryName() + "(" + argsString + ")"), node != null ? node.span : null, true);
5927 } 5876 }
5928 if (this.isStatic) { 5877 if (this.isStatic) {
5929 if (this.declaringType.get$isTop()) { 5878 if (this.declaringType.get$isTop()) {
5930 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + argsString + ")"), node != null ? node.span : node, true); 5879 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + argsString + ")"), node != null ? node.span : null, true);
5931 } 5880 }
5932 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + "." + this.get$jsname() + "(" + argsString + ")"), node.span, true); 5881 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + "." + this.get$jsname() + "(" + argsString + ")"), node.span, true);
5933 } 5882 }
5934 var code = ("" + target.code + "." + this.get$jsname() + "(" + argsString + ") "); 5883 var code = ("" + target.get$code() + "." + this.get$jsname() + "(" + argsStrin g + ")");
5935 if (target.get$isConst()) {
5936 if ((target instanceof GlobalValue)) {
5937 target = target.get$dynamic().get$exp();
5938 }
5939 if (this.name == "get:length") {
5940 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5941 code = ("" + target.get$dynamic().get$values().get$length());
5942 }
5943 }
5944 else if (this.name == "isEmpty") {
5945 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5946 code = ("" + target.get$dynamic().get$values().isEmpty$0());
5947 }
5948 }
5949 }
5950 if (this.name == "get:typeName" && this.declaringType.get$library().get$isDom( )) { 5884 if (this.name == "get:typeName" && this.declaringType.get$library().get$isDom( )) {
5951 $globals.world.gen.corejs.ensureTypeNameOf(); 5885 $globals.world.gen.corejs.ensureTypeNameOf();
5952 } 5886 }
5953 return new Value(this.get$inferredResult(), code, node.span, true); 5887 return new Value(this.get$inferredResult(), code, node.span, true);
5954 } 5888 }
5955 MethodMember.prototype._invokeConstructor = function(context, node, target, args , argsString) { 5889 MethodMember.prototype._invokeConstructor = function(context, node, target, args , argsString) {
5956 this.declaringType.markUsed(); 5890 this.declaringType.markUsed();
5957 var ctor = this.get$constructorName(); 5891 var ctor = this.get$constructorName();
5958 if (ctor != "") ctor = ("." + ctor + "$ctor"); 5892 if (ctor != "") ctor = ("." + ctor + "$ctor");
5959 if (!target.isType) { 5893 if (!target.isType) {
5960 var code = ("" + this.declaringType.get$nativeName() + ctor + ".call(" + arg sString + ")"); 5894 var code = ("" + this.declaringType.get$nativeName() + ctor + ".call(" + arg sString + ")");
5961 return new Value(target.get$type(), code, node.span, true); 5895 return new Value(target.get$type(), code, node.span, true);
5962 } 5896 }
5963 else { 5897 else {
5964 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" + args String + ")"); 5898 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" + args String + ")");
5965 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge t$isConst()) { 5899 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge t$isConst()) {
5966 return this._invokeConstConstructor(node, code, target, args); 5900 return this._invokeConstConstructor(node, code, target, args);
5967 } 5901 }
5968 else { 5902 else {
5969 var span = node != null ? node.span : target.span; 5903 var span = node != null ? node.span : target.span;
5970 return new Value(target.get$type(), code, span, true); 5904 return new Value(target.get$type(), code, span, true);
5971 } 5905 }
5972 } 5906 }
5973 } 5907 }
5974 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) { 5908 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) {
5975 var fields = new HashMapImplementation(); 5909 var fields = new HashMapImplementation();
5976 for (var i = 0; 5910 for (var i = (0);
5977 i < this.parameters.get$length(); i++) { 5911 i < this.parameters.get$length(); i++) {
5978 var param = this.parameters.$index(i); 5912 var param = this.parameters.$index(i);
5979 if (param.get$isInitializer()) { 5913 if (param.get$isInitializer()) {
5980 var value = null; 5914 var value = null;
5981 if (i < args.get$length()) { 5915 if (i < args.get$length()) {
5982 value = args.values.$index(i); 5916 value = args.values.$index(i);
5983 } 5917 }
5984 else { 5918 else {
5985 value = args.getValue(param.get$name()); 5919 value = args.getValue(param.get$name());
5986 if (value == null) { 5920 if (value == null) {
5987 value = param.get$value(); 5921 value = param.get$value();
5988 } 5922 }
5989 } 5923 }
5990 fields.$setindex(param.get$name(), value.get$constValue()); 5924 fields.$setindex(param.get$name(), value.get$constValue());
5991 } 5925 }
5992 } 5926 }
5993 if (this.definition.initializers != null) { 5927 if (this.definition.initializers != null) {
5994 this.generator._pushBlock(false); 5928 this.generator._pushBlock(false);
5995 for (var j = 0; 5929 for (var j = (0);
5996 j < this.definition.formals.get$length(); j++) { 5930 j < this.definition.formals.get$length(); j++) {
5997 var name = this.definition.formals.$index(j).get$name().get$name(); 5931 var name = this.definition.formals.$index(j).get$name().get$name();
5998 var value = null; 5932 var value = null;
5999 if (j < args.get$length()) { 5933 if (j < args.get$length()) {
6000 value = args.values.$index(j); 5934 value = args.values.$index(j);
6001 } 5935 }
6002 else { 5936 else {
6003 value = args.getValue(this.parameters.$index(j).get$name()); 5937 value = args.getValue(this.parameters.$index(j).get$name());
6004 if (value == null) { 5938 if (value == null) {
6005 value = this.parameters.$index(j).get$value(); 5939 value = this.parameters.$index(j).get$value();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6043 var f = $$i.next$0(); 5977 var f = $$i.next$0();
6044 if ((f instanceof FieldMember) && !f.get$isStatic() && !fields.containsKey(f .get$name())) { 5978 if ((f instanceof FieldMember) && !f.get$isStatic() && !fields.containsKey(f .get$name())) {
6045 if (!f.get$isFinal()) { 5979 if (!f.get$isFinal()) {
6046 $globals.world.error(("const class \"" + this.declaringType.name + "\" h as non-final ") + ("field \"" + f.get$name() + "\""), f.get$span()); 5980 $globals.world.error(("const class \"" + this.declaringType.name + "\" h as non-final ") + ("field \"" + f.get$name() + "\""), f.get$span());
6047 } 5981 }
6048 if (f.get$value() != null) { 5982 if (f.get$value() != null) {
6049 fields.$setindex(f.get$name(), f.computeValue$0()); 5983 fields.$setindex(f.get$name(), f.computeValue$0());
6050 } 5984 }
6051 } 5985 }
6052 } 5986 }
6053 return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$fac tory(target.get$type(), fields, code, node.span), args.values); 5987 return $globals.world.gen.globalForConst(new ObjectValue(fields, true, target. get$type(), code, node.span), args.values);
6054 } 5988 }
6055 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar gsCode, isDynamic) { 5989 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar gsCode, isDynamic) {
6056 var allConst = target.get$isConst() && args.values.every((function (arg) { 5990 var allConst = target.get$isConst() && args.values.every((function (arg) {
6057 return arg.get$isConst(); 5991 return arg.get$isConst();
6058 }) 5992 })
6059 ); 5993 );
6060 if (this.declaringType.get$isNum()) { 5994 if (this.declaringType.get$isNum()) {
6061 if (!allConst) { 5995 if (!allConst) {
6062 var code; 5996 var code;
6063 if (this.name == ":negate") { 5997 if (this.name == ":negate") {
6064 code = ("-" + target.code); 5998 code = ("-" + target.get$code());
6065 } 5999 }
6066 else if (this.name == ":bit_not") { 6000 else if (this.name == ":bit_not") {
6067 code = ("~" + target.code); 6001 code = ("~" + target.get$code());
6068 } 6002 }
6069 else if (this.name == ":truncdiv" || this.name == ":mod") { 6003 else if (this.name == ":truncdiv" || this.name == ":mod") {
6070 $globals.world.gen.corejs.useOperator(this.name); 6004 $globals.world.gen.corejs.useOperator(this.name);
6071 code = ("" + this.get$jsname() + "(" + target.code + ", " + argsCode.$in dex(0) + ")"); 6005 code = ("" + this.get$jsname() + "(" + target.get$code() + ", " + argsCo de.$index((0)) + ")");
6072 } 6006 }
6073 else { 6007 else {
6074 var op = TokenKind.rawOperatorFromMethod(this.name); 6008 var op = TokenKind.rawOperatorFromMethod(this.name);
6075 code = ("" + target.code + " " + op + " " + argsCode.$index(0)); 6009 code = ("" + target.get$code() + " " + op + " " + argsCode.$index((0)));
6076 } 6010 }
6077 return new Value(this.get$inferredResult(), code, node.span, true); 6011 return new Value(this.get$inferredResult(), code, node.span, true);
6078 } 6012 }
6079 else { 6013 else {
6080 var value; 6014 var value;
6081 var val0, val1, ival0, ival1; 6015 var val0, val1, ival0, ival1;
6082 val0 = target.get$dynamic().get$actualValue(); 6016 val0 = target.get$dynamic().get$actualValue();
6083 ival0 = val0.toInt(); 6017 ival0 = val0.toInt();
6084 if (args.values.get$length() > 0) { 6018 if (args.values.get$length() > (0)) {
6085 val1 = args.values.$index(0).get$dynamic().get$actualValue(); 6019 val1 = args.values.$index((0)).get$dynamic().get$actualValue();
6086 ival1 = val1.toInt(); 6020 ival1 = val1.toInt();
6087 } 6021 }
6088 switch (this.name) { 6022 switch (this.name) {
6089 case ":negate": 6023 case ":negate":
6090 6024
6091 value = -val0; 6025 value = -val0;
6092 break; 6026 break;
6093 6027
6094 case ":add": 6028 case ":add":
6095 6029
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6180 6114
6181 value = (ival0 >> ival1).toDouble(); 6115 value = (ival0 >> ival1).toDouble();
6182 break; 6116 break;
6183 6117
6184 case ":shr": 6118 case ":shr":
6185 6119
6186 value = (ival0 >>> ival1).toDouble(); 6120 value = (ival0 >>> ival1).toDouble();
6187 break; 6121 break;
6188 6122
6189 } 6123 }
6190 return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), va lue, ("" + value), node.span); 6124 if (this.get$inferredResult().get$isInt()) {
6125 return Value.fromInt(value.toInt$0(), node.span);
6126 }
6127 else if (this.get$inferredResult().get$isDouble()) {
6128 return Value.fromDouble(value.toDouble$0(), node.span);
6129 }
6130 else if (this.get$inferredResult().get$isNum()) {
6131 return Value.fromDouble(value.toDouble$0(), node.span);
6132 }
6133 else if (this.get$inferredResult().get$isBool()) {
6134 return Value.fromBool(value, node.span);
6135 }
6136 else {
6137 $globals.world.internalError(("unsupported const result type \"" + this. get$inferredResult().name + "\""), node.span);
6138 }
6191 } 6139 }
6192 } 6140 }
6193 else if (this.declaringType.get$isString()) { 6141 else if (this.declaringType.get$isString()) {
6194 if (this.name == ":index") { 6142 if (this.name == ":index") {
6195 return new Value(this.declaringType, ("" + target.code + "[" + argsCode.$i ndex(0) + "]"), node.span, true); 6143 return new Value(this.declaringType, ("" + target.get$code() + "[" + argsC ode.$index((0)) + "]"), node.span, true);
6196 } 6144 }
6197 else if (this.name == ":add") { 6145 else if (this.name == ":add") {
6198 if (allConst) { 6146 if (allConst) {
6199 var value = target.get$dynamic().get$actualValue() + args.values.$index( 0).get$dynamic().get$actualValue(); 6147 var value = target.get$dynamic().get$actualValue() + args.values.$index( (0)).get$dynamic().get$actualValue();
6200 return Value.fromString(value, node.span); 6148 return Value.fromString(value, node.span);
6201 } 6149 }
6202 return new Value(this.declaringType, ("" + target.code + " + " + argsCode. $index(0)), node.span, true); 6150 return new Value(this.declaringType, ("" + target.get$code() + " + " + arg sCode.$index((0))), node.span, true);
6203 } 6151 }
6204 } 6152 }
6205 else if (this.declaringType.get$isNative()) { 6153 else if (this.declaringType.get$isNative()) {
6206 if (this.name == ":index") { 6154 if (this.name == ":index") {
6207 return new Value(this.returnType, ("" + target.code + "[" + argsCode.$inde x(0) + "]"), node.span, true); 6155 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCode .$index((0)) + "]"), node.span, true);
6208 } 6156 }
6209 else if (this.name == ":setindex") { 6157 else if (this.name == ":setindex") {
6210 return new Value(this.returnType, ("" + target.code + "[" + argsCode.$inde x(0) + "] = " + argsCode.$index(1)), node.span, true); 6158 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCode .$index((0)) + "] = " + argsCode.$index((1))), node.span, true);
6211 } 6159 }
6212 } 6160 }
6213 if (this.name == ":eq" || this.name == ":ne") { 6161 if (this.name == ":eq" || this.name == ":ne") {
6214 var op = this.name == ":eq" ? "==" : "!="; 6162 var op = this.name == ":eq" ? "==" : "!=";
6215 if (this.name == ":ne") { 6163 if (this.name == ":ne") {
6216 target.invoke(context, ":eq", node, args, isDynamic); 6164 target.invoke(context, ":eq", node, args, isDynamic);
6217 } 6165 }
6218 if (allConst) { 6166 if (allConst) {
6219 var val0 = target.get$dynamic().get$actualValue(); 6167 var val0 = target.get$dynamic().get$actualValue();
6220 var val1 = args.values.$index(0).get$dynamic().get$actualValue(); 6168 var val1 = args.values.$index((0)).get$dynamic().get$actualValue();
6221 var newVal = this.name == ":eq" ? $eq(val0, val1) : $ne(val0, val1); 6169 var newVal = this.name == ":eq" ? $eq(val0, val1) : $ne(val0, val1);
6222 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, n ewVal, ("" + newVal), node.span); 6170 return Value.fromBool(newVal, node.span);
6223 } 6171 }
6224 if ($eq(argsCode.$index(0), "null")) { 6172 if ($eq(argsCode.$index((0)), "null")) {
6225 return new Value(this.get$inferredResult(), ("" + target.code + " " + op + " null"), node.span, true); 6173 return new Value(this.get$inferredResult(), ("" + target.get$code() + " " + op + " null"), node.span, true);
6226 } 6174 }
6227 else if (target.get$type().get$isNum() || target.get$type().get$isString()) { 6175 else if (target.get$type().get$isNum() || target.get$type().get$isString()) {
6228 return new Value(this.get$inferredResult(), ("" + target.code + " " + op + " " + argsCode.$index(0)), node.span, true); 6176 return new Value(this.get$inferredResult(), ("" + target.get$code() + " " + op + " " + argsCode.$index((0))), node.span, true);
6229 } 6177 }
6230 $globals.world.gen.corejs.useOperator(this.name); 6178 $globals.world.gen.corejs.useOperator(this.name);
6231 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + target.code + ", " + argsCode.$index(0) + ")"), node.span, true); 6179 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + target.get$code() + ", " + argsCode.$index((0)) + ")"), node.span, true);
6232 } 6180 }
6233 if (this.get$isCallMethod()) { 6181 if (this.get$isCallMethod()) {
6234 this.declaringType.markUsed(); 6182 this.declaringType.markUsed();
6235 return new Value(this.get$inferredResult(), ("" + target.code + "(" + String s.join(argsCode, ", ") + ")"), node.span, true); 6183 return new Value(this.get$inferredResult(), ("" + target.get$code() + "(" + Strings.join(argsCode, ", ") + ")"), node.span, true);
6236 } 6184 }
6237 if (this.name == ":index") { 6185 if (this.name == ":index") {
6238 $globals.world.gen.corejs.useIndex = true; 6186 $globals.world.gen.corejs.useIndex = true;
6239 } 6187 }
6240 else if (this.name == ":setindex") { 6188 else if (this.name == ":setindex") {
6241 $globals.world.gen.corejs.useSetIndex = true; 6189 $globals.world.gen.corejs.useSetIndex = true;
6242 } 6190 }
6243 var argsString = Strings.join(argsCode, ", "); 6191 var argsString = Strings.join(argsCode, ", ");
6244 return new Value(this.get$inferredResult(), ("" + target.code + "." + this.get $jsname() + "(" + argsString + ")"), node.span, true); 6192 return new Value(this.get$inferredResult(), ("" + target.get$code() + "." + th is.get$jsname() + "(" + argsString + ")"), node.span, true);
6245 } 6193 }
6246 MethodMember.prototype.resolve = function() { 6194 MethodMember.prototype.resolve = function() {
6247 this.isStatic = this.declaringType.get$isTop(); 6195 this.isStatic = this.declaringType.get$isTop();
6248 this.isConst = false; 6196 this.isConst = false;
6249 this.isFactory = false; 6197 this.isFactory = false;
6250 this.isAbstract = !this.declaringType.get$isClass(); 6198 this.isAbstract = !this.declaringType.get$isClass();
6251 if (this.definition.modifiers != null) { 6199 if (this.definition.modifiers != null) {
6252 var $$list = this.definition.modifiers; 6200 var $$list = this.definition.modifiers;
6253 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 6201 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
6254 var mod = $$list.$index($$i); 6202 var mod = $$list.$index($$i);
6255 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) { 6203 if ($eq(mod.get$kind(), (84))) {
6256 if (this.isStatic) { 6204 if (this.isStatic) {
6257 $globals.world.error("duplicate static modifier", mod.get$span()); 6205 $globals.world.error("duplicate static modifier", mod.get$span());
6258 } 6206 }
6259 this.isStatic = true; 6207 this.isStatic = true;
6260 } 6208 }
6261 else if (this.get$isConstructor() && $eq(mod.get$kind(), 91/*TokenKind.CON ST*/)) { 6209 else if (this.get$isConstructor() && $eq(mod.get$kind(), (91))) {
6262 if (this.isConst) { 6210 if (this.isConst) {
6263 $globals.world.error("duplicate const modifier", mod.get$span()); 6211 $globals.world.error("duplicate const modifier", mod.get$span());
6264 } 6212 }
6265 this.isConst = true; 6213 this.isConst = true;
6266 } 6214 }
6267 else if ($eq(mod.get$kind(), 73/*TokenKind.FACTORY*/)) { 6215 else if ($eq(mod.get$kind(), (73))) {
6268 if (this.isFactory) { 6216 if (this.isFactory) {
6269 $globals.world.error("duplicate factory modifier", mod.get$span()); 6217 $globals.world.error("duplicate factory modifier", mod.get$span());
6270 } 6218 }
6271 this.isFactory = true; 6219 this.isFactory = true;
6272 } 6220 }
6273 else if ($eq(mod.get$kind(), 71/*TokenKind.ABSTRACT*/)) { 6221 else if ($eq(mod.get$kind(), (71))) {
6274 if (this.isAbstract) { 6222 if (this.isAbstract) {
6275 if (this.declaringType.get$isClass()) { 6223 if (this.declaringType.get$isClass()) {
6276 $globals.world.error("duplicate abstract modifier", mod.get$span()); 6224 $globals.world.error("duplicate abstract modifier", mod.get$span());
6277 } 6225 }
6278 else if (!this.get$isCallMethod()) { 6226 else if (!this.get$isCallMethod()) {
6279 $globals.world.error("abstract modifier not allowed on interface mem bers", mod.get$span()); 6227 $globals.world.error("abstract modifier not allowed on interface mem bers", mod.get$span());
6280 } 6228 }
6281 } 6229 }
6282 this.isAbstract = true; 6230 this.isAbstract = true;
6283 } 6231 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6368 MemberSet.prototype.get$containsMethods = function() { 6316 MemberSet.prototype.get$containsMethods = function() {
6369 return this.members.some((function (m) { 6317 return this.members.some((function (m) {
6370 return (m instanceof MethodMember); 6318 return (m instanceof MethodMember);
6371 }) 6319 })
6372 ); 6320 );
6373 } 6321 }
6374 MemberSet.prototype.add = function(member) { 6322 MemberSet.prototype.add = function(member) {
6375 return this.members.add(member); 6323 return this.members.add(member);
6376 } 6324 }
6377 MemberSet.prototype.get$isStatic = function() { 6325 MemberSet.prototype.get$isStatic = function() {
6378 return this.members.get$length() == 1 && this.members.$index(0).get$isStatic() ; 6326 return this.members.get$length() == (1) && this.members.$index((0)).get$isStat ic();
6379 } 6327 }
6380 MemberSet.prototype.get$isOperator = function() { 6328 MemberSet.prototype.get$isOperator = function() {
6381 return this.members.$index(0).get$isOperator(); 6329 return this.members.$index((0)).get$isOperator();
6382 } 6330 }
6383 MemberSet.prototype.canInvoke = function(context, args) { 6331 MemberSet.prototype.canInvoke = function(context, args) {
6384 return this.members.some((function (m) { 6332 return this.members.some((function (m) {
6385 return m.canInvoke$2(context, args); 6333 return m.canInvoke$2(context, args);
6386 }) 6334 })
6387 ); 6335 );
6388 } 6336 }
6389 MemberSet.prototype._makeError = function(node, target, action) { 6337 MemberSet.prototype._makeError = function(node, target, action) {
6390 if (!target.get$type().get$isVar()) { 6338 if (!target.get$type().get$isVar()) {
6391 $globals.world.warning(("could not find applicable " + action + " for \"" + this.name + "\""), node.span); 6339 $globals.world.warning(("could not find applicable " + action + " for \"" + this.name + "\""), node.span);
6392 } 6340 }
6393 return new Value($globals.world.varType, ("" + target.code + "." + this.jsname + "() /*no applicable " + action + "*/"), node.span, true); 6341 return new Value($globals.world.varType, ("" + target.get$code() + "." + this. jsname + "() /*no applicable " + action + "*/"), node.span, true);
6394 } 6342 }
6395 MemberSet.prototype.get$treatAsField = function() { 6343 MemberSet.prototype.get$treatAsField = function() {
6396 if (this._treatAsField == null) { 6344 if (this._treatAsField == null) {
6397 this._treatAsField = !this.isVar && (this.members.some((function (m) { 6345 this._treatAsField = !this.isVar && (this.members.some((function (m) {
6398 return m.get$requiresFieldSyntax(); 6346 return m.get$requiresFieldSyntax();
6399 }) 6347 })
6400 ) || this.members.every((function (m) { 6348 ) || this.members.every((function (m) {
6401 return !m.get$requiresPropertySyntax(); 6349 return !m.get$requiresPropertySyntax();
6402 }) 6350 })
6403 )); 6351 ));
(...skipping 17 matching lines...) Expand all
6421 }) 6369 })
6422 ); 6370 );
6423 if (this.isVar) { 6371 if (this.isVar) {
6424 targets.forEach$1((function (m) { 6372 targets.forEach$1((function (m) {
6425 return m._get$3$isDynamic(context, node, target, true); 6373 return m._get$3$isDynamic(context, node, target, true);
6426 }) 6374 })
6427 ); 6375 );
6428 returnValue = new Value(this._foldTypes(targets), null, node.span, true); 6376 returnValue = new Value(this._foldTypes(targets), null, node.span, true);
6429 } 6377 }
6430 else { 6378 else {
6431 if (this.members.get$length() == 1) { 6379 if (this.members.get$length() == (1)) {
6432 return this.members.$index(0)._get$4(context, node, target, isDynamic); 6380 return this.members.$index((0))._get$4(context, node, target, isDynamic);
6433 } 6381 }
6434 else if ($eq(targets.get$length(), 1)) { 6382 else if ($eq(targets.get$length(), (1))) {
6435 return targets.$index(0)._get$4(context, node, target, isDynamic); 6383 return targets.$index((0))._get$4(context, node, target, isDynamic);
6436 } 6384 }
6437 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6385 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6438 var member = $$i.next$0(); 6386 var member = $$i.next$0();
6439 var value = member._get$3$isDynamic(context, node, target, true); 6387 var value = member._get$3$isDynamic(context, node, target, true);
6440 returnValue = this._tryUnion(returnValue, value, node); 6388 returnValue = this._tryUnion(returnValue, value, node);
6441 } 6389 }
6442 if (returnValue == null) { 6390 if (returnValue == null) {
6443 return this._makeError(node, target, "getter"); 6391 return this._makeError(node, target, "getter");
6444 } 6392 }
6445 } 6393 }
6446 if (returnValue.code == null) { 6394 if (returnValue.get$code() == null) {
6447 if (this.get$treatAsField()) { 6395 if (this.get$treatAsField()) {
6448 return new Value(returnValue.get$type(), ("" + target.code + "." + this.js name), node.span, true); 6396 return new Value(returnValue.get$type(), ("" + target.get$code() + "." + t his.jsname), node.span, true);
6449 } 6397 }
6450 else { 6398 else {
6451 return new Value(returnValue.get$type(), ("" + target.code + ".get$" + thi s.jsname + "()"), node.span, true); 6399 return new Value(returnValue.get$type(), ("" + target.get$code() + ".get$" + this.jsname + "()"), node.span, true);
6452 } 6400 }
6453 } 6401 }
6454 return returnValue; 6402 return returnValue;
6455 } 6403 }
6456 MemberSet.prototype._set = function(context, node, target, value, isDynamic) { 6404 MemberSet.prototype._set = function(context, node, target, value, isDynamic) {
6457 var returnValue; 6405 var returnValue;
6458 var targets = this.members.filter((function (m) { 6406 var targets = this.members.filter((function (m) {
6459 return m.get$canSet(); 6407 return m.get$canSet();
6460 }) 6408 })
6461 ); 6409 );
6462 if (this.isVar) { 6410 if (this.isVar) {
6463 targets.forEach$1((function (m) { 6411 targets.forEach$1((function (m) {
6464 return m._set$4$isDynamic(context, node, target, value, true); 6412 return m._set$4$isDynamic(context, node, target, value, true);
6465 }) 6413 })
6466 ); 6414 );
6467 returnValue = new Value(this._foldTypes(targets), null, node.span, true); 6415 returnValue = new Value(this._foldTypes(targets), null, node.span, true);
6468 } 6416 }
6469 else { 6417 else {
6470 if (this.members.get$length() == 1) { 6418 if (this.members.get$length() == (1)) {
6471 return this.members.$index(0)._set$5(context, node, target, value, isDynam ic); 6419 return this.members.$index((0))._set$5(context, node, target, value, isDyn amic);
6472 } 6420 }
6473 else if ($eq(targets.get$length(), 1)) { 6421 else if ($eq(targets.get$length(), (1))) {
6474 return targets.$index(0)._set$5(context, node, target, value, isDynamic); 6422 return targets.$index((0))._set$5(context, node, target, value, isDynamic) ;
6475 } 6423 }
6476 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6424 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6477 var member = $$i.next$0(); 6425 var member = $$i.next$0();
6478 var res = member._set$4$isDynamic(context, node, target, value, true); 6426 var res = member._set$4$isDynamic(context, node, target, value, true);
6479 returnValue = this._tryUnion(returnValue, res, node); 6427 returnValue = this._tryUnion(returnValue, res, node);
6480 } 6428 }
6481 if (returnValue == null) { 6429 if (returnValue == null) {
6482 return this._makeError(node, target, "setter"); 6430 return this._makeError(node, target, "setter");
6483 } 6431 }
6484 } 6432 }
6485 if (returnValue.code == null) { 6433 if (returnValue.get$code() == null) {
6486 if (this.get$treatAsField()) { 6434 if (this.get$treatAsField()) {
6487 return new Value(returnValue.get$type(), ("" + target.code + "." + this.js name + " = " + value.code), node.span, true); 6435 return new Value(returnValue.get$type(), ("" + target.get$code() + "." + t his.jsname + " = " + value.get$code()), node.span, true);
6488 } 6436 }
6489 else { 6437 else {
6490 return new Value(returnValue.get$type(), ("" + target.code + ".set$" + thi s.jsname + "(" + value.code + ")"), node.span, true); 6438 return new Value(returnValue.get$type(), ("" + target.get$code() + ".set$" + this.jsname + "(" + value.get$code() + ")"), node.span, true);
6491 } 6439 }
6492 } 6440 }
6493 return returnValue; 6441 return returnValue;
6494 } 6442 }
6495 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) { 6443 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) {
6496 if (this.isVar && !this.get$isOperator()) { 6444 if (this.isVar && !this.get$isOperator()) {
6497 return this.invokeOnVar(context, node, target, args); 6445 return this.invokeOnVar(context, node, target, args);
6498 } 6446 }
6499 if (this.members.get$length() == 1) { 6447 if (this.members.get$length() == (1)) {
6500 return this.members.$index(0).invoke$5(context, node, target, args, isDynami c); 6448 return this.members.$index((0)).invoke$5(context, node, target, args, isDyna mic);
6501 } 6449 }
6502 var targets = this.members.filter((function (m) { 6450 var targets = this.members.filter((function (m) {
6503 return m.canInvoke$2(context, args); 6451 return m.canInvoke$2(context, args);
6504 }) 6452 })
6505 ); 6453 );
6506 if ($eq(targets.get$length(), 1)) { 6454 if ($eq(targets.get$length(), (1))) {
6507 return targets.$index(0).invoke$5(context, node, target, args, isDynamic); 6455 return targets.$index((0)).invoke$5(context, node, target, args, isDynamic);
6508 } 6456 }
6509 var returnValue = null; 6457 var returnValue = null;
6510 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6458 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6511 var member = $$i.next$0(); 6459 var member = $$i.next$0();
6512 var res = member.invoke$4$isDynamic(context, node, target, args, true); 6460 var res = member.invoke$4$isDynamic(context, node, target, args, true);
6513 returnValue = this._tryUnion(returnValue, res, node); 6461 returnValue = this._tryUnion(returnValue, res, node);
6514 } 6462 }
6515 if (returnValue == null) { 6463 if (returnValue == null) {
6516 return this._makeError(node, target, "method"); 6464 return this._makeError(node, target, "method");
6517 } 6465 }
6518 if (returnValue.code == null) { 6466 if (returnValue.get$code() == null) {
6519 if (this.name == ":call") { 6467 if (this.name == ":call") {
6520 return target._varCall(context, node, args); 6468 return target._varCall(context, node, args);
6521 } 6469 }
6522 else if (this.get$isOperator()) { 6470 else if (this.get$isOperator()) {
6523 return this.invokeSpecial(target, args, returnValue.get$type()); 6471 return this.invokeSpecial(target, args, returnValue.get$type());
6524 } 6472 }
6525 else { 6473 else {
6526 return this.invokeOnVar(context, node, target, args); 6474 return this.invokeOnVar(context, node, target, args);
6527 } 6475 }
6528 } 6476 }
6529 return returnValue; 6477 return returnValue;
6530 } 6478 }
6531 MemberSet.prototype.invokeSpecial = function(target, args, returnType) { 6479 MemberSet.prototype.invokeSpecial = function(target, args, returnType) {
6532 var argsString = args.getCode(); 6480 var argsString = args.getCode();
6533 if (this.name == ":index" || this.name == ":setindex") { 6481 if (this.name == ":index" || this.name == ":setindex") {
6534 return new Value(returnType, ("" + target.code + "." + this.jsname + "(" + a rgsString + ")"), target.span, true); 6482 return new Value(returnType, ("" + target.get$code() + "." + this.jsname + " (" + argsString + ")"), target.span, true);
6535 } 6483 }
6536 else { 6484 else {
6537 if (argsString.get$length() > 0) argsString = (", " + argsString); 6485 if (argsString.get$length() > (0)) argsString = (", " + argsString);
6538 $globals.world.gen.corejs.useOperator(this.name); 6486 $globals.world.gen.corejs.useOperator(this.name);
6539 return new Value(returnType, ("" + this.jsname + "(" + target.code + argsStr ing + ")"), target.span, true); 6487 return new Value(returnType, ("" + this.jsname + "(" + target.get$code() + a rgsString + ")"), target.span, true);
6540 } 6488 }
6541 } 6489 }
6542 MemberSet.prototype.invokeOnVar = function(context, node, target, args) { 6490 MemberSet.prototype.invokeOnVar = function(context, node, target, args) {
6543 var member = this.getVarMember(context, node, args); 6491 var member = this.getVarMember(context, node, args);
6544 return member.invoke$4(context, node, target, args); 6492 return member.invoke$4(context, node, target, args);
6545 } 6493 }
6546 MemberSet.prototype._tryUnion = function(x, y, node) { 6494 MemberSet.prototype._tryUnion = function(x, y, node) {
6547 if (x == null) return y; 6495 if (x == null) return y;
6548 var type = Type.union(x.get$type(), y.get$type()); 6496 var type = Type.union(x.get$type(), y.get$type());
6549 if (x.code == y.code) { 6497 if (x.get$code() == y.get$code()) {
6550 if ($eq(type, x.get$type())) { 6498 if ($eq(type, x.get$type())) {
6551 return x; 6499 return x;
6552 } 6500 }
6553 else if (x.get$isConst() || y.get$isConst()) { 6501 else if (x.get$isConst() || y.get$isConst()) {
6554 $globals.world.internalError("unexpected: union of const values "); 6502 $globals.world.internalError("unexpected: union of const values ");
6555 } 6503 }
6556 else { 6504 else {
6557 var ret = new Value(type, x.code, node.span, true); 6505 var ret = new Value(type, x.get$code(), node.span, true);
6558 ret.set$isSuper(x.isSuper && y.isSuper); 6506 ret.set$isSuper(x.isSuper && y.isSuper);
6559 ret.set$needsTemp(x.needsTemp || y.needsTemp); 6507 ret.set$needsTemp(x.needsTemp || y.needsTemp);
6560 ret.set$isType(x.isType && y.isType); 6508 ret.set$isType(x.isType && y.isType);
6561 return ret; 6509 return ret;
6562 } 6510 }
6563 } 6511 }
6564 else { 6512 else {
6565 return new Value(type, null, node.span, true); 6513 return new Value(type, null, node.span, true);
6566 } 6514 }
6567 } 6515 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6649 Token.prototype.get$kind = function() { return this.kind; }; 6597 Token.prototype.get$kind = function() { return this.kind; };
6650 Token.prototype.get$end = function() { return this.end; }; 6598 Token.prototype.get$end = function() { return this.end; };
6651 Token.prototype.get$start = function() { return this.start; }; 6599 Token.prototype.get$start = function() { return this.start; };
6652 Token.prototype.get$text = function() { 6600 Token.prototype.get$text = function() {
6653 return this.source.get$text().substring(this.start, this.end); 6601 return this.source.get$text().substring(this.start, this.end);
6654 } 6602 }
6655 Token.prototype.toString = function() { 6603 Token.prototype.toString = function() {
6656 var kindText = TokenKind.kindToString(this.kind); 6604 var kindText = TokenKind.kindToString(this.kind);
6657 var actualText = this.get$text(); 6605 var actualText = this.get$text();
6658 if ($ne(kindText, actualText)) { 6606 if ($ne(kindText, actualText)) {
6659 if (actualText.get$length() > 10) { 6607 if (actualText.get$length() > (10)) {
6660 actualText = actualText.substring$2(0, 8) + "..."; 6608 actualText = actualText.substring$2((0), (8)) + "...";
6661 } 6609 }
6662 return ("" + kindText + "(" + actualText + ")"); 6610 return ("" + kindText + "(" + actualText + ")");
6663 } 6611 }
6664 else { 6612 else {
6665 return kindText; 6613 return kindText;
6666 } 6614 }
6667 } 6615 }
6668 Token.prototype.get$span = function() { 6616 Token.prototype.get$span = function() {
6669 return new SourceSpan(this.source, this.start, this.end); 6617 return new SourceSpan(this.source, this.start, this.end);
6670 } 6618 }
(...skipping 29 matching lines...) Expand all
6700 // Initializers done 6648 // Initializers done
6701 } 6649 }
6702 SourceFile.prototype.get$filename = function() { return this.filename; }; 6650 SourceFile.prototype.get$filename = function() { return this.filename; };
6703 SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrar y; }; 6651 SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrar y; };
6704 SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInL ibrary = value; }; 6652 SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInL ibrary = value; };
6705 SourceFile.prototype.get$text = function() { 6653 SourceFile.prototype.get$text = function() {
6706 return this._text; 6654 return this._text;
6707 } 6655 }
6708 SourceFile.prototype.get$lineStarts = function() { 6656 SourceFile.prototype.get$lineStarts = function() {
6709 if (this._lineStarts == null) { 6657 if (this._lineStarts == null) {
6710 var starts = [0]; 6658 var starts = [(0)];
6711 var index = 0; 6659 var index = (0);
6712 while (index < this.get$text().length) { 6660 while (index < this.get$text().length) {
6713 index = this.get$text().indexOf("\n", index) + 1; 6661 index = this.get$text().indexOf("\n", index) + (1);
6714 if (index <= 0) break; 6662 if (index <= (0)) break;
6715 starts.add$1(index); 6663 starts.add$1(index);
6716 } 6664 }
6717 starts.add$1(this.get$text().length + 1); 6665 starts.add$1(this.get$text().length + (1));
6718 this._lineStarts = starts; 6666 this._lineStarts = starts;
6719 } 6667 }
6720 return this._lineStarts; 6668 return this._lineStarts;
6721 } 6669 }
6722 SourceFile.prototype.getLine = function(position) { 6670 SourceFile.prototype.getLine = function(position) {
6723 var starts = this.get$lineStarts(); 6671 var starts = this.get$lineStarts();
6724 for (var i = 0; 6672 for (var i = (0);
6725 i < starts.get$length(); i++) { 6673 i < starts.get$length(); i++) {
6726 if (starts.$index(i) > position) return i - 1; 6674 if (starts.$index(i) > position) return i - (1);
6727 } 6675 }
6728 $globals.world.internalError("bad position"); 6676 $globals.world.internalError("bad position");
6729 } 6677 }
6730 SourceFile.prototype.getColumn = function(line, position) { 6678 SourceFile.prototype.getColumn = function(line, position) {
6731 return position - this.get$lineStarts().$index(line); 6679 return position - this.get$lineStarts().$index(line);
6732 } 6680 }
6733 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) { 6681 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) {
6734 var line = this.getLine(start); 6682 var line = this.getLine(start);
6735 var column = this.getColumn(line, start); 6683 var column = this.getColumn(line, start);
6736 var buf = new StringBufferImpl(("" + this.filename + ":" + (line + 1) + ":" + (column + 1) + ": " + message)); 6684 var buf = new StringBufferImpl(("" + this.filename + ":" + (line + (1)) + ":" + (column + (1)) + ": " + message));
6737 if (includeText) { 6685 if (includeText) {
6738 buf.add$1("\n"); 6686 buf.add$1("\n");
6739 var textLine; 6687 var textLine;
6740 if ((line + 2) < this._lineStarts.get$length()) { 6688 if ((line + (2)) < this._lineStarts.get$length()) {
6741 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + 1)); 6689 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + (1)));
6742 } 6690 }
6743 else { 6691 else {
6744 textLine = this.get$text().substring(this._lineStarts.$index(line)) + "\n" ; 6692 textLine = this.get$text().substring(this._lineStarts.$index(line)) + "\n" ;
6745 } 6693 }
6746 var toColumn = Math.min(column + (end - start), textLine.get$length()); 6694 var toColumn = Math.min(column + (end - start), textLine.get$length());
6747 if ($globals.options.useColors) { 6695 if ($globals.options.useColors) {
6748 buf.add$1(textLine.substring$2(0, column)); 6696 buf.add$1(textLine.substring$2((0), column));
6749 buf.add$1($globals._RED_COLOR); 6697 buf.add$1($globals._RED_COLOR);
6750 buf.add$1(textLine.substring$2(column, toColumn)); 6698 buf.add$1(textLine.substring$2(column, toColumn));
6751 buf.add$1($globals._NO_COLOR); 6699 buf.add$1($globals._NO_COLOR);
6752 buf.add$1(textLine.substring$1(toColumn)); 6700 buf.add$1(textLine.substring$1(toColumn));
6753 } 6701 }
6754 else { 6702 else {
6755 buf.add$1(textLine); 6703 buf.add$1(textLine);
6756 } 6704 }
6757 var i = 0; 6705 var i = (0);
6758 for (; i < column; i++) { 6706 for (; i < column; i++) {
6759 buf.add$1(" "); 6707 buf.add$1(" ");
6760 } 6708 }
6761 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR); 6709 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR);
6762 for (; i < toColumn; i++) { 6710 for (; i < toColumn; i++) {
6763 buf.add$1("^"); 6711 buf.add$1("^");
6764 } 6712 }
6765 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR); 6713 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR);
6766 } 6714 }
6767 return buf.toString$0(); 6715 return buf.toString$0();
(...skipping 21 matching lines...) Expand all
6789 SourceSpan.prototype.get$end = function() { return this.end; }; 6737 SourceSpan.prototype.get$end = function() { return this.end; };
6790 SourceSpan.prototype.get$text = function() { 6738 SourceSpan.prototype.get$text = function() {
6791 return this.file.get$text().substring(this.start, this.end); 6739 return this.file.get$text().substring(this.start, this.end);
6792 } 6740 }
6793 SourceSpan.prototype.toMessageString = function(message) { 6741 SourceSpan.prototype.toMessageString = function(message) {
6794 return this.file.getLocationMessage(message, this.start, this.end, true); 6742 return this.file.getLocationMessage(message, this.start, this.end, true);
6795 } 6743 }
6796 SourceSpan.prototype.get$locationText = function() { 6744 SourceSpan.prototype.get$locationText = function() {
6797 var line = this.file.getLine(this.start); 6745 var line = this.file.getLine(this.start);
6798 var column = this.file.getColumn(line, this.start); 6746 var column = this.file.getColumn(line, this.start);
6799 return ("" + this.file.filename + ":" + (line + 1) + ":" + (column + 1)); 6747 return ("" + this.file.filename + ":" + (line + (1)) + ":" + (column + (1)));
6800 } 6748 }
6801 SourceSpan.prototype.compareTo = function(other) { 6749 SourceSpan.prototype.compareTo = function(other) {
6802 if ($eq(this.file, other.file)) { 6750 if ($eq(this.file, other.file)) {
6803 var d = this.start - other.start; 6751 var d = this.start - other.start;
6804 return d == 0 ? (this.end - other.end) : d; 6752 return d == (0) ? (this.end - other.end) : d;
6805 } 6753 }
6806 return this.file.compareTo(other.file); 6754 return this.file.compareTo(other.file);
6807 } 6755 }
6808 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo; 6756 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo;
6809 SourceSpan.prototype.end$0 = function() { 6757 SourceSpan.prototype.end$0 = function() {
6810 return this.end.call$0(); 6758 return this.end.call$0();
6811 }; 6759 };
6812 SourceSpan.prototype.start$0 = function() { 6760 SourceSpan.prototype.start$0 = function() {
6813 return this.start.call$0(); 6761 return this.start.call$0();
6814 }; 6762 };
6815 // ********** Code for InterpStack ************** 6763 // ********** Code for InterpStack **************
6816 function InterpStack(previous, quote, isMultiline) { 6764 function InterpStack(previous, quote, isMultiline) {
6817 this.previous = previous; 6765 this.previous = previous;
6818 this.quote = quote; 6766 this.quote = quote;
6819 this.isMultiline = isMultiline; 6767 this.isMultiline = isMultiline;
6820 this.depth = -1; 6768 this.depth = (-1);
6821 // Initializers done 6769 // Initializers done
6822 } 6770 }
6823 InterpStack.prototype.get$previous = function() { return this.previous; }; 6771 InterpStack.prototype.get$previous = function() { return this.previous; };
6824 InterpStack.prototype.set$previous = function(value) { return this.previous = va lue; }; 6772 InterpStack.prototype.set$previous = function(value) { return this.previous = va lue; };
6825 InterpStack.prototype.get$quote = function() { return this.quote; }; 6773 InterpStack.prototype.get$quote = function() { return this.quote; };
6826 InterpStack.prototype.get$isMultiline = function() { return this.isMultiline; }; 6774 InterpStack.prototype.get$isMultiline = function() { return this.isMultiline; };
6827 InterpStack.prototype.get$depth = function() { return this.depth; }; 6775 InterpStack.prototype.get$depth = function() { return this.depth; };
6828 InterpStack.prototype.set$depth = function(value) { return this.depth = value; } ; 6776 InterpStack.prototype.set$depth = function(value) { return this.depth = value; } ;
6829 InterpStack.prototype.pop = function() { 6777 InterpStack.prototype.pop = function() {
6830 return this.previous; 6778 return this.previous;
6831 } 6779 }
6832 InterpStack.push = function(stack, quote, isMultiline) { 6780 InterpStack.push = function(stack, quote, isMultiline) {
6833 var newStack = new InterpStack(stack, quote, isMultiline); 6781 var newStack = new InterpStack(stack, quote, isMultiline);
6834 if (stack != null) newStack.set$previous(stack); 6782 if (stack != null) newStack.set$previous(stack);
6835 return newStack; 6783 return newStack;
6836 } 6784 }
6837 InterpStack.prototype.next$0 = function() { 6785 InterpStack.prototype.next$0 = function() {
6838 return this.next(); 6786 return this.next();
6839 }; 6787 };
6840 // ********** Code for TokenizerHelpers ************** 6788 // ********** Code for TokenizerHelpers **************
6841 function TokenizerHelpers() { 6789 function TokenizerHelpers() {
6842 // Initializers done 6790 // Initializers done
6843 } 6791 }
6844 TokenizerHelpers.isIdentifierStart = function(c) { 6792 TokenizerHelpers.isIdentifierStart = function(c) {
6845 return ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95); 6793 return ((c >= (97) && c <= (122)) || (c >= (65) && c <= (90)) || c == (95));
6846 } 6794 }
6847 TokenizerHelpers.isDigit = function(c) { 6795 TokenizerHelpers.isDigit = function(c) {
6848 return (c >= 48 && c <= 57); 6796 return (c >= (48) && c <= (57));
6849 } 6797 }
6850 TokenizerHelpers.isIdentifierPart = function(c) { 6798 TokenizerHelpers.isIdentifierPart = function(c) {
6851 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c) | | c == 36); 6799 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c) | | c == (36));
6852 } 6800 }
6853 TokenizerHelpers.isInterpIdentifierPart = function(c) { 6801 TokenizerHelpers.isInterpIdentifierPart = function(c) {
6854 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c)); 6802 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c));
6855 } 6803 }
6856 // ********** Code for TokenizerBase ************** 6804 // ********** Code for TokenizerBase **************
6857 $inherits(TokenizerBase, TokenizerHelpers); 6805 $inherits(TokenizerBase, TokenizerHelpers);
6858 function TokenizerBase(_source, _skipWhitespace, index) { 6806 function TokenizerBase(_source, _skipWhitespace, index) {
6859 this._source = _source; 6807 this._source = _source;
6860 this._skipWhitespace = _skipWhitespace; 6808 this._skipWhitespace = _skipWhitespace;
6861 this._lang_index = index; 6809 this._lang_index = index;
6862 // Initializers done 6810 // Initializers done
6863 TokenizerHelpers.call(this); 6811 TokenizerHelpers.call(this);
6864 this._text = this._source.get$text(); 6812 this._text = this._source.get$text();
6865 } 6813 }
6866 TokenizerBase.prototype._nextChar = function() { 6814 TokenizerBase.prototype._nextChar = function() {
6867 if (this._lang_index < this._text.length) { 6815 if (this._lang_index < this._text.length) {
6868 return this._text.charCodeAt(this._lang_index++); 6816 return this._text.charCodeAt(this._lang_index++);
6869 } 6817 }
6870 else { 6818 else {
6871 return 0; 6819 return (0);
6872 } 6820 }
6873 } 6821 }
6874 TokenizerBase.prototype._peekChar = function() { 6822 TokenizerBase.prototype._peekChar = function() {
6875 if (this._lang_index < this._text.length) { 6823 if (this._lang_index < this._text.length) {
6876 return this._text.charCodeAt(this._lang_index); 6824 return this._text.charCodeAt(this._lang_index);
6877 } 6825 }
6878 else { 6826 else {
6879 return 0; 6827 return (0);
6880 } 6828 }
6881 } 6829 }
6882 TokenizerBase.prototype._maybeEatChar = function(ch) { 6830 TokenizerBase.prototype._maybeEatChar = function(ch) {
6883 if (this._lang_index < this._text.length) { 6831 if (this._lang_index < this._text.length) {
6884 if (this._text.charCodeAt(this._lang_index) == ch) { 6832 if (this._text.charCodeAt(this._lang_index) == ch) {
6885 this._lang_index++; 6833 this._lang_index++;
6886 return true; 6834 return true;
6887 } 6835 }
6888 else { 6836 else {
6889 return false; 6837 return false;
6890 } 6838 }
6891 } 6839 }
6892 else { 6840 else {
6893 return false; 6841 return false;
6894 } 6842 }
6895 } 6843 }
6896 TokenizerBase.prototype._finishToken = function(kind) { 6844 TokenizerBase.prototype._finishToken = function(kind) {
6897 return new Token(kind, this._source, this._startIndex, this._lang_index); 6845 return new Token(kind, this._source, this._startIndex, this._lang_index);
6898 } 6846 }
6899 TokenizerBase.prototype._errorToken = function(message) { 6847 TokenizerBase.prototype._errorToken = function(message) {
6900 return new ErrorToken(65/*TokenKind.ERROR*/, this._source, this._startIndex, t his._lang_index, message); 6848 return new ErrorToken((65), this._source, this._startIndex, this._lang_index, message);
6901 } 6849 }
6902 TokenizerBase.prototype.finishWhitespace = function() { 6850 TokenizerBase.prototype.finishWhitespace = function() {
6903 this._lang_index--; 6851 this._lang_index--;
6904 while (this._lang_index < this._text.length) { 6852 while (this._lang_index < this._text.length) {
6905 var ch = this._text.charCodeAt(this._lang_index++); 6853 var ch = this._text.charCodeAt(this._lang_index++);
6906 if (ch == 32 || ch == 9 || ch == 13) { 6854 if (ch == (32) || ch == (9) || ch == (13)) {
6907 } 6855 }
6908 else if (ch == 10) { 6856 else if (ch == (10)) {
6909 if (!this._skipWhitespace) { 6857 if (!this._skipWhitespace) {
6910 return this._finishToken(63/*TokenKind.WHITESPACE*/); 6858 return this._finishToken((63));
6911 } 6859 }
6912 } 6860 }
6913 else { 6861 else {
6914 this._lang_index--; 6862 this._lang_index--;
6915 if (this._skipWhitespace) { 6863 if (this._skipWhitespace) {
6916 return this.next(); 6864 return this.next();
6917 } 6865 }
6918 else { 6866 else {
6919 return this._finishToken(63/*TokenKind.WHITESPACE*/); 6867 return this._finishToken((63));
6920 } 6868 }
6921 } 6869 }
6922 } 6870 }
6923 return this._finishToken(1/*TokenKind.END_OF_FILE*/); 6871 return this._finishToken((1));
6924 } 6872 }
6925 TokenizerBase.prototype.finishHashBang = function() { 6873 TokenizerBase.prototype.finishHashBang = function() {
6926 while (true) { 6874 while (true) {
6927 var ch = this._nextChar(); 6875 var ch = this._nextChar();
6928 if (ch == 0 || ch == 10 || ch == 13) { 6876 if (ch == (0) || ch == (10) || ch == (13)) {
6929 return this._finishToken(13/*TokenKind.HASHBANG*/); 6877 return this._finishToken((13));
6930 } 6878 }
6931 } 6879 }
6932 } 6880 }
6933 TokenizerBase.prototype.finishSingleLineComment = function() { 6881 TokenizerBase.prototype.finishSingleLineComment = function() {
6934 while (true) { 6882 while (true) {
6935 var ch = this._nextChar(); 6883 var ch = this._nextChar();
6936 if (ch == 0 || ch == 10 || ch == 13) { 6884 if (ch == (0) || ch == (10) || ch == (13)) {
6937 if (this._skipWhitespace) { 6885 if (this._skipWhitespace) {
6938 return this.next(); 6886 return this.next();
6939 } 6887 }
6940 else { 6888 else {
6941 return this._finishToken(64/*TokenKind.COMMENT*/); 6889 return this._finishToken((64));
6942 } 6890 }
6943 } 6891 }
6944 } 6892 }
6945 } 6893 }
6946 TokenizerBase.prototype.finishMultiLineComment = function() { 6894 TokenizerBase.prototype.finishMultiLineComment = function() {
6947 var nesting = 1; 6895 var nesting = (1);
6948 do { 6896 do {
6949 var ch = this._nextChar(); 6897 var ch = this._nextChar();
6950 if (ch == 0) { 6898 if (ch == (0)) {
6951 return this._errorToken(); 6899 return this._errorToken();
6952 } 6900 }
6953 else if (ch == 42) { 6901 else if (ch == (42)) {
6954 if (this._maybeEatChar(47)) { 6902 if (this._maybeEatChar((47))) {
6955 nesting--; 6903 nesting--;
6956 } 6904 }
6957 } 6905 }
6958 else if (ch == 47) { 6906 else if (ch == (47)) {
6959 if (this._maybeEatChar(42)) { 6907 if (this._maybeEatChar((42))) {
6960 nesting++; 6908 nesting++;
6961 } 6909 }
6962 } 6910 }
6963 } 6911 }
6964 while (nesting > 0) 6912 while (nesting > (0))
6965 if (this._skipWhitespace) { 6913 if (this._skipWhitespace) {
6966 return this.next(); 6914 return this.next();
6967 } 6915 }
6968 else { 6916 else {
6969 return this._finishToken(64/*TokenKind.COMMENT*/); 6917 return this._finishToken((64));
6970 } 6918 }
6971 } 6919 }
6972 TokenizerBase.prototype.eatDigits = function() { 6920 TokenizerBase.prototype.eatDigits = function() {
6973 while (this._lang_index < this._text.length) { 6921 while (this._lang_index < this._text.length) {
6974 if (TokenizerHelpers.isDigit(this._text.charCodeAt(this._lang_index))) { 6922 if (TokenizerHelpers.isDigit(this._text.charCodeAt(this._lang_index))) {
6975 this._lang_index++; 6923 this._lang_index++;
6976 } 6924 }
6977 else { 6925 else {
6978 return; 6926 return;
6979 } 6927 }
6980 } 6928 }
6981 } 6929 }
6982 TokenizerBase._hexDigit = function(c) { 6930 TokenizerBase._hexDigit = function(c) {
6983 if (c >= 48 && c <= 57) { 6931 if (c >= (48) && c <= (57)) {
6984 return c - 48; 6932 return c - (48);
6985 } 6933 }
6986 else if (c >= 97 && c <= 102) { 6934 else if (c >= (97) && c <= (102)) {
6987 return c - 87; 6935 return c - (87);
6988 } 6936 }
6989 else if (c >= 65 && c <= 70) { 6937 else if (c >= (65) && c <= (70)) {
6990 return c - 55; 6938 return c - (55);
6991 } 6939 }
6992 else { 6940 else {
6993 return -1; 6941 return (-1);
6994 } 6942 }
6995 } 6943 }
6996 TokenizerBase.prototype.readHex = function(hexLength) { 6944 TokenizerBase.prototype.readHex = function(hexLength) {
6997 var maxIndex; 6945 var maxIndex;
6998 if (hexLength == null) { 6946 if (hexLength == null) {
6999 maxIndex = this._text.length - 1; 6947 maxIndex = this._text.length - (1);
7000 } 6948 }
7001 else { 6949 else {
7002 maxIndex = this._lang_index + hexLength; 6950 maxIndex = this._lang_index + hexLength;
7003 if (maxIndex >= this._text.length) return -1; 6951 if (maxIndex >= this._text.length) return (-1);
7004 } 6952 }
7005 var result = 0; 6953 var result = (0);
7006 while (this._lang_index < maxIndex) { 6954 while (this._lang_index < maxIndex) {
7007 var digit = TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)) ; 6955 var digit = TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)) ;
7008 if (digit == -1) { 6956 if (digit == (-1)) {
7009 if (hexLength == null) { 6957 if (hexLength == null) {
7010 return result; 6958 return result;
7011 } 6959 }
7012 else { 6960 else {
7013 return -1; 6961 return (-1);
7014 } 6962 }
7015 } 6963 }
7016 TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)); 6964 TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index));
7017 result = (result * 16) + digit; 6965 result = (result * (16)) + digit;
7018 this._lang_index++; 6966 this._lang_index++;
7019 } 6967 }
7020 return result; 6968 return result;
7021 } 6969 }
7022 TokenizerBase.prototype.finishHex = function() { 6970 TokenizerBase.prototype.finishHex = function() {
7023 var value = this.readHex(); 6971 var value = this.readHex();
7024 return new LiteralToken(61/*TokenKind.HEX_INTEGER*/, this._source, this._start Index, this._lang_index, value); 6972 return new LiteralToken((61), this._source, this._startIndex, this._lang_index , value);
7025 } 6973 }
7026 TokenizerBase.prototype.finishNumber = function() { 6974 TokenizerBase.prototype.finishNumber = function() {
7027 this.eatDigits(); 6975 this.eatDigits();
7028 if (this._peekChar() == 46) { 6976 if (this._peekChar() == (46)) {
7029 this._nextChar(); 6977 this._nextChar();
7030 if (TokenizerHelpers.isDigit(this._peekChar())) { 6978 if (TokenizerHelpers.isDigit(this._peekChar())) {
7031 this.eatDigits(); 6979 this.eatDigits();
7032 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/); 6980 return this.finishNumberExtra((62));
7033 } 6981 }
7034 else { 6982 else {
7035 this._lang_index--; 6983 this._lang_index--;
7036 } 6984 }
7037 } 6985 }
7038 return this.finishNumberExtra(60/*TokenKind.INTEGER*/); 6986 return this.finishNumberExtra((60));
7039 } 6987 }
7040 TokenizerBase.prototype.finishNumberExtra = function(kind) { 6988 TokenizerBase.prototype.finishNumberExtra = function(kind) {
7041 if (this._maybeEatChar(101) || this._maybeEatChar(69)) { 6989 if (this._maybeEatChar((101)) || this._maybeEatChar((69))) {
7042 kind = 62/*TokenKind.DOUBLE*/; 6990 kind = (62);
7043 this._maybeEatChar(45); 6991 this._maybeEatChar((45));
7044 this._maybeEatChar(43); 6992 this._maybeEatChar((43));
7045 this.eatDigits(); 6993 this.eatDigits();
7046 } 6994 }
7047 if (this._peekChar() != 0 && TokenizerHelpers.isIdentifierStart(this._peekChar ())) { 6995 if (this._peekChar() != (0) && TokenizerHelpers.isIdentifierStart(this._peekCh ar())) {
7048 this._nextChar(); 6996 this._nextChar();
7049 return this._errorToken("illegal character in number"); 6997 return this._errorToken("illegal character in number");
7050 } 6998 }
7051 return this._finishToken(kind); 6999 return this._finishToken(kind);
7052 } 7000 }
7053 TokenizerBase.prototype._makeStringToken = function(buf, isPart) { 7001 TokenizerBase.prototype._makeStringToken = function(buf, isPart) {
7054 var s = Strings.String$fromCharCodes$factory(buf); 7002 var s = Strings.String$fromCharCodes$factory(buf);
7055 var kind = isPart ? 59/*TokenKind.STRING_PART*/ : 58/*TokenKind.STRING*/; 7003 var kind = isPart ? (59) : (58);
7056 return new LiteralToken(kind, this._source, this._startIndex, this._lang_index , s); 7004 return new LiteralToken(kind, this._source, this._startIndex, this._lang_index , s);
7057 } 7005 }
7058 TokenizerBase.prototype._makeRawStringToken = function(isMultiline) { 7006 TokenizerBase.prototype._makeRawStringToken = function(isMultiline) {
7059 var s; 7007 var s;
7060 if (isMultiline) { 7008 if (isMultiline) {
7061 if (this._source.get$text()[this._startIndex + 4] == "\n") { 7009 if (this._source.get$text()[this._startIndex + (4)] == "\n") {
7062 s = this._source.get$text().substring(this._startIndex + 5, this._lang_ind ex - 3); 7010 s = this._source.get$text().substring(this._startIndex + (5), this._lang_i ndex - (3));
7063 } 7011 }
7064 else { 7012 else {
7065 s = this._source.get$text().substring(this._startIndex + 4, this._lang_ind ex - 3); 7013 s = this._source.get$text().substring(this._startIndex + (4), this._lang_i ndex - (3));
7066 } 7014 }
7067 } 7015 }
7068 else { 7016 else {
7069 s = this._source.get$text().substring(this._startIndex + 2, this._lang_index - 1); 7017 s = this._source.get$text().substring(this._startIndex + (2), this._lang_ind ex - (1));
7070 } 7018 }
7071 return new LiteralToken(58/*TokenKind.STRING*/, this._source, this._startIndex , this._lang_index, s); 7019 return new LiteralToken((58), this._source, this._startIndex, this._lang_index , s);
7072 } 7020 }
7073 TokenizerBase.prototype.finishMultilineString = function(quote) { 7021 TokenizerBase.prototype.finishMultilineString = function(quote) {
7074 var buf = new Array(); 7022 var buf = new Array();
7075 while (true) { 7023 while (true) {
7076 var ch = this._nextChar(); 7024 var ch = this._nextChar();
7077 if (ch == 0) { 7025 if (ch == (0)) {
7078 return this._errorToken(); 7026 return this._errorToken();
7079 } 7027 }
7080 else if (ch == quote) { 7028 else if (ch == quote) {
7081 if (this._maybeEatChar(quote)) { 7029 if (this._maybeEatChar(quote)) {
7082 if (this._maybeEatChar(quote)) { 7030 if (this._maybeEatChar(quote)) {
7083 return this._makeStringToken(buf, false); 7031 return this._makeStringToken(buf, false);
7084 } 7032 }
7085 buf.add$1(quote); 7033 buf.add$1(quote);
7086 } 7034 }
7087 buf.add$1(quote); 7035 buf.add$1(quote);
7088 } 7036 }
7089 else if (ch == 36) { 7037 else if (ch == (36)) {
7090 this._interpStack = InterpStack.push(this._interpStack, quote, true); 7038 this._interpStack = InterpStack.push(this._interpStack, quote, true);
7091 return this._makeStringToken(buf, true); 7039 return this._makeStringToken(buf, true);
7092 } 7040 }
7093 else if (ch == 92) { 7041 else if (ch == (92)) {
7094 var escapeVal = this.readEscapeSequence(); 7042 var escapeVal = this.readEscapeSequence();
7095 if ($eq(escapeVal, -1)) { 7043 if ($eq(escapeVal, (-1))) {
7096 return this._errorToken("invalid hex escape sequence"); 7044 return this._errorToken("invalid hex escape sequence");
7097 } 7045 }
7098 else { 7046 else {
7099 buf.add$1(escapeVal); 7047 buf.add$1(escapeVal);
7100 } 7048 }
7101 } 7049 }
7102 else { 7050 else {
7103 buf.add$1(ch); 7051 buf.add$1(ch);
7104 } 7052 }
7105 } 7053 }
7106 } 7054 }
7107 TokenizerBase.prototype._finishOpenBrace = function() { 7055 TokenizerBase.prototype._finishOpenBrace = function() {
7108 var $0; 7056 var $0;
7109 if (this._interpStack != null) { 7057 if (this._interpStack != null) {
7110 if (this._interpStack.depth == -1) { 7058 if (this._interpStack.depth == (-1)) {
7111 this._interpStack.depth = 1; 7059 this._interpStack.depth = (1);
7112 } 7060 }
7113 else { 7061 else {
7114 ($0 = this._interpStack).depth = $0.depth + 1; 7062 ($0 = this._interpStack).depth = $0.depth + (1);
7115 } 7063 }
7116 } 7064 }
7117 return this._finishToken(6/*TokenKind.LBRACE*/); 7065 return this._finishToken((6));
7118 } 7066 }
7119 TokenizerBase.prototype._finishCloseBrace = function() { 7067 TokenizerBase.prototype._finishCloseBrace = function() {
7120 var $0; 7068 var $0;
7121 if (this._interpStack != null) { 7069 if (this._interpStack != null) {
7122 ($0 = this._interpStack).depth = $0.depth - 1; 7070 ($0 = this._interpStack).depth = $0.depth - (1);
7123 } 7071 }
7124 return this._finishToken(7/*TokenKind.RBRACE*/); 7072 return this._finishToken((7));
7125 } 7073 }
7126 TokenizerBase.prototype.finishString = function(quote) { 7074 TokenizerBase.prototype.finishString = function(quote) {
7127 if (this._maybeEatChar(quote)) { 7075 if (this._maybeEatChar(quote)) {
7128 if (this._maybeEatChar(quote)) { 7076 if (this._maybeEatChar(quote)) {
7129 this._maybeEatChar(10); 7077 this._maybeEatChar((10));
7130 return this.finishMultilineString(quote); 7078 return this.finishMultilineString(quote);
7131 } 7079 }
7132 else { 7080 else {
7133 return this._makeStringToken(new Array(), false); 7081 return this._makeStringToken(new Array(), false);
7134 } 7082 }
7135 } 7083 }
7136 return this.finishStringBody(quote); 7084 return this.finishStringBody(quote);
7137 } 7085 }
7138 TokenizerBase.prototype.finishRawString = function(quote) { 7086 TokenizerBase.prototype.finishRawString = function(quote) {
7139 if (this._maybeEatChar(quote)) { 7087 if (this._maybeEatChar(quote)) {
7140 if (this._maybeEatChar(quote)) { 7088 if (this._maybeEatChar(quote)) {
7141 return this.finishMultilineRawString(quote); 7089 return this.finishMultilineRawString(quote);
7142 } 7090 }
7143 else { 7091 else {
7144 return this._makeStringToken(new Array(), false); 7092 return this._makeStringToken(new Array(), false);
7145 } 7093 }
7146 } 7094 }
7147 while (true) { 7095 while (true) {
7148 var ch = this._nextChar(); 7096 var ch = this._nextChar();
7149 if (ch == quote) { 7097 if (ch == quote) {
7150 return this._makeRawStringToken(false); 7098 return this._makeRawStringToken(false);
7151 } 7099 }
7152 else if (ch == 0) { 7100 else if (ch == (0)) {
7153 return this._errorToken(); 7101 return this._errorToken();
7154 } 7102 }
7155 } 7103 }
7156 } 7104 }
7157 TokenizerBase.prototype.finishMultilineRawString = function(quote) { 7105 TokenizerBase.prototype.finishMultilineRawString = function(quote) {
7158 while (true) { 7106 while (true) {
7159 var ch = this._nextChar(); 7107 var ch = this._nextChar();
7160 if (ch == 0) { 7108 if (ch == (0)) {
7161 return this._errorToken(); 7109 return this._errorToken();
7162 } 7110 }
7163 else if (ch == quote && this._maybeEatChar(quote) && this._maybeEatChar(quot e)) { 7111 else if (ch == quote && this._maybeEatChar(quote) && this._maybeEatChar(quot e)) {
7164 return this._makeRawStringToken(true); 7112 return this._makeRawStringToken(true);
7165 } 7113 }
7166 } 7114 }
7167 } 7115 }
7168 TokenizerBase.prototype.finishStringBody = function(quote) { 7116 TokenizerBase.prototype.finishStringBody = function(quote) {
7169 var buf = new Array(); 7117 var buf = new Array();
7170 while (true) { 7118 while (true) {
7171 var ch = this._nextChar(); 7119 var ch = this._nextChar();
7172 if (ch == quote) { 7120 if (ch == quote) {
7173 return this._makeStringToken(buf, false); 7121 return this._makeStringToken(buf, false);
7174 } 7122 }
7175 else if (ch == 36) { 7123 else if (ch == (36)) {
7176 this._interpStack = InterpStack.push(this._interpStack, quote, false); 7124 this._interpStack = InterpStack.push(this._interpStack, quote, false);
7177 return this._makeStringToken(buf, true); 7125 return this._makeStringToken(buf, true);
7178 } 7126 }
7179 else if (ch == 0) { 7127 else if (ch == (0)) {
7180 return this._errorToken(); 7128 return this._errorToken();
7181 } 7129 }
7182 else if (ch == 92) { 7130 else if (ch == (92)) {
7183 var escapeVal = this.readEscapeSequence(); 7131 var escapeVal = this.readEscapeSequence();
7184 if ($eq(escapeVal, -1)) { 7132 if ($eq(escapeVal, (-1))) {
7185 return this._errorToken("invalid hex escape sequence"); 7133 return this._errorToken("invalid hex escape sequence");
7186 } 7134 }
7187 else { 7135 else {
7188 buf.add$1(escapeVal); 7136 buf.add$1(escapeVal);
7189 } 7137 }
7190 } 7138 }
7191 else { 7139 else {
7192 buf.add$1(ch); 7140 buf.add$1(ch);
7193 } 7141 }
7194 } 7142 }
7195 } 7143 }
7196 TokenizerBase.prototype.readEscapeSequence = function() { 7144 TokenizerBase.prototype.readEscapeSequence = function() {
7197 var ch = this._nextChar(); 7145 var ch = this._nextChar();
7198 var hexValue; 7146 var hexValue;
7199 switch (ch) { 7147 switch (ch) {
7200 case 110: 7148 case (110):
7201 7149
7202 return 10; 7150 return (10);
7203 7151
7204 case 114: 7152 case (114):
7205 7153
7206 return 13; 7154 return (13);
7207 7155
7208 case 102: 7156 case (102):
7209 7157
7210 return 12; 7158 return (12);
7211 7159
7212 case 98: 7160 case (98):
7213 7161
7214 return 8; 7162 return (8);
7215 7163
7216 case 116: 7164 case (116):
7217 7165
7218 return 9; 7166 return (9);
7219 7167
7220 case 118: 7168 case (118):
7221 7169
7222 return 11; 7170 return (11);
7223 7171
7224 case 120: 7172 case (120):
7225 7173
7226 hexValue = this.readHex(2); 7174 hexValue = this.readHex((2));
7227 break; 7175 break;
7228 7176
7229 case 117: 7177 case (117):
7230 7178
7231 if (this._maybeEatChar(123)) { 7179 if (this._maybeEatChar((123))) {
7232 hexValue = this.readHex(); 7180 hexValue = this.readHex();
7233 if (!this._maybeEatChar(125)) { 7181 if (!this._maybeEatChar((125))) {
7234 return -1; 7182 return (-1);
7235 } 7183 }
7236 else { 7184 else {
7237 break; 7185 break;
7238 } 7186 }
7239 } 7187 }
7240 else { 7188 else {
7241 hexValue = this.readHex(4); 7189 hexValue = this.readHex((4));
7242 break; 7190 break;
7243 } 7191 }
7244 7192
7245 default: 7193 default:
7246 7194
7247 return ch; 7195 return ch;
7248 7196
7249 } 7197 }
7250 if (hexValue == -1) return -1; 7198 if (hexValue == (-1)) return (-1);
7251 if (hexValue < 55296 || hexValue > 57343 && hexValue <= 65535) { 7199 if (hexValue < (55296) || hexValue > (57343) && hexValue <= (65535)) {
7252 return hexValue; 7200 return hexValue;
7253 } 7201 }
7254 else if (hexValue <= 1114111) { 7202 else if (hexValue <= (1114111)) {
7255 $globals.world.fatal("unicode values greater than 2 bytes not implemented ye t"); 7203 $globals.world.fatal("unicode values greater than 2 bytes not implemented ye t");
7256 return -1; 7204 return (-1);
7257 } 7205 }
7258 else { 7206 else {
7259 return -1; 7207 return (-1);
7260 } 7208 }
7261 } 7209 }
7262 TokenizerBase.prototype.finishDot = function() { 7210 TokenizerBase.prototype.finishDot = function() {
7263 if (TokenizerHelpers.isDigit(this._peekChar())) { 7211 if (TokenizerHelpers.isDigit(this._peekChar())) {
7264 this.eatDigits(); 7212 this.eatDigits();
7265 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/); 7213 return this.finishNumberExtra((62));
7266 } 7214 }
7267 else { 7215 else {
7268 return this._finishToken(14/*TokenKind.DOT*/); 7216 return this._finishToken((14));
7269 } 7217 }
7270 } 7218 }
7271 TokenizerBase.prototype.finishIdentifier = function(ch) { 7219 TokenizerBase.prototype.finishIdentifier = function(ch) {
7272 if (this._interpStack != null && this._interpStack.depth == -1) { 7220 if (this._interpStack != null && this._interpStack.depth == (-1)) {
7273 this._interpStack.depth = 0; 7221 this._interpStack.depth = (0);
7274 if (ch == 36) { 7222 if (ch == (36)) {
7275 return this._errorToken("illegal character after $ in string interpolation "); 7223 return this._errorToken("illegal character after $ in string interpolation ");
7276 } 7224 }
7277 while (this._lang_index < this._text.length) { 7225 while (this._lang_index < this._text.length) {
7278 if (!TokenizerHelpers.isInterpIdentifierPart(this._text.charCodeAt(this._l ang_index++))) { 7226 if (!TokenizerHelpers.isInterpIdentifierPart(this._text.charCodeAt(this._l ang_index++))) {
7279 this._lang_index--; 7227 this._lang_index--;
7280 break; 7228 break;
7281 } 7229 }
7282 } 7230 }
7283 } 7231 }
7284 else { 7232 else {
7285 while (this._lang_index < this._text.length) { 7233 while (this._lang_index < this._text.length) {
7286 if (!TokenizerHelpers.isIdentifierPart(this._text.charCodeAt(this._lang_in dex++))) { 7234 if (!TokenizerHelpers.isIdentifierPart(this._text.charCodeAt(this._lang_in dex++))) {
7287 this._lang_index--; 7235 this._lang_index--;
7288 break; 7236 break;
7289 } 7237 }
7290 } 7238 }
7291 } 7239 }
7292 var kind = this.getIdentifierKind(); 7240 var kind = this.getIdentifierKind();
7293 if (kind == 70/*TokenKind.IDENTIFIER*/) { 7241 if (kind == (70)) {
7294 return this._finishToken(70/*TokenKind.IDENTIFIER*/); 7242 return this._finishToken((70));
7295 } 7243 }
7296 else { 7244 else {
7297 return this._finishToken(kind); 7245 return this._finishToken(kind);
7298 } 7246 }
7299 } 7247 }
7300 TokenizerBase.prototype.next$0 = TokenizerBase.prototype.next; 7248 TokenizerBase.prototype.next$0 = TokenizerBase.prototype.next;
7301 // ********** Code for Tokenizer ************** 7249 // ********** Code for Tokenizer **************
7302 $inherits(Tokenizer, TokenizerBase); 7250 $inherits(Tokenizer, TokenizerBase);
7303 function Tokenizer(source, skipWhitespace, index) { 7251 function Tokenizer(source, skipWhitespace, index) {
7304 // Initializers done 7252 // Initializers done
7305 TokenizerBase.call(this, source, skipWhitespace, index); 7253 TokenizerBase.call(this, source, skipWhitespace, index);
7306 } 7254 }
7307 Tokenizer.prototype.next = function() { 7255 Tokenizer.prototype.next = function() {
7308 this._startIndex = this._lang_index; 7256 this._startIndex = this._lang_index;
7309 if (this._interpStack != null && this._interpStack.depth == 0) { 7257 if (this._interpStack != null && this._interpStack.depth == (0)) {
7310 var istack = this._interpStack; 7258 var istack = this._interpStack;
7311 this._interpStack = this._interpStack.pop(); 7259 this._interpStack = this._interpStack.pop();
7312 if (istack.get$isMultiline()) { 7260 if (istack.get$isMultiline()) {
7313 return this.finishMultilineString(istack.get$quote()); 7261 return this.finishMultilineString(istack.get$quote());
7314 } 7262 }
7315 else { 7263 else {
7316 return this.finishStringBody(istack.get$quote()); 7264 return this.finishStringBody(istack.get$quote());
7317 } 7265 }
7318 } 7266 }
7319 var ch; 7267 var ch;
7320 ch = this._nextChar(); 7268 ch = this._nextChar();
7321 switch (ch) { 7269 switch (ch) {
7322 case 0: 7270 case (0):
7323 7271
7324 return this._finishToken(1/*TokenKind.END_OF_FILE*/); 7272 return this._finishToken((1));
7325 7273
7326 case 32: 7274 case (32):
7327 case 9: 7275 case (9):
7328 case 10: 7276 case (10):
7329 case 13: 7277 case (13):
7330 7278
7331 return this.finishWhitespace(); 7279 return this.finishWhitespace();
7332 7280
7333 case 33: 7281 case (33):
7334 7282
7335 if (this._maybeEatChar(61)) { 7283 if (this._maybeEatChar((61))) {
7336 if (this._maybeEatChar(61)) { 7284 if (this._maybeEatChar((61))) {
7337 return this._finishToken(51/*TokenKind.NE_STRICT*/); 7285 return this._finishToken((51));
7338 } 7286 }
7339 else { 7287 else {
7340 return this._finishToken(49/*TokenKind.NE*/); 7288 return this._finishToken((49));
7341 } 7289 }
7342 } 7290 }
7343 else { 7291 else {
7344 return this._finishToken(19/*TokenKind.NOT*/); 7292 return this._finishToken((19));
7345 } 7293 }
7346 7294
7347 case 34: 7295 case (34):
7348 7296
7349 return this.finishString(34); 7297 return this.finishString((34));
7350 7298
7351 case 35: 7299 case (35):
7352 7300
7353 if (this._maybeEatChar(33)) { 7301 if (this._maybeEatChar((33))) {
7354 return this.finishHashBang(); 7302 return this.finishHashBang();
7355 } 7303 }
7356 else { 7304 else {
7357 return this._finishToken(12/*TokenKind.HASH*/); 7305 return this._finishToken((12));
7358 } 7306 }
7359 7307
7360 case 36: 7308 case (36):
7361 7309
7362 if (this._maybeEatChar(34)) { 7310 if (this._maybeEatChar((34))) {
7363 return this.finishString(34); 7311 return this.finishString((34));
7364 } 7312 }
7365 else if (this._maybeEatChar(39)) { 7313 else if (this._maybeEatChar((39))) {
7366 return this.finishString(39); 7314 return this.finishString((39));
7367 } 7315 }
7368 else { 7316 else {
7369 return this.finishIdentifier(36); 7317 return this.finishIdentifier((36));
7370 } 7318 }
7371 7319
7372 case 37: 7320 case (37):
7373 7321
7374 if (this._maybeEatChar(61)) { 7322 if (this._maybeEatChar((61))) {
7375 return this._finishToken(32/*TokenKind.ASSIGN_MOD*/); 7323 return this._finishToken((32));
7376 } 7324 }
7377 else { 7325 else {
7378 return this._finishToken(47/*TokenKind.MOD*/); 7326 return this._finishToken((47));
7379 } 7327 }
7380 7328
7381 case 38: 7329 case (38):
7382 7330
7383 if (this._maybeEatChar(38)) { 7331 if (this._maybeEatChar((38))) {
7384 return this._finishToken(35/*TokenKind.AND*/); 7332 return this._finishToken((35));
7385 } 7333 }
7386 else if (this._maybeEatChar(61)) { 7334 else if (this._maybeEatChar((61))) {
7387 return this._finishToken(23/*TokenKind.ASSIGN_AND*/); 7335 return this._finishToken((23));
7388 } 7336 }
7389 else { 7337 else {
7390 return this._finishToken(38/*TokenKind.BIT_AND*/); 7338 return this._finishToken((38));
7391 } 7339 }
7392 7340
7393 case 39: 7341 case (39):
7394 7342
7395 return this.finishString(39); 7343 return this.finishString((39));
7396 7344
7397 case 40: 7345 case (40):
7398 7346
7399 return this._finishToken(2/*TokenKind.LPAREN*/); 7347 return this._finishToken((2));
7400 7348
7401 case 41: 7349 case (41):
7402 7350
7403 return this._finishToken(3/*TokenKind.RPAREN*/); 7351 return this._finishToken((3));
7404 7352
7405 case 42: 7353 case (42):
7406 7354
7407 if (this._maybeEatChar(61)) { 7355 if (this._maybeEatChar((61))) {
7408 return this._finishToken(29/*TokenKind.ASSIGN_MUL*/); 7356 return this._finishToken((29));
7409 } 7357 }
7410 else { 7358 else {
7411 return this._finishToken(44/*TokenKind.MUL*/); 7359 return this._finishToken((44));
7412 } 7360 }
7413 7361
7414 case 43: 7362 case (43):
7415 7363
7416 if (this._maybeEatChar(43)) { 7364 if (this._maybeEatChar((43))) {
7417 return this._finishToken(16/*TokenKind.INCR*/); 7365 return this._finishToken((16));
7418 } 7366 }
7419 else if (this._maybeEatChar(61)) { 7367 else if (this._maybeEatChar((61))) {
7420 return this._finishToken(27/*TokenKind.ASSIGN_ADD*/); 7368 return this._finishToken((27));
7421 } 7369 }
7422 else { 7370 else {
7423 return this._finishToken(42/*TokenKind.ADD*/); 7371 return this._finishToken((42));
7424 } 7372 }
7425 7373
7426 case 44: 7374 case (44):
7427 7375
7428 return this._finishToken(11/*TokenKind.COMMA*/); 7376 return this._finishToken((11));
7429 7377
7430 case 45: 7378 case (45):
7431 7379
7432 if (this._maybeEatChar(45)) { 7380 if (this._maybeEatChar((45))) {
7433 return this._finishToken(17/*TokenKind.DECR*/); 7381 return this._finishToken((17));
7434 } 7382 }
7435 else if (this._maybeEatChar(61)) { 7383 else if (this._maybeEatChar((61))) {
7436 return this._finishToken(28/*TokenKind.ASSIGN_SUB*/); 7384 return this._finishToken((28));
7437 } 7385 }
7438 else { 7386 else {
7439 return this._finishToken(43/*TokenKind.SUB*/); 7387 return this._finishToken((43));
7440 } 7388 }
7441 7389
7442 case 46: 7390 case (46):
7443 7391
7444 if (this._maybeEatChar(46)) { 7392 if (this._maybeEatChar((46))) {
7445 if (this._maybeEatChar(46)) { 7393 if (this._maybeEatChar((46))) {
7446 return this._finishToken(15/*TokenKind.ELLIPSIS*/); 7394 return this._finishToken((15));
7447 } 7395 }
7448 else { 7396 else {
7449 return this._errorToken(); 7397 return this._errorToken();
7450 } 7398 }
7451 } 7399 }
7452 else { 7400 else {
7453 return this.finishDot(); 7401 return this.finishDot();
7454 } 7402 }
7455 7403
7456 case 47: 7404 case (47):
7457 7405
7458 if (this._maybeEatChar(42)) { 7406 if (this._maybeEatChar((42))) {
7459 return this.finishMultiLineComment(); 7407 return this.finishMultiLineComment();
7460 } 7408 }
7461 else if (this._maybeEatChar(47)) { 7409 else if (this._maybeEatChar((47))) {
7462 return this.finishSingleLineComment(); 7410 return this.finishSingleLineComment();
7463 } 7411 }
7464 else if (this._maybeEatChar(61)) { 7412 else if (this._maybeEatChar((61))) {
7465 return this._finishToken(30/*TokenKind.ASSIGN_DIV*/); 7413 return this._finishToken((30));
7466 } 7414 }
7467 else { 7415 else {
7468 return this._finishToken(45/*TokenKind.DIV*/); 7416 return this._finishToken((45));
7469 } 7417 }
7470 7418
7471 case 48: 7419 case (48):
7472 7420
7473 if (this._maybeEatChar(88)) { 7421 if (this._maybeEatChar((88))) {
7474 return this.finishHex(); 7422 return this.finishHex();
7475 } 7423 }
7476 else if (this._maybeEatChar(120)) { 7424 else if (this._maybeEatChar((120))) {
7477 return this.finishHex(); 7425 return this.finishHex();
7478 } 7426 }
7479 else { 7427 else {
7480 return this.finishNumber(); 7428 return this.finishNumber();
7481 } 7429 }
7482 7430
7483 case 58: 7431 case (58):
7484 7432
7485 return this._finishToken(8/*TokenKind.COLON*/); 7433 return this._finishToken((8));
7486 7434
7487 case 59: 7435 case (59):
7488 7436
7489 return this._finishToken(10/*TokenKind.SEMICOLON*/); 7437 return this._finishToken((10));
7490 7438
7491 case 60: 7439 case (60):
7492 7440
7493 if (this._maybeEatChar(60)) { 7441 if (this._maybeEatChar((60))) {
7494 if (this._maybeEatChar(61)) { 7442 if (this._maybeEatChar((61))) {
7495 return this._finishToken(24/*TokenKind.ASSIGN_SHL*/); 7443 return this._finishToken((24));
7496 } 7444 }
7497 else { 7445 else {
7498 return this._finishToken(39/*TokenKind.SHL*/); 7446 return this._finishToken((39));
7499 } 7447 }
7500 } 7448 }
7501 else if (this._maybeEatChar(61)) { 7449 else if (this._maybeEatChar((61))) {
7502 return this._finishToken(54/*TokenKind.LTE*/); 7450 return this._finishToken((54));
7503 } 7451 }
7504 else { 7452 else {
7505 return this._finishToken(52/*TokenKind.LT*/); 7453 return this._finishToken((52));
7506 } 7454 }
7507 7455
7508 case 61: 7456 case (61):
7509 7457
7510 if (this._maybeEatChar(61)) { 7458 if (this._maybeEatChar((61))) {
7511 if (this._maybeEatChar(61)) { 7459 if (this._maybeEatChar((61))) {
7512 return this._finishToken(50/*TokenKind.EQ_STRICT*/); 7460 return this._finishToken((50));
7513 } 7461 }
7514 else { 7462 else {
7515 return this._finishToken(48/*TokenKind.EQ*/); 7463 return this._finishToken((48));
7516 } 7464 }
7517 } 7465 }
7518 else if (this._maybeEatChar(62)) { 7466 else if (this._maybeEatChar((62))) {
7519 return this._finishToken(9/*TokenKind.ARROW*/); 7467 return this._finishToken((9));
7520 } 7468 }
7521 else { 7469 else {
7522 return this._finishToken(20/*TokenKind.ASSIGN*/); 7470 return this._finishToken((20));
7523 } 7471 }
7524 7472
7525 case 62: 7473 case (62):
7526 7474
7527 if (this._maybeEatChar(61)) { 7475 if (this._maybeEatChar((61))) {
7528 return this._finishToken(55/*TokenKind.GTE*/); 7476 return this._finishToken((55));
7529 } 7477 }
7530 else if (this._maybeEatChar(62)) { 7478 else if (this._maybeEatChar((62))) {
7531 if (this._maybeEatChar(61)) { 7479 if (this._maybeEatChar((61))) {
7532 return this._finishToken(25/*TokenKind.ASSIGN_SAR*/); 7480 return this._finishToken((25));
7533 } 7481 }
7534 else if (this._maybeEatChar(62)) { 7482 else if (this._maybeEatChar((62))) {
7535 if (this._maybeEatChar(61)) { 7483 if (this._maybeEatChar((61))) {
7536 return this._finishToken(26/*TokenKind.ASSIGN_SHR*/); 7484 return this._finishToken((26));
7537 } 7485 }
7538 else { 7486 else {
7539 return this._finishToken(41/*TokenKind.SHR*/); 7487 return this._finishToken((41));
7540 } 7488 }
7541 } 7489 }
7542 else { 7490 else {
7543 return this._finishToken(40/*TokenKind.SAR*/); 7491 return this._finishToken((40));
7544 } 7492 }
7545 } 7493 }
7546 else { 7494 else {
7547 return this._finishToken(53/*TokenKind.GT*/); 7495 return this._finishToken((53));
7548 } 7496 }
7549 7497
7550 case 63: 7498 case (63):
7551 7499
7552 return this._finishToken(33/*TokenKind.CONDITIONAL*/); 7500 return this._finishToken((33));
7553 7501
7554 case 64: 7502 case (64):
7555 7503
7556 if (this._maybeEatChar(34)) { 7504 if (this._maybeEatChar((34))) {
7557 return this.finishRawString(34); 7505 return this.finishRawString((34));
7558 } 7506 }
7559 else if (this._maybeEatChar(39)) { 7507 else if (this._maybeEatChar((39))) {
7560 return this.finishRawString(39); 7508 return this.finishRawString((39));
7561 } 7509 }
7562 else { 7510 else {
7563 return this._errorToken(); 7511 return this._errorToken();
7564 } 7512 }
7565 7513
7566 case 91: 7514 case (91):
7567 7515
7568 if (this._maybeEatChar(93)) { 7516 if (this._maybeEatChar((93))) {
7569 if (this._maybeEatChar(61)) { 7517 if (this._maybeEatChar((61))) {
7570 return this._finishToken(57/*TokenKind.SETINDEX*/); 7518 return this._finishToken((57));
7571 } 7519 }
7572 else { 7520 else {
7573 return this._finishToken(56/*TokenKind.INDEX*/); 7521 return this._finishToken((56));
7574 } 7522 }
7575 } 7523 }
7576 else { 7524 else {
7577 return this._finishToken(4/*TokenKind.LBRACK*/); 7525 return this._finishToken((4));
7578 } 7526 }
7579 7527
7580 case 93: 7528 case (93):
7581 7529
7582 return this._finishToken(5/*TokenKind.RBRACK*/); 7530 return this._finishToken((5));
7583 7531
7584 case 94: 7532 case (94):
7585 7533
7586 if (this._maybeEatChar(61)) { 7534 if (this._maybeEatChar((61))) {
7587 return this._finishToken(22/*TokenKind.ASSIGN_XOR*/); 7535 return this._finishToken((22));
7588 } 7536 }
7589 else { 7537 else {
7590 return this._finishToken(37/*TokenKind.BIT_XOR*/); 7538 return this._finishToken((37));
7591 } 7539 }
7592 7540
7593 case 123: 7541 case (123):
7594 7542
7595 return this._finishOpenBrace(); 7543 return this._finishOpenBrace();
7596 7544
7597 case 124: 7545 case (124):
7598 7546
7599 if (this._maybeEatChar(61)) { 7547 if (this._maybeEatChar((61))) {
7600 return this._finishToken(21/*TokenKind.ASSIGN_OR*/); 7548 return this._finishToken((21));
7601 } 7549 }
7602 else if (this._maybeEatChar(124)) { 7550 else if (this._maybeEatChar((124))) {
7603 return this._finishToken(34/*TokenKind.OR*/); 7551 return this._finishToken((34));
7604 } 7552 }
7605 else { 7553 else {
7606 return this._finishToken(36/*TokenKind.BIT_OR*/); 7554 return this._finishToken((36));
7607 } 7555 }
7608 7556
7609 case 125: 7557 case (125):
7610 7558
7611 return this._finishCloseBrace(); 7559 return this._finishCloseBrace();
7612 7560
7613 case 126: 7561 case (126):
7614 7562
7615 if (this._maybeEatChar(47)) { 7563 if (this._maybeEatChar((47))) {
7616 if (this._maybeEatChar(61)) { 7564 if (this._maybeEatChar((61))) {
7617 return this._finishToken(31/*TokenKind.ASSIGN_TRUNCDIV*/); 7565 return this._finishToken((31));
7618 } 7566 }
7619 else { 7567 else {
7620 return this._finishToken(46/*TokenKind.TRUNCDIV*/); 7568 return this._finishToken((46));
7621 } 7569 }
7622 } 7570 }
7623 else { 7571 else {
7624 return this._finishToken(18/*TokenKind.BIT_NOT*/); 7572 return this._finishToken((18));
7625 } 7573 }
7626 7574
7627 default: 7575 default:
7628 7576
7629 if (TokenizerHelpers.isIdentifierStart(ch)) { 7577 if (TokenizerHelpers.isIdentifierStart(ch)) {
7630 return this.finishIdentifier(ch); 7578 return this.finishIdentifier(ch);
7631 } 7579 }
7632 else if (TokenizerHelpers.isDigit(ch)) { 7580 else if (TokenizerHelpers.isDigit(ch)) {
7633 return this.finishNumber(); 7581 return this.finishNumber();
7634 } 7582 }
7635 else { 7583 else {
7636 return this._errorToken(); 7584 return this._errorToken();
7637 } 7585 }
7638 7586
7639 } 7587 }
7640 } 7588 }
7641 Tokenizer.prototype.getIdentifierKind = function() { 7589 Tokenizer.prototype.getIdentifierKind = function() {
7642 var i0 = this._startIndex; 7590 var i0 = this._startIndex;
7643 var ch; 7591 var ch;
7644 switch (this._lang_index - i0) { 7592 switch (this._lang_index - i0) {
7645 case 2: 7593 case (2):
7646 7594
7647 ch = this._text.charCodeAt(i0); 7595 ch = this._text.charCodeAt(i0);
7648 if (ch == 100) { 7596 if (ch == (100)) {
7649 if (this._text.charCodeAt(i0 + 1) == 111) return 94/*TokenKind.DO*/; 7597 if (this._text.charCodeAt(i0 + (1)) == (111)) return (94);
7650 } 7598 }
7651 else if (ch == 105) { 7599 else if (ch == (105)) {
7652 ch = this._text.charCodeAt(i0 + 1); 7600 ch = this._text.charCodeAt(i0 + (1));
7653 if (ch == 102) { 7601 if (ch == (102)) {
7654 return 101/*TokenKind.IF*/; 7602 return (101);
7655 } 7603 }
7656 else if (ch == 110) { 7604 else if (ch == (110)) {
7657 return 102/*TokenKind.IN*/; 7605 return (102);
7658 } 7606 }
7659 else if (ch == 115) { 7607 else if (ch == (115)) {
7660 return 103/*TokenKind.IS*/; 7608 return (103);
7661 } 7609 }
7662 } 7610 }
7663 return 70/*TokenKind.IDENTIFIER*/; 7611 return (70);
7664 7612
7665 case 3: 7613 case (3):
7666 7614
7667 ch = this._text.charCodeAt(i0); 7615 ch = this._text.charCodeAt(i0);
7668 if (ch == 102) { 7616 if (ch == (102)) {
7669 if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2 ) == 114) return 100/*TokenKind.FOR*/; 7617 if (this._text.charCodeAt(i0 + (1)) == (111) && this._text.charCodeAt(i0 + (2)) == (114)) return (100);
7670 } 7618 }
7671 else if (ch == 103) { 7619 else if (ch == (103)) {
7672 if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2 ) == 116) return 74/*TokenKind.GET*/; 7620 if (this._text.charCodeAt(i0 + (1)) == (101) && this._text.charCodeAt(i0 + (2)) == (116)) return (74);
7673 } 7621 }
7674 else if (ch == 110) { 7622 else if (ch == (110)) {
7675 if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2 ) == 119) return 104/*TokenKind.NEW*/; 7623 if (this._text.charCodeAt(i0 + (1)) == (101) && this._text.charCodeAt(i0 + (2)) == (119)) return (104);
7676 } 7624 }
7677 else if (ch == 115) { 7625 else if (ch == (115)) {
7678 if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2 ) == 116) return 82/*TokenKind.SET*/; 7626 if (this._text.charCodeAt(i0 + (1)) == (101) && this._text.charCodeAt(i0 + (2)) == (116)) return (82);
7679 } 7627 }
7680 else if (ch == 116) { 7628 else if (ch == (116)) {
7681 if (this._text.charCodeAt(i0 + 1) == 114 && this._text.charCodeAt(i0 + 2 ) == 121) return 112/*TokenKind.TRY*/; 7629 if (this._text.charCodeAt(i0 + (1)) == (114) && this._text.charCodeAt(i0 + (2)) == (121)) return (112);
7682 } 7630 }
7683 else if (ch == 118) { 7631 else if (ch == (118)) {
7684 if (this._text.charCodeAt(i0 + 1) == 97 && this._text.charCodeAt(i0 + 2) == 114) return 113/*TokenKind.VAR*/; 7632 if (this._text.charCodeAt(i0 + (1)) == (97) && this._text.charCodeAt(i0 + (2)) == (114)) return (113);
7685 } 7633 }
7686 return 70/*TokenKind.IDENTIFIER*/; 7634 return (70);
7687 7635
7688 case 4: 7636 case (4):
7689 7637
7690 ch = this._text.charCodeAt(i0); 7638 ch = this._text.charCodeAt(i0);
7691 if (ch == 99) { 7639 if (ch == (99)) {
7692 if (this._text.charCodeAt(i0 + 1) == 97 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 101) return 88/*TokenKind.CASE*/; 7640 if (this._text.charCodeAt(i0 + (1)) == (97) && this._text.charCodeAt(i0 + (2)) == (115) && this._text.charCodeAt(i0 + (3)) == (101)) return (88);
7693 } 7641 }
7694 else if (ch == 101) { 7642 else if (ch == (101)) {
7695 if (this._text.charCodeAt(i0 + 1) == 108 && this._text.charCodeAt(i0 + 2 ) == 115 && this._text.charCodeAt(i0 + 3) == 101) return 95/*TokenKind.ELSE*/; 7643 if (this._text.charCodeAt(i0 + (1)) == (108) && this._text.charCodeAt(i0 + (2)) == (115) && this._text.charCodeAt(i0 + (3)) == (101)) return (95);
7696 } 7644 }
7697 else if (ch == 110) { 7645 else if (ch == (110)) {
7698 if (this._text.charCodeAt(i0 + 1) == 117 && this._text.charCodeAt(i0 + 2 ) == 108 && this._text.charCodeAt(i0 + 3) == 108) return 105/*TokenKind.NULL*/; 7646 if (this._text.charCodeAt(i0 + (1)) == (117) && this._text.charCodeAt(i0 + (2)) == (108) && this._text.charCodeAt(i0 + (3)) == (108)) return (105);
7699 } 7647 }
7700 else if (ch == 116) { 7648 else if (ch == (116)) {
7701 ch = this._text.charCodeAt(i0 + 1); 7649 ch = this._text.charCodeAt(i0 + (1));
7702 if (ch == 104) { 7650 if (ch == (104)) {
7703 if (this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 115) return 109/*TokenKind.THIS*/; 7651 if (this._text.charCodeAt(i0 + (2)) == (105) && this._text.charCodeAt( i0 + (3)) == (115)) return (109);
7704 } 7652 }
7705 else if (ch == 114) { 7653 else if (ch == (114)) {
7706 if (this._text.charCodeAt(i0 + 2) == 117 && this._text.charCodeAt(i0 + 3) == 101) return 111/*TokenKind.TRUE*/; 7654 if (this._text.charCodeAt(i0 + (2)) == (117) && this._text.charCodeAt( i0 + (3)) == (101)) return (111);
7707 } 7655 }
7708 } 7656 }
7709 else if (ch == 118) { 7657 else if (ch == (118)) {
7710 if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2 ) == 105 && this._text.charCodeAt(i0 + 3) == 100) return 114/*TokenKind.VOID*/; 7658 if (this._text.charCodeAt(i0 + (1)) == (111) && this._text.charCodeAt(i0 + (2)) == (105) && this._text.charCodeAt(i0 + (3)) == (100)) return (114);
7711 } 7659 }
7712 return 70/*TokenKind.IDENTIFIER*/; 7660 return (70);
7713 7661
7714 case 5: 7662 case (5):
7715 7663
7716 ch = this._text.charCodeAt(i0); 7664 ch = this._text.charCodeAt(i0);
7717 if (ch == 97) { 7665 if (ch == (97)) {
7718 if (this._text.charCodeAt(i0 + 1) == 119 && this._text.charCodeAt(i0 + 2 ) == 97 && this._text.charCodeAt(i0 + 3) == 105 && this._text.charCodeAt(i0 + 4) == 116) return 86/*TokenKind.AWAIT*/; 7666 if (this._text.charCodeAt(i0 + (1)) == (119) && this._text.charCodeAt(i0 + (2)) == (97) && this._text.charCodeAt(i0 + (3)) == (105) && this._text.charCo deAt(i0 + (4)) == (116)) return (86);
7719 } 7667 }
7720 else if (ch == 98) { 7668 else if (ch == (98)) {
7721 if (this._text.charCodeAt(i0 + 1) == 114 && this._text.charCodeAt(i0 + 2 ) == 101 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 107) return 87/*TokenKind.BREAK*/; 7669 if (this._text.charCodeAt(i0 + (1)) == (114) && this._text.charCodeAt(i0 + (2)) == (101) && this._text.charCodeAt(i0 + (3)) == (97) && this._text.charCo deAt(i0 + (4)) == (107)) return (87);
7722 } 7670 }
7723 else if (ch == 99) { 7671 else if (ch == (99)) {
7724 ch = this._text.charCodeAt(i0 + 1); 7672 ch = this._text.charCodeAt(i0 + (1));
7725 if (ch == 97) { 7673 if (ch == (97)) {
7726 if (this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 99 && this._text.charCodeAt(i0 + 4) == 104) return 89/*TokenKind.CATCH*/; 7674 if (this._text.charCodeAt(i0 + (2)) == (116) && this._text.charCodeAt( i0 + (3)) == (99) && this._text.charCodeAt(i0 + (4)) == (104)) return (89);
7727 } 7675 }
7728 else if (ch == 108) { 7676 else if (ch == (108)) {
7729 if (this._text.charCodeAt(i0 + 2) == 97 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 115) return 90/*TokenKind.CLASS*/; 7677 if (this._text.charCodeAt(i0 + (2)) == (97) && this._text.charCodeAt(i 0 + (3)) == (115) && this._text.charCodeAt(i0 + (4)) == (115)) return (90);
7730 } 7678 }
7731 else if (ch == 111) { 7679 else if (ch == (111)) {
7732 if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 116) return 91/*TokenKind.CONST*/ ; 7680 if (this._text.charCodeAt(i0 + (2)) == (110) && this._text.charCodeAt( i0 + (3)) == (115) && this._text.charCodeAt(i0 + (4)) == (116)) return (91);
7733 } 7681 }
7734 } 7682 }
7735 else if (ch == 102) { 7683 else if (ch == (102)) {
7736 ch = this._text.charCodeAt(i0 + 1); 7684 ch = this._text.charCodeAt(i0 + (1));
7737 if (ch == 97) { 7685 if (ch == (97)) {
7738 if (this._text.charCodeAt(i0 + 2) == 108 && this._text.charCodeAt(i0 + 3) == 115 && this._text.charCodeAt(i0 + 4) == 101) return 97/*TokenKind.FALSE*/ ; 7686 if (this._text.charCodeAt(i0 + (2)) == (108) && this._text.charCodeAt( i0 + (3)) == (115) && this._text.charCodeAt(i0 + (4)) == (101)) return (97);
7739 } 7687 }
7740 else if (ch == 105) { 7688 else if (ch == (105)) {
7741 if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 108) return 98/*TokenKind.FINAL*/; 7689 if (this._text.charCodeAt(i0 + (2)) == (110) && this._text.charCodeAt( i0 + (3)) == (97) && this._text.charCodeAt(i0 + (4)) == (108)) return (98);
7742 } 7690 }
7743 } 7691 }
7744 else if (ch == 115) { 7692 else if (ch == (115)) {
7745 if (this._text.charCodeAt(i0 + 1) == 117 && this._text.charCodeAt(i0 + 2 ) == 112 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4 ) == 114) return 107/*TokenKind.SUPER*/; 7693 if (this._text.charCodeAt(i0 + (1)) == (117) && this._text.charCodeAt(i0 + (2)) == (112) && this._text.charCodeAt(i0 + (3)) == (101) && this._text.charC odeAt(i0 + (4)) == (114)) return (107);
7746 } 7694 }
7747 else if (ch == 116) { 7695 else if (ch == (116)) {
7748 if (this._text.charCodeAt(i0 + 1) == 104 && this._text.charCodeAt(i0 + 2 ) == 114 && this._text.charCodeAt(i0 + 3) == 111 && this._text.charCodeAt(i0 + 4 ) == 119) return 110/*TokenKind.THROW*/; 7696 if (this._text.charCodeAt(i0 + (1)) == (104) && this._text.charCodeAt(i0 + (2)) == (114) && this._text.charCodeAt(i0 + (3)) == (111) && this._text.charC odeAt(i0 + (4)) == (119)) return (110);
7749 } 7697 }
7750 else if (ch == 119) { 7698 else if (ch == (119)) {
7751 if (this._text.charCodeAt(i0 + 1) == 104 && this._text.charCodeAt(i0 + 2 ) == 105 && this._text.charCodeAt(i0 + 3) == 108 && this._text.charCodeAt(i0 + 4 ) == 101) return 115/*TokenKind.WHILE*/; 7699 if (this._text.charCodeAt(i0 + (1)) == (104) && this._text.charCodeAt(i0 + (2)) == (105) && this._text.charCodeAt(i0 + (3)) == (108) && this._text.charC odeAt(i0 + (4)) == (101)) return (115);
7752 } 7700 }
7753 return 70/*TokenKind.IDENTIFIER*/; 7701 return (70);
7754 7702
7755 case 6: 7703 case (6):
7756 7704
7757 ch = this._text.charCodeAt(i0); 7705 ch = this._text.charCodeAt(i0);
7758 if (ch == 97) { 7706 if (ch == (97)) {
7759 if (this._text.charCodeAt(i0 + 1) == 115 && this._text.charCodeAt(i0 + 2 ) == 115 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4 ) == 114 && this._text.charCodeAt(i0 + 5) == 116) return 72/*TokenKind.ASSERT*/; 7707 if (this._text.charCodeAt(i0 + (1)) == (115) && this._text.charCodeAt(i0 + (2)) == (115) && this._text.charCodeAt(i0 + (3)) == (101) && this._text.charC odeAt(i0 + (4)) == (114) && this._text.charCodeAt(i0 + (5)) == (116)) return (72 );
7760 } 7708 }
7761 else if (ch == 105) { 7709 else if (ch == (105)) {
7762 if (this._text.charCodeAt(i0 + 1) == 109 && this._text.charCodeAt(i0 + 2 ) == 112 && this._text.charCodeAt(i0 + 3) == 111 && this._text.charCodeAt(i0 + 4 ) == 114 && this._text.charCodeAt(i0 + 5) == 116) return 76/*TokenKind.IMPORT*/; 7710 if (this._text.charCodeAt(i0 + (1)) == (109) && this._text.charCodeAt(i0 + (2)) == (112) && this._text.charCodeAt(i0 + (3)) == (111) && this._text.charC odeAt(i0 + (4)) == (114) && this._text.charCodeAt(i0 + (5)) == (116)) return (76 );
7763 } 7711 }
7764 else if (ch == 110) { 7712 else if (ch == (110)) {
7765 ch = this._text.charCodeAt(i0 + 1); 7713 ch = this._text.charCodeAt(i0 + (1));
7766 if (ch == 97) { 7714 if (ch == (97)) {
7767 if (this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 105 && this._text.charCodeAt(i0 + 4) == 118 && this._text.charCodeAt(i0 + 5) == 101) return 79/*TokenKind.NATIVE*/; 7715 if (this._text.charCodeAt(i0 + (2)) == (116) && this._text.charCodeAt( i0 + (3)) == (105) && this._text.charCodeAt(i0 + (4)) == (118) && this._text.cha rCodeAt(i0 + (5)) == (101)) return (79);
7768 } 7716 }
7769 else if (ch == 101) { 7717 else if (ch == (101)) {
7770 if (this._text.charCodeAt(i0 + 2) == 103 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 116 && this._text.charCodeAt(i0 + 5) == 101) return 80/*TokenKind.NEGATE*/; 7718 if (this._text.charCodeAt(i0 + (2)) == (103) && this._text.charCodeAt( i0 + (3)) == (97) && this._text.charCodeAt(i0 + (4)) == (116) && this._text.char CodeAt(i0 + (5)) == (101)) return (80);
7771 } 7719 }
7772 } 7720 }
7773 else if (ch == 114) { 7721 else if (ch == (114)) {
7774 if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2 ) == 116 && this._text.charCodeAt(i0 + 3) == 117 && this._text.charCodeAt(i0 + 4 ) == 114 && this._text.charCodeAt(i0 + 5) == 110) return 106/*TokenKind.RETURN*/ ; 7722 if (this._text.charCodeAt(i0 + (1)) == (101) && this._text.charCodeAt(i0 + (2)) == (116) && this._text.charCodeAt(i0 + (3)) == (117) && this._text.charC odeAt(i0 + (4)) == (114) && this._text.charCodeAt(i0 + (5)) == (110)) return (10 6);
7775 } 7723 }
7776 else if (ch == 115) { 7724 else if (ch == (115)) {
7777 ch = this._text.charCodeAt(i0 + 1); 7725 ch = this._text.charCodeAt(i0 + (1));
7778 if (ch == 111) { 7726 if (ch == (111)) {
7779 if (this._text.charCodeAt(i0 + 2) == 117 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4) == 99 && this._text.charCodeAt(i0 + 5) == 101) return 83/*TokenKind.SOURCE*/; 7727 if (this._text.charCodeAt(i0 + (2)) == (117) && this._text.charCodeAt( i0 + (3)) == (114) && this._text.charCodeAt(i0 + (4)) == (99) && this._text.char CodeAt(i0 + (5)) == (101)) return (83);
7780 } 7728 }
7781 else if (ch == 116) { 7729 else if (ch == (116)) {
7782 if (this._text.charCodeAt(i0 + 2) == 97 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 105 && this._text.charCodeAt(i0 + 5) == 99) return 84/*TokenKind.STATIC*/; 7730 if (this._text.charCodeAt(i0 + (2)) == (97) && this._text.charCodeAt(i 0 + (3)) == (116) && this._text.charCodeAt(i0 + (4)) == (105) && this._text.char CodeAt(i0 + (5)) == (99)) return (84);
7783 } 7731 }
7784 else if (ch == 119) { 7732 else if (ch == (119)) {
7785 if (this._text.charCodeAt(i0 + 2) == 105 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 99 && this._text.charCodeAt(i0 + 5) == 104) return 108/*TokenKind.SWITCH*/; 7733 if (this._text.charCodeAt(i0 + (2)) == (105) && this._text.charCodeAt( i0 + (3)) == (116) && this._text.charCodeAt(i0 + (4)) == (99) && this._text.char CodeAt(i0 + (5)) == (104)) return (108);
7786 } 7734 }
7787 } 7735 }
7788 return 70/*TokenKind.IDENTIFIER*/; 7736 return (70);
7789 7737
7790 case 7: 7738 case (7):
7791 7739
7792 ch = this._text.charCodeAt(i0); 7740 ch = this._text.charCodeAt(i0);
7793 if (ch == 100) { 7741 if (ch == (100)) {
7794 if (this._text.charCodeAt(i0 + 1) == 101 && this._text.charCodeAt(i0 + 2 ) == 102 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 117 && this._text.charCodeAt(i0 + 5) == 108 && this._text.charCodeAt(i0 + 6) == 116) return 93/*TokenKind.DEFAULT*/; 7742 if (this._text.charCodeAt(i0 + (1)) == (101) && this._text.charCodeAt(i0 + (2)) == (102) && this._text.charCodeAt(i0 + (3)) == (97) && this._text.charCo deAt(i0 + (4)) == (117) && this._text.charCodeAt(i0 + (5)) == (108) && this._tex t.charCodeAt(i0 + (6)) == (116)) return (93);
7795 } 7743 }
7796 else if (ch == 101) { 7744 else if (ch == (101)) {
7797 if (this._text.charCodeAt(i0 + 1) == 120 && this._text.charCodeAt(i0 + 2 ) == 116 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4 ) == 110 && this._text.charCodeAt(i0 + 5) == 100 && this._text.charCodeAt(i0 + 6 ) == 115) return 96/*TokenKind.EXTENDS*/; 7745 if (this._text.charCodeAt(i0 + (1)) == (120) && this._text.charCodeAt(i0 + (2)) == (116) && this._text.charCodeAt(i0 + (3)) == (101) && this._text.charC odeAt(i0 + (4)) == (110) && this._text.charCodeAt(i0 + (5)) == (100) && this._te xt.charCodeAt(i0 + (6)) == (115)) return (96);
7798 } 7746 }
7799 else if (ch == 102) { 7747 else if (ch == (102)) {
7800 ch = this._text.charCodeAt(i0 + 1); 7748 ch = this._text.charCodeAt(i0 + (1));
7801 if (ch == 97) { 7749 if (ch == (97)) {
7802 if (this._text.charCodeAt(i0 + 2) == 99 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 111 && this._text.charCodeAt(i0 + 5) == 114 && this._text.charCodeAt(i0 + 6) == 121) return 73/*TokenKind.FACTORY* /; 7750 if (this._text.charCodeAt(i0 + (2)) == (99) && this._text.charCodeAt(i 0 + (3)) == (116) && this._text.charCodeAt(i0 + (4)) == (111) && this._text.char CodeAt(i0 + (5)) == (114) && this._text.charCodeAt(i0 + (6)) == (121)) return (7 3);
7803 } 7751 }
7804 else if (ch == 105) { 7752 else if (ch == (105)) {
7805 if (this._text.charCodeAt(i0 + 2) == 110 && this._text.charCodeAt(i0 + 3) == 97 && this._text.charCodeAt(i0 + 4) == 108 && this._text.charCodeAt(i0 + 5) == 108 && this._text.charCodeAt(i0 + 6) == 121) return 99/*TokenKind.FINALLY* /; 7753 if (this._text.charCodeAt(i0 + (2)) == (110) && this._text.charCodeAt( i0 + (3)) == (97) && this._text.charCodeAt(i0 + (4)) == (108) && this._text.char CodeAt(i0 + (5)) == (108) && this._text.charCodeAt(i0 + (6)) == (121)) return (9 9);
7806 } 7754 }
7807 } 7755 }
7808 else if (ch == 108) { 7756 else if (ch == (108)) {
7809 if (this._text.charCodeAt(i0 + 1) == 105 && this._text.charCodeAt(i0 + 2 ) == 98 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4) == 97 && this._text.charCodeAt(i0 + 5) == 114 && this._text.charCodeAt(i0 + 6) == 121) return 78/*TokenKind.LIBRARY*/; 7757 if (this._text.charCodeAt(i0 + (1)) == (105) && this._text.charCodeAt(i0 + (2)) == (98) && this._text.charCodeAt(i0 + (3)) == (114) && this._text.charCo deAt(i0 + (4)) == (97) && this._text.charCodeAt(i0 + (5)) == (114) && this._text .charCodeAt(i0 + (6)) == (121)) return (78);
7810 } 7758 }
7811 else if (ch == 116) { 7759 else if (ch == (116)) {
7812 if (this._text.charCodeAt(i0 + 1) == 121 && this._text.charCodeAt(i0 + 2 ) == 112 && this._text.charCodeAt(i0 + 3) == 101 && this._text.charCodeAt(i0 + 4 ) == 100 && this._text.charCodeAt(i0 + 5) == 101 && this._text.charCodeAt(i0 + 6 ) == 102) return 85/*TokenKind.TYPEDEF*/; 7760 if (this._text.charCodeAt(i0 + (1)) == (121) && this._text.charCodeAt(i0 + (2)) == (112) && this._text.charCodeAt(i0 + (3)) == (101) && this._text.charC odeAt(i0 + (4)) == (100) && this._text.charCodeAt(i0 + (5)) == (101) && this._te xt.charCodeAt(i0 + (6)) == (102)) return (85);
7813 } 7761 }
7814 return 70/*TokenKind.IDENTIFIER*/; 7762 return (70);
7815 7763
7816 case 8: 7764 case (8):
7817 7765
7818 ch = this._text.charCodeAt(i0); 7766 ch = this._text.charCodeAt(i0);
7819 if (ch == 97) { 7767 if (ch == (97)) {
7820 if (this._text.charCodeAt(i0 + 1) == 98 && this._text.charCodeAt(i0 + 2) == 115 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 97 && this._text.charCodeAt(i0 + 6) == 99 && this._text.charCodeAt(i0 + 7) == 116) return 71/*TokenKind.ABSTRACT*/; 7768 if (this._text.charCodeAt(i0 + (1)) == (98) && this._text.charCodeAt(i0 + (2)) == (115) && this._text.charCodeAt(i0 + (3)) == (116) && this._text.charCo deAt(i0 + (4)) == (114) && this._text.charCodeAt(i0 + (5)) == (97) && this._text .charCodeAt(i0 + (6)) == (99) && this._text.charCodeAt(i0 + (7)) == (116)) retur n (71);
7821 } 7769 }
7822 else if (ch == 99) { 7770 else if (ch == (99)) {
7823 if (this._text.charCodeAt(i0 + 1) == 111 && this._text.charCodeAt(i0 + 2 ) == 110 && this._text.charCodeAt(i0 + 3) == 116 && this._text.charCodeAt(i0 + 4 ) == 105 && this._text.charCodeAt(i0 + 5) == 110 && this._text.charCodeAt(i0 + 6 ) == 117 && this._text.charCodeAt(i0 + 7) == 101) return 92/*TokenKind.CONTINUE* /; 7771 if (this._text.charCodeAt(i0 + (1)) == (111) && this._text.charCodeAt(i0 + (2)) == (110) && this._text.charCodeAt(i0 + (3)) == (116) && this._text.charC odeAt(i0 + (4)) == (105) && this._text.charCodeAt(i0 + (5)) == (110) && this._te xt.charCodeAt(i0 + (6)) == (117) && this._text.charCodeAt(i0 + (7)) == (101)) re turn (92);
7824 } 7772 }
7825 else if (ch == 111) { 7773 else if (ch == (111)) {
7826 if (this._text.charCodeAt(i0 + 1) == 112 && this._text.charCodeAt(i0 + 2 ) == 101 && this._text.charCodeAt(i0 + 3) == 114 && this._text.charCodeAt(i0 + 4 ) == 97 && this._text.charCodeAt(i0 + 5) == 116 && this._text.charCodeAt(i0 + 6) == 111 && this._text.charCodeAt(i0 + 7) == 114) return 81/*TokenKind.OPERATOR*/ ; 7774 if (this._text.charCodeAt(i0 + (1)) == (112) && this._text.charCodeAt(i0 + (2)) == (101) && this._text.charCodeAt(i0 + (3)) == (114) && this._text.charC odeAt(i0 + (4)) == (97) && this._text.charCodeAt(i0 + (5)) == (116) && this._tex t.charCodeAt(i0 + (6)) == (111) && this._text.charCodeAt(i0 + (7)) == (114)) ret urn (81);
7827 } 7775 }
7828 return 70/*TokenKind.IDENTIFIER*/; 7776 return (70);
7829 7777
7830 case 9: 7778 case (9):
7831 7779
7832 if (this._text.charCodeAt(i0) == 105 && this._text.charCodeAt(i0 + 1) == 1 10 && this._text.charCodeAt(i0 + 2) == 116 && this._text.charCodeAt(i0 + 3) == 1 01 && this._text.charCodeAt(i0 + 4) == 114 && this._text.charCodeAt(i0 + 5) == 1 02 && this._text.charCodeAt(i0 + 6) == 97 && this._text.charCodeAt(i0 + 7) == 99 && this._text.charCodeAt(i0 + 8) == 101) return 77/*TokenKind.INTERFACE*/; 7780 if (this._text.charCodeAt(i0) == (105) && this._text.charCodeAt(i0 + (1)) == (110) && this._text.charCodeAt(i0 + (2)) == (116) && this._text.charCodeAt(i0 + (3)) == (101) && this._text.charCodeAt(i0 + (4)) == (114) && this._text.charC odeAt(i0 + (5)) == (102) && this._text.charCodeAt(i0 + (6)) == (97) && this._tex t.charCodeAt(i0 + (7)) == (99) && this._text.charCodeAt(i0 + (8)) == (101)) retu rn (77);
7833 return 70/*TokenKind.IDENTIFIER*/; 7781 return (70);
7834 7782
7835 case 10: 7783 case (10):
7836 7784
7837 if (this._text.charCodeAt(i0) == 105 && this._text.charCodeAt(i0 + 1) == 1 09 && this._text.charCodeAt(i0 + 2) == 112 && this._text.charCodeAt(i0 + 3) == 1 08 && this._text.charCodeAt(i0 + 4) == 101 && this._text.charCodeAt(i0 + 5) == 1 09 && this._text.charCodeAt(i0 + 6) == 101 && this._text.charCodeAt(i0 + 7) == 1 10 && this._text.charCodeAt(i0 + 8) == 116 && this._text.charCodeAt(i0 + 9) == 1 15) return 75/*TokenKind.IMPLEMENTS*/; 7785 if (this._text.charCodeAt(i0) == (105) && this._text.charCodeAt(i0 + (1)) == (109) && this._text.charCodeAt(i0 + (2)) == (112) && this._text.charCodeAt(i0 + (3)) == (108) && this._text.charCodeAt(i0 + (4)) == (101) && this._text.charC odeAt(i0 + (5)) == (109) && this._text.charCodeAt(i0 + (6)) == (101) && this._te xt.charCodeAt(i0 + (7)) == (110) && this._text.charCodeAt(i0 + (8)) == (116) && this._text.charCodeAt(i0 + (9)) == (115)) return (75);
7838 return 70/*TokenKind.IDENTIFIER*/; 7786 return (70);
7839 7787
7840 default: 7788 default:
7841 7789
7842 return 70/*TokenKind.IDENTIFIER*/; 7790 return (70);
7843 7791
7844 } 7792 }
7845 } 7793 }
7846 Tokenizer.prototype.next$0 = Tokenizer.prototype.next; 7794 Tokenizer.prototype.next$0 = Tokenizer.prototype.next;
7847 // ********** Code for TokenKind ************** 7795 // ********** Code for TokenKind **************
7848 function TokenKind() {} 7796 function TokenKind() {}
7849 TokenKind.kindToString = function(kind) { 7797 TokenKind.kindToString = function(kind) {
7850 switch (kind) { 7798 switch (kind) {
7851 case 1/*TokenKind.END_OF_FILE*/: 7799 case (1):
7852 7800
7853 return "end of file"; 7801 return "end of file";
7854 7802
7855 case 2/*TokenKind.LPAREN*/: 7803 case (2):
7856 7804
7857 return "("; 7805 return "(";
7858 7806
7859 case 3/*TokenKind.RPAREN*/: 7807 case (3):
7860 7808
7861 return ")"; 7809 return ")";
7862 7810
7863 case 4/*TokenKind.LBRACK*/: 7811 case (4):
7864 7812
7865 return "["; 7813 return "[";
7866 7814
7867 case 5/*TokenKind.RBRACK*/: 7815 case (5):
7868 7816
7869 return "]"; 7817 return "]";
7870 7818
7871 case 6/*TokenKind.LBRACE*/: 7819 case (6):
7872 7820
7873 return "{"; 7821 return "{";
7874 7822
7875 case 7/*TokenKind.RBRACE*/: 7823 case (7):
7876 7824
7877 return "}"; 7825 return "}";
7878 7826
7879 case 8/*TokenKind.COLON*/: 7827 case (8):
7880 7828
7881 return ":"; 7829 return ":";
7882 7830
7883 case 9/*TokenKind.ARROW*/: 7831 case (9):
7884 7832
7885 return "=>"; 7833 return "=>";
7886 7834
7887 case 10/*TokenKind.SEMICOLON*/: 7835 case (10):
7888 7836
7889 return ";"; 7837 return ";";
7890 7838
7891 case 11/*TokenKind.COMMA*/: 7839 case (11):
7892 7840
7893 return ","; 7841 return ",";
7894 7842
7895 case 12/*TokenKind.HASH*/: 7843 case (12):
7896 7844
7897 return "#"; 7845 return "#";
7898 7846
7899 case 13/*TokenKind.HASHBANG*/: 7847 case (13):
7900 7848
7901 return "#!"; 7849 return "#!";
7902 7850
7903 case 14/*TokenKind.DOT*/: 7851 case (14):
7904 7852
7905 return "."; 7853 return ".";
7906 7854
7907 case 15/*TokenKind.ELLIPSIS*/: 7855 case (15):
7908 7856
7909 return "..."; 7857 return "...";
7910 7858
7911 case 16/*TokenKind.INCR*/: 7859 case (16):
7912 7860
7913 return "++"; 7861 return "++";
7914 7862
7915 case 17/*TokenKind.DECR*/: 7863 case (17):
7916 7864
7917 return "--"; 7865 return "--";
7918 7866
7919 case 18/*TokenKind.BIT_NOT*/: 7867 case (18):
7920 7868
7921 return "~"; 7869 return "~";
7922 7870
7923 case 19/*TokenKind.NOT*/: 7871 case (19):
7924 7872
7925 return "!"; 7873 return "!";
7926 7874
7927 case 20/*TokenKind.ASSIGN*/: 7875 case (20):
7928 7876
7929 return "="; 7877 return "=";
7930 7878
7931 case 21/*TokenKind.ASSIGN_OR*/: 7879 case (21):
7932 7880
7933 return "|="; 7881 return "|=";
7934 7882
7935 case 22/*TokenKind.ASSIGN_XOR*/: 7883 case (22):
7936 7884
7937 return "^="; 7885 return "^=";
7938 7886
7939 case 23/*TokenKind.ASSIGN_AND*/: 7887 case (23):
7940 7888
7941 return "&="; 7889 return "&=";
7942 7890
7943 case 24/*TokenKind.ASSIGN_SHL*/: 7891 case (24):
7944 7892
7945 return "<<="; 7893 return "<<=";
7946 7894
7947 case 25/*TokenKind.ASSIGN_SAR*/: 7895 case (25):
7948 7896
7949 return ">>="; 7897 return ">>=";
7950 7898
7951 case 26/*TokenKind.ASSIGN_SHR*/: 7899 case (26):
7952 7900
7953 return ">>>="; 7901 return ">>>=";
7954 7902
7955 case 27/*TokenKind.ASSIGN_ADD*/: 7903 case (27):
7956 7904
7957 return "+="; 7905 return "+=";
7958 7906
7959 case 28/*TokenKind.ASSIGN_SUB*/: 7907 case (28):
7960 7908
7961 return "-="; 7909 return "-=";
7962 7910
7963 case 29/*TokenKind.ASSIGN_MUL*/: 7911 case (29):
7964 7912
7965 return "*="; 7913 return "*=";
7966 7914
7967 case 30/*TokenKind.ASSIGN_DIV*/: 7915 case (30):
7968 7916
7969 return "/="; 7917 return "/=";
7970 7918
7971 case 31/*TokenKind.ASSIGN_TRUNCDIV*/: 7919 case (31):
7972 7920
7973 return "~/="; 7921 return "~/=";
7974 7922
7975 case 32/*TokenKind.ASSIGN_MOD*/: 7923 case (32):
7976 7924
7977 return "%="; 7925 return "%=";
7978 7926
7979 case 33/*TokenKind.CONDITIONAL*/: 7927 case (33):
7980 7928
7981 return "?"; 7929 return "?";
7982 7930
7983 case 34/*TokenKind.OR*/: 7931 case (34):
7984 7932
7985 return "||"; 7933 return "||";
7986 7934
7987 case 35/*TokenKind.AND*/: 7935 case (35):
7988 7936
7989 return "&&"; 7937 return "&&";
7990 7938
7991 case 36/*TokenKind.BIT_OR*/: 7939 case (36):
7992 7940
7993 return "|"; 7941 return "|";
7994 7942
7995 case 37/*TokenKind.BIT_XOR*/: 7943 case (37):
7996 7944
7997 return "^"; 7945 return "^";
7998 7946
7999 case 38/*TokenKind.BIT_AND*/: 7947 case (38):
8000 7948
8001 return "&"; 7949 return "&";
8002 7950
8003 case 39/*TokenKind.SHL*/: 7951 case (39):
8004 7952
8005 return "<<"; 7953 return "<<";
8006 7954
8007 case 40/*TokenKind.SAR*/: 7955 case (40):
8008 7956
8009 return ">>"; 7957 return ">>";
8010 7958
8011 case 41/*TokenKind.SHR*/: 7959 case (41):
8012 7960
8013 return ">>>"; 7961 return ">>>";
8014 7962
8015 case 42/*TokenKind.ADD*/: 7963 case (42):
8016 7964
8017 return "+"; 7965 return "+";
8018 7966
8019 case 43/*TokenKind.SUB*/: 7967 case (43):
8020 7968
8021 return "-"; 7969 return "-";
8022 7970
8023 case 44/*TokenKind.MUL*/: 7971 case (44):
8024 7972
8025 return "*"; 7973 return "*";
8026 7974
8027 case 45/*TokenKind.DIV*/: 7975 case (45):
8028 7976
8029 return "/"; 7977 return "/";
8030 7978
8031 case 46/*TokenKind.TRUNCDIV*/: 7979 case (46):
8032 7980
8033 return "~/"; 7981 return "~/";
8034 7982
8035 case 47/*TokenKind.MOD*/: 7983 case (47):
8036 7984
8037 return "%"; 7985 return "%";
8038 7986
8039 case 48/*TokenKind.EQ*/: 7987 case (48):
8040 7988
8041 return "=="; 7989 return "==";
8042 7990
8043 case 49/*TokenKind.NE*/: 7991 case (49):
8044 7992
8045 return "!="; 7993 return "!=";
8046 7994
8047 case 50/*TokenKind.EQ_STRICT*/: 7995 case (50):
8048 7996
8049 return "==="; 7997 return "===";
8050 7998
8051 case 51/*TokenKind.NE_STRICT*/: 7999 case (51):
8052 8000
8053 return "!=="; 8001 return "!==";
8054 8002
8055 case 52/*TokenKind.LT*/: 8003 case (52):
8056 8004
8057 return "<"; 8005 return "<";
8058 8006
8059 case 53/*TokenKind.GT*/: 8007 case (53):
8060 8008
8061 return ">"; 8009 return ">";
8062 8010
8063 case 54/*TokenKind.LTE*/: 8011 case (54):
8064 8012
8065 return "<="; 8013 return "<=";
8066 8014
8067 case 55/*TokenKind.GTE*/: 8015 case (55):
8068 8016
8069 return ">="; 8017 return ">=";
8070 8018
8071 case 56/*TokenKind.INDEX*/: 8019 case (56):
8072 8020
8073 return "[]"; 8021 return "[]";
8074 8022
8075 case 57/*TokenKind.SETINDEX*/: 8023 case (57):
8076 8024
8077 return "[]="; 8025 return "[]=";
8078 8026
8079 case 58/*TokenKind.STRING*/: 8027 case (58):
8080 8028
8081 return "string"; 8029 return "string";
8082 8030
8083 case 59/*TokenKind.STRING_PART*/: 8031 case (59):
8084 8032
8085 return "string part"; 8033 return "string part";
8086 8034
8087 case 60/*TokenKind.INTEGER*/: 8035 case (60):
8088 8036
8089 return "integer"; 8037 return "integer";
8090 8038
8091 case 61/*TokenKind.HEX_INTEGER*/: 8039 case (61):
8092 8040
8093 return "hex integer"; 8041 return "hex integer";
8094 8042
8095 case 62/*TokenKind.DOUBLE*/: 8043 case (62):
8096 8044
8097 return "double"; 8045 return "double";
8098 8046
8099 case 63/*TokenKind.WHITESPACE*/: 8047 case (63):
8100 8048
8101 return "whitespace"; 8049 return "whitespace";
8102 8050
8103 case 64/*TokenKind.COMMENT*/: 8051 case (64):
8104 8052
8105 return "comment"; 8053 return "comment";
8106 8054
8107 case 65/*TokenKind.ERROR*/: 8055 case (65):
8108 8056
8109 return "error"; 8057 return "error";
8110 8058
8111 case 66/*TokenKind.INCOMPLETE_STRING*/: 8059 case (66):
8112 8060
8113 return "incomplete string"; 8061 return "incomplete string";
8114 8062
8115 case 67/*TokenKind.INCOMPLETE_COMMENT*/: 8063 case (67):
8116 8064
8117 return "incomplete comment"; 8065 return "incomplete comment";
8118 8066
8119 case 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/: 8067 case (68):
8120 8068
8121 return "incomplete multiline string dq"; 8069 return "incomplete multiline string dq";
8122 8070
8123 case 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/: 8071 case (69):
8124 8072
8125 return "incomplete multiline string sq"; 8073 return "incomplete multiline string sq";
8126 8074
8127 case 70/*TokenKind.IDENTIFIER*/: 8075 case (70):
8128 8076
8129 return "identifier"; 8077 return "identifier";
8130 8078
8131 case 71/*TokenKind.ABSTRACT*/: 8079 case (71):
8132 8080
8133 return "pseudo-keyword 'abstract'"; 8081 return "pseudo-keyword 'abstract'";
8134 8082
8135 case 72/*TokenKind.ASSERT*/: 8083 case (72):
8136 8084
8137 return "pseudo-keyword 'assert'"; 8085 return "pseudo-keyword 'assert'";
8138 8086
8139 case 90/*TokenKind.CLASS*/: 8087 case (90):
8140 8088
8141 return "pseudo-keyword 'class'"; 8089 return "pseudo-keyword 'class'";
8142 8090
8143 case 96/*TokenKind.EXTENDS*/: 8091 case (96):
8144 8092
8145 return "pseudo-keyword 'extends'"; 8093 return "pseudo-keyword 'extends'";
8146 8094
8147 case 73/*TokenKind.FACTORY*/: 8095 case (73):
8148 8096
8149 return "pseudo-keyword 'factory'"; 8097 return "pseudo-keyword 'factory'";
8150 8098
8151 case 74/*TokenKind.GET*/: 8099 case (74):
8152 8100
8153 return "pseudo-keyword 'get'"; 8101 return "pseudo-keyword 'get'";
8154 8102
8155 case 75/*TokenKind.IMPLEMENTS*/: 8103 case (75):
8156 8104
8157 return "pseudo-keyword 'implements'"; 8105 return "pseudo-keyword 'implements'";
8158 8106
8159 case 76/*TokenKind.IMPORT*/: 8107 case (76):
8160 8108
8161 return "pseudo-keyword 'import'"; 8109 return "pseudo-keyword 'import'";
8162 8110
8163 case 77/*TokenKind.INTERFACE*/: 8111 case (77):
8164 8112
8165 return "pseudo-keyword 'interface'"; 8113 return "pseudo-keyword 'interface'";
8166 8114
8167 case 78/*TokenKind.LIBRARY*/: 8115 case (78):
8168 8116
8169 return "pseudo-keyword 'library'"; 8117 return "pseudo-keyword 'library'";
8170 8118
8171 case 79/*TokenKind.NATIVE*/: 8119 case (79):
8172 8120
8173 return "pseudo-keyword 'native'"; 8121 return "pseudo-keyword 'native'";
8174 8122
8175 case 80/*TokenKind.NEGATE*/: 8123 case (80):
8176 8124
8177 return "pseudo-keyword 'negate'"; 8125 return "pseudo-keyword 'negate'";
8178 8126
8179 case 81/*TokenKind.OPERATOR*/: 8127 case (81):
8180 8128
8181 return "pseudo-keyword 'operator'"; 8129 return "pseudo-keyword 'operator'";
8182 8130
8183 case 82/*TokenKind.SET*/: 8131 case (82):
8184 8132
8185 return "pseudo-keyword 'set'"; 8133 return "pseudo-keyword 'set'";
8186 8134
8187 case 83/*TokenKind.SOURCE*/: 8135 case (83):
8188 8136
8189 return "pseudo-keyword 'source'"; 8137 return "pseudo-keyword 'source'";
8190 8138
8191 case 84/*TokenKind.STATIC*/: 8139 case (84):
8192 8140
8193 return "pseudo-keyword 'static'"; 8141 return "pseudo-keyword 'static'";
8194 8142
8195 case 85/*TokenKind.TYPEDEF*/: 8143 case (85):
8196 8144
8197 return "pseudo-keyword 'typedef'"; 8145 return "pseudo-keyword 'typedef'";
8198 8146
8199 case 86/*TokenKind.AWAIT*/: 8147 case (86):
8200 8148
8201 return "keyword 'await'"; 8149 return "keyword 'await'";
8202 8150
8203 case 87/*TokenKind.BREAK*/: 8151 case (87):
8204 8152
8205 return "keyword 'break'"; 8153 return "keyword 'break'";
8206 8154
8207 case 88/*TokenKind.CASE*/: 8155 case (88):
8208 8156
8209 return "keyword 'case'"; 8157 return "keyword 'case'";
8210 8158
8211 case 89/*TokenKind.CATCH*/: 8159 case (89):
8212 8160
8213 return "keyword 'catch'"; 8161 return "keyword 'catch'";
8214 8162
8215 case 91/*TokenKind.CONST*/: 8163 case (91):
8216 8164
8217 return "keyword 'const'"; 8165 return "keyword 'const'";
8218 8166
8219 case 92/*TokenKind.CONTINUE*/: 8167 case (92):
8220 8168
8221 return "keyword 'continue'"; 8169 return "keyword 'continue'";
8222 8170
8223 case 93/*TokenKind.DEFAULT*/: 8171 case (93):
8224 8172
8225 return "keyword 'default'"; 8173 return "keyword 'default'";
8226 8174
8227 case 94/*TokenKind.DO*/: 8175 case (94):
8228 8176
8229 return "keyword 'do'"; 8177 return "keyword 'do'";
8230 8178
8231 case 95/*TokenKind.ELSE*/: 8179 case (95):
8232 8180
8233 return "keyword 'else'"; 8181 return "keyword 'else'";
8234 8182
8235 case 97/*TokenKind.FALSE*/: 8183 case (97):
8236 8184
8237 return "keyword 'false'"; 8185 return "keyword 'false'";
8238 8186
8239 case 98/*TokenKind.FINAL*/: 8187 case (98):
8240 8188
8241 return "keyword 'final'"; 8189 return "keyword 'final'";
8242 8190
8243 case 99/*TokenKind.FINALLY*/: 8191 case (99):
8244 8192
8245 return "keyword 'finally'"; 8193 return "keyword 'finally'";
8246 8194
8247 case 100/*TokenKind.FOR*/: 8195 case (100):
8248 8196
8249 return "keyword 'for'"; 8197 return "keyword 'for'";
8250 8198
8251 case 101/*TokenKind.IF*/: 8199 case (101):
8252 8200
8253 return "keyword 'if'"; 8201 return "keyword 'if'";
8254 8202
8255 case 102/*TokenKind.IN*/: 8203 case (102):
8256 8204
8257 return "keyword 'in'"; 8205 return "keyword 'in'";
8258 8206
8259 case 103/*TokenKind.IS*/: 8207 case (103):
8260 8208
8261 return "keyword 'is'"; 8209 return "keyword 'is'";
8262 8210
8263 case 104/*TokenKind.NEW*/: 8211 case (104):
8264 8212
8265 return "keyword 'new'"; 8213 return "keyword 'new'";
8266 8214
8267 case 105/*TokenKind.NULL*/: 8215 case (105):
8268 8216
8269 return "keyword 'null'"; 8217 return "keyword 'null'";
8270 8218
8271 case 106/*TokenKind.RETURN*/: 8219 case (106):
8272 8220
8273 return "keyword 'return'"; 8221 return "keyword 'return'";
8274 8222
8275 case 107/*TokenKind.SUPER*/: 8223 case (107):
8276 8224
8277 return "keyword 'super'"; 8225 return "keyword 'super'";
8278 8226
8279 case 108/*TokenKind.SWITCH*/: 8227 case (108):
8280 8228
8281 return "keyword 'switch'"; 8229 return "keyword 'switch'";
8282 8230
8283 case 109/*TokenKind.THIS*/: 8231 case (109):
8284 8232
8285 return "keyword 'this'"; 8233 return "keyword 'this'";
8286 8234
8287 case 110/*TokenKind.THROW*/: 8235 case (110):
8288 8236
8289 return "keyword 'throw'"; 8237 return "keyword 'throw'";
8290 8238
8291 case 111/*TokenKind.TRUE*/: 8239 case (111):
8292 8240
8293 return "keyword 'true'"; 8241 return "keyword 'true'";
8294 8242
8295 case 112/*TokenKind.TRY*/: 8243 case (112):
8296 8244
8297 return "keyword 'try'"; 8245 return "keyword 'try'";
8298 8246
8299 case 113/*TokenKind.VAR*/: 8247 case (113):
8300 8248
8301 return "keyword 'var'"; 8249 return "keyword 'var'";
8302 8250
8303 case 114/*TokenKind.VOID*/: 8251 case (114):
8304 8252
8305 return "keyword 'void'"; 8253 return "keyword 'void'";
8306 8254
8307 case 115/*TokenKind.WHILE*/: 8255 case (115):
8308 8256
8309 return "keyword 'while'"; 8257 return "keyword 'while'";
8310 8258
8311 default: 8259 default:
8312 8260
8313 return "TokenKind(" + kind.toString() + ")"; 8261 return "TokenKind(" + kind.toString() + ")";
8314 8262
8315 } 8263 }
8316 } 8264 }
8317 TokenKind.isIdentifier = function(kind) { 8265 TokenKind.isIdentifier = function(kind) {
8318 return kind >= 70/*TokenKind.IDENTIFIER*/ && kind < 86/*TokenKind.AWAIT*/; 8266 return kind >= (70) && kind < (86);
8319 } 8267 }
8320 TokenKind.infixPrecedence = function(kind) { 8268 TokenKind.infixPrecedence = function(kind) {
8321 switch (kind) { 8269 switch (kind) {
8322 case 20/*TokenKind.ASSIGN*/: 8270 case (20):
8323 8271
8324 return 2; 8272 return (2);
8325 8273
8326 case 21/*TokenKind.ASSIGN_OR*/: 8274 case (21):
8327 8275
8328 return 2; 8276 return (2);
8329 8277
8330 case 22/*TokenKind.ASSIGN_XOR*/: 8278 case (22):
8331 8279
8332 return 2; 8280 return (2);
8333 8281
8334 case 23/*TokenKind.ASSIGN_AND*/: 8282 case (23):
8335 8283
8336 return 2; 8284 return (2);
8337 8285
8338 case 24/*TokenKind.ASSIGN_SHL*/: 8286 case (24):
8339 8287
8340 return 2; 8288 return (2);
8341 8289
8342 case 25/*TokenKind.ASSIGN_SAR*/: 8290 case (25):
8343 8291
8344 return 2; 8292 return (2);
8345 8293
8346 case 26/*TokenKind.ASSIGN_SHR*/: 8294 case (26):
8347 8295
8348 return 2; 8296 return (2);
8349 8297
8350 case 27/*TokenKind.ASSIGN_ADD*/: 8298 case (27):
8351 8299
8352 return 2; 8300 return (2);
8353 8301
8354 case 28/*TokenKind.ASSIGN_SUB*/: 8302 case (28):
8355 8303
8356 return 2; 8304 return (2);
8357 8305
8358 case 29/*TokenKind.ASSIGN_MUL*/: 8306 case (29):
8359 8307
8360 return 2; 8308 return (2);
8361 8309
8362 case 30/*TokenKind.ASSIGN_DIV*/: 8310 case (30):
8363 8311
8364 return 2; 8312 return (2);
8365 8313
8366 case 31/*TokenKind.ASSIGN_TRUNCDIV*/: 8314 case (31):
8367 8315
8368 return 2; 8316 return (2);
8369 8317
8370 case 32/*TokenKind.ASSIGN_MOD*/: 8318 case (32):
8371 8319
8372 return 2; 8320 return (2);
8373 8321
8374 case 33/*TokenKind.CONDITIONAL*/: 8322 case (33):
8375 8323
8376 return 3; 8324 return (3);
8377 8325
8378 case 34/*TokenKind.OR*/: 8326 case (34):
8379 8327
8380 return 4; 8328 return (4);
8381 8329
8382 case 35/*TokenKind.AND*/: 8330 case (35):
8383 8331
8384 return 5; 8332 return (5);
8385 8333
8386 case 36/*TokenKind.BIT_OR*/: 8334 case (36):
8387 8335
8388 return 6; 8336 return (6);
8389 8337
8390 case 37/*TokenKind.BIT_XOR*/: 8338 case (37):
8391 8339
8392 return 7; 8340 return (7);
8393 8341
8394 case 38/*TokenKind.BIT_AND*/: 8342 case (38):
8395 8343
8396 return 8; 8344 return (8);
8397 8345
8398 case 39/*TokenKind.SHL*/: 8346 case (39):
8399 8347
8400 return 11; 8348 return (11);
8401 8349
8402 case 40/*TokenKind.SAR*/: 8350 case (40):
8403 8351
8404 return 11; 8352 return (11);
8405 8353
8406 case 41/*TokenKind.SHR*/: 8354 case (41):
8407 8355
8408 return 11; 8356 return (11);
8409 8357
8410 case 42/*TokenKind.ADD*/: 8358 case (42):
8411 8359
8412 return 12; 8360 return (12);
8413 8361
8414 case 43/*TokenKind.SUB*/: 8362 case (43):
8415 8363
8416 return 12; 8364 return (12);
8417 8365
8418 case 44/*TokenKind.MUL*/: 8366 case (44):
8419 8367
8420 return 13; 8368 return (13);
8421 8369
8422 case 45/*TokenKind.DIV*/: 8370 case (45):
8423 8371
8424 return 13; 8372 return (13);
8425 8373
8426 case 46/*TokenKind.TRUNCDIV*/: 8374 case (46):
8427 8375
8428 return 13; 8376 return (13);
8429 8377
8430 case 47/*TokenKind.MOD*/: 8378 case (47):
8431 8379
8432 return 13; 8380 return (13);
8433 8381
8434 case 48/*TokenKind.EQ*/: 8382 case (48):
8435 8383
8436 return 9; 8384 return (9);
8437 8385
8438 case 49/*TokenKind.NE*/: 8386 case (49):
8439 8387
8440 return 9; 8388 return (9);
8441 8389
8442 case 50/*TokenKind.EQ_STRICT*/: 8390 case (50):
8443 8391
8444 return 9; 8392 return (9);
8445 8393
8446 case 51/*TokenKind.NE_STRICT*/: 8394 case (51):
8447 8395
8448 return 9; 8396 return (9);
8449 8397
8450 case 52/*TokenKind.LT*/: 8398 case (52):
8451 8399
8452 return 10; 8400 return (10);
8453 8401
8454 case 53/*TokenKind.GT*/: 8402 case (53):
8455 8403
8456 return 10; 8404 return (10);
8457 8405
8458 case 54/*TokenKind.LTE*/: 8406 case (54):
8459 8407
8460 return 10; 8408 return (10);
8461 8409
8462 case 55/*TokenKind.GTE*/: 8410 case (55):
8463 8411
8464 return 10; 8412 return (10);
8465 8413
8466 case 103/*TokenKind.IS*/: 8414 case (103):
8467 8415
8468 return 10; 8416 return (10);
8469 8417
8470 default: 8418 default:
8471 8419
8472 return -1; 8420 return (-1);
8473 8421
8474 } 8422 }
8475 } 8423 }
8476 TokenKind.rawOperatorFromMethod = function(name) { 8424 TokenKind.rawOperatorFromMethod = function(name) {
8477 switch (name) { 8425 switch (name) {
8478 case ":bit_not": 8426 case ":bit_not":
8479 8427
8480 return "~"; 8428 return "~";
8481 8429
8482 case ":bit_or": 8430 case ":bit_or":
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
8556 return "[]="; 8504 return "[]=";
8557 8505
8558 case ":ne": 8506 case ":ne":
8559 8507
8560 return "!="; 8508 return "!=";
8561 8509
8562 } 8510 }
8563 } 8511 }
8564 TokenKind.binaryMethodName = function(kind) { 8512 TokenKind.binaryMethodName = function(kind) {
8565 switch (kind) { 8513 switch (kind) {
8566 case 18/*TokenKind.BIT_NOT*/: 8514 case (18):
8567 8515
8568 return ":bit_not"; 8516 return ":bit_not";
8569 8517
8570 case 36/*TokenKind.BIT_OR*/: 8518 case (36):
8571 8519
8572 return ":bit_or"; 8520 return ":bit_or";
8573 8521
8574 case 37/*TokenKind.BIT_XOR*/: 8522 case (37):
8575 8523
8576 return ":bit_xor"; 8524 return ":bit_xor";
8577 8525
8578 case 38/*TokenKind.BIT_AND*/: 8526 case (38):
8579 8527
8580 return ":bit_and"; 8528 return ":bit_and";
8581 8529
8582 case 39/*TokenKind.SHL*/: 8530 case (39):
8583 8531
8584 return ":shl"; 8532 return ":shl";
8585 8533
8586 case 40/*TokenKind.SAR*/: 8534 case (40):
8587 8535
8588 return ":sar"; 8536 return ":sar";
8589 8537
8590 case 41/*TokenKind.SHR*/: 8538 case (41):
8591 8539
8592 return ":shr"; 8540 return ":shr";
8593 8541
8594 case 42/*TokenKind.ADD*/: 8542 case (42):
8595 8543
8596 return ":add"; 8544 return ":add";
8597 8545
8598 case 43/*TokenKind.SUB*/: 8546 case (43):
8599 8547
8600 return ":sub"; 8548 return ":sub";
8601 8549
8602 case 44/*TokenKind.MUL*/: 8550 case (44):
8603 8551
8604 return ":mul"; 8552 return ":mul";
8605 8553
8606 case 45/*TokenKind.DIV*/: 8554 case (45):
8607 8555
8608 return ":div"; 8556 return ":div";
8609 8557
8610 case 46/*TokenKind.TRUNCDIV*/: 8558 case (46):
8611 8559
8612 return ":truncdiv"; 8560 return ":truncdiv";
8613 8561
8614 case 47/*TokenKind.MOD*/: 8562 case (47):
8615 8563
8616 return ":mod"; 8564 return ":mod";
8617 8565
8618 case 48/*TokenKind.EQ*/: 8566 case (48):
8619 8567
8620 return ":eq"; 8568 return ":eq";
8621 8569
8622 case 52/*TokenKind.LT*/: 8570 case (52):
8623 8571
8624 return ":lt"; 8572 return ":lt";
8625 8573
8626 case 53/*TokenKind.GT*/: 8574 case (53):
8627 8575
8628 return ":gt"; 8576 return ":gt";
8629 8577
8630 case 54/*TokenKind.LTE*/: 8578 case (54):
8631 8579
8632 return ":lte"; 8580 return ":lte";
8633 8581
8634 case 55/*TokenKind.GTE*/: 8582 case (55):
8635 8583
8636 return ":gte"; 8584 return ":gte";
8637 8585
8638 case 56/*TokenKind.INDEX*/: 8586 case (56):
8639 8587
8640 return ":index"; 8588 return ":index";
8641 8589
8642 case 57/*TokenKind.SETINDEX*/: 8590 case (57):
8643 8591
8644 return ":setindex"; 8592 return ":setindex";
8645 8593
8646 } 8594 }
8647 } 8595 }
8648 TokenKind.kindFromAssign = function(kind) { 8596 TokenKind.kindFromAssign = function(kind) {
8649 if (kind == 20/*TokenKind.ASSIGN*/) return 0; 8597 if (kind == (20)) return (0);
8650 if (kind > 20/*TokenKind.ASSIGN*/ && kind <= 32/*TokenKind.ASSIGN_MOD*/) { 8598 if (kind > (20) && kind <= (32)) {
8651 return kind + (15); 8599 return kind + (15);
8652 } 8600 }
8653 return -1; 8601 return (-1);
8654 } 8602 }
8655 // ********** Code for Parser ************** 8603 // ********** Code for Parser **************
8656 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset ) { 8604 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset ) {
8657 this._inhibitLambda = false 8605 this._inhibitLambda = false
8658 this._afterParensIndex = 0 8606 this._afterParensIndex = (0)
8659 this._recover = false 8607 this._recover = false
8660 this.source = source; 8608 this.source = source;
8661 this.diet = diet; 8609 this.diet = diet;
8662 this.throwOnIncomplete = throwOnIncomplete; 8610 this.throwOnIncomplete = throwOnIncomplete;
8663 this.optionalSemicolons = optionalSemicolons; 8611 this.optionalSemicolons = optionalSemicolons;
8664 // Initializers done 8612 // Initializers done
8665 this.tokenizer = new Tokenizer(this.source, true, startOffset); 8613 this.tokenizer = new Tokenizer(this.source, true, startOffset);
8666 this._peekToken = this.tokenizer.next(); 8614 this._peekToken = this.tokenizer.next();
8667 this._afterParens = []; 8615 this._afterParens = [];
8668 } 8616 }
8669 Parser.prototype.get$enableAwait = function() { 8617 Parser.prototype.get$enableAwait = function() {
8670 return $globals.experimentalAwaitPhase != null; 8618 return $globals.experimentalAwaitPhase != null;
8671 } 8619 }
8672 Parser.prototype.isPrematureEndOfFile = function() { 8620 Parser.prototype.isPrematureEndOfFile = function() {
8673 if (this.throwOnIncomplete && this._maybeEat(1/*TokenKind.END_OF_FILE*/)) { 8621 if (this.throwOnIncomplete && this._maybeEat((1))) {
8674 $throw(new IncompleteSourceException(this._previousToken)); 8622 $throw(new IncompleteSourceException(this._previousToken));
8675 } 8623 }
8676 else if (this._maybeEat(1/*TokenKind.END_OF_FILE*/)) { 8624 else if (this._maybeEat((1))) {
8677 this._lang_error("unexpected end of file", this._peekToken.get$span()); 8625 this._lang_error("unexpected end of file", this._peekToken.get$span());
8678 return true; 8626 return true;
8679 } 8627 }
8680 else { 8628 else {
8681 return false; 8629 return false;
8682 } 8630 }
8683 } 8631 }
8684 Parser.prototype._recoverTo = function(kind1, kind2, kind3) { 8632 Parser.prototype._recoverTo = function(kind1, kind2, kind3) {
8685 while (!this.isPrematureEndOfFile()) { 8633 while (!this.isPrematureEndOfFile()) {
8686 var kind = this._peek(); 8634 var kind = this._peek();
(...skipping 13 matching lines...) Expand all
8700 this._peekToken = this.tokenizer.next(); 8648 this._peekToken = this.tokenizer.next();
8701 return this._previousToken; 8649 return this._previousToken;
8702 } 8650 }
8703 Parser.prototype._peekKind = function(kind) { 8651 Parser.prototype._peekKind = function(kind) {
8704 return this._peekToken.kind == kind; 8652 return this._peekToken.kind == kind;
8705 } 8653 }
8706 Parser.prototype._peekIdentifier = function() { 8654 Parser.prototype._peekIdentifier = function() {
8707 return this._isIdentifier(this._peekToken.kind); 8655 return this._isIdentifier(this._peekToken.kind);
8708 } 8656 }
8709 Parser.prototype._isIdentifier = function(kind) { 8657 Parser.prototype._isIdentifier = function(kind) {
8710 return TokenKind.isIdentifier(kind) || (!this.get$enableAwait() && $eq(kind, 8 6/*TokenKind.AWAIT*/)); 8658 return TokenKind.isIdentifier(kind) || (!this.get$enableAwait() && $eq(kind, ( 86)));
8711 } 8659 }
8712 Parser.prototype._maybeEat = function(kind) { 8660 Parser.prototype._maybeEat = function(kind) {
8713 if (this._peekToken.kind == kind) { 8661 if (this._peekToken.kind == kind) {
8714 this._previousToken = this._peekToken; 8662 this._previousToken = this._peekToken;
8715 this._peekToken = this.tokenizer.next(); 8663 this._peekToken = this.tokenizer.next();
8716 return true; 8664 return true;
8717 } 8665 }
8718 else { 8666 else {
8719 return false; 8667 return false;
8720 } 8668 }
8721 } 8669 }
8722 Parser.prototype._eat = function(kind) { 8670 Parser.prototype._eat = function(kind) {
8723 if (!this._maybeEat(kind)) { 8671 if (!this._maybeEat(kind)) {
8724 this._errorExpected(TokenKind.kindToString(kind)); 8672 this._errorExpected(TokenKind.kindToString(kind));
8725 } 8673 }
8726 } 8674 }
8727 Parser.prototype._eatSemicolon = function() { 8675 Parser.prototype._eatSemicolon = function() {
8728 if (this.optionalSemicolons && this._peekKind(1/*TokenKind.END_OF_FILE*/)) ret urn; 8676 if (this.optionalSemicolons && this._peekKind((1))) return;
8729 this._eat(10/*TokenKind.SEMICOLON*/); 8677 this._eat((10));
8730 } 8678 }
8731 Parser.prototype._errorExpected = function(expected) { 8679 Parser.prototype._errorExpected = function(expected) {
8732 if (this.throwOnIncomplete) this.isPrematureEndOfFile(); 8680 if (this.throwOnIncomplete) this.isPrematureEndOfFile();
8733 var tok = this._lang_next(); 8681 var tok = this._lang_next();
8734 if ((tok instanceof ErrorToken) && tok.get$message() != null) { 8682 if ((tok instanceof ErrorToken) && tok.get$message() != null) {
8735 this._lang_error(tok.get$message(), tok.get$span()); 8683 this._lang_error(tok.get$message(), tok.get$span());
8736 } 8684 }
8737 else { 8685 else {
8738 this._lang_error(("expected " + expected + ", but found " + tok), tok.get$sp an()); 8686 this._lang_error(("expected " + expected + ", but found " + tok), tok.get$sp an());
8739 } 8687 }
8740 } 8688 }
8741 Parser.prototype._lang_error = function(message, location) { 8689 Parser.prototype._lang_error = function(message, location) {
8742 if (this._recover) return; 8690 if (this._recover) return;
8743 if (location == null) { 8691 if (location == null) {
8744 location = this._peekToken.get$span(); 8692 location = this._peekToken.get$span();
8745 } 8693 }
8746 $globals.world.fatal(message, location); 8694 $globals.world.fatal(message, location);
8747 this._recover = true; 8695 this._recover = true;
8748 } 8696 }
8749 Parser.prototype._skipBlock = function() { 8697 Parser.prototype._skipBlock = function() {
8750 var depth = 1; 8698 var depth = (1);
8751 this._eat(6/*TokenKind.LBRACE*/); 8699 this._eat((6));
8752 while (true) { 8700 while (true) {
8753 var tok = this._lang_next(); 8701 var tok = this._lang_next();
8754 if ($eq(tok.get$kind(), 6/*TokenKind.LBRACE*/)) { 8702 if ($eq(tok.get$kind(), (6))) {
8755 depth += 1; 8703 depth += (1);
8756 } 8704 }
8757 else if ($eq(tok.get$kind(), 7/*TokenKind.RBRACE*/)) { 8705 else if ($eq(tok.get$kind(), (7))) {
8758 depth -= 1; 8706 depth -= (1);
8759 if (depth == 0) return; 8707 if (depth == (0)) return;
8760 } 8708 }
8761 else if ($eq(tok.get$kind(), 1/*TokenKind.END_OF_FILE*/)) { 8709 else if ($eq(tok.get$kind(), (1))) {
8762 this._lang_error("unexpected end of file during diet parse", tok.get$span( )); 8710 this._lang_error("unexpected end of file during diet parse", tok.get$span( ));
8763 return; 8711 return;
8764 } 8712 }
8765 } 8713 }
8766 } 8714 }
8767 Parser.prototype._makeSpan = function(start) { 8715 Parser.prototype._makeSpan = function(start) {
8768 return new SourceSpan(this.source, start, this._previousToken.end); 8716 return new SourceSpan(this.source, start, this._previousToken.end);
8769 } 8717 }
8770 Parser.prototype.compilationUnit = function() { 8718 Parser.prototype.compilationUnit = function() {
8771 var ret = []; 8719 var ret = [];
8772 this._maybeEat(13/*TokenKind.HASHBANG*/); 8720 this._maybeEat((13));
8773 while (this._peekKind(12/*TokenKind.HASH*/)) { 8721 while (this._peekKind((12))) {
8774 ret.add$1(this.directive()); 8722 ret.add$1(this.directive());
8775 } 8723 }
8776 this._recover = false; 8724 this._recover = false;
8777 while (!this._maybeEat(1/*TokenKind.END_OF_FILE*/)) { 8725 while (!this._maybeEat((1))) {
8778 ret.add$1(this.topLevelDefinition()); 8726 ret.add$1(this.topLevelDefinition());
8779 } 8727 }
8780 this._recover = false; 8728 this._recover = false;
8781 return ret; 8729 return ret;
8782 } 8730 }
8783 Parser.prototype.directive = function() { 8731 Parser.prototype.directive = function() {
8784 var start = this._peekToken.start; 8732 var start = this._peekToken.start;
8785 this._eat(12/*TokenKind.HASH*/); 8733 this._eat((12));
8786 var name = this.identifier(); 8734 var name = this.identifier();
8787 var args = this.arguments(); 8735 var args = this.arguments();
8788 this._eatSemicolon(); 8736 this._eatSemicolon();
8789 return new DirectiveDefinition(name, args, this._makeSpan(start)); 8737 return new DirectiveDefinition(name, args, this._makeSpan(start));
8790 } 8738 }
8791 Parser.prototype.topLevelDefinition = function() { 8739 Parser.prototype.topLevelDefinition = function() {
8792 switch (this._peek()) { 8740 switch (this._peek()) {
8793 case 90/*TokenKind.CLASS*/: 8741 case (90):
8794 8742
8795 return this.classDefinition(90/*TokenKind.CLASS*/); 8743 return this.classDefinition((90));
8796 8744
8797 case 77/*TokenKind.INTERFACE*/: 8745 case (77):
8798 8746
8799 return this.classDefinition(77/*TokenKind.INTERFACE*/); 8747 return this.classDefinition((77));
8800 8748
8801 case 85/*TokenKind.TYPEDEF*/: 8749 case (85):
8802 8750
8803 return this.functionTypeAlias(); 8751 return this.functionTypeAlias();
8804 8752
8805 default: 8753 default:
8806 8754
8807 return this.declaration(true); 8755 return this.declaration(true);
8808 8756
8809 } 8757 }
8810 } 8758 }
8811 Parser.prototype.classDefinition = function(kind) { 8759 Parser.prototype.classDefinition = function(kind) {
8812 var start = this._peekToken.start; 8760 var start = this._peekToken.start;
8813 this._eat(kind); 8761 this._eat(kind);
8814 var name = this.identifier(); 8762 var name = this.identifier();
8815 var typeParams = null; 8763 var typeParams = null;
8816 if (this._peekKind(52/*TokenKind.LT*/)) { 8764 if (this._peekKind((52))) {
8817 typeParams = this.typeParameters(); 8765 typeParams = this.typeParameters();
8818 } 8766 }
8819 var _extends = null; 8767 var _extends = null;
8820 if (this._maybeEat(96/*TokenKind.EXTENDS*/)) { 8768 if (this._maybeEat((96))) {
8821 _extends = this.typeList(); 8769 _extends = this.typeList();
8822 } 8770 }
8823 var _implements = null; 8771 var _implements = null;
8824 if (this._maybeEat(75/*TokenKind.IMPLEMENTS*/)) { 8772 if (this._maybeEat((75))) {
8825 _implements = this.typeList(); 8773 _implements = this.typeList();
8826 } 8774 }
8827 var _native = null; 8775 var _native = null;
8828 if (this._maybeEat(79/*TokenKind.NATIVE*/)) { 8776 if (this._maybeEat((79))) {
8829 _native = this.maybeStringLiteral(); 8777 _native = this.maybeStringLiteral();
8830 if (_native != null) _native = new NativeType(_native); 8778 if (_native != null) _native = new NativeType(_native);
8831 } 8779 }
8832 var oldFactory = this._maybeEat(73/*TokenKind.FACTORY*/); 8780 var oldFactory = this._maybeEat((73));
8833 var defaultType = null; 8781 var defaultType = null;
8834 if (oldFactory || this._maybeEat(93/*TokenKind.DEFAULT*/)) { 8782 if (oldFactory || this._maybeEat((93))) {
8835 if (oldFactory) { 8783 if (oldFactory) {
8836 $globals.world.warning("factory no longer supported, use \"default\" inste ad", this._previousToken.get$span()); 8784 $globals.world.warning("factory no longer supported, use \"default\" inste ad", this._previousToken.get$span());
8837 } 8785 }
8838 var baseType = this.nameTypeReference(); 8786 var baseType = this.nameTypeReference();
8839 var typeParams0 = null; 8787 var typeParams0 = null;
8840 if (this._peekKind(52/*TokenKind.LT*/)) { 8788 if (this._peekKind((52))) {
8841 typeParams0 = this.typeParameters(); 8789 typeParams0 = this.typeParameters();
8842 } 8790 }
8843 defaultType = new DefaultTypeReference(oldFactory, baseType, typeParams0, th is._makeSpan(baseType.get$span().get$start())); 8791 defaultType = new DefaultTypeReference(oldFactory, baseType, typeParams0, th is._makeSpan(baseType.get$span().get$start()));
8844 } 8792 }
8845 var body = []; 8793 var body = [];
8846 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 8794 if (this._maybeEat((6))) {
8847 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 8795 while (!this._maybeEat((7))) {
8848 body.add$1(this.declaration(true)); 8796 body.add$1(this.declaration(true));
8849 if (this._recover) { 8797 if (this._recover) {
8850 if (!this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.SEMICOLON*/)) break; 8798 if (!this._recoverTo((7), (10))) break;
8851 this._maybeEat(10/*TokenKind.SEMICOLON*/); 8799 this._maybeEat((10));
8852 } 8800 }
8853 } 8801 }
8854 } 8802 }
8855 else { 8803 else {
8856 this._errorExpected("block starting with \"{\" or \";\""); 8804 this._errorExpected("block starting with \"{\" or \";\"");
8857 } 8805 }
8858 return new TypeDefinition(kind == 90/*TokenKind.CLASS*/, name, typeParams, _ex tends, _implements, _native, defaultType, body, this._makeSpan(start)); 8806 return new TypeDefinition(kind == (90), name, typeParams, _extends, _implement s, _native, defaultType, body, this._makeSpan(start));
8859 } 8807 }
8860 Parser.prototype.functionTypeAlias = function() { 8808 Parser.prototype.functionTypeAlias = function() {
8861 var start = this._peekToken.start; 8809 var start = this._peekToken.start;
8862 this._eat(85/*TokenKind.TYPEDEF*/); 8810 this._eat((85));
8863 var di = this.declaredIdentifier(false); 8811 var di = this.declaredIdentifier(false);
8864 var typeParams = null; 8812 var typeParams = null;
8865 if (this._peekKind(52/*TokenKind.LT*/)) { 8813 if (this._peekKind((52))) {
8866 typeParams = this.typeParameters(); 8814 typeParams = this.typeParameters();
8867 } 8815 }
8868 var formals = this.formalParameterList(); 8816 var formals = this.formalParameterList();
8869 this._eatSemicolon(); 8817 this._eatSemicolon();
8870 var func = new FunctionDefinition(null, di.get$type(), di.get$name(), formals, null, null, null, this._makeSpan(start)); 8818 var func = new FunctionDefinition(null, di.get$type(), di.get$name(), formals, null, null, null, this._makeSpan(start));
8871 return new FunctionTypeDefinition(func, typeParams, this._makeSpan(start)); 8819 return new FunctionTypeDefinition(func, typeParams, this._makeSpan(start));
8872 } 8820 }
8873 Parser.prototype.initializers = function() { 8821 Parser.prototype.initializers = function() {
8874 this._inhibitLambda = true; 8822 this._inhibitLambda = true;
8875 var ret = []; 8823 var ret = [];
8876 do { 8824 do {
8877 ret.add$1(this.expression()); 8825 ret.add$1(this.expression());
8878 } 8826 }
8879 while (this._maybeEat(11/*TokenKind.COMMA*/)) 8827 while (this._maybeEat((11)))
8880 this._inhibitLambda = false; 8828 this._inhibitLambda = false;
8881 return ret; 8829 return ret;
8882 } 8830 }
8883 Parser.prototype.get$initializers = function() { 8831 Parser.prototype.get$initializers = function() {
8884 return this.initializers.bind(this); 8832 return this.initializers.bind(this);
8885 } 8833 }
8886 Parser.prototype.functionBody = function(inExpression) { 8834 Parser.prototype.functionBody = function(inExpression) {
8887 var start = this._peekToken.start; 8835 var start = this._peekToken.start;
8888 if (this._maybeEat(9/*TokenKind.ARROW*/)) { 8836 if (this._maybeEat((9))) {
8889 var expr = this.expression(); 8837 var expr = this.expression();
8890 if (!inExpression) { 8838 if (!inExpression) {
8891 this._eatSemicolon(); 8839 this._eatSemicolon();
8892 } 8840 }
8893 return new ReturnStatement(expr, this._makeSpan(start)); 8841 return new ReturnStatement(expr, this._makeSpan(start));
8894 } 8842 }
8895 else if (this._peekKind(6/*TokenKind.LBRACE*/)) { 8843 else if (this._peekKind((6))) {
8896 if (this.diet) { 8844 if (this.diet) {
8897 this._skipBlock(); 8845 this._skipBlock();
8898 return new DietStatement(this._makeSpan(start)); 8846 return new DietStatement(this._makeSpan(start));
8899 } 8847 }
8900 else { 8848 else {
8901 return this.block(); 8849 return this.block();
8902 } 8850 }
8903 } 8851 }
8904 else if (!inExpression) { 8852 else if (!inExpression) {
8905 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 8853 if (this._maybeEat((10))) {
8906 return null; 8854 return null;
8907 } 8855 }
8908 } 8856 }
8909 this._lang_error("Expected function body (neither { nor => found)"); 8857 this._lang_error("Expected function body (neither { nor => found)");
8910 } 8858 }
8911 Parser.prototype.finishField = function(start, modifiers, type, name, value) { 8859 Parser.prototype.finishField = function(start, modifiers, type, name, value) {
8912 var names = [name]; 8860 var names = [name];
8913 var values = [value]; 8861 var values = [value];
8914 while (this._maybeEat(11/*TokenKind.COMMA*/)) { 8862 while (this._maybeEat((11))) {
8915 names.add$1(this.identifier()); 8863 names.add$1(this.identifier());
8916 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 8864 if (this._maybeEat((20))) {
8917 values.add$1(this.expression()); 8865 values.add$1(this.expression());
8918 } 8866 }
8919 else { 8867 else {
8920 values.add$1(); 8868 values.add$1();
8921 } 8869 }
8922 } 8870 }
8923 this._eatSemicolon(); 8871 this._eatSemicolon();
8924 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s tart)); 8872 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s tart));
8925 } 8873 }
8926 Parser.prototype.finishDefinition = function(start, modifiers, di) { 8874 Parser.prototype.finishDefinition = function(start, modifiers, di) {
8927 switch (this._peek()) { 8875 switch (this._peek()) {
8928 case 2/*TokenKind.LPAREN*/: 8876 case (2):
8929 8877
8930 var formals = this.formalParameterList(); 8878 var formals = this.formalParameterList();
8931 var inits = null, native_ = null; 8879 var inits = null, native_ = null;
8932 if (this._maybeEat(8/*TokenKind.COLON*/)) { 8880 if (this._maybeEat((8))) {
8933 inits = this.initializers(); 8881 inits = this.initializers();
8934 } 8882 }
8935 if (this._maybeEat(79/*TokenKind.NATIVE*/)) { 8883 if (this._maybeEat((79))) {
8936 native_ = this.maybeStringLiteral(); 8884 native_ = this.maybeStringLiteral();
8937 if (native_ == null) native_ = ""; 8885 if (native_ == null) native_ = "";
8938 } 8886 }
8939 var body = this.functionBody(false); 8887 var body = this.functionBody(false);
8940 if (di.get$name() == null) { 8888 if (di.get$name() == null) {
8941 di.set$name(di.get$type().get$name()); 8889 di.set$name(di.get$type().get$name());
8942 } 8890 }
8943 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for mals, inits, native_, body, this._makeSpan(start)); 8891 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for mals, inits, native_, body, this._makeSpan(start));
8944 8892
8945 case 20/*TokenKind.ASSIGN*/: 8893 case (20):
8946 8894
8947 this._eat(20/*TokenKind.ASSIGN*/); 8895 this._eat((20));
8948 var value = this.expression(); 8896 var value = this.expression();
8949 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va lue); 8897 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va lue);
8950 8898
8951 case 11/*TokenKind.COMMA*/: 8899 case (11):
8952 case 10/*TokenKind.SEMICOLON*/: 8900 case (10):
8953 8901
8954 return this.finishField(start, modifiers, di.get$type(), di.get$name(), nu ll); 8902 return this.finishField(start, modifiers, di.get$type(), di.get$name(), nu ll);
8955 8903
8956 default: 8904 default:
8957 8905
8958 this._errorExpected("declaration"); 8906 this._errorExpected("declaration");
8959 return null; 8907 return null;
8960 8908
8961 } 8909 }
8962 } 8910 }
8963 Parser.prototype.declaration = function(includeOperators) { 8911 Parser.prototype.declaration = function(includeOperators) {
8964 var start = this._peekToken.start; 8912 var start = this._peekToken.start;
8965 if (this._peekKind(73/*TokenKind.FACTORY*/)) { 8913 if (this._peekKind((73))) {
8966 return this.factoryConstructorDeclaration(); 8914 return this.factoryConstructorDeclaration();
8967 } 8915 }
8968 var modifiers = this._readModifiers(); 8916 var modifiers = this._readModifiers();
8969 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include Operators)); 8917 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include Operators));
8970 } 8918 }
8971 Parser.prototype.factoryConstructorDeclaration = function() { 8919 Parser.prototype.factoryConstructorDeclaration = function() {
8972 var start = this._peekToken.start; 8920 var start = this._peekToken.start;
8973 var factoryToken = this._lang_next(); 8921 var factoryToken = this._lang_next();
8974 var names = [this.identifier()]; 8922 var names = [this.identifier()];
8975 while (this._maybeEat(14/*TokenKind.DOT*/)) { 8923 while (this._maybeEat((14))) {
8976 names.add$1(this.identifier()); 8924 names.add$1(this.identifier());
8977 } 8925 }
8978 if (this._peekKind(52/*TokenKind.LT*/)) { 8926 if (this._peekKind((52))) {
8979 var tp = this.typeParameters(); 8927 var tp = this.typeParameters();
8980 $globals.world.warning("type parameters on factories are no longer supported , place them on the class instead", this._makeSpan(tp.$index(0).get$span().get$s tart())); 8928 $globals.world.warning("type parameters on factories are no longer supported , place them on the class instead", this._makeSpan(tp.$index((0)).get$span().get $start()));
8981 } 8929 }
8982 var name = null; 8930 var name = null;
8983 var type = null; 8931 var type = null;
8984 if (this._maybeEat(14/*TokenKind.DOT*/)) { 8932 if (this._maybeEat((14))) {
8985 name = this.identifier(); 8933 name = this.identifier();
8986 } 8934 }
8987 else { 8935 else {
8988 if (names.get$length() > 1) { 8936 if (names.get$length() > (1)) {
8989 name = names.removeLast$0(); 8937 name = names.removeLast$0();
8990 } 8938 }
8991 else { 8939 else {
8992 name = new Identifier("", names.$index(0).get$span()); 8940 name = new Identifier("", names.$index((0)).get$span());
8993 } 8941 }
8994 } 8942 }
8995 if (names.get$length() > 1) { 8943 if (names.get$length() > (1)) {
8996 this._lang_error("unsupported qualified name for factory", names.$index(0).g et$span()); 8944 this._lang_error("unsupported qualified name for factory", names.$index((0)) .get$span());
8997 } 8945 }
8998 type = new NameTypeReference(false, names.$index(0), null, names.$index(0).get $span()); 8946 type = new NameTypeReference(false, names.$index((0)), null, names.$index((0)) .get$span());
8999 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); 8947 var di = new DeclaredIdentifier(type, name, this._makeSpan(start));
9000 return this.finishDefinition(start, [factoryToken], di); 8948 return this.finishDefinition(start, [factoryToken], di);
9001 } 8949 }
9002 Parser.prototype.statement = function() { 8950 Parser.prototype.statement = function() {
9003 switch (this._peek()) { 8951 switch (this._peek()) {
9004 case 87/*TokenKind.BREAK*/: 8952 case (87):
9005 8953
9006 return this.breakStatement(); 8954 return this.breakStatement();
9007 8955
9008 case 92/*TokenKind.CONTINUE*/: 8956 case (92):
9009 8957
9010 return this.continueStatement(); 8958 return this.continueStatement();
9011 8959
9012 case 106/*TokenKind.RETURN*/: 8960 case (106):
9013 8961
9014 return this.returnStatement(); 8962 return this.returnStatement();
9015 8963
9016 case 110/*TokenKind.THROW*/: 8964 case (110):
9017 8965
9018 return this.throwStatement(); 8966 return this.throwStatement();
9019 8967
9020 case 72/*TokenKind.ASSERT*/: 8968 case (72):
9021 8969
9022 return this.assertStatement(); 8970 return this.assertStatement();
9023 8971
9024 case 115/*TokenKind.WHILE*/: 8972 case (115):
9025 8973
9026 return this.whileStatement(); 8974 return this.whileStatement();
9027 8975
9028 case 94/*TokenKind.DO*/: 8976 case (94):
9029 8977
9030 return this.doStatement(); 8978 return this.doStatement();
9031 8979
9032 case 100/*TokenKind.FOR*/: 8980 case (100):
9033 8981
9034 return this.forStatement(); 8982 return this.forStatement();
9035 8983
9036 case 101/*TokenKind.IF*/: 8984 case (101):
9037 8985
9038 return this.ifStatement(); 8986 return this.ifStatement();
9039 8987
9040 case 108/*TokenKind.SWITCH*/: 8988 case (108):
9041 8989
9042 return this.switchStatement(); 8990 return this.switchStatement();
9043 8991
9044 case 112/*TokenKind.TRY*/: 8992 case (112):
9045 8993
9046 return this.tryStatement(); 8994 return this.tryStatement();
9047 8995
9048 case 6/*TokenKind.LBRACE*/: 8996 case (6):
9049 8997
9050 return this.block(); 8998 return this.block();
9051 8999
9052 case 10/*TokenKind.SEMICOLON*/: 9000 case (10):
9053 9001
9054 return this.emptyStatement(); 9002 return this.emptyStatement();
9055 9003
9056 case 98/*TokenKind.FINAL*/: 9004 case (98):
9057 9005
9058 return this.declaration(false); 9006 return this.declaration(false);
9059 9007
9060 case 113/*TokenKind.VAR*/: 9008 case (113):
9061 9009
9062 return this.declaration(false); 9010 return this.declaration(false);
9063 9011
9064 default: 9012 default:
9065 9013
9066 return this.finishExpressionAsStatement(this.expression()); 9014 return this.finishExpressionAsStatement(this.expression());
9067 9015
9068 } 9016 }
9069 } 9017 }
9070 Parser.prototype.finishExpressionAsStatement = function(expr) { 9018 Parser.prototype.finishExpressionAsStatement = function(expr) {
9071 var start = expr.get$span().get$start(); 9019 var start = expr.get$span().get$start();
9072 if (this._maybeEat(8/*TokenKind.COLON*/)) { 9020 if (this._maybeEat((8))) {
9073 var label = this._makeLabel(expr); 9021 var label = this._makeLabel(expr);
9074 return new LabeledStatement(label, this.statement(), this._makeSpan(start)); 9022 return new LabeledStatement(label, this.statement(), this._makeSpan(start));
9075 } 9023 }
9076 if ((expr instanceof LambdaExpression)) { 9024 if ((expr instanceof LambdaExpression)) {
9077 if (!(expr.get$func().get$body() instanceof BlockStatement)) { 9025 if (!(expr.get$func().get$body() instanceof BlockStatement)) {
9078 this._eatSemicolon(); 9026 this._eatSemicolon();
9079 expr.get$func().set$span(this._makeSpan(start)); 9027 expr.get$func().set$span(this._makeSpan(start));
9080 } 9028 }
9081 return expr.get$func(); 9029 return expr.get$func();
9082 } 9030 }
9083 else if ((expr instanceof DeclaredIdentifier)) { 9031 else if ((expr instanceof DeclaredIdentifier)) {
9084 var value = null; 9032 var value = null;
9085 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 9033 if (this._maybeEat((20))) {
9086 value = this.expression(); 9034 value = this.expression();
9087 } 9035 }
9088 return this.finishField(start, null, expr.get$type(), expr.get$name(), value ); 9036 return this.finishField(start, null, expr.get$type(), expr.get$name(), value );
9089 } 9037 }
9090 else if (this._isBin(expr, 20/*TokenKind.ASSIGN*/) && ((expr.get$x() instanceo f DeclaredIdentifier))) { 9038 else if (this._isBin(expr, (20)) && ((expr.get$x() instanceof DeclaredIdentifi er))) {
9091 var di = expr.get$x(); 9039 var di = expr.get$x();
9092 return this.finishField(start, null, di.type, di.name, expr.get$y()); 9040 return this.finishField(start, null, di.type, di.name, expr.get$y());
9093 } 9041 }
9094 else if (this._isBin(expr, 52/*TokenKind.LT*/) && this._maybeEat(11/*TokenKind .COMMA*/)) { 9042 else if (this._isBin(expr, (52)) && this._maybeEat((11))) {
9095 var baseType = this._makeType(expr.get$x()); 9043 var baseType = this._makeType(expr.get$x());
9096 var typeArgs = [this._makeType(expr.get$y())]; 9044 var typeArgs = [this._makeType(expr.get$y())];
9097 var gt = this._finishTypeArguments(baseType, 0, typeArgs); 9045 var gt = this._finishTypeArguments(baseType, (0), typeArgs);
9098 var name = this.identifier(); 9046 var name = this.identifier();
9099 var value = null; 9047 var value = null;
9100 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 9048 if (this._maybeEat((20))) {
9101 value = this.expression(); 9049 value = this.expression();
9102 } 9050 }
9103 return this.finishField(expr.get$span().get$start(), null, gt, name, value); 9051 return this.finishField(expr.get$span().get$start(), null, gt, name, value);
9104 } 9052 }
9105 else { 9053 else {
9106 this._eatSemicolon(); 9054 this._eatSemicolon();
9107 return new ExpressionStatement(expr, this._makeSpan(expr.get$span().get$star t())); 9055 return new ExpressionStatement(expr, this._makeSpan(expr.get$span().get$star t()));
9108 } 9056 }
9109 } 9057 }
9110 Parser.prototype.testCondition = function() { 9058 Parser.prototype.testCondition = function() {
9111 this._eatLeftParen(); 9059 this._eatLeftParen();
9112 var ret = this.expression(); 9060 var ret = this.expression();
9113 this._eat(3/*TokenKind.RPAREN*/); 9061 this._eat((3));
9114 return ret; 9062 return ret;
9115 } 9063 }
9116 Parser.prototype.block = function() { 9064 Parser.prototype.block = function() {
9117 var start = this._peekToken.start; 9065 var start = this._peekToken.start;
9118 this._eat(6/*TokenKind.LBRACE*/); 9066 this._eat((6));
9119 var stmts = []; 9067 var stmts = [];
9120 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 9068 while (!this._maybeEat((7))) {
9121 stmts.add$1(this.statement()); 9069 stmts.add$1(this.statement());
9122 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.S EMICOLON*/)) break; 9070 if (this._recover && !this._recoverTo((7), (10))) break;
9123 } 9071 }
9124 this._recover = false; 9072 this._recover = false;
9125 return new BlockStatement(stmts, this._makeSpan(start)); 9073 return new BlockStatement(stmts, this._makeSpan(start));
9126 } 9074 }
9127 Parser.prototype.emptyStatement = function() { 9075 Parser.prototype.emptyStatement = function() {
9128 var start = this._peekToken.start; 9076 var start = this._peekToken.start;
9129 this._eat(10/*TokenKind.SEMICOLON*/); 9077 this._eat((10));
9130 return new EmptyStatement(this._makeSpan(start)); 9078 return new EmptyStatement(this._makeSpan(start));
9131 } 9079 }
9132 Parser.prototype.ifStatement = function() { 9080 Parser.prototype.ifStatement = function() {
9133 var start = this._peekToken.start; 9081 var start = this._peekToken.start;
9134 this._eat(101/*TokenKind.IF*/); 9082 this._eat((101));
9135 var test = this.testCondition(); 9083 var test = this.testCondition();
9136 var trueBranch = this.statement(); 9084 var trueBranch = this.statement();
9137 var falseBranch = null; 9085 var falseBranch = null;
9138 if (this._maybeEat(95/*TokenKind.ELSE*/)) { 9086 if (this._maybeEat((95))) {
9139 falseBranch = this.statement(); 9087 falseBranch = this.statement();
9140 } 9088 }
9141 return new IfStatement(test, trueBranch, falseBranch, this._makeSpan(start)); 9089 return new IfStatement(test, trueBranch, falseBranch, this._makeSpan(start));
9142 } 9090 }
9143 Parser.prototype.whileStatement = function() { 9091 Parser.prototype.whileStatement = function() {
9144 var start = this._peekToken.start; 9092 var start = this._peekToken.start;
9145 this._eat(115/*TokenKind.WHILE*/); 9093 this._eat((115));
9146 var test = this.testCondition(); 9094 var test = this.testCondition();
9147 var body = this.statement(); 9095 var body = this.statement();
9148 return new WhileStatement(test, body, this._makeSpan(start)); 9096 return new WhileStatement(test, body, this._makeSpan(start));
9149 } 9097 }
9150 Parser.prototype.doStatement = function() { 9098 Parser.prototype.doStatement = function() {
9151 var start = this._peekToken.start; 9099 var start = this._peekToken.start;
9152 this._eat(94/*TokenKind.DO*/); 9100 this._eat((94));
9153 var body = this.statement(); 9101 var body = this.statement();
9154 this._eat(115/*TokenKind.WHILE*/); 9102 this._eat((115));
9155 var test = this.testCondition(); 9103 var test = this.testCondition();
9156 this._eatSemicolon(); 9104 this._eatSemicolon();
9157 return new DoStatement(body, test, this._makeSpan(start)); 9105 return new DoStatement(body, test, this._makeSpan(start));
9158 } 9106 }
9159 Parser.prototype.forStatement = function() { 9107 Parser.prototype.forStatement = function() {
9160 var start = this._peekToken.start; 9108 var start = this._peekToken.start;
9161 this._eat(100/*TokenKind.FOR*/); 9109 this._eat((100));
9162 this._eatLeftParen(); 9110 this._eatLeftParen();
9163 var init = this.forInitializerStatement(start); 9111 var init = this.forInitializerStatement(start);
9164 if ((init instanceof ForInStatement)) { 9112 if ((init instanceof ForInStatement)) {
9165 return init; 9113 return init;
9166 } 9114 }
9167 var test = null; 9115 var test = null;
9168 if (!this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 9116 if (!this._maybeEat((10))) {
9169 test = this.expression(); 9117 test = this.expression();
9170 this._eatSemicolon(); 9118 this._eatSemicolon();
9171 } 9119 }
9172 var step = []; 9120 var step = [];
9173 if (!this._maybeEat(3/*TokenKind.RPAREN*/)) { 9121 if (!this._maybeEat((3))) {
9174 step.add$1(this.expression()); 9122 step.add$1(this.expression());
9175 while (this._maybeEat(11/*TokenKind.COMMA*/)) { 9123 while (this._maybeEat((11))) {
9176 step.add$1(this.expression()); 9124 step.add$1(this.expression());
9177 } 9125 }
9178 this._eat(3/*TokenKind.RPAREN*/); 9126 this._eat((3));
9179 } 9127 }
9180 var body = this.statement(); 9128 var body = this.statement();
9181 return new ForStatement(init, test, step, body, this._makeSpan(start)); 9129 return new ForStatement(init, test, step, body, this._makeSpan(start));
9182 } 9130 }
9183 Parser.prototype.forInitializerStatement = function(start) { 9131 Parser.prototype.forInitializerStatement = function(start) {
9184 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 9132 if (this._maybeEat((10))) {
9185 return null; 9133 return null;
9186 } 9134 }
9187 else { 9135 else {
9188 var init = this.expression(); 9136 var init = this.expression();
9189 if (this._peekKind(11/*TokenKind.COMMA*/) && this._isBin(init, 52/*TokenKind .LT*/)) { 9137 if (this._peekKind((11)) && this._isBin(init, (52))) {
9190 this._eat(11/*TokenKind.COMMA*/); 9138 this._eat((11));
9191 var baseType = this._makeType(init.get$x()); 9139 var baseType = this._makeType(init.get$x());
9192 var typeArgs = [this._makeType(init.get$y())]; 9140 var typeArgs = [this._makeType(init.get$y())];
9193 var gt = this._finishTypeArguments(baseType, 0, typeArgs); 9141 var gt = this._finishTypeArguments(baseType, (0), typeArgs);
9194 var name = this.identifier(); 9142 var name = this.identifier();
9195 init = new DeclaredIdentifier(gt, name, this._makeSpan(init.get$span().get $start())); 9143 init = new DeclaredIdentifier(gt, name, this._makeSpan(init.get$span().get $start()));
9196 } 9144 }
9197 if (this._maybeEat(102/*TokenKind.IN*/)) { 9145 if (this._maybeEat((102))) {
9198 return this._finishForIn(start, this._makeDeclaredIdentifier(init)); 9146 return this._finishForIn(start, this._makeDeclaredIdentifier(init));
9199 } 9147 }
9200 else { 9148 else {
9201 return this.finishExpressionAsStatement(init); 9149 return this.finishExpressionAsStatement(init);
9202 } 9150 }
9203 } 9151 }
9204 } 9152 }
9205 Parser.prototype._finishForIn = function(start, di) { 9153 Parser.prototype._finishForIn = function(start, di) {
9206 var expr = this.expression(); 9154 var expr = this.expression();
9207 this._eat(3/*TokenKind.RPAREN*/); 9155 this._eat((3));
9208 var body = this.statement(); 9156 var body = this.statement();
9209 return new ForInStatement(di, expr, body, this._makeSpan(start)); 9157 return new ForInStatement(di, expr, body, this._makeSpan(start));
9210 } 9158 }
9211 Parser.prototype.tryStatement = function() { 9159 Parser.prototype.tryStatement = function() {
9212 var start = this._peekToken.start; 9160 var start = this._peekToken.start;
9213 this._eat(112/*TokenKind.TRY*/); 9161 this._eat((112));
9214 var body = this.block(); 9162 var body = this.block();
9215 var catches = []; 9163 var catches = [];
9216 while (this._peekKind(89/*TokenKind.CATCH*/)) { 9164 while (this._peekKind((89))) {
9217 catches.add$1(this.catchNode()); 9165 catches.add$1(this.catchNode());
9218 } 9166 }
9219 var finallyBlock = null; 9167 var finallyBlock = null;
9220 if (this._maybeEat(99/*TokenKind.FINALLY*/)) { 9168 if (this._maybeEat((99))) {
9221 finallyBlock = this.block(); 9169 finallyBlock = this.block();
9222 } 9170 }
9223 return new TryStatement(body, catches, finallyBlock, this._makeSpan(start)); 9171 return new TryStatement(body, catches, finallyBlock, this._makeSpan(start));
9224 } 9172 }
9225 Parser.prototype.catchNode = function() { 9173 Parser.prototype.catchNode = function() {
9226 var start = this._peekToken.start; 9174 var start = this._peekToken.start;
9227 this._eat(89/*TokenKind.CATCH*/); 9175 this._eat((89));
9228 this._eatLeftParen(); 9176 this._eatLeftParen();
9229 var exc = this.declaredIdentifier(false); 9177 var exc = this.declaredIdentifier(false);
9230 var trace = null; 9178 var trace = null;
9231 if (this._maybeEat(11/*TokenKind.COMMA*/)) { 9179 if (this._maybeEat((11))) {
9232 trace = this.declaredIdentifier(false); 9180 trace = this.declaredIdentifier(false);
9233 } 9181 }
9234 this._eat(3/*TokenKind.RPAREN*/); 9182 this._eat((3));
9235 var body = this.block(); 9183 var body = this.block();
9236 return new CatchNode(exc, trace, body, this._makeSpan(start)); 9184 return new CatchNode(exc, trace, body, this._makeSpan(start));
9237 } 9185 }
9238 Parser.prototype.switchStatement = function() { 9186 Parser.prototype.switchStatement = function() {
9239 var start = this._peekToken.start; 9187 var start = this._peekToken.start;
9240 this._eat(108/*TokenKind.SWITCH*/); 9188 this._eat((108));
9241 var test = this.testCondition(); 9189 var test = this.testCondition();
9242 var cases = []; 9190 var cases = [];
9243 this._eat(6/*TokenKind.LBRACE*/); 9191 this._eat((6));
9244 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 9192 while (!this._maybeEat((7))) {
9245 cases.add$1(this.caseNode()); 9193 cases.add$1(this.caseNode());
9246 } 9194 }
9247 return new SwitchStatement(test, cases, this._makeSpan(start)); 9195 return new SwitchStatement(test, cases, this._makeSpan(start));
9248 } 9196 }
9249 Parser.prototype._peekCaseEnd = function() { 9197 Parser.prototype._peekCaseEnd = function() {
9250 var kind = this._peek(); 9198 var kind = this._peek();
9251 return $eq(kind, 7/*TokenKind.RBRACE*/) || $eq(kind, 88/*TokenKind.CASE*/) || $eq(kind, 93/*TokenKind.DEFAULT*/); 9199 return $eq(kind, (7)) || $eq(kind, (88)) || $eq(kind, (93));
9252 } 9200 }
9253 Parser.prototype.caseNode = function() { 9201 Parser.prototype.caseNode = function() {
9254 var start = this._peekToken.start; 9202 var start = this._peekToken.start;
9255 var label = null; 9203 var label = null;
9256 if (this._peekIdentifier()) { 9204 if (this._peekIdentifier()) {
9257 label = this.identifier(); 9205 label = this.identifier();
9258 this._eat(8/*TokenKind.COLON*/); 9206 this._eat((8));
9259 } 9207 }
9260 var cases = []; 9208 var cases = [];
9261 while (true) { 9209 while (true) {
9262 if (this._maybeEat(88/*TokenKind.CASE*/)) { 9210 if (this._maybeEat((88))) {
9263 cases.add$1(this.expression()); 9211 cases.add$1(this.expression());
9264 this._eat(8/*TokenKind.COLON*/); 9212 this._eat((8));
9265 } 9213 }
9266 else if (this._maybeEat(93/*TokenKind.DEFAULT*/)) { 9214 else if (this._maybeEat((93))) {
9267 cases.add$1(); 9215 cases.add$1();
9268 this._eat(8/*TokenKind.COLON*/); 9216 this._eat((8));
9269 } 9217 }
9270 else { 9218 else {
9271 break; 9219 break;
9272 } 9220 }
9273 } 9221 }
9274 if ($eq(cases.get$length(), 0)) { 9222 if ($eq(cases.get$length(), (0))) {
9275 this._lang_error("case or default"); 9223 this._lang_error("case or default");
9276 } 9224 }
9277 var stmts = []; 9225 var stmts = [];
9278 while (!this._peekCaseEnd()) { 9226 while (!this._peekCaseEnd()) {
9279 stmts.add$1(this.statement()); 9227 stmts.add$1(this.statement());
9280 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 88/*TokenKind.C ASE*/, 93/*TokenKind.DEFAULT*/)) { 9228 if (this._recover && !this._recoverTo((7), (88), (93))) {
9281 break; 9229 break;
9282 } 9230 }
9283 } 9231 }
9284 return new CaseNode(label, cases, stmts, this._makeSpan(start)); 9232 return new CaseNode(label, cases, stmts, this._makeSpan(start));
9285 } 9233 }
9286 Parser.prototype.returnStatement = function() { 9234 Parser.prototype.returnStatement = function() {
9287 var start = this._peekToken.start; 9235 var start = this._peekToken.start;
9288 this._eat(106/*TokenKind.RETURN*/); 9236 this._eat((106));
9289 var expr; 9237 var expr;
9290 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 9238 if (this._maybeEat((10))) {
9291 expr = null; 9239 expr = null;
9292 } 9240 }
9293 else { 9241 else {
9294 expr = this.expression(); 9242 expr = this.expression();
9295 this._eatSemicolon(); 9243 this._eatSemicolon();
9296 } 9244 }
9297 return new ReturnStatement(expr, this._makeSpan(start)); 9245 return new ReturnStatement(expr, this._makeSpan(start));
9298 } 9246 }
9299 Parser.prototype.throwStatement = function() { 9247 Parser.prototype.throwStatement = function() {
9300 var start = this._peekToken.start; 9248 var start = this._peekToken.start;
9301 this._eat(110/*TokenKind.THROW*/); 9249 this._eat((110));
9302 var expr; 9250 var expr;
9303 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 9251 if (this._maybeEat((10))) {
9304 expr = null; 9252 expr = null;
9305 } 9253 }
9306 else { 9254 else {
9307 expr = this.expression(); 9255 expr = this.expression();
9308 this._eatSemicolon(); 9256 this._eatSemicolon();
9309 } 9257 }
9310 return new ThrowStatement(expr, this._makeSpan(start)); 9258 return new ThrowStatement(expr, this._makeSpan(start));
9311 } 9259 }
9312 Parser.prototype.assertStatement = function() { 9260 Parser.prototype.assertStatement = function() {
9313 var start = this._peekToken.start; 9261 var start = this._peekToken.start;
9314 this._eat(72/*TokenKind.ASSERT*/); 9262 this._eat((72));
9315 this._eatLeftParen(); 9263 this._eatLeftParen();
9316 var expr = this.expression(); 9264 var expr = this.expression();
9317 this._eat(3/*TokenKind.RPAREN*/); 9265 this._eat((3));
9318 this._eatSemicolon(); 9266 this._eatSemicolon();
9319 return new AssertStatement(expr, this._makeSpan(start)); 9267 return new AssertStatement(expr, this._makeSpan(start));
9320 } 9268 }
9321 Parser.prototype.breakStatement = function() { 9269 Parser.prototype.breakStatement = function() {
9322 var start = this._peekToken.start; 9270 var start = this._peekToken.start;
9323 this._eat(87/*TokenKind.BREAK*/); 9271 this._eat((87));
9324 var name = null; 9272 var name = null;
9325 if (this._peekIdentifier()) { 9273 if (this._peekIdentifier()) {
9326 name = this.identifier(); 9274 name = this.identifier();
9327 } 9275 }
9328 this._eatSemicolon(); 9276 this._eatSemicolon();
9329 return new BreakStatement(name, this._makeSpan(start)); 9277 return new BreakStatement(name, this._makeSpan(start));
9330 } 9278 }
9331 Parser.prototype.continueStatement = function() { 9279 Parser.prototype.continueStatement = function() {
9332 var start = this._peekToken.start; 9280 var start = this._peekToken.start;
9333 this._eat(92/*TokenKind.CONTINUE*/); 9281 this._eat((92));
9334 var name = null; 9282 var name = null;
9335 if (this._peekIdentifier()) { 9283 if (this._peekIdentifier()) {
9336 name = this.identifier(); 9284 name = this.identifier();
9337 } 9285 }
9338 this._eatSemicolon(); 9286 this._eatSemicolon();
9339 return new ContinueStatement(name, this._makeSpan(start)); 9287 return new ContinueStatement(name, this._makeSpan(start));
9340 } 9288 }
9341 Parser.prototype.expression = function() { 9289 Parser.prototype.expression = function() {
9342 return this.infixExpression(0); 9290 return this.infixExpression((0));
9343 } 9291 }
9344 Parser.prototype._makeType = function(expr) { 9292 Parser.prototype._makeType = function(expr) {
9345 if ((expr instanceof VarExpression)) { 9293 if ((expr instanceof VarExpression)) {
9346 return new NameTypeReference(false, expr.get$name(), null, expr.get$span()); 9294 return new NameTypeReference(false, expr.get$name(), null, expr.get$span());
9347 } 9295 }
9348 else if ((expr instanceof DotExpression)) { 9296 else if ((expr instanceof DotExpression)) {
9349 var type = this._makeType(expr.get$self()); 9297 var type = this._makeType(expr.get$self());
9350 if (type.get$names() == null) { 9298 if (type.get$names() == null) {
9351 type.set$names([expr.get$name()]); 9299 type.set$names([expr.get$name()]);
9352 } 9300 }
9353 else { 9301 else {
9354 type.get$names().add$1(expr.get$name()); 9302 type.get$names().add$1(expr.get$name());
9355 } 9303 }
9356 type.set$span(expr.get$span()); 9304 type.set$span(expr.get$span());
9357 return type; 9305 return type;
9358 } 9306 }
9359 else { 9307 else {
9360 this._lang_error("expected type reference"); 9308 this._lang_error("expected type reference");
9361 return null; 9309 return null;
9362 } 9310 }
9363 } 9311 }
9364 Parser.prototype.infixExpression = function(precedence) { 9312 Parser.prototype.infixExpression = function(precedence) {
9365 return this.finishInfixExpression(this.unaryExpression(), precedence); 9313 return this.finishInfixExpression(this.unaryExpression(), precedence);
9366 } 9314 }
9367 Parser.prototype._finishDeclaredId = function(type) { 9315 Parser.prototype._finishDeclaredId = function(type) {
9368 var name = this.identifier(); 9316 var name = this.identifier();
9369 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().get$start()))); 9317 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().get$start())));
9370 } 9318 }
9371 Parser.prototype._fixAsType = function(x) { 9319 Parser.prototype._fixAsType = function(x) {
9372 if (this._maybeEat(53/*TokenKind.GT*/)) { 9320 if (this._maybeEat((53))) {
9373 var base = this._makeType(x.x); 9321 var base = this._makeType(x.x);
9374 var typeParam = this._makeType(x.y); 9322 var typeParam = this._makeType(x.y);
9375 var type = new GenericTypeReference(base, [typeParam], 0, this._makeSpan(x.s pan.start)); 9323 var type = new GenericTypeReference(base, [typeParam], (0), this._makeSpan(x .span.start));
9376 return this._finishDeclaredId(type); 9324 return this._finishDeclaredId(type);
9377 } 9325 }
9378 else { 9326 else {
9379 var base = this._makeType(x.x); 9327 var base = this._makeType(x.x);
9380 var paramBase = this._makeType(x.y); 9328 var paramBase = this._makeType(x.y);
9381 var firstParam = this.addTypeArguments(paramBase, 1); 9329 var firstParam = this.addTypeArguments(paramBase, (1));
9382 var type; 9330 var type;
9383 if (firstParam.get$depth() <= 0) { 9331 if (firstParam.get$depth() <= (0)) {
9384 type = new GenericTypeReference(base, [firstParam], 0, this._makeSpan(x.sp an.start)); 9332 type = new GenericTypeReference(base, [firstParam], (0), this._makeSpan(x. span.start));
9385 } 9333 }
9386 else if (this._maybeEat(11/*TokenKind.COMMA*/)) { 9334 else if (this._maybeEat((11))) {
9387 type = this._finishTypeArguments(base, 0, [firstParam]); 9335 type = this._finishTypeArguments(base, (0), [firstParam]);
9388 } 9336 }
9389 else { 9337 else {
9390 this._eat(53/*TokenKind.GT*/); 9338 this._eat((53));
9391 type = new GenericTypeReference(base, [firstParam], 0, this._makeSpan(x.sp an.start)); 9339 type = new GenericTypeReference(base, [firstParam], (0), this._makeSpan(x. span.start));
9392 } 9340 }
9393 return this._finishDeclaredId(type); 9341 return this._finishDeclaredId(type);
9394 } 9342 }
9395 } 9343 }
9396 Parser.prototype.finishInfixExpression = function(x, precedence) { 9344 Parser.prototype.finishInfixExpression = function(x, precedence) {
9397 while (true) { 9345 while (true) {
9398 var kind = this._peek(); 9346 var kind = this._peek();
9399 var prec = TokenKind.infixPrecedence(this._peek()); 9347 var prec = TokenKind.infixPrecedence(this._peek());
9400 if (prec >= precedence) { 9348 if (prec >= precedence) {
9401 if (kind == 52/*TokenKind.LT*/ || kind == 53/*TokenKind.GT*/) { 9349 if (kind == (52) || kind == (53)) {
9402 if (this._isBin(x, 52/*TokenKind.LT*/)) { 9350 if (this._isBin(x, (52))) {
9403 return this._fixAsType(x); 9351 return this._fixAsType(x);
9404 } 9352 }
9405 } 9353 }
9406 var op = this._lang_next(); 9354 var op = this._lang_next();
9407 if ($eq(op.get$kind(), 103/*TokenKind.IS*/)) { 9355 if ($eq(op.get$kind(), (103))) {
9408 var isTrue = !this._maybeEat(19/*TokenKind.NOT*/); 9356 var isTrue = !this._maybeEat((19));
9409 var typeRef = this.type(0); 9357 var typeRef = this.type((0));
9410 x = new IsExpression(isTrue, x, typeRef, this._makeSpan(x.span.start)); 9358 x = new IsExpression(isTrue, x, typeRef, this._makeSpan(x.span.start));
9411 continue; 9359 continue;
9412 } 9360 }
9413 var y = this.infixExpression($eq(prec, 2) ? prec : prec + 1); 9361 var y = this.infixExpression($eq(prec, (2)) ? prec : prec + (1));
9414 if ($eq(op.get$kind(), 33/*TokenKind.CONDITIONAL*/)) { 9362 if ($eq(op.get$kind(), (33))) {
9415 this._eat(8/*TokenKind.COLON*/); 9363 this._eat((8));
9416 var z = this.infixExpression(prec); 9364 var z = this.infixExpression(prec);
9417 x = new ConditionalExpression(x, y, z, this._makeSpan(x.span.start)); 9365 x = new ConditionalExpression(x, y, z, this._makeSpan(x.span.start));
9418 } 9366 }
9419 else { 9367 else {
9420 x = new BinaryExpression(op, x, y, this._makeSpan(x.span.start)); 9368 x = new BinaryExpression(op, x, y, this._makeSpan(x.span.start));
9421 } 9369 }
9422 } 9370 }
9423 else { 9371 else {
9424 break; 9372 break;
9425 } 9373 }
9426 } 9374 }
9427 return x; 9375 return x;
9428 } 9376 }
9429 Parser.prototype._isPrefixUnaryOperator = function(kind) { 9377 Parser.prototype._isPrefixUnaryOperator = function(kind) {
9430 switch (kind) { 9378 switch (kind) {
9431 case 42/*TokenKind.ADD*/: 9379 case (42):
9432 case 43/*TokenKind.SUB*/: 9380 case (43):
9433 case 19/*TokenKind.NOT*/: 9381 case (19):
9434 case 18/*TokenKind.BIT_NOT*/: 9382 case (18):
9435 case 16/*TokenKind.INCR*/: 9383 case (16):
9436 case 17/*TokenKind.DECR*/: 9384 case (17):
9437 9385
9438 return true; 9386 return true;
9439 9387
9440 default: 9388 default:
9441 9389
9442 return false; 9390 return false;
9443 9391
9444 } 9392 }
9445 } 9393 }
9446 Parser.prototype.unaryExpression = function() { 9394 Parser.prototype.unaryExpression = function() {
9447 var start = this._peekToken.start; 9395 var start = this._peekToken.start;
9448 if (this._isPrefixUnaryOperator(this._peek())) { 9396 if (this._isPrefixUnaryOperator(this._peek())) {
9449 var tok = this._lang_next(); 9397 var tok = this._lang_next();
9450 var expr = this.unaryExpression(); 9398 var expr = this.unaryExpression();
9451 return new UnaryExpression(tok, expr, this._makeSpan(start)); 9399 return new UnaryExpression(tok, expr, this._makeSpan(start));
9452 } 9400 }
9453 else if (this.get$enableAwait() && this._maybeEat(86/*TokenKind.AWAIT*/)) { 9401 else if (this.get$enableAwait() && this._maybeEat((86))) {
9454 var expr = this.unaryExpression(); 9402 var expr = this.unaryExpression();
9455 return new AwaitExpression(expr, this._makeSpan(start)); 9403 return new AwaitExpression(expr, this._makeSpan(start));
9456 } 9404 }
9457 return this.finishPostfixExpression(this.primary()); 9405 return this.finishPostfixExpression(this.primary());
9458 } 9406 }
9459 Parser.prototype.argument = function() { 9407 Parser.prototype.argument = function() {
9460 var start = this._peekToken.start; 9408 var start = this._peekToken.start;
9461 var expr; 9409 var expr;
9462 var label = null; 9410 var label = null;
9463 if (this._maybeEat(15/*TokenKind.ELLIPSIS*/)) { 9411 if (this._maybeEat((15))) {
9464 label = new Identifier("...", this._makeSpan(start)); 9412 label = new Identifier("...", this._makeSpan(start));
9465 } 9413 }
9466 expr = this.expression(); 9414 expr = this.expression();
9467 if (label == null && this._maybeEat(8/*TokenKind.COLON*/)) { 9415 if (label == null && this._maybeEat((8))) {
9468 label = this._makeLabel(expr); 9416 label = this._makeLabel(expr);
9469 expr = this.expression(); 9417 expr = this.expression();
9470 } 9418 }
9471 return new ArgumentNode(label, expr, this._makeSpan(start)); 9419 return new ArgumentNode(label, expr, this._makeSpan(start));
9472 } 9420 }
9473 Parser.prototype.arguments = function() { 9421 Parser.prototype.arguments = function() {
9474 var args = []; 9422 var args = [];
9475 this._eatLeftParen(); 9423 this._eatLeftParen();
9476 var saved = this._inhibitLambda; 9424 var saved = this._inhibitLambda;
9477 this._inhibitLambda = false; 9425 this._inhibitLambda = false;
9478 if (!this._maybeEat(3/*TokenKind.RPAREN*/)) { 9426 if (!this._maybeEat((3))) {
9479 do { 9427 do {
9480 args.add$1(this.argument()); 9428 args.add$1(this.argument());
9481 } 9429 }
9482 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9430 while (this._maybeEat((11)))
9483 this._eat(3/*TokenKind.RPAREN*/); 9431 this._eat((3));
9484 } 9432 }
9485 this._inhibitLambda = saved; 9433 this._inhibitLambda = saved;
9486 return args; 9434 return args;
9487 } 9435 }
9488 Parser.prototype.get$arguments = function() { 9436 Parser.prototype.get$arguments = function() {
9489 return this.arguments.bind(this); 9437 return this.arguments.bind(this);
9490 } 9438 }
9491 Parser.prototype.finishPostfixExpression = function(expr) { 9439 Parser.prototype.finishPostfixExpression = function(expr) {
9492 switch (this._peek()) { 9440 switch (this._peek()) {
9493 case 2/*TokenKind.LPAREN*/: 9441 case (2):
9494 9442
9495 return this.finishCallOrLambdaExpression(expr); 9443 return this.finishCallOrLambdaExpression(expr);
9496 9444
9497 case 4/*TokenKind.LBRACK*/: 9445 case (4):
9498 9446
9499 this._eat(4/*TokenKind.LBRACK*/); 9447 this._eat((4));
9500 var index = this.expression(); 9448 var index = this.expression();
9501 this._eat(5/*TokenKind.RBRACK*/); 9449 this._eat((5));
9502 return this.finishPostfixExpression(new IndexExpression(expr, index, this. _makeSpan(expr.get$span().get$start()))); 9450 return this.finishPostfixExpression(new IndexExpression(expr, index, this. _makeSpan(expr.get$span().get$start())));
9503 9451
9504 case 14/*TokenKind.DOT*/: 9452 case (14):
9505 9453
9506 this._eat(14/*TokenKind.DOT*/); 9454 this._eat((14));
9507 var name = this.identifier(); 9455 var name = this.identifier();
9508 var ret = new DotExpression(expr, name, this._makeSpan(expr.get$span().get $start())); 9456 var ret = new DotExpression(expr, name, this._makeSpan(expr.get$span().get $start()));
9509 return this.finishPostfixExpression(ret); 9457 return this.finishPostfixExpression(ret);
9510 9458
9511 case 16/*TokenKind.INCR*/: 9459 case (16):
9512 case 17/*TokenKind.DECR*/: 9460 case (17):
9513 9461
9514 var tok = this._lang_next(); 9462 var tok = this._lang_next();
9515 return new PostfixExpression(expr, tok, this._makeSpan(expr.get$span().get $start())); 9463 return new PostfixExpression(expr, tok, this._makeSpan(expr.get$span().get $start()));
9516 9464
9517 case 9/*TokenKind.ARROW*/: 9465 case (9):
9518 case 6/*TokenKind.LBRACE*/: 9466 case (6):
9519 9467
9520 return expr; 9468 return expr;
9521 9469
9522 default: 9470 default:
9523 9471
9524 if (this._peekIdentifier()) { 9472 if (this._peekIdentifier()) {
9525 return this.finishPostfixExpression(new DeclaredIdentifier(this._makeTyp e(expr), this.identifier(), this._makeSpan(expr.get$span().get$start()))); 9473 return this.finishPostfixExpression(new DeclaredIdentifier(this._makeTyp e(expr), this.identifier(), this._makeSpan(expr.get$span().get$start())));
9526 } 9474 }
9527 else { 9475 else {
9528 return expr; 9476 return expr;
(...skipping 17 matching lines...) Expand all
9546 } 9494 }
9547 Parser.prototype._isBin = function(expr, kind) { 9495 Parser.prototype._isBin = function(expr, kind) {
9548 return (expr instanceof BinaryExpression) && $eq(expr.get$op().get$kind(), kin d); 9496 return (expr instanceof BinaryExpression) && $eq(expr.get$op().get$kind(), kin d);
9549 } 9497 }
9550 Parser.prototype._makeLiteral = function(value) { 9498 Parser.prototype._makeLiteral = function(value) {
9551 return new LiteralExpression(value, value.span); 9499 return new LiteralExpression(value, value.span);
9552 } 9500 }
9553 Parser.prototype.primary = function() { 9501 Parser.prototype.primary = function() {
9554 var start = this._peekToken.start; 9502 var start = this._peekToken.start;
9555 switch (this._peek()) { 9503 switch (this._peek()) {
9556 case 109/*TokenKind.THIS*/: 9504 case (109):
9557 9505
9558 this._eat(109/*TokenKind.THIS*/); 9506 this._eat((109));
9559 return new ThisExpression(this._makeSpan(start)); 9507 return new ThisExpression(this._makeSpan(start));
9560 9508
9561 case 107/*TokenKind.SUPER*/: 9509 case (107):
9562 9510
9563 this._eat(107/*TokenKind.SUPER*/); 9511 this._eat((107));
9564 return new SuperExpression(this._makeSpan(start)); 9512 return new SuperExpression(this._makeSpan(start));
9565 9513
9566 case 91/*TokenKind.CONST*/: 9514 case (91):
9567 9515
9568 this._eat(91/*TokenKind.CONST*/); 9516 this._eat((91));
9569 if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind. INDEX*/)) { 9517 if (this._peekKind((4)) || this._peekKind((56))) {
9570 return this.finishListLiteral(start, true, null); 9518 return this.finishListLiteral(start, true, null);
9571 } 9519 }
9572 else if (this._peekKind(6/*TokenKind.LBRACE*/)) { 9520 else if (this._peekKind((6))) {
9573 return this.finishMapLiteral(start, true, null); 9521 return this.finishMapLiteral(start, true, null, null);
9574 } 9522 }
9575 else if (this._peekKind(52/*TokenKind.LT*/)) { 9523 else if (this._peekKind((52))) {
9576 return this.finishTypedLiteral(start, true); 9524 return this.finishTypedLiteral(start, true);
9577 } 9525 }
9578 else { 9526 else {
9579 return this.finishNewExpression(start, true); 9527 return this.finishNewExpression(start, true);
9580 } 9528 }
9581 9529
9582 case 104/*TokenKind.NEW*/: 9530 case (104):
9583 9531
9584 this._eat(104/*TokenKind.NEW*/); 9532 this._eat((104));
9585 return this.finishNewExpression(start, false); 9533 return this.finishNewExpression(start, false);
9586 9534
9587 case 2/*TokenKind.LPAREN*/: 9535 case (2):
9588 9536
9589 return this._parenOrLambda(); 9537 return this._parenOrLambda();
9590 9538
9591 case 4/*TokenKind.LBRACK*/: 9539 case (4):
9592 case 56/*TokenKind.INDEX*/: 9540 case (56):
9593 9541
9594 return this.finishListLiteral(start, false, null); 9542 return this.finishListLiteral(start, false, null);
9595 9543
9596 case 6/*TokenKind.LBRACE*/: 9544 case (6):
9597 9545
9598 return this.finishMapLiteral(start, false, null); 9546 return this.finishMapLiteral(start, false, null, null);
9599 9547
9600 case 105/*TokenKind.NULL*/: 9548 case (105):
9601 9549
9602 this._eat(105/*TokenKind.NULL*/); 9550 this._eat((105));
9603 return this._makeLiteral(Value.fromNull(this._makeSpan(start))); 9551 return this._makeLiteral(Value.fromNull(this._makeSpan(start)));
9604 9552
9605 case 111/*TokenKind.TRUE*/: 9553 case (111):
9606 9554
9607 this._eat(111/*TokenKind.TRUE*/); 9555 this._eat((111));
9608 return this._makeLiteral(Value.fromBool(true, this._makeSpan(start))); 9556 return this._makeLiteral(Value.fromBool(true, this._makeSpan(start)));
9609 9557
9610 case 97/*TokenKind.FALSE*/: 9558 case (97):
9611 9559
9612 this._eat(97/*TokenKind.FALSE*/); 9560 this._eat((97));
9613 return this._makeLiteral(Value.fromBool(false, this._makeSpan(start))); 9561 return this._makeLiteral(Value.fromBool(false, this._makeSpan(start)));
9614 9562
9615 case 61/*TokenKind.HEX_INTEGER*/: 9563 case (61):
9616 9564
9617 var t = this._lang_next(); 9565 var t = this._lang_next();
9618 return this._makeLiteral(Value.fromInt(t.get$value(), t.get$span())); 9566 return this._makeLiteral(Value.fromInt(t.get$value(), t.get$span()));
9619 9567
9620 case 60/*TokenKind.INTEGER*/: 9568 case (60):
9621 9569
9622 var t = this._lang_next(); 9570 var t = this._lang_next();
9623 return this._makeLiteral(Value.fromInt(Math.parseInt(t.get$text()), t.get$ span())); 9571 return this._makeLiteral(Value.fromInt(Math.parseInt(t.get$text()), t.get$ span()));
9624 9572
9625 case 62/*TokenKind.DOUBLE*/: 9573 case (62):
9626 9574
9627 var t = this._lang_next(); 9575 var t = this._lang_next();
9628 return this._makeLiteral(Value.fromDouble(Math.parseDouble(t.get$text()), t.get$span())); 9576 return this._makeLiteral(Value.fromDouble(Math.parseDouble(t.get$text()), t.get$span()));
9629 9577
9630 case 58/*TokenKind.STRING*/: 9578 case (58):
9631 9579
9632 var t = this._lang_next(); 9580 var t = this._lang_next();
9633 return this._makeLiteral(Value.fromString(t.get$value(), t.get$span())); 9581 return this._makeLiteral(Value.fromString(t.get$value(), t.get$span()));
9634 9582
9635 case 59/*TokenKind.STRING_PART*/: 9583 case (59):
9636 9584
9637 return this.stringInterpolation(); 9585 return this.stringInterpolation();
9638 9586
9639 case 52/*TokenKind.LT*/: 9587 case (52):
9640 9588
9641 return this.finishTypedLiteral(start, false); 9589 return this.finishTypedLiteral(start, false);
9642 9590
9643 case 114/*TokenKind.VOID*/: 9591 case (114):
9644 case 113/*TokenKind.VAR*/: 9592 case (113):
9645 case 98/*TokenKind.FINAL*/: 9593 case (98):
9646 9594
9647 return this.declaredIdentifier(false); 9595 return this.declaredIdentifier(false);
9648 9596
9649 default: 9597 default:
9650 9598
9651 if (!this._peekIdentifier()) { 9599 if (!this._peekIdentifier()) {
9652 this._errorExpected("expression"); 9600 this._errorExpected("expression");
9653 } 9601 }
9654 return new VarExpression(this.identifier(), this._makeSpan(start)); 9602 return new VarExpression(this.identifier(), this._makeSpan(start));
9655 9603
9656 } 9604 }
9657 } 9605 }
9658 Parser.prototype.stringInterpolation = function() { 9606 Parser.prototype.stringInterpolation = function() {
9659 var start = this._peekToken.start; 9607 var start = this._peekToken.start;
9660 var pieces = new Array(); 9608 var pieces = new Array();
9661 var startQuote = null, endQuote = null; 9609 var startQuote = null, endQuote = null;
9662 while (this._peekKind(59/*TokenKind.STRING_PART*/)) { 9610 while (this._peekKind((59))) {
9663 var token = this._lang_next(); 9611 var token = this._lang_next();
9664 pieces.add$1(this._makeLiteral(Value.fromString(token.get$value(), token.get $span()))); 9612 pieces.add$1(this._makeLiteral(Value.fromString(token.get$value(), token.get $span())));
9665 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 9613 if (this._maybeEat((6))) {
9666 pieces.add$1(this.expression()); 9614 pieces.add$1(this.expression());
9667 this._eat(7/*TokenKind.RBRACE*/); 9615 this._eat((7));
9668 } 9616 }
9669 else if (this._maybeEat(109/*TokenKind.THIS*/)) { 9617 else if (this._maybeEat((109))) {
9670 pieces.add$1(new ThisExpression(this._previousToken.get$span())); 9618 pieces.add$1(new ThisExpression(this._previousToken.get$span()));
9671 } 9619 }
9672 else { 9620 else {
9673 var id = this.identifier(); 9621 var id = this.identifier();
9674 pieces.add$1(new VarExpression(id, id.get$span())); 9622 pieces.add$1(new VarExpression(id, id.get$span()));
9675 } 9623 }
9676 } 9624 }
9677 var tok = this._lang_next(); 9625 var tok = this._lang_next();
9678 if ($ne(tok.get$kind(), 58/*TokenKind.STRING*/)) { 9626 if ($ne(tok.get$kind(), (58))) {
9679 this._errorExpected("interpolated string"); 9627 this._errorExpected("interpolated string");
9680 } 9628 }
9681 pieces.add$1(this._makeLiteral(Value.fromString(tok.get$value(), tok.get$span( )))); 9629 pieces.add$1(this._makeLiteral(Value.fromString(tok.get$value(), tok.get$span( ))));
9682 var span = this._makeSpan(start); 9630 var span = this._makeSpan(start);
9683 return new StringInterpExpression(pieces, span); 9631 return new StringInterpExpression(pieces, span);
9684 } 9632 }
9685 Parser.prototype.maybeStringLiteral = function() { 9633 Parser.prototype.maybeStringLiteral = function() {
9686 var kind = this._peek(); 9634 var kind = this._peek();
9687 if ($eq(kind, 58/*TokenKind.STRING*/)) { 9635 if ($eq(kind, (58))) {
9688 var t = this._lang_next(); 9636 var t = this._lang_next();
9689 return t.get$value(); 9637 return t.get$value();
9690 } 9638 }
9691 else if ($eq(kind, 59/*TokenKind.STRING_PART*/)) { 9639 else if ($eq(kind, (59))) {
9692 this._lang_next(); 9640 this._lang_next();
9693 this._errorExpected("string literal, but found interpolated string start"); 9641 this._errorExpected("string literal, but found interpolated string start");
9694 } 9642 }
9695 return null; 9643 return null;
9696 } 9644 }
9697 Parser.prototype._parenOrLambda = function() { 9645 Parser.prototype._parenOrLambda = function() {
9698 var start = this._peekToken.start; 9646 var start = this._peekToken.start;
9699 if (this._atClosureParameters()) { 9647 if (this._atClosureParameters()) {
9700 var formals = this.formalParameterList(); 9648 var formals = this.formalParameterList();
9701 var body = this.functionBody(true); 9649 var body = this.functionBody(true);
9702 var func = new FunctionDefinition(null, null, null, formals, null, null, bod y, this._makeSpan(start)); 9650 var func = new FunctionDefinition(null, null, null, formals, null, null, bod y, this._makeSpan(start));
9703 return new LambdaExpression(func, func.get$span()); 9651 return new LambdaExpression(func, func.get$span());
9704 } 9652 }
9705 else { 9653 else {
9706 this._eatLeftParen(); 9654 this._eatLeftParen();
9707 var saved = this._inhibitLambda; 9655 var saved = this._inhibitLambda;
9708 this._inhibitLambda = false; 9656 this._inhibitLambda = false;
9709 var expr = this.expression(); 9657 var expr = this.expression();
9710 this._eat(3/*TokenKind.RPAREN*/); 9658 this._eat((3));
9711 this._inhibitLambda = saved; 9659 this._inhibitLambda = saved;
9712 return new ParenExpression(expr, this._makeSpan(start)); 9660 return new ParenExpression(expr, this._makeSpan(start));
9713 } 9661 }
9714 } 9662 }
9715 Parser.prototype._atClosureParameters = function() { 9663 Parser.prototype._atClosureParameters = function() {
9716 if (this._inhibitLambda) return false; 9664 if (this._inhibitLambda) return false;
9717 var after = this._peekAfterCloseParen(); 9665 var after = this._peekAfterCloseParen();
9718 return after.kind == 9/*TokenKind.ARROW*/ || after.kind == 6/*TokenKind.LBRACE */; 9666 return after.kind == (9) || after.kind == (6);
9719 } 9667 }
9720 Parser.prototype._eatLeftParen = function() { 9668 Parser.prototype._eatLeftParen = function() {
9721 this._eat(2/*TokenKind.LPAREN*/); 9669 this._eat((2));
9722 this._afterParensIndex++; 9670 this._afterParensIndex++;
9723 } 9671 }
9724 Parser.prototype._peekAfterCloseParen = function() { 9672 Parser.prototype._peekAfterCloseParen = function() {
9725 if (this._afterParensIndex < this._afterParens.get$length()) { 9673 if (this._afterParensIndex < this._afterParens.get$length()) {
9726 return this._afterParens.$index(this._afterParensIndex); 9674 return this._afterParens.$index(this._afterParensIndex);
9727 } 9675 }
9728 this._afterParensIndex = 0; 9676 this._afterParensIndex = (0);
9729 this._afterParens.clear(); 9677 this._afterParens.clear();
9730 var tokens = [this._lang_next()]; 9678 var tokens = [this._lang_next()];
9731 this._lookaheadAfterParens(tokens); 9679 this._lookaheadAfterParens(tokens);
9732 var after = this._peekToken; 9680 var after = this._peekToken;
9733 tokens.add$1(after); 9681 tokens.add$1(after);
9734 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer); 9682 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer);
9735 this._lang_next(); 9683 this._lang_next();
9736 return after; 9684 return after;
9737 } 9685 }
9738 Parser.prototype._lookaheadAfterParens = function(tokens) { 9686 Parser.prototype._lookaheadAfterParens = function(tokens) {
9739 var saved = this._afterParens.get$length(); 9687 var saved = this._afterParens.get$length();
9740 this._afterParens.add(null); 9688 this._afterParens.add(null);
9741 while (true) { 9689 while (true) {
9742 var token = this._lang_next(); 9690 var token = this._lang_next();
9743 tokens.add(token); 9691 tokens.add(token);
9744 var kind = token.kind; 9692 var kind = token.kind;
9745 if (kind == 3/*TokenKind.RPAREN*/ || kind == 1/*TokenKind.END_OF_FILE*/) { 9693 if (kind == (3) || kind == (1)) {
9746 this._afterParens.$setindex(saved, this._peekToken); 9694 this._afterParens.$setindex(saved, this._peekToken);
9747 return; 9695 return;
9748 } 9696 }
9749 else if (kind == 2/*TokenKind.LPAREN*/) { 9697 else if (kind == (2)) {
9750 this._lookaheadAfterParens(tokens); 9698 this._lookaheadAfterParens(tokens);
9751 } 9699 }
9752 } 9700 }
9753 } 9701 }
9754 Parser.prototype._typeAsIdentifier = function(type) { 9702 Parser.prototype._typeAsIdentifier = function(type) {
9755 return type.get$name(); 9703 return type.get$name();
9756 } 9704 }
9757 Parser.prototype._specialIdentifier = function(includeOperators) { 9705 Parser.prototype._specialIdentifier = function(includeOperators) {
9758 var start = this._peekToken.start; 9706 var start = this._peekToken.start;
9759 var name; 9707 var name;
9760 switch (this._peek()) { 9708 switch (this._peek()) {
9761 case 15/*TokenKind.ELLIPSIS*/: 9709 case (15):
9762 9710
9763 this._eat(15/*TokenKind.ELLIPSIS*/); 9711 this._eat((15));
9764 this._lang_error("rest no longer supported", this._previousToken.get$span( )); 9712 this._lang_error("rest no longer supported", this._previousToken.get$span( ));
9765 name = this.identifier().get$name(); 9713 name = this.identifier().get$name();
9766 break; 9714 break;
9767 9715
9768 case 109/*TokenKind.THIS*/: 9716 case (109):
9769 9717
9770 this._eat(109/*TokenKind.THIS*/); 9718 this._eat((109));
9771 this._eat(14/*TokenKind.DOT*/); 9719 this._eat((14));
9772 name = ("this." + this.identifier().get$name()); 9720 name = ("this." + this.identifier().get$name());
9773 break; 9721 break;
9774 9722
9775 case 74/*TokenKind.GET*/: 9723 case (74):
9776 9724
9777 if (!includeOperators) return null; 9725 if (!includeOperators) return null;
9778 this._eat(74/*TokenKind.GET*/); 9726 this._eat((74));
9779 if (this._peekIdentifier()) { 9727 if (this._peekIdentifier()) {
9780 name = ("get:" + this.identifier().get$name()); 9728 name = ("get:" + this.identifier().get$name());
9781 } 9729 }
9782 else { 9730 else {
9783 name = "get"; 9731 name = "get";
9784 } 9732 }
9785 break; 9733 break;
9786 9734
9787 case 82/*TokenKind.SET*/: 9735 case (82):
9788 9736
9789 if (!includeOperators) return null; 9737 if (!includeOperators) return null;
9790 this._eat(82/*TokenKind.SET*/); 9738 this._eat((82));
9791 if (this._peekIdentifier()) { 9739 if (this._peekIdentifier()) {
9792 name = ("set:" + this.identifier().get$name()); 9740 name = ("set:" + this.identifier().get$name());
9793 } 9741 }
9794 else { 9742 else {
9795 name = "set"; 9743 name = "set";
9796 } 9744 }
9797 break; 9745 break;
9798 9746
9799 case 81/*TokenKind.OPERATOR*/: 9747 case (81):
9800 9748
9801 if (!includeOperators) return null; 9749 if (!includeOperators) return null;
9802 this._eat(81/*TokenKind.OPERATOR*/); 9750 this._eat((81));
9803 var kind = this._peek(); 9751 var kind = this._peek();
9804 if ($eq(kind, 80/*TokenKind.NEGATE*/)) { 9752 if ($eq(kind, (80))) {
9805 name = ":negate"; 9753 name = ":negate";
9806 this._lang_next(); 9754 this._lang_next();
9807 } 9755 }
9808 else { 9756 else {
9809 name = TokenKind.binaryMethodName(kind); 9757 name = TokenKind.binaryMethodName(kind);
9810 if (name == null) { 9758 if (name == null) {
9811 name = "operator"; 9759 name = "operator";
9812 } 9760 }
9813 else { 9761 else {
9814 this._lang_next(); 9762 this._lang_next();
9815 } 9763 }
9816 } 9764 }
9817 break; 9765 break;
9818 9766
9819 default: 9767 default:
9820 9768
9821 return null; 9769 return null;
9822 9770
9823 } 9771 }
9824 return new Identifier(name, this._makeSpan(start)); 9772 return new Identifier(name, this._makeSpan(start));
9825 } 9773 }
9826 Parser.prototype.declaredIdentifier = function(includeOperators) { 9774 Parser.prototype.declaredIdentifier = function(includeOperators) {
9827 var start = this._peekToken.start; 9775 var start = this._peekToken.start;
9828 var myType = null; 9776 var myType = null;
9829 var name = this._specialIdentifier(includeOperators); 9777 var name = this._specialIdentifier(includeOperators);
9830 if (name == null) { 9778 if (name == null) {
9831 myType = this.type(0); 9779 myType = this.type((0));
9832 name = this._specialIdentifier(includeOperators); 9780 name = this._specialIdentifier(includeOperators);
9833 if (name == null) { 9781 if (name == null) {
9834 if (this._peekIdentifier()) { 9782 if (this._peekIdentifier()) {
9835 name = this.identifier(); 9783 name = this.identifier();
9836 } 9784 }
9837 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu ll) { 9785 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu ll) {
9838 name = this._typeAsIdentifier(myType); 9786 name = this._typeAsIdentifier(myType);
9839 myType = null; 9787 myType = null;
9840 } 9788 }
9841 else { 9789 else {
9842 } 9790 }
9843 } 9791 }
9844 } 9792 }
9845 return new DeclaredIdentifier(myType, name, this._makeSpan(start)); 9793 return new DeclaredIdentifier(myType, name, this._makeSpan(start));
9846 } 9794 }
9847 Parser.prototype.finishNewExpression = function(start, isConst) { 9795 Parser.prototype.finishNewExpression = function(start, isConst) {
9848 var type = this.type(0); 9796 var type = this.type((0));
9849 var name = null; 9797 var name = null;
9850 if (this._maybeEat(14/*TokenKind.DOT*/)) { 9798 if (this._maybeEat((14))) {
9851 name = this.identifier(); 9799 name = this.identifier();
9852 } 9800 }
9853 var args = this.arguments(); 9801 var args = this.arguments();
9854 return new NewExpression(isConst, type, name, args, this._makeSpan(start)); 9802 return new NewExpression(isConst, type, name, args, this._makeSpan(start));
9855 } 9803 }
9856 Parser.prototype.finishListLiteral = function(start, isConst, type) { 9804 Parser.prototype.finishListLiteral = function(start, isConst, itemType) {
9857 if (this._maybeEat(56/*TokenKind.INDEX*/)) { 9805 if (this._maybeEat((56))) {
9858 return new ListExpression(isConst, type, [], this._makeSpan(start)); 9806 return new ListExpression(isConst, itemType, [], this._makeSpan(start));
9859 } 9807 }
9860 var values = []; 9808 var values = [];
9861 this._eat(4/*TokenKind.LBRACK*/); 9809 this._eat((4));
9862 while (!this._maybeEat(5/*TokenKind.RBRACK*/)) { 9810 while (!this._maybeEat((5))) {
9863 values.add$1(this.expression()); 9811 values.add$1(this.expression());
9864 if (this._recover && !this._recoverTo(5/*TokenKind.RBRACK*/, 11/*TokenKind.C OMMA*/)) break; 9812 if (this._recover && !this._recoverTo((5), (11))) break;
9865 if (!this._maybeEat(11/*TokenKind.COMMA*/)) { 9813 if (!this._maybeEat((11))) {
9866 this._eat(5/*TokenKind.RBRACK*/); 9814 this._eat((5));
9867 break; 9815 break;
9868 } 9816 }
9869 } 9817 }
9870 return new ListExpression(isConst, type, values, this._makeSpan(start)); 9818 return new ListExpression(isConst, itemType, values, this._makeSpan(start));
9871 } 9819 }
9872 Parser.prototype.finishMapLiteral = function(start, isConst, type) { 9820 Parser.prototype.finishMapLiteral = function(start, isConst, keyType, valueType) {
9873 var items = []; 9821 var items = [];
9874 this._eat(6/*TokenKind.LBRACE*/); 9822 this._eat((6));
9875 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 9823 while (!this._maybeEat((7))) {
9876 items.add$1(this.expression()); 9824 items.add$1(this.expression());
9877 this._eat(8/*TokenKind.COLON*/); 9825 this._eat((8));
9878 items.add$1(this.expression()); 9826 items.add$1(this.expression());
9879 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 11/*TokenKind.C OMMA*/)) break; 9827 if (this._recover && !this._recoverTo((7), (11))) break;
9880 if (!this._maybeEat(11/*TokenKind.COMMA*/)) { 9828 if (!this._maybeEat((11))) {
9881 this._eat(7/*TokenKind.RBRACE*/); 9829 this._eat((7));
9882 break; 9830 break;
9883 } 9831 }
9884 } 9832 }
9885 return new MapExpression(isConst, type, items, this._makeSpan(start)); 9833 return new MapExpression(isConst, keyType, valueType, items, this._makeSpan(st art));
9886 } 9834 }
9887 Parser.prototype.finishTypedLiteral = function(start, isConst) { 9835 Parser.prototype.finishTypedLiteral = function(start, isConst) {
9888 var span = this._makeSpan(start); 9836 var span = this._makeSpan(start);
9889 var typeToBeNamedLater = new NameTypeReference(false, null, null, span); 9837 var typeToBeNamedLater = new NameTypeReference(false, null, null, span);
9890 var genericType = this.addTypeArguments(typeToBeNamedLater, 0); 9838 var genericType = this.addTypeArguments(typeToBeNamedLater, (0));
9891 if (this._peekKind(4/*TokenKind.LBRACK*/) || this._peekKind(56/*TokenKind.INDE X*/)) { 9839 var typeArgs = genericType.get$typeArguments();
9892 genericType.set$baseType(new TypeReference(span, $globals.world.listType)); 9840 if (this._peekKind((4)) || this._peekKind((56))) {
9893 return this.finishListLiteral(start, isConst, genericType); 9841 if ($ne(typeArgs.get$length(), (1))) {
9842 $globals.world.error("exactly one type argument expected for list", generi cType.get$span());
9843 }
9844 return this.finishListLiteral(start, isConst, typeArgs.$index((0)));
9894 } 9845 }
9895 else if (this._peekKind(6/*TokenKind.LBRACE*/)) { 9846 else if (this._peekKind((6))) {
9896 genericType.set$baseType(new TypeReference(span, $globals.world.mapType)); 9847 var keyType, valueType;
9897 var typeArgs = genericType.get$typeArguments(); 9848 if ($eq(typeArgs.get$length(), (1))) {
9898 if ($eq(typeArgs.get$length(), 1)) { 9849 keyType = null;
9899 genericType.set$typeArguments([new TypeReference(span, $globals.world.stri ngType), typeArgs.$index(0)]); 9850 valueType = typeArgs.$index((0));
9900 } 9851 }
9901 else if ($eq(typeArgs.get$length(), 2)) { 9852 else if ($eq(typeArgs.get$length(), (2))) {
9902 var keyType = typeArgs.$index(0); 9853 var keyType0 = typeArgs.$index((0));
9903 if (!(keyType instanceof NameTypeReference) || $ne(keyType.get$name().get$ name(), "String")) { 9854 $globals.world.warning("a map literal takes one type argument specifying t he value type", keyType0.get$span());
9904 $globals.world.error("the key type of a map literal is implicitly \"Stri ng\"", keyType.get$span()); 9855 valueType = typeArgs.$index((1));
9905 }
9906 else {
9907 $globals.world.warning("a map literal takes one type argument specifying the value type", keyType.get$span());
9908 }
9909 } 9856 }
9910 return this.finishMapLiteral(start, isConst, genericType); 9857 return this.finishMapLiteral(start, isConst, keyType, valueType);
9911 } 9858 }
9912 else { 9859 else {
9913 this._errorExpected("array or map literal"); 9860 this._errorExpected("array or map literal");
9914 } 9861 }
9915 } 9862 }
9916 Parser.prototype._readModifiers = function() { 9863 Parser.prototype._readModifiers = function() {
9917 var modifiers = null; 9864 var modifiers = null;
9918 while (true) { 9865 while (true) {
9919 switch (this._peek()) { 9866 switch (this._peek()) {
9920 case 84/*TokenKind.STATIC*/: 9867 case (84):
9921 case 98/*TokenKind.FINAL*/: 9868 case (98):
9922 case 91/*TokenKind.CONST*/: 9869 case (91):
9923 case 71/*TokenKind.ABSTRACT*/: 9870 case (71):
9924 case 73/*TokenKind.FACTORY*/: 9871 case (73):
9925 9872
9926 if (modifiers == null) modifiers = []; 9873 if (modifiers == null) modifiers = [];
9927 modifiers.add$1(this._lang_next()); 9874 modifiers.add$1(this._lang_next());
9928 break; 9875 break;
9929 9876
9930 default: 9877 default:
9931 9878
9932 return modifiers; 9879 return modifiers;
9933 9880
9934 } 9881 }
9935 } 9882 }
9936 return null; 9883 return null;
9937 } 9884 }
9938 Parser.prototype.typeParameter = function() { 9885 Parser.prototype.typeParameter = function() {
9939 var start = this._peekToken.start; 9886 var start = this._peekToken.start;
9940 var name = this.identifier(); 9887 var name = this.identifier();
9941 var myType = null; 9888 var myType = null;
9942 if (this._maybeEat(96/*TokenKind.EXTENDS*/)) { 9889 if (this._maybeEat((96))) {
9943 myType = this.type(1); 9890 myType = this.type((1));
9944 } 9891 }
9945 var tp = new TypeParameter(name, myType, this._makeSpan(start)); 9892 var tp = new TypeParameter(name, myType, this._makeSpan(start));
9946 return new ParameterType(name.get$name(), tp); 9893 return new ParameterType(name.get$name(), tp);
9947 } 9894 }
9948 Parser.prototype.get$typeParameter = function() { 9895 Parser.prototype.get$typeParameter = function() {
9949 return this.typeParameter.bind(this); 9896 return this.typeParameter.bind(this);
9950 } 9897 }
9951 Parser.prototype.typeParameters = function() { 9898 Parser.prototype.typeParameters = function() {
9952 this._eat(52/*TokenKind.LT*/); 9899 this._eat((52));
9953 var closed = false; 9900 var closed = false;
9954 var ret = []; 9901 var ret = [];
9955 do { 9902 do {
9956 var tp = this.typeParameter(); 9903 var tp = this.typeParameter();
9957 ret.add$1(tp); 9904 ret.add$1(tp);
9958 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc e) && $eq(tp.get$typeParameter().get$extendsType().get$depth(), 0)) { 9905 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc e) && $eq(tp.get$typeParameter().get$extendsType().get$depth(), (0))) {
9959 closed = true; 9906 closed = true;
9960 break; 9907 break;
9961 } 9908 }
9962 } 9909 }
9963 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9910 while (this._maybeEat((11)))
9964 if (!closed) { 9911 if (!closed) {
9965 this._eat(53/*TokenKind.GT*/); 9912 this._eat((53));
9966 } 9913 }
9967 return ret; 9914 return ret;
9968 } 9915 }
9969 Parser.prototype.get$typeParameters = function() { 9916 Parser.prototype.get$typeParameters = function() {
9970 return this.typeParameters.bind(this); 9917 return this.typeParameters.bind(this);
9971 } 9918 }
9972 Parser.prototype._eatClosingAngle = function(depth) { 9919 Parser.prototype._eatClosingAngle = function(depth) {
9973 if (this._maybeEat(53/*TokenKind.GT*/)) { 9920 if (this._maybeEat((53))) {
9974 return depth; 9921 return depth;
9975 } 9922 }
9976 else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) { 9923 else if (depth > (0) && this._maybeEat((40))) {
9977 return depth - 1; 9924 return depth - (1);
9978 } 9925 }
9979 else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) { 9926 else if (depth > (1) && this._maybeEat((41))) {
9980 return depth - 2; 9927 return depth - (2);
9981 } 9928 }
9982 else { 9929 else {
9983 this._errorExpected(">"); 9930 this._errorExpected(">");
9984 return depth; 9931 return depth;
9985 } 9932 }
9986 } 9933 }
9987 Parser.prototype.addTypeArguments = function(baseType, depth) { 9934 Parser.prototype.addTypeArguments = function(baseType, depth) {
9988 this._eat(52/*TokenKind.LT*/); 9935 this._eat((52));
9989 return this._finishTypeArguments(baseType, depth, []); 9936 return this._finishTypeArguments(baseType, depth, []);
9990 } 9937 }
9991 Parser.prototype._finishTypeArguments = function(baseType, depth, types) { 9938 Parser.prototype._finishTypeArguments = function(baseType, depth, types) {
9992 var delta = -1; 9939 var delta = (-1);
9993 do { 9940 do {
9994 var myType = this.type(depth + 1); 9941 var myType = this.type(depth + (1));
9995 types.add$1(myType); 9942 types.add$1(myType);
9996 if ((myType instanceof GenericTypeReference) && myType.get$depth() <= depth) { 9943 if ((myType instanceof GenericTypeReference) && myType.get$depth() <= depth) {
9997 delta = depth - myType.get$depth(); 9944 delta = depth - myType.get$depth();
9998 break; 9945 break;
9999 } 9946 }
10000 } 9947 }
10001 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9948 while (this._maybeEat((11)))
10002 if (delta >= 0) { 9949 if (delta >= (0)) {
10003 depth = depth - delta; 9950 depth = depth - delta;
10004 } 9951 }
10005 else { 9952 else {
10006 depth = this._eatClosingAngle(depth); 9953 depth = this._eatClosingAngle(depth);
10007 } 9954 }
10008 var span = this._makeSpan(baseType.span.start); 9955 var span = this._makeSpan(baseType.span.start);
10009 return new GenericTypeReference(baseType, types, depth, span); 9956 return new GenericTypeReference(baseType, types, depth, span);
10010 } 9957 }
10011 Parser.prototype.typeList = function() { 9958 Parser.prototype.typeList = function() {
10012 var types = []; 9959 var types = [];
10013 do { 9960 do {
10014 types.add$1(this.type(0)); 9961 types.add$1(this.type((0)));
10015 } 9962 }
10016 while (this._maybeEat(11/*TokenKind.COMMA*/)) 9963 while (this._maybeEat((11)))
10017 return types; 9964 return types;
10018 } 9965 }
10019 Parser.prototype.nameTypeReference = function() { 9966 Parser.prototype.nameTypeReference = function() {
10020 var start = this._peekToken.start; 9967 var start = this._peekToken.start;
10021 var name; 9968 var name;
10022 var names = null; 9969 var names = null;
10023 var typeArgs = null; 9970 var typeArgs = null;
10024 var isFinal = false; 9971 var isFinal = false;
10025 switch (this._peek()) { 9972 switch (this._peek()) {
10026 case 114/*TokenKind.VOID*/: 9973 case (114):
10027 9974
10028 return new TypeReference(this._lang_next().get$span(), $globals.world.void Type); 9975 return new TypeReference(this._lang_next().get$span(), $globals.world.void Type);
10029 9976
10030 case 113/*TokenKind.VAR*/: 9977 case (113):
10031 9978
10032 return new TypeReference(this._lang_next().get$span(), $globals.world.varT ype); 9979 return new TypeReference(this._lang_next().get$span(), $globals.world.varT ype);
10033 9980
10034 case 98/*TokenKind.FINAL*/: 9981 case (98):
10035 9982
10036 this._eat(98/*TokenKind.FINAL*/); 9983 this._eat((98));
10037 isFinal = true; 9984 isFinal = true;
10038 name = this.identifier(); 9985 name = this.identifier();
10039 break; 9986 break;
10040 9987
10041 default: 9988 default:
10042 9989
10043 name = this.identifier(); 9990 name = this.identifier();
10044 break; 9991 break;
10045 9992
10046 } 9993 }
10047 while (this._maybeEat(14/*TokenKind.DOT*/)) { 9994 while (this._maybeEat((14))) {
10048 if (names == null) names = []; 9995 if (names == null) names = [];
10049 names.add$1(this.identifier()); 9996 names.add$1(this.identifier());
10050 } 9997 }
10051 return new NameTypeReference(isFinal, name, names, this._makeSpan(start)); 9998 return new NameTypeReference(isFinal, name, names, this._makeSpan(start));
10052 } 9999 }
10053 Parser.prototype.type = function(depth) { 10000 Parser.prototype.type = function(depth) {
10054 var typeRef = this.nameTypeReference(); 10001 var typeRef = this.nameTypeReference();
10055 if (this._peekKind(52/*TokenKind.LT*/)) { 10002 if (this._peekKind((52))) {
10056 return this.addTypeArguments(typeRef, depth); 10003 return this.addTypeArguments(typeRef, depth);
10057 } 10004 }
10058 else { 10005 else {
10059 return typeRef; 10006 return typeRef;
10060 } 10007 }
10061 } 10008 }
10062 Parser.prototype.type.$optional = ['depth', '0'] 10009 Parser.prototype.type.$optional = ['depth', '(0)']
10063 Parser.prototype.get$type = function() { 10010 Parser.prototype.get$type = function() {
10064 return this.type.bind(this); 10011 return this.type.bind(this);
10065 } 10012 }
10066 Parser.prototype.formalParameter = function(inOptionalBlock) { 10013 Parser.prototype.formalParameter = function(inOptionalBlock) {
10067 var start = this._peekToken.start; 10014 var start = this._peekToken.start;
10068 var isThis = false; 10015 var isThis = false;
10069 var isRest = false; 10016 var isRest = false;
10070 var di = this.declaredIdentifier(false); 10017 var di = this.declaredIdentifier(false);
10071 var type = di.get$type(); 10018 var type = di.get$type();
10072 var name = di.get$name(); 10019 var name = di.get$name();
10073 if (name == null) { 10020 if (name == null) {
10074 this._lang_error("Formal parameter invalid", this._makeSpan(start)); 10021 this._lang_error("Formal parameter invalid", this._makeSpan(start));
10075 } 10022 }
10076 var value = null; 10023 var value = null;
10077 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 10024 if (this._maybeEat((20))) {
10078 if (!inOptionalBlock) { 10025 if (!inOptionalBlock) {
10079 this._lang_error("default values only allowed inside [optional] section"); 10026 this._lang_error("default values only allowed inside [optional] section");
10080 } 10027 }
10081 value = this.expression(); 10028 value = this.expression();
10082 } 10029 }
10083 else if (this._peekKind(2/*TokenKind.LPAREN*/)) { 10030 else if (this._peekKind((2))) {
10084 var formals = this.formalParameterList(); 10031 var formals = this.formalParameterList();
10085 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start)); 10032 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start));
10086 type = new FunctionTypeReference(false, func, func.get$span()); 10033 type = new FunctionTypeReference(false, func, func.get$span());
10087 } 10034 }
10088 if (inOptionalBlock && value == null) { 10035 if (inOptionalBlock && value == null) {
10089 value = this._makeLiteral(Value.fromNull(this._makeSpan(start))); 10036 value = this._makeLiteral(Value.fromNull(this._makeSpan(start)));
10090 } 10037 }
10091 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) ); 10038 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) );
10092 } 10039 }
10093 Parser.prototype.formalParameterList = function() { 10040 Parser.prototype.formalParameterList = function() {
10094 this._eatLeftParen(); 10041 this._eatLeftParen();
10095 var formals = []; 10042 var formals = [];
10096 var inOptionalBlock = false; 10043 var inOptionalBlock = false;
10097 if (!this._maybeEat(3/*TokenKind.RPAREN*/)) { 10044 if (!this._maybeEat((3))) {
10098 if (this._maybeEat(4/*TokenKind.LBRACK*/)) { 10045 if (this._maybeEat((4))) {
10099 inOptionalBlock = true; 10046 inOptionalBlock = true;
10100 } 10047 }
10101 formals.add$1(this.formalParameter(inOptionalBlock)); 10048 formals.add$1(this.formalParameter(inOptionalBlock));
10102 while (this._maybeEat(11/*TokenKind.COMMA*/)) { 10049 while (this._maybeEat((11))) {
10103 if (this._maybeEat(4/*TokenKind.LBRACK*/)) { 10050 if (this._maybeEat((4))) {
10104 if (inOptionalBlock) { 10051 if (inOptionalBlock) {
10105 this._lang_error("already inside an optional block", this._previousTok en.get$span()); 10052 this._lang_error("already inside an optional block", this._previousTok en.get$span());
10106 } 10053 }
10107 inOptionalBlock = true; 10054 inOptionalBlock = true;
10108 } 10055 }
10109 formals.add$1(this.formalParameter(inOptionalBlock)); 10056 formals.add$1(this.formalParameter(inOptionalBlock));
10110 } 10057 }
10111 if (inOptionalBlock) { 10058 if (inOptionalBlock) {
10112 this._eat(5/*TokenKind.RBRACK*/); 10059 this._eat((5));
10113 } 10060 }
10114 this._eat(3/*TokenKind.RPAREN*/); 10061 this._eat((3));
10115 } 10062 }
10116 return formals; 10063 return formals;
10117 } 10064 }
10118 Parser.prototype.identifier = function() { 10065 Parser.prototype.identifier = function() {
10119 var tok = this._lang_next(); 10066 var tok = this._lang_next();
10120 if (!this._isIdentifier(tok.get$kind())) { 10067 if (!this._isIdentifier(tok.get$kind())) {
10121 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); 10068 this._lang_error(("expected identifier, but found " + tok), tok.get$span());
10122 } 10069 }
10123 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); 10070 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start()));
10124 } 10071 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
10166 this.token = token; 10113 this.token = token;
10167 // Initializers done 10114 // Initializers done
10168 } 10115 }
10169 IncompleteSourceException.prototype.toString = function() { 10116 IncompleteSourceException.prototype.toString = function() {
10170 if (this.token.get$span() == null) return ("Unexpected " + this.token); 10117 if (this.token.get$span() == null) return ("Unexpected " + this.token);
10171 return this.token.get$span().toMessageString(("Unexpected " + this.token)); 10118 return this.token.get$span().toMessageString(("Unexpected " + this.token));
10172 } 10119 }
10173 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto type.toString; 10120 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto type.toString;
10174 // ********** Code for DivertedTokenSource ************** 10121 // ********** Code for DivertedTokenSource **************
10175 function DivertedTokenSource(tokens, parser, previousTokenizer) { 10122 function DivertedTokenSource(tokens, parser, previousTokenizer) {
10176 this._lang_pos = 0 10123 this._lang_pos = (0)
10177 this.tokens = tokens; 10124 this.tokens = tokens;
10178 this.parser = parser; 10125 this.parser = parser;
10179 this.previousTokenizer = previousTokenizer; 10126 this.previousTokenizer = previousTokenizer;
10180 // Initializers done 10127 // Initializers done
10181 } 10128 }
10182 DivertedTokenSource.prototype.next = function() { 10129 DivertedTokenSource.prototype.next = function() {
10183 var token = this.tokens.$index(this._lang_pos); 10130 var token = this.tokens.$index(this._lang_pos);
10184 ++this._lang_pos; 10131 ++this._lang_pos;
10185 if (this._lang_pos == this.tokens.get$length()) { 10132 if (this._lang_pos == this.tokens.get$length()) {
10186 this.parser.tokenizer = this.previousTokenizer; 10133 this.parser.tokenizer = this.previousTokenizer;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
10303 this.type = type; 10250 this.type = type;
10304 this.names = names; 10251 this.names = names;
10305 this.values = values; 10252 this.values = values;
10306 // Initializers done 10253 // Initializers done
10307 Definition.call(this, span); 10254 Definition.call(this, span);
10308 } 10255 }
10309 VariableDefinition.prototype.get$type = function() { return this.type; }; 10256 VariableDefinition.prototype.get$type = function() { return this.type; };
10310 VariableDefinition.prototype.set$type = function(value) { return this.type = val ue; }; 10257 VariableDefinition.prototype.set$type = function(value) { return this.type = val ue; };
10311 VariableDefinition.prototype.get$names = function() { return this.names; }; 10258 VariableDefinition.prototype.get$names = function() { return this.names; };
10312 VariableDefinition.prototype.set$names = function(value) { return this.names = v alue; }; 10259 VariableDefinition.prototype.set$names = function(value) { return this.names = v alue; };
10313 VariableDefinition.prototype.get$values = function() { return this.values; };
10314 VariableDefinition.prototype.set$values = function(value) { return this.values = value; };
10315 VariableDefinition.prototype.visit = function(visitor) { 10260 VariableDefinition.prototype.visit = function(visitor) {
10316 return visitor.visitVariableDefinition(this); 10261 return visitor.visitVariableDefinition(this);
10317 } 10262 }
10318 VariableDefinition.prototype.visit$1 = VariableDefinition.prototype.visit; 10263 VariableDefinition.prototype.visit$1 = VariableDefinition.prototype.visit;
10319 // ********** Code for FunctionDefinition ************** 10264 // ********** Code for FunctionDefinition **************
10320 $inherits(FunctionDefinition, Definition); 10265 $inherits(FunctionDefinition, Definition);
10321 function FunctionDefinition(modifiers, returnType, name, formals, initializers, nativeBody, body, span) { 10266 function FunctionDefinition(modifiers, returnType, name, formals, initializers, nativeBody, body, span) {
10322 this.modifiers = modifiers; 10267 this.modifiers = modifiers;
10323 this.returnType = returnType; 10268 this.returnType = returnType;
10324 this.name = name; 10269 this.name = name;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
10680 NewExpression.prototype.get$name = function() { return this.name; }; 10625 NewExpression.prototype.get$name = function() { return this.name; };
10681 NewExpression.prototype.set$name = function(value) { return this.name = value; } ; 10626 NewExpression.prototype.set$name = function(value) { return this.name = value; } ;
10682 NewExpression.prototype.get$arguments = function() { return this.arguments; }; 10627 NewExpression.prototype.get$arguments = function() { return this.arguments; };
10683 NewExpression.prototype.set$arguments = function(value) { return this.arguments = value; }; 10628 NewExpression.prototype.set$arguments = function(value) { return this.arguments = value; };
10684 NewExpression.prototype.visit = function(visitor) { 10629 NewExpression.prototype.visit = function(visitor) {
10685 return visitor.visitNewExpression(this); 10630 return visitor.visitNewExpression(this);
10686 } 10631 }
10687 NewExpression.prototype.visit$1 = NewExpression.prototype.visit; 10632 NewExpression.prototype.visit$1 = NewExpression.prototype.visit;
10688 // ********** Code for ListExpression ************** 10633 // ********** Code for ListExpression **************
10689 $inherits(ListExpression, Expression); 10634 $inherits(ListExpression, Expression);
10690 function ListExpression(isConst, type, values, span) { 10635 function ListExpression(isConst, itemType, values, span) {
10691 this.isConst = isConst; 10636 this.isConst = isConst;
10692 this.type = type; 10637 this.itemType = itemType;
10693 this.values = values; 10638 this.values = values;
10694 // Initializers done 10639 // Initializers done
10695 Expression.call(this, span); 10640 Expression.call(this, span);
10696 } 10641 }
10697 ListExpression.prototype.get$isConst = function() { return this.isConst; }; 10642 ListExpression.prototype.get$isConst = function() { return this.isConst; };
10698 ListExpression.prototype.set$isConst = function(value) { return this.isConst = v alue; }; 10643 ListExpression.prototype.set$isConst = function(value) { return this.isConst = v alue; };
10699 ListExpression.prototype.get$type = function() { return this.type; };
10700 ListExpression.prototype.set$type = function(value) { return this.type = value; };
10701 ListExpression.prototype.get$values = function() { return this.values; };
10702 ListExpression.prototype.set$values = function(value) { return this.values = val ue; };
10703 ListExpression.prototype.visit = function(visitor) { 10644 ListExpression.prototype.visit = function(visitor) {
10704 return visitor.visitListExpression(this); 10645 return visitor.visitListExpression(this);
10705 } 10646 }
10706 ListExpression.prototype.visit$1 = ListExpression.prototype.visit; 10647 ListExpression.prototype.visit$1 = ListExpression.prototype.visit;
10707 // ********** Code for MapExpression ************** 10648 // ********** Code for MapExpression **************
10708 $inherits(MapExpression, Expression); 10649 $inherits(MapExpression, Expression);
10709 function MapExpression(isConst, type, items, span) { 10650 function MapExpression(isConst, keyType, valueType, items, span) {
10710 this.isConst = isConst; 10651 this.isConst = isConst;
10711 this.type = type; 10652 this.keyType = keyType;
10653 this.valueType = valueType;
10712 this.items = items; 10654 this.items = items;
10713 // Initializers done 10655 // Initializers done
10714 Expression.call(this, span); 10656 Expression.call(this, span);
10715 } 10657 }
10716 MapExpression.prototype.get$isConst = function() { return this.isConst; }; 10658 MapExpression.prototype.get$isConst = function() { return this.isConst; };
10717 MapExpression.prototype.set$isConst = function(value) { return this.isConst = va lue; }; 10659 MapExpression.prototype.set$isConst = function(value) { return this.isConst = va lue; };
10718 MapExpression.prototype.get$type = function() { return this.type; };
10719 MapExpression.prototype.set$type = function(value) { return this.type = value; } ;
10720 MapExpression.prototype.visit = function(visitor) { 10660 MapExpression.prototype.visit = function(visitor) {
10721 return visitor.visitMapExpression(this); 10661 return visitor.visitMapExpression(this);
10722 } 10662 }
10723 MapExpression.prototype.visit$1 = MapExpression.prototype.visit; 10663 MapExpression.prototype.visit$1 = MapExpression.prototype.visit;
10724 // ********** Code for ConditionalExpression ************** 10664 // ********** Code for ConditionalExpression **************
10725 $inherits(ConditionalExpression, Expression); 10665 $inherits(ConditionalExpression, Expression);
10726 function ConditionalExpression(test, trueBranch, falseBranch, span) { 10666 function ConditionalExpression(test, trueBranch, falseBranch, span) {
10727 this.test = test; 10667 this.test = test;
10728 this.trueBranch = trueBranch; 10668 this.trueBranch = trueBranch;
10729 this.falseBranch = falseBranch; 10669 this.falseBranch = falseBranch;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
11088 } 11028 }
11089 Type.prototype.get$isFunction = function() { 11029 Type.prototype.get$isFunction = function() {
11090 return false; 11030 return false;
11091 } 11031 }
11092 Type.prototype.get$isList = function() { 11032 Type.prototype.get$isList = function() {
11093 return false; 11033 return false;
11094 } 11034 }
11095 Type.prototype.get$isNum = function() { 11035 Type.prototype.get$isNum = function() {
11096 return false; 11036 return false;
11097 } 11037 }
11038 Type.prototype.get$isInt = function() {
11039 return false;
11040 }
11041 Type.prototype.get$isDouble = function() {
11042 return false;
11043 }
11098 Type.prototype.get$isVoid = function() { 11044 Type.prototype.get$isVoid = function() {
11099 return false; 11045 return false;
11100 } 11046 }
11101 Type.prototype.get$isNullable = function() { 11047 Type.prototype.get$isNullable = function() {
11102 return true; 11048 return true;
11103 } 11049 }
11104 Type.prototype.get$isVarOrFunction = function() { 11050 Type.prototype.get$isVarOrFunction = function() {
11105 return this.get$isVar() || this.get$isFunction(); 11051 return this.get$isVar() || this.get$isFunction();
11106 } 11052 }
11107 Type.prototype.get$isVarOrObject = function() { 11053 Type.prototype.get$isVarOrObject = function() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
11221 Type.prototype._getMemberInParents = function(memberName) { 11167 Type.prototype._getMemberInParents = function(memberName) {
11222 if (this.get$isClass()) { 11168 if (this.get$isClass()) {
11223 if (this.get$parent() != null) { 11169 if (this.get$parent() != null) {
11224 return this.get$parent().getMember(memberName); 11170 return this.get$parent().getMember(memberName);
11225 } 11171 }
11226 else { 11172 else {
11227 return null; 11173 return null;
11228 } 11174 }
11229 } 11175 }
11230 else { 11176 else {
11231 if (this.get$interfaces() != null && this.get$interfaces().get$length() > 0) { 11177 if (this.get$interfaces() != null && this.get$interfaces().get$length() > (0 )) {
11232 var $$list = this.get$interfaces(); 11178 var $$list = this.get$interfaces();
11233 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 11179 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
11234 var i = $$list.$index($$i); 11180 var i = $$list.$index($$i);
11235 var ret = i.getMember$1(memberName); 11181 var ret = i.getMember$1(memberName);
11236 if (ret != null) { 11182 if (ret != null) {
11237 return ret; 11183 return ret;
11238 } 11184 }
11239 } 11185 }
11240 } 11186 }
11241 return $globals.world.objectType.getMember(memberName); 11187 return $globals.world.objectType.getMember(memberName);
(...skipping 10 matching lines...) Expand all
11252 this._resolvedMembers.$setindex(memberName, ret); 11198 this._resolvedMembers.$setindex(memberName, ret);
11253 if (member.get$isStatic()) { 11199 if (member.get$isStatic()) {
11254 return ret; 11200 return ret;
11255 } 11201 }
11256 else { 11202 else {
11257 var $$list = this.get$subtypes(); 11203 var $$list = this.get$subtypes();
11258 for (var $$i = this.get$subtypes().iterator(); $$i.hasNext$0(); ) { 11204 for (var $$i = this.get$subtypes().iterator(); $$i.hasNext$0(); ) {
11259 var t = $$i.next$0(); 11205 var t = $$i.next$0();
11260 if (!this.get$isClass() && t.get$isClass()) { 11206 if (!this.get$isClass() && t.get$isClass()) {
11261 var m = t.getMember$1(memberName); 11207 var m = t.getMember$1(memberName);
11262 if (m != null && ret.members.indexOf(m) == -1) { 11208 if (m != null && ret.members.indexOf(m) == (-1)) {
11263 ret.add(m); 11209 ret.add(m);
11264 } 11210 }
11265 } 11211 }
11266 else { 11212 else {
11267 var m = t.get$members().$index(memberName); 11213 var m = t.get$members().$index(memberName);
11268 if (m != null) ret.add(m); 11214 if (m != null) ret.add(m);
11269 } 11215 }
11270 } 11216 }
11271 return ret; 11217 return ret;
11272 } 11218 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
11346 } 11292 }
11347 if (this.get$interfaces() != null && this.get$interfaces().some((function (i) { 11293 if (this.get$interfaces() != null && this.get$interfaces().some((function (i) {
11348 return i.isSubtypeOf$1(other); 11294 return i.isSubtypeOf$1(other);
11349 }) 11295 })
11350 )) { 11296 )) {
11351 return true; 11297 return true;
11352 } 11298 }
11353 return false; 11299 return false;
11354 } 11300 }
11355 Type.prototype.hashCode = function() { 11301 Type.prototype.hashCode = function() {
11356 var libraryCode = this.get$library() == null ? 1 : this.get$library().hashCode (); 11302 var libraryCode = this.get$library() == null ? (1) : this.get$library().hashCo de();
11357 var nameCode = this.name == null ? 1 : this.name.hashCode(); 11303 var nameCode = this.name == null ? (1) : this.name.hashCode();
11358 return (libraryCode << 4) ^ nameCode; 11304 return (libraryCode << (4)) ^ nameCode;
11359 } 11305 }
11360 Type.prototype.$eq = function(other) { 11306 Type.prototype.$eq = function(other) {
11361 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this .get$library(), other.get$library()); 11307 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this .get$library(), other.get$library());
11362 } 11308 }
11363 Type._isFunctionSubtypeOf = function(t, s) { 11309 Type._isFunctionSubtypeOf = function(t, s) {
11364 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) { 11310 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) {
11365 return false; 11311 return false;
11366 } 11312 }
11367 var tp = t.parameters; 11313 var tp = t.parameters;
11368 var sp = s.parameters; 11314 var sp = s.parameters;
11369 if (tp.get$length() < sp.get$length()) return false; 11315 if (tp.get$length() < sp.get$length()) return false;
11370 for (var i = 0; 11316 for (var i = (0);
11371 i < sp.get$length(); i++) { 11317 i < sp.get$length(); i++) {
11372 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur n false; 11318 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur n false;
11373 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index( i).get$name())) return false; 11319 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index( i).get$name())) return false;
11374 if (!tp.$index(i).get$type().isAssignable$1(sp.$index(i).get$type())) return false; 11320 if (!tp.$index(i).get$type().isAssignable$1(sp.$index(i).get$type())) return false;
11375 } 11321 }
11376 if (tp.get$length() > sp.get$length() && !tp.$index(sp.get$length()).get$isOpt ional()) return false; 11322 if (tp.get$length() > sp.get$length() && !tp.$index(sp.get$length()).get$isOpt ional()) return false;
11377 return true; 11323 return true;
11378 } 11324 }
11379 Type.prototype._checkExtends$0 = Type.prototype._checkExtends; 11325 Type.prototype._checkExtends$0 = Type.prototype._checkExtends;
11380 Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype; 11326 Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
11829 if (!this.library.get$isCore()) return null; 11775 if (!this.library.get$isCore()) return null;
11830 if (this.get$isBool()) return "boolean"; 11776 if (this.get$isBool()) return "boolean";
11831 else if (this.get$isNum()) return "number"; 11777 else if (this.get$isNum()) return "number";
11832 else if (this.get$isString()) return "string"; 11778 else if (this.get$isString()) return "string";
11833 else if (this.get$isFunction()) return "function"; 11779 else if (this.get$isFunction()) return "function";
11834 else return null; 11780 else return null;
11835 } 11781 }
11836 DefinedType.prototype.get$isNum = function() { 11782 DefinedType.prototype.get$isNum = function() {
11837 return this.library != null && this.library.get$isCore() && (this.name == "num " || this.name == "int" || this.name == "double"); 11783 return this.library != null && this.library.get$isCore() && (this.name == "num " || this.name == "int" || this.name == "double");
11838 } 11784 }
11785 DefinedType.prototype.get$isInt = function() {
11786 return $eq(this, $globals.world.intType);
11787 }
11788 DefinedType.prototype.get$isDouble = function() {
11789 return $eq(this, $globals.world.doubleType);
11790 }
11839 DefinedType.prototype.getCallMethod = function() { 11791 DefinedType.prototype.getCallMethod = function() {
11840 return this.members.$index(":call"); 11792 return this.members.$index(":call");
11841 } 11793 }
11842 DefinedType.prototype.getAllMembers = function() { 11794 DefinedType.prototype.getAllMembers = function() {
11843 return HashMapImplementation.HashMapImplementation$from$factory(this.members); 11795 return HashMapImplementation.HashMapImplementation$from$factory(this.members);
11844 } 11796 }
11845 DefinedType.prototype.markUsed = function() { 11797 DefinedType.prototype.markUsed = function() {
11846 if (this.isUsed) return; 11798 if (this.isUsed) return;
11847 this.isUsed = true; 11799 this.isUsed = true;
11848 this._checkExtends(); 11800 this._checkExtends();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
11892 this._subtypes.addAll(st.get$subtypes()); 11844 this._subtypes.addAll(st.get$subtypes());
11893 } 11845 }
11894 } 11846 }
11895 return this._subtypes; 11847 return this._subtypes;
11896 } 11848 }
11897 DefinedType.prototype._cycleInClassExtends = function() { 11849 DefinedType.prototype._cycleInClassExtends = function() {
11898 var seen = new HashSetImplementation(); 11850 var seen = new HashSetImplementation();
11899 seen.add(this); 11851 seen.add(this);
11900 var ancestor = this.get$parent(); 11852 var ancestor = this.get$parent();
11901 while (ancestor != null) { 11853 while (ancestor != null) {
11902 if (ancestor === this) { 11854 if (ancestor == this) {
11903 return true; 11855 return true;
11904 } 11856 }
11905 if (seen.contains(ancestor)) { 11857 if (seen.contains(ancestor)) {
11906 return false; 11858 return false;
11907 } 11859 }
11908 seen.add(ancestor); 11860 seen.add(ancestor);
11909 ancestor = ancestor.get$parent(); 11861 ancestor = ancestor.get$parent();
11910 } 11862 }
11911 return false; 11863 return false;
11912 } 11864 }
11913 DefinedType.prototype._cycleInInterfaceExtends = function() { 11865 DefinedType.prototype._cycleInInterfaceExtends = function() {
11914 var $this = this; // closure support 11866 var $this = this; // closure support
11915 var seen = new HashSetImplementation(); 11867 var seen = new HashSetImplementation();
11916 seen.add(this); 11868 seen.add(this);
11917 function _helper(ancestor) { 11869 function _helper(ancestor) {
11918 if (ancestor == null) return false; 11870 if (ancestor == null) return false;
11919 if (ancestor === $this) return true; 11871 if (ancestor == $this) return true;
11920 if (seen.contains(ancestor)) { 11872 if (seen.contains(ancestor)) {
11921 return false; 11873 return false;
11922 } 11874 }
11923 seen.add(ancestor); 11875 seen.add(ancestor);
11924 if (ancestor.get$interfaces() != null) { 11876 if (ancestor.get$interfaces() != null) {
11925 var $$list = ancestor.get$interfaces(); 11877 var $$list = ancestor.get$interfaces();
11926 for (var $$i = ancestor.get$interfaces().iterator$0(); $$i.hasNext$0(); ) { 11878 for (var $$i = ancestor.get$interfaces().iterator$0(); $$i.hasNext$0(); ) {
11927 var parent = $$i.next$0(); 11879 var parent = $$i.next$0();
11928 if (_helper(parent)) return true; 11880 if (_helper(parent)) return true;
11929 } 11881 }
11930 } 11882 }
11931 return false; 11883 return false;
11932 } 11884 }
11933 for (var i = 0; 11885 for (var i = (0);
11934 i < this.interfaces.get$length(); i++) { 11886 i < this.interfaces.get$length(); i++) {
11935 if (_helper(this.interfaces.$index(i))) return i; 11887 if (_helper(this.interfaces.$index(i))) return i;
11936 } 11888 }
11937 return -1; 11889 return (-1);
11938 } 11890 }
11939 DefinedType.prototype.resolve = function() { 11891 DefinedType.prototype.resolve = function() {
11940 if ((this.definition instanceof TypeDefinition)) { 11892 if ((this.definition instanceof TypeDefinition)) {
11941 var typeDef = this.definition; 11893 var typeDef = this.definition;
11942 if (this.isClass) { 11894 if (this.isClass) {
11943 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > 0) { 11895 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > (0 )) {
11944 if (typeDef.extendsTypes.get$length() > 1) { 11896 if (typeDef.extendsTypes.get$length() > (1)) {
11945 $globals.world.error("more than one base class", typeDef.extendsTypes. $index(1).get$span()); 11897 $globals.world.error("more than one base class", typeDef.extendsTypes. $index((1)).get$span());
11946 } 11898 }
11947 var extendsTypeRef = typeDef.extendsTypes.$index(0); 11899 var extendsTypeRef = typeDef.extendsTypes.$index((0));
11948 if ((extendsTypeRef instanceof GenericTypeReference)) { 11900 if ((extendsTypeRef instanceof GenericTypeReference)) {
11949 var g = extendsTypeRef; 11901 var g = extendsTypeRef;
11950 this.set$parent(this.resolveType(g.baseType, true)); 11902 this.set$parent(this.resolveType(g.baseType, true));
11951 } 11903 }
11952 this.set$parent(this.resolveType(extendsTypeRef, true)); 11904 this.set$parent(this.resolveType(extendsTypeRef, true));
11953 if (!this.get$parent().get$isClass()) { 11905 if (!this.get$parent().get$isClass()) {
11954 $globals.world.error("class may not extend an interface - use implemen ts", typeDef.extendsTypes.$index(0).get$span()); 11906 $globals.world.error("class may not extend an interface - use implemen ts", typeDef.extendsTypes.$index((0)).get$span());
11955 } 11907 }
11956 this.get$parent().addDirectSubtype(this); 11908 this.get$parent().addDirectSubtype(this);
11957 if (this._cycleInClassExtends()) { 11909 if (this._cycleInClassExtends()) {
11958 $globals.world.error(("class \"" + this.name + "\" has a cycle in its inheritance chain"), extendsTypeRef.get$span()); 11910 $globals.world.error(("class \"" + this.name + "\" has a cycle in its inheritance chain"), extendsTypeRef.get$span());
11959 } 11911 }
11960 } 11912 }
11961 else { 11913 else {
11962 if (!this.get$isObject()) { 11914 if (!this.get$isObject()) {
11963 this.set$parent($globals.world.objectType); 11915 this.set$parent($globals.world.objectType);
11964 this.get$parent().addDirectSubtype(this); 11916 this.get$parent().addDirectSubtype(this);
11965 } 11917 }
11966 } 11918 }
11967 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes); 11919 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes);
11968 if (typeDef.defaultType != null) { 11920 if (typeDef.defaultType != null) {
11969 $globals.world.error("default not allowed on classes", typeDef.defaultTy pe.span); 11921 $globals.world.error("default not allowed on classes", typeDef.defaultTy pe.span);
11970 } 11922 }
11971 } 11923 }
11972 else { 11924 else {
11973 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length( ) > 0) { 11925 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length( ) > (0)) {
11974 $globals.world.error("implements not allowed on interfaces (use extends) ", typeDef.implementsTypes.$index(0).get$span()); 11926 $globals.world.error("implements not allowed on interfaces (use extends) ", typeDef.implementsTypes.$index((0)).get$span());
11975 } 11927 }
11976 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes); 11928 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes);
11977 var res = this._cycleInInterfaceExtends(); 11929 var res = this._cycleInInterfaceExtends();
11978 if (res >= 0) { 11930 if (res >= (0)) {
11979 $globals.world.error(("interface \"" + this.name + "\" has a cycle in it s inheritance chain"), typeDef.extendsTypes.$index(res).get$span()); 11931 $globals.world.error(("interface \"" + this.name + "\" has a cycle in it s inheritance chain"), typeDef.extendsTypes.$index(res).get$span());
11980 } 11932 }
11981 if (typeDef.defaultType != null) { 11933 if (typeDef.defaultType != null) {
11982 this.defaultType = this.resolveType(typeDef.defaultType.baseType, true); 11934 this.defaultType = this.resolveType(typeDef.defaultType.baseType, true);
11983 if (this.defaultType == null) { 11935 if (this.defaultType == null) {
11984 $globals.world.warning("unresolved default class", typeDef.defaultType .span); 11936 $globals.world.warning("unresolved default class", typeDef.defaultType .span);
11985 } 11937 }
11986 else { 11938 else {
11987 this.defaultType._resolveTypeParams(typeDef.defaultType.typeParameters ); 11939 this.defaultType._resolveTypeParams(typeDef.defaultType.typeParameters );
11988 } 11940 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
12029 if (methodName == null) methodName = definition.name.name; 11981 if (methodName == null) methodName = definition.name.name;
12030 var method = new MethodMember(methodName, this, definition); 11982 var method = new MethodMember(methodName, this, definition);
12031 if (method.get$isConstructor()) { 11983 if (method.get$isConstructor()) {
12032 if (this.constructors.containsKey(method.get$constructorName())) { 11984 if (this.constructors.containsKey(method.get$constructorName())) {
12033 $globals.world.error(("duplicate constructor definition of " + method.get$ name()), definition.span); 11985 $globals.world.error(("duplicate constructor definition of " + method.get$ name()), definition.span);
12034 return; 11986 return;
12035 } 11987 }
12036 this.constructors.$setindex(method.get$constructorName(), method); 11988 this.constructors.$setindex(method.get$constructorName(), method);
12037 return; 11989 return;
12038 } 11990 }
12039 if (definition.modifiers != null && definition.modifiers.get$length() == 1 && $eq(definition.modifiers.$index(0).get$kind(), 73/*TokenKind.FACTORY*/)) { 11991 if (definition.modifiers != null && definition.modifiers.get$length() == (1) & & $eq(definition.modifiers.$index((0)).get$kind(), (73))) {
12040 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) { 11992 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) {
12041 $globals.world.error(("duplicate factory definition of \"" + method.get$na me() + "\""), definition.span); 11993 $globals.world.error(("duplicate factory definition of \"" + method.get$na me() + "\""), definition.span);
12042 return; 11994 return;
12043 } 11995 }
12044 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod); 11996 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod);
12045 return; 11997 return;
12046 } 11998 }
12047 if (methodName.startsWith("get:") || methodName.startsWith("set:")) { 11999 if (methodName.startsWith("get:") || methodName.startsWith("set:")) {
12048 var propName = methodName.substring(4); 12000 var propName = methodName.substring((4));
12049 var prop = this.members.$index(propName); 12001 var prop = this.members.$index(propName);
12050 if (prop == null) { 12002 if (prop == null) {
12051 prop = new PropertyMember(propName, this); 12003 prop = new PropertyMember(propName, this);
12052 this.members.$setindex(propName, prop); 12004 this.members.$setindex(propName, prop);
12053 } 12005 }
12054 if (!(prop instanceof PropertyMember)) { 12006 if (!(prop instanceof PropertyMember)) {
12055 $globals.world.error(("property conflicts with field \"" + propName + "\"" ), definition.span); 12007 $globals.world.error(("property conflicts with field \"" + propName + "\"" ), definition.span);
12056 return; 12008 return;
12057 } 12009 }
12058 if (methodName[0] == "g") { 12010 if (methodName[(0)] == "g") {
12059 if (prop.get$getter() != null) { 12011 if (prop.get$getter() != null) {
12060 $globals.world.error(("duplicate getter definition for \"" + propName + "\""), definition.span); 12012 $globals.world.error(("duplicate getter definition for \"" + propName + "\""), definition.span);
12061 } 12013 }
12062 prop.set$getter(method); 12014 prop.set$getter(method);
12063 } 12015 }
12064 else { 12016 else {
12065 if (prop.get$setter() != null) { 12017 if (prop.get$setter() != null) {
12066 $globals.world.error(("duplicate setter definition for \"" + propName + "\""), definition.span); 12018 $globals.world.error(("duplicate setter definition for \"" + propName + "\""), definition.span);
12067 } 12019 }
12068 prop.set$setter(method); 12020 prop.set$setter(method);
12069 } 12021 }
12070 return; 12022 return;
12071 } 12023 }
12072 if (this.members.containsKey(methodName)) { 12024 if (this.members.containsKey(methodName)) {
12073 $globals.world.error(("duplicate method definition of \"" + method.get$name( ) + "\""), definition.span); 12025 $globals.world.error(("duplicate method definition of \"" + method.get$name( ) + "\""), definition.span);
12074 return; 12026 return;
12075 } 12027 }
12076 this.members.$setindex(methodName, method); 12028 this.members.$setindex(methodName, method);
12077 } 12029 }
12078 DefinedType.prototype.addField = function(definition) { 12030 DefinedType.prototype.addField = function(definition) {
12079 for (var i = 0; 12031 for (var i = (0);
12080 i < definition.names.get$length(); i++) { 12032 i < definition.names.get$length(); i++) {
12081 var name = definition.names.$index(i).get$name(); 12033 var name = definition.names.$index(i).get$name();
12082 if (this.members.containsKey(name)) { 12034 if (this.members.containsKey(name)) {
12083 $globals.world.error(("duplicate field definition of \"" + name + "\""), d efinition.span); 12035 $globals.world.error(("duplicate field definition of \"" + name + "\""), d efinition.span);
12084 return; 12036 return;
12085 } 12037 }
12086 var value = null; 12038 var value = null;
12087 if (definition.values != null) { 12039 if (definition.values != null) {
12088 value = definition.values.$index(i); 12040 value = definition.values.$index(i);
12089 } 12041 }
(...skipping 21 matching lines...) Expand all
12111 return this.defaultType.getFactory(this, constructorName); 12063 return this.defaultType.getFactory(this, constructorName);
12112 } 12064 }
12113 return ret; 12065 return ret;
12114 } 12066 }
12115 ret = this.factories.getFactory(this.name, constructorName); 12067 ret = this.factories.getFactory(this.name, constructorName);
12116 if (ret != null) return ret; 12068 if (ret != null) return ret;
12117 return this._tryCreateDefaultConstructor(constructorName); 12069 return this._tryCreateDefaultConstructor(constructorName);
12118 } 12070 }
12119 DefinedType.prototype._checkDefaultTypeParams = function() { 12071 DefinedType.prototype._checkDefaultTypeParams = function() {
12120 function toList(list) { 12072 function toList(list) {
12121 return (list != null ? list : const$127/*const []*/); 12073 return (list != null ? list : const$127);
12122 } 12074 }
12123 var typeDef = this.definition; 12075 var typeDef = this.definition;
12124 if (typeDef.defaultType.oldFactory) { 12076 if (typeDef.defaultType.oldFactory) {
12125 return; 12077 return;
12126 } 12078 }
12127 var interfaceParams = toList(this.typeParameters); 12079 var interfaceParams = toList(this.typeParameters);
12128 var defaultParams = toList(typeDef.defaultType.typeParameters); 12080 var defaultParams = toList(typeDef.defaultType.typeParameters);
12129 var classParams = toList(this.defaultType.typeParameters); 12081 var classParams = toList(this.defaultType.typeParameters);
12130 if ($ne(interfaceParams.get$length(), defaultParams.get$length()) || $ne(defau ltParams.get$length(), classParams.get$length())) { 12082 if ($ne(interfaceParams.get$length(), defaultParams.get$length()) || $ne(defau ltParams.get$length(), classParams.get$length())) {
12131 $globals.world.error("\"default\" must have the same number of type paramete rs as the class and interface do", this.get$span(), typeDef.defaultType.span, th is.defaultType.get$span()); 12083 $globals.world.error("\"default\" must have the same number of type paramete rs as the class and interface do", this.get$span(), typeDef.defaultType.span, th is.defaultType.get$span());
12132 return; 12084 return;
12133 } 12085 }
12134 for (var i = 0; 12086 for (var i = (0);
12135 i < interfaceParams.get$length(); i++) { 12087 i < interfaceParams.get$length(); i++) {
12136 var ip = interfaceParams.$index(i); 12088 var ip = interfaceParams.$index(i);
12137 var dp = defaultParams.$index(i); 12089 var dp = defaultParams.$index(i);
12138 var cp = classParams.$index(i); 12090 var cp = classParams.$index(i);
12139 dp.resolve$0(); 12091 dp.resolve$0();
12140 if ($ne(ip.get$name(), dp.get$name()) || $ne(dp.get$name(), cp.get$name())) { 12092 if ($ne(ip.get$name(), dp.get$name()) || $ne(dp.get$name(), cp.get$name())) {
12141 $globals.world.error("default class must have the same type parameter name s as the class and interface", ip.get$span(), dp.get$span(), cp.get$span()); 12093 $globals.world.error("default class must have the same type parameter name s as the class and interface", ip.get$span(), dp.get$span(), cp.get$span());
12142 } 12094 }
12143 else if ($ne(dp.get$extendsType(), cp.get$extendsType())) { 12095 else if ($ne(dp.get$extendsType(), cp.get$extendsType())) {
12144 $globals.world.error("default class type parameters must have the same ext ends as the class does", dp.get$span(), cp.get$span()); 12096 $globals.world.error("default class type parameters must have the same ext ends as the class does", dp.get$span(), cp.get$span());
12145 } 12097 }
12146 else if (!dp.get$extendsType().isSubtypeOf$1(ip.get$extendsType())) { 12098 else if (!dp.get$extendsType().isSubtypeOf$1(ip.get$extendsType())) {
12147 $globals.world.warning("\"default\" can only have tighter type parameter \ "extends\" than the interface", dp.get$span(), ip.get$span()); 12099 $globals.world.warning("\"default\" can only have tighter type parameter \ "extends\" than the interface", dp.get$span(), ip.get$span());
12148 } 12100 }
12149 } 12101 }
12150 } 12102 }
12151 DefinedType.prototype._tryCreateDefaultConstructor = function(name) { 12103 DefinedType.prototype._tryCreateDefaultConstructor = function(name) {
12152 if (name == "" && this.definition != null && this.isClass && this.constructors .get$length() == 0) { 12104 if (name == "" && this.definition != null && this.isClass && this.constructors .get$length() == (0)) {
12153 var span = this.definition.span; 12105 var span = this.definition.span;
12154 var inits = null, native_ = null, body = null; 12106 var inits = null, native_ = null, body = null;
12155 if (this.isNative) { 12107 if (this.isNative) {
12156 native_ = ""; 12108 native_ = "";
12157 inits = null; 12109 inits = null;
12158 } 12110 }
12159 else { 12111 else {
12160 body = null; 12112 body = null;
12161 inits = [new CallExpression(new SuperExpression(span), [], span)]; 12113 inits = [new CallExpression(new SuperExpression(span), [], span)];
12162 } 12114 }
(...skipping 19 matching lines...) Expand all
12182 } 12134 }
12183 return this._getMemberInParents(memberName); 12135 return this._getMemberInParents(memberName);
12184 } 12136 }
12185 DefinedType.prototype.resolveTypeParams = function(inType) { 12137 DefinedType.prototype.resolveTypeParams = function(inType) {
12186 return this; 12138 return this;
12187 } 12139 }
12188 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) { 12140 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) {
12189 var jsnames = []; 12141 var jsnames = [];
12190 var names = []; 12142 var names = [];
12191 var typeMap = new HashMapImplementation(); 12143 var typeMap = new HashMapImplementation();
12192 for (var i = 0; 12144 for (var i = (0);
12193 i < typeArgs.get$length(); i++) { 12145 i < typeArgs.get$length(); i++) {
12194 var paramName = this.typeParameters.$index(i).get$name(); 12146 var paramName = this.typeParameters.$index(i).get$name();
12195 typeMap.$setindex(paramName, typeArgs.$index(i)); 12147 typeMap.$setindex(paramName, typeArgs.$index(i));
12196 names.add$1(typeArgs.$index(i).get$name()); 12148 names.add$1(typeArgs.$index(i).get$name());
12197 jsnames.add$1(typeArgs.$index(i).get$jsname()); 12149 jsnames.add$1(typeArgs.$index(i).get$jsname());
12198 } 12150 }
12199 var jsname = ("" + this.get$jsname() + "_" + Strings.join(jsnames, "$")); 12151 var jsname = ("" + this.get$jsname() + "_" + Strings.join(jsnames, "$"));
12200 var simpleName = ("" + this.name + "<" + Strings.join(names, ", ") + ">"); 12152 var simpleName = ("" + this.name + "<" + Strings.join(names, ", ") + ">");
12201 var key = Strings.join(names, "$"); 12153 var key = Strings.join(names, "$");
12202 var ret = this._concreteTypes.$index(key); 12154 var ret = this._concreteTypes.$index(key);
(...skipping 25 matching lines...) Expand all
12228 DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition; 12180 DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition;
12229 // ********** Code for NativeType ************** 12181 // ********** Code for NativeType **************
12230 function NativeType(name) { 12182 function NativeType(name) {
12231 this.isConstructorHidden = false 12183 this.isConstructorHidden = false
12232 this.isJsGlobalObject = false 12184 this.isJsGlobalObject = false
12233 this.isSingleton = false 12185 this.isSingleton = false
12234 this.name = name; 12186 this.name = name;
12235 // Initializers done 12187 // Initializers done
12236 while (true) { 12188 while (true) {
12237 if (this.name.startsWith("@")) { 12189 if (this.name.startsWith("@")) {
12238 this.name = this.name.substring(1); 12190 this.name = this.name.substring((1));
12239 this.isJsGlobalObject = true; 12191 this.isJsGlobalObject = true;
12240 } 12192 }
12241 else if (this.name.startsWith("*")) { 12193 else if (this.name.startsWith("*")) {
12242 this.name = this.name.substring(1); 12194 this.name = this.name.substring((1));
12243 this.isConstructorHidden = true; 12195 this.isConstructorHidden = true;
12244 } 12196 }
12245 else { 12197 else {
12246 break; 12198 break;
12247 } 12199 }
12248 } 12200 }
12249 if (this.name.startsWith("=")) { 12201 if (this.name.startsWith("=")) {
12250 this.name = this.name.substring(1); 12202 this.name = this.name.substring((1));
12251 this.isSingleton = true; 12203 this.isSingleton = true;
12252 } 12204 }
12253 } 12205 }
12254 NativeType.prototype.get$name = function() { return this.name; }; 12206 NativeType.prototype.get$name = function() { return this.name; };
12255 NativeType.prototype.set$name = function(value) { return this.name = value; }; 12207 NativeType.prototype.set$name = function(value) { return this.name = value; };
12256 // ********** Code for FixedCollection ************** 12208 // ********** Code for FixedCollection **************
12257 function FixedCollection(value, length) { 12209 function FixedCollection(value, length) {
12258 this.value = value; 12210 this.value = value;
12259 this.length = length; 12211 this.length = length;
12260 // Initializers done 12212 // Initializers done
12261 } 12213 }
12262 FixedCollection.prototype.get$value = function() { return this.value; }; 12214 FixedCollection.prototype.get$value = function() { return this.value; };
12263 FixedCollection.prototype.get$length = function() { return this.length; }; 12215 FixedCollection.prototype.get$length = function() { return this.length; };
12264 FixedCollection.prototype.iterator = function() { 12216 FixedCollection.prototype.iterator = function() {
12265 return new FixedIterator_E(this.value, this.length); 12217 return new FixedIterator_E(this.value, this.length);
12266 } 12218 }
12267 FixedCollection.prototype.forEach = function(f) { 12219 FixedCollection.prototype.forEach = function(f) {
12268 Collections.forEach(this, f); 12220 Collections.forEach(this, f);
12269 } 12221 }
12270 FixedCollection.prototype.filter = function(f) { 12222 FixedCollection.prototype.filter = function(f) {
12271 return Collections.filter(this, new Array(), f); 12223 return Collections.filter(this, new Array(), f);
12272 } 12224 }
12273 FixedCollection.prototype.every = function(f) { 12225 FixedCollection.prototype.every = function(f) {
12274 return Collections.every(this, f); 12226 return Collections.every(this, f);
12275 } 12227 }
12276 FixedCollection.prototype.some = function(f) { 12228 FixedCollection.prototype.some = function(f) {
12277 return Collections.some(this, f); 12229 return Collections.some(this, f);
12278 } 12230 }
12279 FixedCollection.prototype.isEmpty = function() { 12231 FixedCollection.prototype.isEmpty = function() {
12280 return this.length == 0; 12232 return this.length == (0);
12281 } 12233 }
12282 FixedCollection.prototype.every$1 = function($0) { 12234 FixedCollection.prototype.every$1 = function($0) {
12283 return this.every(to$call$1($0)); 12235 return this.every(to$call$1($0));
12284 }; 12236 };
12285 FixedCollection.prototype.filter$1 = function($0) { 12237 FixedCollection.prototype.filter$1 = function($0) {
12286 return this.filter(to$call$1($0)); 12238 return this.filter(to$call$1($0));
12287 }; 12239 };
12288 FixedCollection.prototype.forEach$1 = function($0) { 12240 FixedCollection.prototype.forEach$1 = function($0) {
12289 return this.forEach(to$call$1($0)); 12241 return this.forEach(to$call$1($0));
12290 }; 12242 };
12291 FixedCollection.prototype.isEmpty$0 = FixedCollection.prototype.isEmpty; 12243 FixedCollection.prototype.isEmpty$0 = FixedCollection.prototype.isEmpty;
12292 FixedCollection.prototype.iterator$0 = FixedCollection.prototype.iterator; 12244 FixedCollection.prototype.iterator$0 = FixedCollection.prototype.iterator;
12293 FixedCollection.prototype.some$1 = function($0) { 12245 FixedCollection.prototype.some$1 = function($0) {
12294 return this.some(to$call$1($0)); 12246 return this.some(to$call$1($0));
12295 }; 12247 };
12296 // ********** Code for FixedCollection_Type ************** 12248 // ********** Code for FixedCollection_Type **************
12297 $inherits(FixedCollection_Type, FixedCollection); 12249 $inherits(FixedCollection_Type, FixedCollection);
12298 function FixedCollection_Type(value, length) { 12250 function FixedCollection_Type(value, length) {
12299 this.value = value; 12251 this.value = value;
12300 this.length = length; 12252 this.length = length;
12301 // Initializers done 12253 // Initializers done
12302 } 12254 }
12303 // ********** Code for FixedIterator ************** 12255 // ********** Code for FixedIterator **************
12304 function FixedIterator(value, length) { 12256 function FixedIterator(value, length) {
12305 this._index = 0 12257 this._index = (0)
12306 this.value = value; 12258 this.value = value;
12307 this.length = length; 12259 this.length = length;
12308 // Initializers done 12260 // Initializers done
12309 } 12261 }
12310 FixedIterator.prototype.get$value = function() { return this.value; }; 12262 FixedIterator.prototype.get$value = function() { return this.value; };
12311 FixedIterator.prototype.get$length = function() { return this.length; }; 12263 FixedIterator.prototype.get$length = function() { return this.length; };
12312 FixedIterator.prototype.hasNext = function() { 12264 FixedIterator.prototype.hasNext = function() {
12313 return this._index < this.length; 12265 return this._index < this.length;
12314 } 12266 }
12315 FixedIterator.prototype.next = function() { 12267 FixedIterator.prototype.next = function() {
12316 this._index++; 12268 this._index++;
12317 return this.value; 12269 return this.value;
12318 } 12270 }
12319 FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext; 12271 FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext;
12320 FixedIterator.prototype.next$0 = FixedIterator.prototype.next; 12272 FixedIterator.prototype.next$0 = FixedIterator.prototype.next;
12321 // ********** Code for FixedIterator_E ************** 12273 // ********** Code for FixedIterator_E **************
12322 $inherits(FixedIterator_E, FixedIterator); 12274 $inherits(FixedIterator_E, FixedIterator);
12323 function FixedIterator_E(value, length) { 12275 function FixedIterator_E(value, length) {
12324 this._index = 0 12276 this._index = (0)
12325 this.value = value; 12277 this.value = value;
12326 this.length = length; 12278 this.length = length;
12327 // Initializers done 12279 // Initializers done
12328 } 12280 }
12329 // ********** Code for Value ************** 12281 // ********** Code for Value **************
12330 function Value(_type, code, span, needsTemp) { 12282 function Value(_type, code, span, needsTemp) {
12331 this.isSuper = false 12283 this.isSuper = false
12332 this.isType = false 12284 this.isType = false
12333 this.isFinal = false 12285 this.isFinal = false
12334 this.allowDynamic = true 12286 this.allowDynamic = true
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
12374 if (!$globals.options.forceDynamic || !this.allowDynamic || this.isType || thi s.isSuper || this.get$isConst()) { 12326 if (!$globals.options.forceDynamic || !this.allowDynamic || this.isType || thi s.isSuper || this.get$isConst()) {
12375 return this._type; 12327 return this._type;
12376 } 12328 }
12377 else { 12329 else {
12378 return $globals.world.varType; 12330 return $globals.world.varType;
12379 } 12331 }
12380 } 12332 }
12381 Value.prototype.get$isConst = function() { 12333 Value.prototype.get$isConst = function() {
12382 return false; 12334 return false;
12383 } 12335 }
12384 Value.prototype.get$canonicalCode = function() {
12385 return null;
12386 }
12387 Value.prototype.get$constValue = function() { 12336 Value.prototype.get$constValue = function() {
12388 return null; 12337 return null;
12389 } 12338 }
12390 Value.prototype.get_ = function(context, name, node) { 12339 Value.prototype.get_ = function(context, name, node) {
12391 var member = this._resolveMember(context, name, node, false); 12340 var member = this._resolveMember(context, name, node, false);
12392 if (member != null) { 12341 if (member != null) {
12393 return member._get$3(context, node, this); 12342 return member._get$3(context, node, this);
12394 } 12343 }
12395 else { 12344 else {
12396 return this.invokeNoSuchMethod(context, ("get:" + name), node); 12345 return this.invokeNoSuchMethod(context, ("get:" + name), node);
12397 } 12346 }
12398 } 12347 }
12399 Value.prototype.set_ = function(context, name, node, value, isDynamic) { 12348 Value.prototype.set_ = function(context, name, node, value, isDynamic) {
12400 var member = this._resolveMember(context, name, node, isDynamic); 12349 var member = this._resolveMember(context, name, node, isDynamic);
12401 if (member != null) { 12350 if (member != null) {
12402 return member._set$5(context, node, this, value, isDynamic); 12351 return member._set$5(context, node, this, value, isDynamic);
12403 } 12352 }
12404 else { 12353 else {
12405 return this.invokeNoSuchMethod(context, ("set:" + name), node, new Arguments (null, [value])); 12354 return this.invokeNoSuchMethod(context, ("set:" + name), node, new Arguments (null, [value]));
12406 } 12355 }
12407 } 12356 }
12357 Value.prototype.binop = function(kind, other, context, node) {
12358 switch (kind) {
12359 case (35):
12360 case (34):
12361
12362 var code = ("" + this.get$code() + " " + node.get$op() + " " + other.get$c ode());
12363 return new Value($globals.world.nonNullBool, code, node.get$span(), true);
12364
12365 case (50):
12366
12367 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " == " + other.get$code()), node.get$span(), true);
12368
12369 case (51):
12370
12371 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " != " + other.get$code()), node.get$span(), true);
12372
12373 }
12374 var name = kind == (49) ? ":ne" : TokenKind.binaryMethodName(kind);
12375 return this.invoke(context, name, node, new Arguments(null, [other]), false);
12376 }
12408 Value.prototype.invoke = function(context, name, node, args, isDynamic) { 12377 Value.prototype.invoke = function(context, name, node, args, isDynamic) {
12409 if (name == ":call") { 12378 if (name == ":call") {
12410 if (this.isType) { 12379 if (this.isType) {
12411 $globals.world.error("must use \"new\" or \"const\" to construct a new ins tance", node.span); 12380 $globals.world.error("must use \"new\" or \"const\" to construct a new ins tance", node.span);
12412 } 12381 }
12413 if (this.get$type().needsVarCall(args)) { 12382 if (this.get$type().needsVarCall(args)) {
12414 return this._varCall(context, node, args); 12383 return this._varCall(context, node, args);
12415 } 12384 }
12416 } 12385 }
12417 var member = this._resolveMember(context, name, node, isDynamic); 12386 var member = this._resolveMember(context, name, node, isDynamic);
(...skipping 11 matching lines...) Expand all
12429 var member = this._resolveMember(context, name, null, true); 12398 var member = this._resolveMember(context, name, null, true);
12430 return member != null && member.canInvoke$2(context, args); 12399 return member != null && member.canInvoke$2(context, args);
12431 } 12400 }
12432 Value.prototype._hasOverriddenNoSuchMethod = function() { 12401 Value.prototype._hasOverriddenNoSuchMethod = function() {
12433 if (this.isSuper) { 12402 if (this.isSuper) {
12434 var m = this.get$type().getMember("noSuchMethod"); 12403 var m = this.get$type().getMember("noSuchMethod");
12435 return m != null && !m.get$declaringType().get$isObject(); 12404 return m != null && !m.get$declaringType().get$isObject();
12436 } 12405 }
12437 else { 12406 else {
12438 var m = this.get$type().resolveMember("noSuchMethod"); 12407 var m = this.get$type().resolveMember("noSuchMethod");
12439 return m != null && m.get$members().get$length() > 1; 12408 return m != null && m.get$members().get$length() > (1);
12440 } 12409 }
12441 } 12410 }
12442 Value.prototype._tryResolveMember = function(context, name) { 12411 Value.prototype._tryResolveMember = function(context, name) {
12443 if (this.isSuper) { 12412 if (this.isSuper) {
12444 return this.get$type().getMember(name); 12413 return this.get$type().getMember(name);
12445 } 12414 }
12446 else { 12415 else {
12447 return this.get$type().resolveMember(name); 12416 return this.get$type().resolveMember(name);
12448 } 12417 }
12449 } 12418 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
12495 Value.prototype.convertTo = function(context, toType, isDynamic) { 12464 Value.prototype.convertTo = function(context, toType, isDynamic) {
12496 var checked = !isDynamic; 12465 var checked = !isDynamic;
12497 var callMethod = toType.getCallMethod(); 12466 var callMethod = toType.getCallMethod();
12498 if (callMethod != null) { 12467 if (callMethod != null) {
12499 if (checked && !toType.isAssignable(this.get$type())) { 12468 if (checked && !toType.isAssignable(this.get$type())) {
12500 this.convertWarning(toType); 12469 this.convertWarning(toType);
12501 } 12470 }
12502 return this._maybeWrapFunction(toType, callMethod); 12471 return this._maybeWrapFunction(toType, callMethod);
12503 } 12472 }
12504 var fromType = this.get$type(); 12473 var fromType = this.get$type();
12505 if (this.get$type().get$isVar() && (this.code != "null" || !toType.get$isNulla ble())) { 12474 if (this.get$type().get$isVar() && (this.get$code() != "null" || !toType.get$i sNullable())) {
12506 fromType = $globals.world.objectType; 12475 fromType = $globals.world.objectType;
12507 } 12476 }
12508 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); 12477 var bothNum = this.get$type().get$isNum() && toType.get$isNum();
12509 if (fromType.isSubtypeOf(toType) || bothNum) { 12478 if (fromType.isSubtypeOf(toType) || bothNum) {
12510 return this; 12479 return this;
12511 } 12480 }
12512 if (checked && !toType.isSubtypeOf(this.get$type())) { 12481 if (checked && !toType.isSubtypeOf(this.get$type())) {
12513 this.convertWarning(toType); 12482 this.convertWarning(toType);
12514 } 12483 }
12515 if ($globals.options.enableTypeChecks) { 12484 if ($globals.options.enableTypeChecks) {
12516 if (context == null && isDynamic) { 12485 if (context == null && isDynamic) {
12517 return null; 12486 return null;
12518 } 12487 }
12519 return this._typeAssert(context, toType, isDynamic); 12488 return this._typeAssert(context, toType, isDynamic);
12520 } 12489 }
12521 else { 12490 else {
12522 return this; 12491 return this;
12523 } 12492 }
12524 } 12493 }
12525 Value.prototype._maybeWrapFunction = function(toType, callMethod) { 12494 Value.prototype._maybeWrapFunction = function(toType, callMethod) {
12526 var arity = callMethod.parameters.get$length(); 12495 var arity = callMethod.parameters.get$length();
12527 var myCall = this.get$type().getCallMethod(); 12496 var myCall = this.get$type().getCallMethod();
12528 var result = this; 12497 var result = this;
12529 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { 12498 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) {
12530 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$ factory(arity)); 12499 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$ factory(arity));
12531 result = new Value(toType, ("to$" + stub.name + "(" + this.code + ")"), this .span, true); 12500 result = new Value(toType, ("to$" + stub.name + "(" + this.get$code() + ")") , this.span, true);
12532 } 12501 }
12533 if (toType.get$library().get$isDom() && !this.get$type().get$library().get$isD om()) { 12502 if (toType.get$library().get$isDom() && !this.get$type().get$library().get$isD om()) {
12534 if (arity == 0) { 12503 if (arity == (0)) {
12535 $globals.world.gen.corejs.useWrap0 = true; 12504 $globals.world.gen.corejs.useWrap0 = true;
12536 } 12505 }
12537 else { 12506 else {
12538 $globals.world.gen.corejs.useWrap1 = true; 12507 $globals.world.gen.corejs.useWrap1 = true;
12539 } 12508 }
12540 result = new Value(toType, ("$wrap_call$" + arity + "(" + result.code + ")") , this.span, true); 12509 result = new Value(toType, ("$wrap_call$" + arity + "(" + result.get$code() + ")"), this.span, true);
12541 } 12510 }
12542 return result; 12511 return result;
12543 } 12512 }
12544 Value.prototype._typeAssert = function(context, toType, isDynamic) { 12513 Value.prototype._typeAssert = function(context, toType, isDynamic) {
12545 if ((toType instanceof ParameterType)) { 12514 if ((toType instanceof ParameterType)) {
12546 var p = toType; 12515 var p = toType;
12547 toType = p.extendsType; 12516 toType = p.extendsType;
12548 } 12517 }
12549 if (toType.get$isObject() || toType.get$isVar()) { 12518 if (toType.get$isObject() || toType.get$isVar()) {
12550 $globals.world.internalError(("We thought " + this.get$type().name + " is no t a subtype of " + toType.name + "?")); 12519 $globals.world.internalError(("We thought " + this.get$type().name + " is no t a subtype of " + toType.name + "?"));
12551 } 12520 }
12552 function throwTypeError(paramName) { 12521 function throwTypeError(paramName) {
12553 return $globals.world.withoutForceDynamic((function () { 12522 return $globals.world.withoutForceDynamic((function () {
12554 var typeErrorCtor = $globals.world.typeErrorType.getConstructor("_internal "); 12523 var typeErrorCtor = $globals.world.typeErrorType.getConstructor("_internal ");
12555 $globals.world.gen.corejs.ensureTypeNameOf(); 12524 $globals.world.gen.corejs.ensureTypeNameOf();
12556 var result = typeErrorCtor.invoke$5(context, null, new Value.type$ctor($gl obals.world.typeErrorType, null), new Arguments(null, [new Value($globals.world. objectType, paramName, null, true), new Value($globals.world.stringType, ("\"" + toType.name + "\""), null, true)]), isDynamic); 12525 var result = typeErrorCtor.invoke$5(context, null, new Value.type$ctor($gl obals.world.typeErrorType, null), new Arguments(null, [new Value($globals.world. objectType, paramName, null, true), new Value($globals.world.stringType, ("\"" + toType.name + "\""), null, true)]), isDynamic);
12557 $globals.world.gen.corejs.useThrow = true; 12526 $globals.world.gen.corejs.useThrow = true;
12558 return ("$throw(" + result.get$code() + ")"); 12527 return ("$throw(" + result.get$code() + ")");
12559 }) 12528 })
12560 ); 12529 );
12561 } 12530 }
12562 if (toType.get$isNum()) toType = $globals.world.numType; 12531 if (toType.get$isNum()) toType = $globals.world.numType;
12563 var check; 12532 var check;
12564 if (toType.get$isVoid()) { 12533 if (toType.get$isVoid()) {
12565 check = ("$assert_void(" + this.code + ")"); 12534 check = ("$assert_void(" + this.get$code() + ")");
12566 if (toType.typeCheckCode == null) { 12535 if (toType.typeCheckCode == null) {
12567 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu rn null;\n " + throwTypeError("x") + "\n}"); 12536 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu rn null;\n " + throwTypeError("x") + "\n}");
12568 } 12537 }
12569 } 12538 }
12570 else if ($eq(toType, $globals.world.nonNullBool)) { 12539 else if ($eq(toType, $globals.world.nonNullBool)) {
12571 $globals.world.gen.corejs.useNotNullBool = true; 12540 $globals.world.gen.corejs.useNotNullBool = true;
12572 check = ("$notnull_bool(" + this.code + ")"); 12541 check = ("$notnull_bool(" + this.get$code() + ")");
12573 } 12542 }
12574 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null) { 12543 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null) {
12575 check = ("$assert_" + toType.name + "(" + this.code + ")"); 12544 check = ("$assert_" + toType.name + "(" + this.get$code() + ")");
12576 if (toType.typeCheckCode == null) { 12545 if (toType.typeCheckCode == null) {
12577 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if ( x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " + throwTypeError("x") + "\n}"); 12546 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if ( x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " + throwTypeError("x") + "\n}");
12578 } 12547 }
12579 } 12548 }
12580 else { 12549 else {
12581 toType.isChecked = true; 12550 toType.isChecked = true;
12582 var checkName = "assert$" + toType.get$jsname(); 12551 var checkName = "assert$" + toType.get$jsname();
12583 var temp = context.getTemp(this); 12552 var temp = context.getTemp(this);
12584 check = ("(" + context.assignTemp(temp, this).code + " == null ? null :"); 12553 check = ("(" + context.assignTemp(temp, this).get$code() + " == null ? null :");
12585 check = check + (" " + temp.get$code() + "." + checkName + "())"); 12554 check = check + (" " + temp.get$code() + "." + checkName + "())");
12586 if ($ne(this, temp)) context.freeTemp(temp); 12555 if ($ne(this, temp)) context.freeTemp(temp);
12587 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () { 12556 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () {
12588 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType Error("this")); 12557 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType Error("this"));
12589 }) 12558 })
12590 ); 12559 );
12591 } 12560 }
12592 return new Value(toType, check, this.span, true); 12561 return new Value(toType, check, this.span, true);
12593 } 12562 }
12594 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck) { 12563 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck) {
12595 if (toType.get$isVar()) { 12564 if (toType.get$isVar()) {
12596 $globals.world.error("can not resolve type", span); 12565 $globals.world.error("can not resolve type", span);
12597 } 12566 }
12598 var testCode = null; 12567 var testCode = null;
12599 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete rType)) { 12568 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete rType)) {
12600 if (this.needsTemp) { 12569 if (this.needsTemp) {
12601 return new Value($globals.world.nonNullBool, ("(" + this.code + ", true)") , span, true); 12570 return new Value($globals.world.nonNullBool, ("(" + this.get$code() + ", t rue)"), span, true);
12602 } 12571 }
12603 else { 12572 else {
12604 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, t rue, "true", null); 12573 return Value.fromBool(true, span);
12605 } 12574 }
12606 } 12575 }
12607 if (toType.get$library().get$isCore()) { 12576 if (toType.get$library().get$isCore()) {
12608 var typeofName = toType.get$typeofName(); 12577 var typeofName = toType.get$typeofName();
12609 if (typeofName != null) { 12578 if (typeofName != null) {
12610 testCode = ("(typeof(" + this.code + ") " + (isTrue ? "==" : "!=") + " '" + typeofName + "')"); 12579 testCode = ("(typeof(" + this.get$code() + ") " + (isTrue ? "==" : "!=") + " '" + typeofName + "')");
12611 } 12580 }
12612 } 12581 }
12613 if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$i sHiddenNativeType()) { 12582 if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$i sHiddenNativeType()) {
12614 toType.markUsed(); 12583 toType.markUsed();
12615 testCode = ("(" + this.code + " instanceof " + toType.get$jsname() + ")"); 12584 testCode = ("(" + this.get$code() + " instanceof " + toType.get$jsname() + " )");
12616 if (!isTrue) { 12585 if (!isTrue) {
12617 testCode = "!" + testCode; 12586 testCode = "!" + testCode;
12618 } 12587 }
12619 } 12588 }
12620 if (testCode == null) { 12589 if (testCode == null) {
12621 toType.isTested = true; 12590 toType.isTested = true;
12622 var temp = context.getTemp(this); 12591 var temp = context.getTemp(this);
12623 var checkName = ("is$" + toType.get$jsname()); 12592 var checkName = ("is$" + toType.get$jsname());
12624 testCode = ("(" + context.assignTemp(temp, this).code + " &&"); 12593 testCode = ("(" + context.assignTemp(temp, this).get$code() + " &&");
12625 testCode = testCode + (" " + temp.get$code() + "." + checkName + "())"); 12594 testCode = testCode + (" " + temp.get$code() + "." + checkName + "())");
12626 if (isTrue) { 12595 if (isTrue) {
12627 testCode = "!!" + testCode; 12596 testCode = "!!" + testCode;
12628 } 12597 }
12629 else { 12598 else {
12630 testCode = "!" + testCode; 12599 testCode = "!" + testCode;
12631 } 12600 }
12632 if ($ne(this, temp)) context.freeTemp(temp); 12601 if ($ne(this, temp)) context.freeTemp(temp);
12633 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { 12602 if (!$globals.world.objectType.varStubs.containsKey(checkName)) {
12634 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub( checkName, null, Arguments.get$EMPTY(), "return false")); 12603 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub( checkName, null, Arguments.get$EMPTY(), "return false"));
12635 } 12604 }
12636 } 12605 }
12637 return new Value($globals.world.nonNullBool, testCode, span, true); 12606 return new Value($globals.world.nonNullBool, testCode, span, true);
12638 } 12607 }
12639 Value.prototype.convertWarning = function(toType) { 12608 Value.prototype.convertWarning = function(toType) {
12640 $globals.world.warning(("type \"" + this.get$type().name + "\" is not assignab le to \"" + toType.name + "\""), this.span); 12609 $globals.world.warning(("type \"" + this.get$type().name + "\" is not assignab le to \"" + toType.name + "\""), this.span);
12641 } 12610 }
12642 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { 12611 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) {
12643 var pos = ""; 12612 var pos = "";
12644 if (args != null) { 12613 if (args != null) {
12645 var argsCode = []; 12614 var argsCode = [];
12646 for (var i = 0; 12615 for (var i = (0);
12647 i < args.get$length(); i++) { 12616 i < args.get$length(); i++) {
12648 argsCode.add$1(args.values.$index(i).get$code()); 12617 argsCode.add$1(args.values.$index(i).get$code());
12649 } 12618 }
12650 pos = Strings.join(argsCode, ", "); 12619 pos = Strings.join(argsCode, ", ");
12651 } 12620 }
12652 var noSuchArgs = [new Value($globals.world.stringType, ("\"" + name + "\""), n ode.span, true), new Value($globals.world.listType, ("[" + pos + "]"), node.span , true)]; 12621 var noSuchArgs = [new Value($globals.world.stringType, ("\"" + name + "\""), n ode.span, true), new Value($globals.world.listType, ("[" + pos + "]"), node.span , true)];
12653 return this._resolveMember(context, "noSuchMethod", node, false).invoke$4(cont ext, node, this, new Arguments(null, noSuchArgs)); 12622 return this._resolveMember(context, "noSuchMethod", node, false).invoke$4(cont ext, node, this, new Arguments(null, noSuchArgs));
12654 } 12623 }
12655 Value.fromBool = function(value, span) { 12624 Value.fromBool = function(value, span) {
12656 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, value , value.toString(), span); 12625 return new BoolValue(value, true, span);
12657 } 12626 }
12658 Value.fromInt = function(value, span) { 12627 Value.fromInt = function(value, span) {
12659 var strValue = value.toString(); 12628 return new IntValue(value, true, span);
12660 return EvaluatedValue.EvaluatedValue$factory($globals.world.numType, value, st rValue, span);
12661 } 12629 }
12662 Value.fromDouble = function(value, span) { 12630 Value.fromDouble = function(value, span) {
12663 var strValue = value.toString(); 12631 return new DoubleValue(value, true, span);
12664 if ($eq(strValue.indexOf$1("."), -1) && $eq(strValue.indexOf$1("e"), -1)) {
12665 strValue = strValue + ".0";
12666 }
12667 return EvaluatedValue.EvaluatedValue$factory($globals.world.numType, value, st rValue, span);
12668 } 12632 }
12669 Value.fromString = function(value, span) { 12633 Value.fromString = function(value, span) {
12634 return new StringValue(value, true, span);
12635 }
12636 Value.fromNull = function(span) {
12637 return new NullValue(true, span);
12638 }
12639 Value.prototype.binop$4 = Value.prototype.binop;
12640 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass;
12641 Value.prototype.convertTo$2 = function($0, $1) {
12642 return this.convertTo($0, $1, false);
12643 };
12644 Value.prototype.convertTo$3 = Value.prototype.convertTo;
12645 Value.prototype.get_$3 = Value.prototype.get_;
12646 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf;
12647 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) {
12648 return this.instanceOf($0, $1, $2, $3, false);
12649 };
12650 Value.prototype.invoke$4 = function($0, $1, $2, $3) {
12651 return this.invoke($0, $1, $2, $3, false);
12652 };
12653 Value.prototype.invoke$4$isDynamic = Value.prototype.invoke;
12654 Value.prototype.invoke$5 = Value.prototype.invoke;
12655 Value.prototype.needsConversion$1 = Value.prototype.needsConversion;
12656 Value.prototype.set_$4 = function($0, $1, $2, $3) {
12657 return this.set_($0, $1, $2, $3, false);
12658 };
12659 // ********** Code for EvaluatedValue **************
12660 $inherits(EvaluatedValue, Value);
12661 function EvaluatedValue(isConst, type, span) {
12662 this.isConst = isConst;
12663 // Initializers done
12664 Value.call(this, type, "@@@", span, false);
12665 }
12666 EvaluatedValue.prototype.get$isConst = function() { return this.isConst; };
12667 EvaluatedValue.prototype.set$isConst = function(value) { return this.isConst = v alue; };
12668 EvaluatedValue.prototype.get$code = function() {
12669 return "@@@";
12670 }
12671 EvaluatedValue.prototype.get$constValue = function() {
12672 return this;
12673 }
12674 EvaluatedValue.prototype.hashCode = function() {
12675 return this.get$code().hashCode();
12676 }
12677 EvaluatedValue.prototype.$eq = function(other) {
12678 return (other instanceof EvaluatedValue) && $eq(other.get$type(), this.get$typ e()) && $eq(other.get$code(), this.get$code());
12679 }
12680 EvaluatedValue.prototype.hashCode$0 = EvaluatedValue.prototype.hashCode;
12681 // ********** Code for NullValue **************
12682 $inherits(NullValue, EvaluatedValue);
12683 function NullValue(isConst, span) {
12684 // Initializers done
12685 EvaluatedValue.call(this, isConst, $globals.world.varType, span);
12686 }
12687 NullValue.prototype.get$actualValue = function() {
12688 return null;
12689 }
12690 NullValue.prototype.get$code = function() {
12691 return "null";
12692 }
12693 NullValue.prototype.binop = function(kind, other, context, node) {
12694 if (!(other instanceof ListValue)) return Value.prototype.binop.call(this, kin d, other, context, node);
12695 switch (kind) {
12696 case (50):
12697
12698 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12699
12700 case (51):
12701
12702 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12703
12704 }
12705 return Value.prototype.binop.call(this, kind, other, context, node);
12706 }
12707 NullValue.prototype.binop$4 = NullValue.prototype.binop;
12708 // ********** Code for BoolValue **************
12709 $inherits(BoolValue, EvaluatedValue);
12710 function BoolValue(actualValue, isConst, span) {
12711 this.actualValue = actualValue;
12712 // Initializers done
12713 EvaluatedValue.call(this, isConst, $globals.world.nonNullBool, span);
12714 }
12715 BoolValue.prototype.get$actualValue = function() { return this.actualValue; };
12716 BoolValue.prototype.set$actualValue = function(value) { return this.actualValue = value; };
12717 BoolValue.prototype.get$code = function() {
12718 return this.actualValue ? "true" : "false";
12719 }
12720 BoolValue.prototype.binop = function(kind, other, context, node) {
12721 if (!(other instanceof BoolValue)) return Value.prototype.binop.call(this, kin d, other, context, node);
12722 switch (kind) {
12723 case (35):
12724
12725 return new BoolValue(this.actualValue && other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12726
12727 case (34):
12728
12729 return new BoolValue(this.actualValue || other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12730
12731 case (50):
12732
12733 return new BoolValue($eq(this.actualValue, other.get$actualValue()), this. isConst && other.get$isConst(), node.get$span());
12734
12735 case (51):
12736
12737 return new BoolValue($ne(this.actualValue, other.get$actualValue()), this. isConst && other.get$isConst(), node.get$span());
12738
12739 }
12740 return Value.prototype.binop.call(this, kind, other, context, node);
12741 }
12742 BoolValue.prototype.binop$4 = BoolValue.prototype.binop;
12743 // ********** Code for IntValue **************
12744 $inherits(IntValue, EvaluatedValue);
12745 function IntValue(actualValue, isConst, span) {
12746 this.actualValue = actualValue;
12747 // Initializers done
12748 EvaluatedValue.call(this, isConst, $globals.world.intType, span);
12749 }
12750 IntValue.prototype.get$actualValue = function() { return this.actualValue; };
12751 IntValue.prototype.set$actualValue = function(value) { return this.actualValue = value; };
12752 IntValue.prototype.get$code = function() {
12753 return ("(" + this.actualValue + ")");
12754 }
12755 IntValue.prototype.binop = function(kind, other, context, node) {
12756 if (!(other instanceof IntValue)) return Value.prototype.binop.call(this, kind , other, context, node);
12757 switch (kind) {
12758 case (50):
12759
12760 return new BoolValue(this.actualValue == other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12761
12762 case (51):
12763
12764 return new BoolValue(this.actualValue != other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12765
12766 }
12767 return Value.prototype.binop.call(this, kind, other, context, node);
12768 }
12769 IntValue.prototype.binop$4 = IntValue.prototype.binop;
12770 // ********** Code for DoubleValue **************
12771 $inherits(DoubleValue, EvaluatedValue);
12772 function DoubleValue(actualValue, isConst, span) {
12773 this.actualValue = actualValue;
12774 // Initializers done
12775 EvaluatedValue.call(this, isConst, $globals.world.doubleType, span);
12776 }
12777 DoubleValue.prototype.get$actualValue = function() { return this.actualValue; };
12778 DoubleValue.prototype.set$actualValue = function(value) { return this.actualValu e = value; };
12779 DoubleValue.prototype.get$code = function() {
12780 return ("(" + this.actualValue + ")");
12781 }
12782 DoubleValue.prototype.binop = function(kind, other, context, node) {
12783 if (!(other instanceof DoubleValue)) return Value.prototype.binop.call(this, k ind, other, context, node);
12784 switch (kind) {
12785 case (50):
12786
12787 return new BoolValue(this.actualValue == other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12788
12789 case (51):
12790
12791 return new BoolValue(this.actualValue != other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12792
12793 }
12794 return Value.prototype.binop.call(this, kind, other, context, node);
12795 }
12796 DoubleValue.prototype.binop$4 = DoubleValue.prototype.binop;
12797 // ********** Code for StringValue **************
12798 $inherits(StringValue, EvaluatedValue);
12799 function StringValue(actualValue, isConst, span) {
12800 this.actualValue = actualValue;
12801 // Initializers done
12802 EvaluatedValue.call(this, isConst, $globals.world.stringType, span);
12803 }
12804 StringValue.prototype.get$actualValue = function() { return this.actualValue; };
12805 StringValue.prototype.set$actualValue = function(value) { return this.actualValu e = value; };
12806 StringValue.prototype.binop = function(kind, other, context, node) {
12807 if (!(other instanceof StringValue)) return Value.prototype.binop.call(this, k ind, other, context, node);
12808 switch (kind) {
12809 case (50):
12810
12811 return new BoolValue(this.actualValue == other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12812
12813 case (51):
12814
12815 return new BoolValue(this.actualValue != other.get$actualValue(), this.isC onst && other.get$isConst(), node.get$span());
12816
12817 }
12818 return Value.prototype.binop.call(this, kind, other, context, node);
12819 }
12820 StringValue.prototype.get$code = function() {
12670 var buf = new StringBufferImpl(""); 12821 var buf = new StringBufferImpl("");
12671 buf.add("\""); 12822 buf.add("\"");
12672 for (var i = 0; 12823 for (var i = (0);
12673 i < value.length; i++) { 12824 i < this.actualValue.length; i++) {
12674 var ch = value.charCodeAt(i); 12825 var ch = this.actualValue.charCodeAt(i);
12675 switch (ch) { 12826 switch (ch) {
12676 case 9: 12827 case (9):
12677 12828
12678 buf.add("\\t"); 12829 buf.add("\\t");
12679 break; 12830 break;
12680 12831
12681 case 10: 12832 case (10):
12682 12833
12683 buf.add("\\n"); 12834 buf.add("\\n");
12684 break; 12835 break;
12685 12836
12686 case 13: 12837 case (13):
12687 12838
12688 buf.add("\\r"); 12839 buf.add("\\r");
12689 break; 12840 break;
12690 12841
12691 case 34: 12842 case (34):
12692 12843
12693 buf.add("\\\""); 12844 buf.add("\\\"");
12694 break; 12845 break;
12695 12846
12696 case 92: 12847 case (92):
12697 12848
12698 buf.add("\\\\"); 12849 buf.add("\\\\");
12699 break; 12850 break;
12700 12851
12701 default: 12852 default:
12702 12853
12703 if (ch >= 32 && ch <= 126) { 12854 if (ch >= (32) && ch <= (126)) {
12704 buf.add(value[i]); 12855 buf.add(this.actualValue[i]);
12705 } 12856 }
12706 else { 12857 else {
12707 var hex = ch.toRadixString$1(16); 12858 var hex = ch.toRadixString$1((16));
12708 switch (hex.get$length()) { 12859 switch (hex.get$length()) {
12709 case 1: 12860 case (1):
12710 12861
12711 buf.add("\\x0"); 12862 buf.add("\\x0");
12712 buf.add(hex); 12863 buf.add(hex);
12713 break; 12864 break;
12714 12865
12715 case 2: 12866 case (2):
12716 12867
12717 buf.add("\\x"); 12868 buf.add("\\x");
12718 buf.add(hex); 12869 buf.add(hex);
12719 break; 12870 break;
12720 12871
12721 case 3: 12872 case (3):
12722 12873
12723 buf.add("\\u0"); 12874 buf.add("\\u0");
12724 buf.add(hex); 12875 buf.add(hex);
12725 break; 12876 break;
12726 12877
12727 case 4: 12878 case (4):
12728 12879
12729 buf.add("\\u"); 12880 buf.add("\\u");
12730 buf.add(hex); 12881 buf.add(hex);
12731 break; 12882 break;
12732 12883
12733 default: 12884 default:
12734 12885
12735 $globals.world.internalError("unicode values greater than 2 bytes not implemented"); 12886 $globals.world.internalError("unicode values greater than 2 bytes not implemented");
12736 break; 12887 break;
12737 12888
12738 } 12889 }
12739 } 12890 }
12740 break; 12891 break;
12741 12892
12742 } 12893 }
12743 } 12894 }
12744 buf.add("\""); 12895 buf.add("\"");
12745 return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, value, buf.toString(), span); 12896 return buf.toString();
12746 } 12897 }
12747 Value.fromNull = function(span) { 12898 StringValue.prototype.binop$4 = StringValue.prototype.binop;
12748 return EvaluatedValue.EvaluatedValue$factory($globals.world.varType, null, "nu ll", span); 12899 // ********** Code for ListValue **************
12749 } 12900 $inherits(ListValue, EvaluatedValue);
12750 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass; 12901 function ListValue(values, isConst, type, span) {
12751 Value.prototype.convertTo$2 = function($0, $1) {
12752 return this.convertTo($0, $1, false);
12753 };
12754 Value.prototype.convertTo$3 = Value.prototype.convertTo;
12755 Value.prototype.get_$3 = Value.prototype.get_;
12756 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf;
12757 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) {
12758 return this.instanceOf($0, $1, $2, $3, false);
12759 };
12760 Value.prototype.invoke$4 = function($0, $1, $2, $3) {
12761 return this.invoke($0, $1, $2, $3, false);
12762 };
12763 Value.prototype.invoke$4$isDynamic = Value.prototype.invoke;
12764 Value.prototype.invoke$5 = Value.prototype.invoke;
12765 Value.prototype.needsConversion$1 = Value.prototype.needsConversion;
12766 Value.prototype.set_$4 = function($0, $1, $2, $3) {
12767 return this.set_($0, $1, $2, $3, false);
12768 };
12769 // ********** Code for EvaluatedValue **************
12770 $inherits(EvaluatedValue, Value);
12771 function EvaluatedValue() {}
12772 EvaluatedValue._internal$ctor = function(type, actualValue, canonicalCode, span, code) {
12773 this.actualValue = actualValue;
12774 this.canonicalCode = canonicalCode;
12775 // Initializers done
12776 Value.call(this, type, code, span, false);
12777 }
12778 EvaluatedValue._internal$ctor.prototype = EvaluatedValue.prototype;
12779 EvaluatedValue.EvaluatedValue$factory = function(type, actualValue, canonicalCod e, span) {
12780 return new EvaluatedValue._internal$ctor(type, actualValue, canonicalCode, spa n, EvaluatedValue.codeWithComments(canonicalCode, span));
12781 }
12782 EvaluatedValue.prototype.get$actualValue = function() { return this.actualValue; };
12783 EvaluatedValue.prototype.set$actualValue = function(value) { return this.actualV alue = value; };
12784 EvaluatedValue.prototype.get$isConst = function() {
12785 return true;
12786 }
12787 EvaluatedValue.prototype.get$constValue = function() {
12788 return this;
12789 }
12790 EvaluatedValue.prototype.get$canonicalCode = function() { return this.canonicalC ode; };
12791 EvaluatedValue.prototype.set$canonicalCode = function(value) { return this.canon icalCode = value; };
12792 EvaluatedValue.codeWithComments = function(canonicalCode, span) {
12793 return canonicalCode;
12794 }
12795 // ********** Code for ConstListValue **************
12796 $inherits(ConstListValue, EvaluatedValue);
12797 function ConstListValue() {}
12798 ConstListValue._internal$ctor = function(type, values, actualValue, canonicalCod e, span, code) {
12799 this.values = values; 12902 this.values = values;
12800 // Initializers done 12903 // Initializers done
12801 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12904 EvaluatedValue.call(this, isConst, type, span);
12802 } 12905 }
12803 ConstListValue._internal$ctor.prototype = ConstListValue.prototype; 12906 ListValue.prototype.get$code = function() {
12804 ConstListValue.ConstListValue$factory = function(type, values, actualValue, cano nicalCode, span) { 12907 var buf = new StringBufferImpl("");
12805 return new ConstListValue._internal$ctor(type, values, actualValue, canonicalC ode, span, EvaluatedValue.codeWithComments(canonicalCode, span)); 12908 buf.add("[");
12909 for (var i = (0);
12910 i < this.values.get$length(); i = i + (1)) {
12911 if (i > (0)) buf.add(", ");
12912 buf.add(this.values.$index(i).get$code());
12913 }
12914 buf.add("]");
12915 var listCode = buf.toString();
12916 if (!this.isConst) return listCode;
12917 var v = new Value($globals.world.listType, listCode, this.span, true);
12918 var immutableListCtor = $globals.world.immutableListType.getConstructor("from" );
12919 var result = immutableListCtor.invoke$4(null, null, new Value.type$ctor(v.get$ type(), this.span), new Arguments(null, [v]));
12920 return result.get$code();
12806 } 12921 }
12807 ConstListValue.prototype.get$values = function() { return this.values; }; 12922 ListValue.prototype.binop = function(kind, other, context, node) {
12808 ConstListValue.prototype.set$values = function(value) { return this.values = val ue; }; 12923 if (!(other instanceof ListValue)) return Value.prototype.binop.call(this, kin d, other, context, node);
12809 // ********** Code for ConstMapValue ************** 12924 switch (kind) {
12810 $inherits(ConstMapValue, EvaluatedValue); 12925 case (50):
12811 function ConstMapValue() {} 12926
12812 ConstMapValue._internal$ctor = function(type, values, actualValue, canonicalCode , span, code) { 12927 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12928
12929 case (51):
12930
12931 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12932
12933 }
12934 return Value.prototype.binop.call(this, kind, other, context, node);
12935 }
12936 ListValue.prototype.getGlobalValue = function() {
12937 return $globals.world.gen.globalForConst(this, this.values);
12938 }
12939 ListValue.prototype.binop$4 = ListValue.prototype.binop;
12940 ListValue.prototype.getGlobalValue$0 = ListValue.prototype.getGlobalValue;
12941 // ********** Code for MapValue **************
12942 $inherits(MapValue, EvaluatedValue);
12943 function MapValue(values, isConst, type, span) {
12813 this.values = values; 12944 this.values = values;
12814 // Initializers done 12945 // Initializers done
12815 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12946 EvaluatedValue.call(this, isConst, type, span);
12816 } 12947 }
12817 ConstMapValue._internal$ctor.prototype = ConstMapValue.prototype; 12948 MapValue.prototype.get$code = function() {
12818 ConstMapValue.ConstMapValue$factory = function(type, keyValuePairs, actualValue, canonicalCode, span) { 12949 var items = new ListValue(this.values, false, $globals.world.listType, this.sp an);
12819 var values = new HashMapImplementation(); 12950 var tp = $globals.world.corelib.topType;
12820 for (var i = 0; 12951 var f = this.isConst ? tp.getMember$1("_constMap") : tp.getMember$1("_map");
12821 i < keyValuePairs.get$length(); i += 2) { 12952 var value = f.invoke(null, null, new Value.type$ctor(tp, null), new Arguments( null, [items]), false);
12822 values.$setindex(keyValuePairs.$index(i).get$actualValue(), keyValuePairs.$i ndex(i + 1)); 12953 return value.get$code();
12954 }
12955 MapValue.prototype.getGlobalValue = function() {
12956 return $globals.world.gen.globalForConst(this, this.values);
12957 }
12958 MapValue.prototype.binop = function(kind, other, context, node) {
12959 if (!(other instanceof MapValue)) return Value.prototype.binop.call(this, kind , other, context, node);
12960 switch (kind) {
12961 case (50):
12962
12963 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12964
12965 case (51):
12966
12967 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12968
12823 } 12969 }
12824 return new ConstMapValue._internal$ctor(type, values, actualValue, canonicalCo de, span, EvaluatedValue.codeWithComments(canonicalCode, span)); 12970 return Value.prototype.binop.call(this, kind, other, context, node);
12825 } 12971 }
12826 ConstMapValue.prototype.get$values = function() { return this.values; }; 12972 MapValue.prototype.binop$4 = MapValue.prototype.binop;
12827 ConstMapValue.prototype.set$values = function(value) { return this.values = valu e; }; 12973 MapValue.prototype.getGlobalValue$0 = MapValue.prototype.getGlobalValue;
12828 // ********** Code for ConstObjectValue ************** 12974 // ********** Code for ObjectValue **************
12829 $inherits(ConstObjectValue, EvaluatedValue); 12975 $inherits(ObjectValue, EvaluatedValue);
12830 function ConstObjectValue() {} 12976 function ObjectValue(fields, isConst, type, _code, span) {
12831 ConstObjectValue._internal$ctor = function(type, fields, actualValue, canonicalC ode, span, code) {
12832 this.fields = fields; 12977 this.fields = fields;
12978 this._code = _code;
12833 // Initializers done 12979 // Initializers done
12834 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12980 EvaluatedValue.call(this, isConst, type, span);
12835 } 12981 }
12836 ConstObjectValue._internal$ctor.prototype = ConstObjectValue.prototype; 12982 ObjectValue.prototype.get$fields = function() { return this.fields; };
12837 ConstObjectValue.ConstObjectValue$factory = function(type, fields, canonicalCode , span) { 12983 ObjectValue.prototype.set$fields = function(value) { return this.fields = value; };
12838 var fieldValues = []; 12984 ObjectValue.prototype.get$code = function() {
12839 var $$list = fields.getKeys(); 12985 return this._code;
12840 for (var $$i = fields.getKeys().iterator$0(); $$i.hasNext$0(); ) { 12986 }
12841 var f = $$i.next$0(); 12987 ObjectValue.prototype.binop = function(kind, other, context, node) {
12842 fieldValues.add(("" + f + " = " + fields.$index(f).get$actualValue())); 12988 if (!(other instanceof ObjectValue)) return Value.prototype.binop.call(this, k ind, other, context, node);
12989 switch (kind) {
12990 case (50):
12991
12992 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12993
12994 case (51):
12995
12996 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span());
12997
12843 } 12998 }
12844 fieldValues.sort((function (a, b) { 12999 return Value.prototype.binop.call(this, kind, other, context, node);
12845 return a.compareTo$1(b);
12846 })
12847 );
12848 var actualValue = ("const " + type.get$jsname() + " [") + Strings.join(fieldVa lues, ",") + "]";
12849 return new ConstObjectValue._internal$ctor(type, fields, actualValue, canonica lCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
12850 } 13000 }
12851 ConstObjectValue.prototype.get$fields = function() { return this.fields; }; 13001 ObjectValue.prototype.binop$4 = ObjectValue.prototype.binop;
12852 ConstObjectValue.prototype.set$fields = function(value) { return this.fields = v alue; };
12853 // ********** Code for GlobalValue ************** 13002 // ********** Code for GlobalValue **************
12854 $inherits(GlobalValue, Value); 13003 $inherits(GlobalValue, Value);
12855 function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) { 13004 function GlobalValue(type, code, isConst, field, name, exp, span, _dependencies) {
12856 this.field = field; 13005 this.field = field;
12857 this.name = name; 13006 this.name = name;
12858 this.exp = exp; 13007 this.exp = exp;
12859 this.canonicalCode = canonicalCode;
12860 this.dependencies = []; 13008 this.dependencies = [];
12861 // Initializers done 13009 // Initializers done
12862 Value.call(this, type, code, span, !isConst); 13010 Value.call(this, type, code, span, !isConst);
12863 for (var $$i = 0;$$i < _dependencies.get$length(); $$i++) { 13011 for (var $$i = 0;$$i < _dependencies.get$length(); $$i++) {
12864 var dep = _dependencies.$index($$i); 13012 var dep = _dependencies.$index($$i);
12865 this.dependencies.add(dep); 13013 if ((dep instanceof GlobalValue)) {
12866 this.dependencies.addAll(dep.get$dependencies()); 13014 this.dependencies.add(dep);
13015 this.dependencies.addAll(dep.get$dependencies());
13016 }
12867 } 13017 }
12868 } 13018 }
12869 GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) {
12870 var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code);
12871 var codeWithComment = ("" + code + "/*" + field.get$declaringType().get$name() + "." + field.get$name() + "*/");
12872 return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), f ield, null, exp, code, exp.span, dependencies.filter$1((function (d) {
12873 return (d instanceof GlobalValue);
12874 })
12875 ));
12876 }
12877 GlobalValue.GlobalValue$fromConst$factory = function(uniqueId, exp, dependencies ) {
12878 var name = ("const$" + uniqueId);
12879 var codeWithComment = ("" + name + "/*" + _escapeForComment(exp.span.get$text( )) + "*/");
12880 return new GlobalValue(exp.get$type(), codeWithComment, true, null, name, exp, name, exp.span, dependencies.filter$1((function (d) {
12881 return (d instanceof GlobalValue);
12882 })
12883 ));
12884 }
12885 GlobalValue.prototype.get$field = function() { return this.field; }; 13019 GlobalValue.prototype.get$field = function() { return this.field; };
12886 GlobalValue.prototype.set$field = function(value) { return this.field = value; } ; 13020 GlobalValue.prototype.set$field = function(value) { return this.field = value; } ;
12887 GlobalValue.prototype.get$name = function() { return this.name; }; 13021 GlobalValue.prototype.get$name = function() { return this.name; };
12888 GlobalValue.prototype.set$name = function(value) { return this.name = value; }; 13022 GlobalValue.prototype.set$name = function(value) { return this.name = value; };
12889 GlobalValue.prototype.get$exp = function() { return this.exp; }; 13023 GlobalValue.prototype.get$exp = function() { return this.exp; };
12890 GlobalValue.prototype.set$exp = function(value) { return this.exp = value; }; 13024 GlobalValue.prototype.set$exp = function(value) { return this.exp = value; };
12891 GlobalValue.prototype.get$canonicalCode = function() { return this.canonicalCode ; };
12892 GlobalValue.prototype.set$canonicalCode = function(value) { return this.canonica lCode = value; };
12893 GlobalValue.prototype.get$isConst = function() { 13025 GlobalValue.prototype.get$isConst = function() {
12894 return this.exp.get$isConst() && (this.field == null || this.field.isFinal); 13026 return this.exp.get$isConst() && (this.field == null || this.field.isFinal);
12895 } 13027 }
12896 GlobalValue.prototype.get$actualValue = function() { 13028 GlobalValue.prototype.get$actualValue = function() {
12897 return this.exp.get$dynamic().get$actualValue(); 13029 return this.exp.get$dynamic().get$actualValue();
12898 } 13030 }
12899 GlobalValue.prototype.get$constValue = function() { 13031 GlobalValue.prototype.get$constValue = function() {
12900 return this.get$isConst() ? this.exp.get$constValue() : null; 13032 return this.get$isConst() ? this.exp.get$constValue() : null;
12901 } 13033 }
12902 GlobalValue.prototype.get$dependencies = function() { return this.dependencies; }; 13034 GlobalValue.prototype.get$dependencies = function() { return this.dependencies; };
12903 GlobalValue.prototype.set$dependencies = function(value) { return this.dependenc ies = value; }; 13035 GlobalValue.prototype.set$dependencies = function(value) { return this.dependenc ies = value; };
12904 GlobalValue.prototype.compareTo = function(other) { 13036 GlobalValue.prototype.compareTo = function(other) {
12905 if ($eq(other, this)) { 13037 if ($eq(other, this)) {
12906 return 0; 13038 return (0);
12907 } 13039 }
12908 else if (this.dependencies.indexOf(other) >= 0) { 13040 else if (this.dependencies.indexOf(other) >= (0)) {
12909 return 1; 13041 return (1);
12910 } 13042 }
12911 else if (other.dependencies.indexOf(this) >= 0) { 13043 else if (other.dependencies.indexOf(this) >= (0)) {
12912 return -1; 13044 return (-1);
12913 } 13045 }
12914 else if (this.dependencies.get$length() > other.dependencies.get$length()) { 13046 else if (this.dependencies.get$length() > other.dependencies.get$length()) {
12915 return 1; 13047 return (1);
12916 } 13048 }
12917 else if (this.dependencies.get$length() < other.dependencies.get$length()) { 13049 else if (this.dependencies.get$length() < other.dependencies.get$length()) {
12918 return -1; 13050 return (-1);
12919 } 13051 }
12920 else if (this.name == null && other.name != null) { 13052 else if (this.name == null && other.name != null) {
12921 return 1; 13053 return (1);
12922 } 13054 }
12923 else if (this.name != null && other.name == null) { 13055 else if (this.name != null && other.name == null) {
12924 return -1; 13056 return (-1);
12925 } 13057 }
12926 else if (this.name != null) { 13058 else if (this.name != null) {
12927 return this.name.compareTo(other.name); 13059 return this.name.compareTo(other.name);
12928 } 13060 }
12929 else { 13061 else {
12930 return this.field.name.compareTo(other.field.name); 13062 return this.field.name.compareTo(other.field.name);
12931 } 13063 }
12932 } 13064 }
12933 GlobalValue.prototype.compareTo$1 = GlobalValue.prototype.compareTo; 13065 GlobalValue.prototype.compareTo$1 = GlobalValue.prototype.compareTo;
12934 // ********** Code for BareValue ************** 13066 // ********** Code for BareValue **************
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
12977 if (this._location != null) { 13109 if (this._location != null) {
12978 return ("CompilerException: " + this._location.toMessageString(this._lang_me ssage)); 13110 return ("CompilerException: " + this._location.toMessageString(this._lang_me ssage));
12979 } 13111 }
12980 else { 13112 else {
12981 return ("CompilerException: " + this._lang_message); 13113 return ("CompilerException: " + this._lang_message);
12982 } 13114 }
12983 } 13115 }
12984 CompilerException.prototype.toString$0 = CompilerException.prototype.toString; 13116 CompilerException.prototype.toString$0 = CompilerException.prototype.toString;
12985 // ********** Code for World ************** 13117 // ********** Code for World **************
12986 function World(files) { 13118 function World(files) {
12987 this.errors = 0 13119 this.errors = (0)
12988 this.warnings = 0 13120 this.warnings = (0)
12989 this.dartBytesRead = 0 13121 this.dartBytesRead = (0)
12990 this.jsBytesWritten = 0 13122 this.jsBytesWritten = (0)
12991 this.seenFatal = false 13123 this.seenFatal = false
12992 this.files = files; 13124 this.files = files;
12993 this.libraries = new HashMapImplementation(); 13125 this.libraries = new HashMapImplementation();
12994 this._todo = []; 13126 this._todo = [];
12995 this._members = new HashMapImplementation(); 13127 this._members = new HashMapImplementation();
12996 this._topNames = new HashMapImplementation(); 13128 this._topNames = new HashMapImplementation();
12997 this.reader = new LibraryReader(); 13129 this.reader = new LibraryReader();
12998 // Initializers done 13130 // Initializers done
12999 } 13131 }
13000 World.prototype.get$functionType = function() { return this.functionType; }; 13132 World.prototype.get$functionType = function() { return this.functionType; };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
13041 } 13173 }
13042 } 13174 }
13043 World.prototype._addTopName = function(named) { 13175 World.prototype._addTopName = function(named) {
13044 if ((named instanceof Type) && named.get$isNative()) { 13176 if ((named instanceof Type) && named.get$isNative()) {
13045 this._addJavascriptTopName(named, named.get$nativeName()); 13177 this._addJavascriptTopName(named, named.get$nativeName());
13046 } 13178 }
13047 this._addJavascriptTopName(named, named.get$jsname()); 13179 this._addJavascriptTopName(named, named.get$jsname());
13048 } 13180 }
13049 World.prototype._addJavascriptTopName = function(named, name) { 13181 World.prototype._addJavascriptTopName = function(named, name) {
13050 var existing = this._topNames.$index(name); 13182 var existing = this._topNames.$index(name);
13051 if (existing === named) { 13183 if (existing == named) {
13052 if (named.get$avoidNativeName()) { 13184 if (named.get$avoidNativeName()) {
13053 this._renameJavascriptTopName(named); 13185 this._renameJavascriptTopName(named);
13054 } 13186 }
13055 } 13187 }
13056 else if (existing != null) { 13188 else if (existing != null) {
13057 this.info(("mangling matching top level name \"" + named.get$jsname() + "\" in ") + ("both \"" + named.get$library().get$jsname() + "\" and \"" + existing.g et$library().get$jsname() + "\"")); 13189 this.info(("mangling matching top level name \"" + named.get$jsname() + "\" in ") + ("both \"" + named.get$library().get$jsname() + "\" and \"" + existing.g et$library().get$jsname() + "\""));
13058 var existingPri = existing.get$jsnamePriority(); 13190 var existingPri = existing.get$jsnamePriority();
13059 var namedPri = named.get$jsnamePriority(); 13191 var namedPri = named.get$jsnamePriority();
13060 if (existingPri > namedPri || namedPri == 0) { 13192 if (existingPri > namedPri || namedPri == (0)) {
13061 this._renameJavascriptTopName(named); 13193 this._renameJavascriptTopName(named);
13062 } 13194 }
13063 else if (namedPri > existingPri) { 13195 else if (namedPri > existingPri) {
13064 this._renameJavascriptTopName(existing); 13196 this._renameJavascriptTopName(existing);
13065 } 13197 }
13066 else { 13198 else {
13067 var msg = ("conflicting JS name \"" + name + "\" of same ") + ("priority " + existingPri + ": (already defined in) ") + ("" + existing.get$span().get$loca tionText() + " with priority " + namedPri + ")"); 13199 var msg = ("conflicting JS name \"" + name + "\" of same ") + ("priority " + existingPri + ": (already defined in) ") + ("" + existing.get$span().get$loca tionText() + " with priority " + namedPri + ")");
13068 if (named.get$isNative()) { 13200 if (named.get$isNative()) {
13069 $globals.world.info(msg, named.get$span(), existing.get$span()); 13201 $globals.world.info(msg, named.get$span(), existing.get$span());
13070 } 13202 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
13198 } 13330 }
13199 this.libraries.$setindex(filename, library); 13331 this.libraries.$setindex(filename, library);
13200 this._todo.add(library); 13332 this._todo.add(library);
13201 if (filename == "dart:dom") { 13333 if (filename == "dart:dom") {
13202 this.dom = library; 13334 this.dom = library;
13203 } 13335 }
13204 } 13336 }
13205 return library; 13337 return library;
13206 } 13338 }
13207 World.prototype.process = function() { 13339 World.prototype.process = function() {
13208 while (this._todo.get$length() > 0) { 13340 while (this._todo.get$length() > (0)) {
13209 var todo = this._todo; 13341 var todo = this._todo;
13210 this._todo = []; 13342 this._todo = [];
13211 for (var $$i = 0;$$i < todo.get$length(); $$i++) { 13343 for (var $$i = 0;$$i < todo.get$length(); $$i++) {
13212 var lib = todo.$index($$i); 13344 var lib = todo.$index($$i);
13213 lib.visitSources$0(); 13345 lib.visitSources$0();
13214 } 13346 }
13215 } 13347 }
13216 } 13348 }
13217 World.prototype.processDartScript = function(script) { 13349 World.prototype.processDartScript = function(script) {
13218 if (script == null) script = $globals.options.dartScript; 13350 if (script == null) script = $globals.options.dartScript;
13219 var library = this.getOrAddLibrary(script); 13351 var library = this.getOrAddLibrary(script);
13220 this.process(); 13352 this.process();
13221 return library; 13353 return library;
13222 } 13354 }
13223 World.prototype.resolveAll = function() { 13355 World.prototype.resolveAll = function() {
13224 var $$list = this.libraries.getValues(); 13356 var $$list = this.libraries.getValues();
13225 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) { 13357 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) {
13226 var lib = $$i.next$0(); 13358 var lib = $$i.next$0();
13227 lib.resolve$0(); 13359 lib.resolve$0();
13228 } 13360 }
13229 } 13361 }
13230 World.prototype.get$resolveAll = function() { 13362 World.prototype.get$resolveAll = function() {
13231 return this.resolveAll.bind(this); 13363 return this.resolveAll.bind(this);
13232 } 13364 }
13233 World.prototype.findMainMethod = function(lib) { 13365 World.prototype.findMainMethod = function(lib) {
13234 var mainMembers = lib.topType.resolveMember("main"); 13366 var mainMembers = lib.topType.resolveMember("main");
13235 var main = null; 13367 var main = null;
13236 if (mainMembers == null || $eq(mainMembers.get$members().get$length(), 0)) { 13368 if (mainMembers == null || $eq(mainMembers.get$members().get$length(), (0))) {
13237 this.fatal("no main method specified"); 13369 this.fatal("no main method specified");
13238 } 13370 }
13239 else if (mainMembers.get$members().get$length() > 1) { 13371 else if (mainMembers.get$members().get$length() > (1)) {
13240 var $$list = mainMembers.get$members(); 13372 var $$list = mainMembers.get$members();
13241 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) { 13373 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) {
13242 var m = $$i.next$0(); 13374 var m = $$i.next$0();
13243 main = m; 13375 main = m;
13244 this.error("more than one main member (using last?)", main.get$span()); 13376 this.error("more than one main member (using last?)", main.get$span());
13245 } 13377 }
13246 } 13378 }
13247 else { 13379 else {
13248 main = mainMembers.get$members().$index(0); 13380 main = mainMembers.get$members().$index((0));
13249 } 13381 }
13250 return main; 13382 return main;
13251 } 13383 }
13252 World.prototype.generateCode = function(lib) { 13384 World.prototype.generateCode = function(lib) {
13253 var codeWriter = new CodeWriter(); 13385 var codeWriter = new CodeWriter();
13254 this.gen = new WorldGenerator(this.findMainMethod(lib), codeWriter); 13386 this.gen = new WorldGenerator(this.findMainMethod(lib), codeWriter);
13255 this.gen.run(); 13387 this.gen.run();
13256 this.jsBytesWritten = codeWriter.get$text().get$length(); 13388 this.jsBytesWritten = codeWriter.get$text().get$length();
13257 } 13389 }
13258 World.prototype._message = function(color, prefix, message, span, span1, span2, throwing) { 13390 World.prototype._message = function(color, prefix, message, span, span1, span2, throwing) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
13313 World.prototype.withoutForceDynamic = function(fn) { 13445 World.prototype.withoutForceDynamic = function(fn) {
13314 var oldForceDynamic = $globals.options.forceDynamic; 13446 var oldForceDynamic = $globals.options.forceDynamic;
13315 $globals.options.forceDynamic = false; 13447 $globals.options.forceDynamic = false;
13316 try { 13448 try {
13317 return fn(); 13449 return fn();
13318 } finally { 13450 } finally {
13319 $globals.options.forceDynamic = oldForceDynamic; 13451 $globals.options.forceDynamic = oldForceDynamic;
13320 } 13452 }
13321 } 13453 }
13322 World.prototype.get$hasErrors = function() { 13454 World.prototype.get$hasErrors = function() {
13323 return this.errors > 0; 13455 return this.errors > (0);
13324 } 13456 }
13325 World.prototype.printStatus = function() { 13457 World.prototype.printStatus = function() {
13326 this.info(("compiled " + this.dartBytesRead + " bytes Dart -> " + this.jsBytes Written + " bytes JS")); 13458 this.info(("compiled " + this.dartBytesRead + " bytes Dart -> " + this.jsBytes Written + " bytes JS"));
13327 if (this.get$hasErrors()) { 13459 if (this.get$hasErrors()) {
13328 print(("compilation failed with " + this.errors + " errors")); 13460 print(("compilation failed with " + this.errors + " errors"));
13329 } 13461 }
13330 else { 13462 else {
13331 if (this.warnings > 0) { 13463 if (this.warnings > (0)) {
13332 this.info(("compilation completed successfully with " + this.warnings + " warnings")); 13464 this.info(("compilation completed successfully with " + this.warnings + " warnings"));
13333 } 13465 }
13334 else { 13466 else {
13335 this.info("compilation completed sucessfully"); 13467 this.info("compilation completed sucessfully");
13336 } 13468 }
13337 } 13469 }
13338 } 13470 }
13339 World.prototype.withTiming = function(name, f) { 13471 World.prototype.withTiming = function(name, f) {
13340 var sw = new StopwatchImplementation(); 13472 var sw = new StopwatchImplementation();
13341 sw.start(); 13473 sw.start();
(...skipping 23 matching lines...) Expand all
13365 this.useColors = true 13497 this.useColors = true
13366 // Initializers done 13498 // Initializers done
13367 if ($eq(this.config, "dev")) { 13499 if ($eq(this.config, "dev")) {
13368 this.libDir = joinPaths(homedir, "/lib"); 13500 this.libDir = joinPaths(homedir, "/lib");
13369 } 13501 }
13370 else if ($eq(this.config, "sdk")) { 13502 else if ($eq(this.config, "sdk")) {
13371 this.libDir = joinPaths(homedir, "/../lib"); 13503 this.libDir = joinPaths(homedir, "/../lib");
13372 } 13504 }
13373 else { 13505 else {
13374 $globals.world.error(("Invalid configuration " + this.config)); 13506 $globals.world.error(("Invalid configuration " + this.config));
13375 $throw(("Invalid configuration")); 13507 $throw("Invalid configuration");
13376 } 13508 }
13377 var ignoreUnrecognizedFlags = false; 13509 var ignoreUnrecognizedFlags = false;
13378 var passedLibDir = false; 13510 var passedLibDir = false;
13379 this.childArgs = []; 13511 this.childArgs = [];
13380 loop: 13512 loop:
13381 for (var i = 2; 13513 for (var i = (2);
13382 i < args.get$length(); i++) { 13514 i < args.get$length(); i++) {
13383 var arg = args.$index(i); 13515 var arg = args.$index(i);
13384 switch (arg) { 13516 switch (arg) {
13385 case "--enable_leg": 13517 case "--enable_leg":
13386 13518
13387 this.enableLeg = true; 13519 this.enableLeg = true;
13388 break; 13520 break;
13389 13521
13390 case "--leg_only": 13522 case "--leg_only":
13391 13523
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
13461 13593
13462 case "--no_colors": 13594 case "--no_colors":
13463 13595
13464 this.useColors = false; 13596 this.useColors = false;
13465 break; 13597 break;
13466 13598
13467 default: 13599 default:
13468 13600
13469 if (arg.endsWith$1(".dart")) { 13601 if (arg.endsWith$1(".dart")) {
13470 this.dartScript = arg; 13602 this.dartScript = arg;
13471 this.childArgs = args.getRange(i + 1, args.get$length() - i - 1); 13603 this.childArgs = args.getRange(i + (1), args.get$length() - i - (1));
13472 break loop; 13604 break loop;
13473 } 13605 }
13474 else if (arg.startsWith$1("--out=")) { 13606 else if (arg.startsWith$1("--out=")) {
13475 this.outfile = arg.substring$1("--out=".length); 13607 this.outfile = arg.substring$1("--out=".length);
13476 } 13608 }
13477 else if (arg.startsWith$1("--libdir=")) { 13609 else if (arg.startsWith$1("--libdir=")) {
13478 this.libDir = arg.substring$1("--libdir=".length); 13610 this.libDir = arg.substring$1("--libdir=".length);
13479 passedLibDir = true; 13611 passedLibDir = true;
13480 } 13612 }
13481 else { 13613 else {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
13528 this.name = name; 13660 this.name = name;
13529 // Initializers done 13661 // Initializers done
13530 } 13662 }
13531 VarMember.prototype.get$name = function() { return this.name; }; 13663 VarMember.prototype.get$name = function() { return this.name; };
13532 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; }; 13664 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; };
13533 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated = value; }; 13665 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated = value; };
13534 VarMember.prototype.get$returnType = function() { 13666 VarMember.prototype.get$returnType = function() {
13535 return $globals.world.varType; 13667 return $globals.world.varType;
13536 } 13668 }
13537 VarMember.prototype.invoke = function(context, node, target, args) { 13669 VarMember.prototype.invoke = function(context, node, target, args) {
13538 return new Value(this.get$returnType(), ("" + target.code + "." + this.name + "(" + args.getCode() + ")"), node.span, true); 13670 return new Value(this.get$returnType(), ("" + target.get$code() + "." + this.n ame + "(" + args.getCode() + ")"), node.span, true);
13539 } 13671 }
13540 VarMember.prototype.generate$1 = VarMember.prototype.generate; 13672 VarMember.prototype.generate$1 = VarMember.prototype.generate;
13541 VarMember.prototype.invoke$4 = VarMember.prototype.invoke; 13673 VarMember.prototype.invoke$4 = VarMember.prototype.invoke;
13542 // ********** Code for VarFunctionStub ************** 13674 // ********** Code for VarFunctionStub **************
13543 $inherits(VarFunctionStub, VarMember); 13675 $inherits(VarFunctionStub, VarMember);
13544 function VarFunctionStub(name, callArgs) { 13676 function VarFunctionStub(name, callArgs) {
13545 this.args = callArgs.toCallStubArgs(); 13677 this.args = callArgs.toCallStubArgs();
13546 // Initializers done 13678 // Initializers done
13547 VarMember.call(this, name); 13679 VarMember.call(this, name);
13548 $globals.world.functionImplType.markUsed(); 13680 $globals.world.functionImplType.markUsed();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
13624 code.exitBlock("};"); 13756 code.exitBlock("};");
13625 } 13757 }
13626 } 13758 }
13627 VarMethodStub.prototype._needsExactTypeCheck = function() { 13759 VarMethodStub.prototype._needsExactTypeCheck = function() {
13628 var $this = this; // closure support 13760 var $this = this; // closure support
13629 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse; 13761 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse;
13630 var members = this.member.declaringType.resolveMember(this.member.name).member s; 13762 var members = this.member.declaringType.resolveMember(this.member.name).member s;
13631 return members.filter$1((function (m) { 13763 return members.filter$1((function (m) {
13632 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( ); 13764 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( );
13633 }) 13765 })
13634 ).get$length() >= 1; 13766 ).get$length() >= (1);
13635 } 13767 }
13636 VarMethodStub.prototype._useDirectCall = function(args) { 13768 VarMethodStub.prototype._useDirectCall = function(args) {
13637 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) { 13769 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) {
13638 var method = this.member; 13770 var method = this.member;
13639 if (method.needsArgumentConversion(args)) { 13771 if (method.needsArgumentConversion(args)) {
13640 return false; 13772 return false;
13641 } 13773 }
13642 for (var i = args.get$length(); 13774 for (var i = args.get$length();
13643 i < method.parameters.get$length(); i++) { 13775 i < method.parameters.get$length(); i++) {
13644 if ($ne(method.parameters.$index(i).get$value().get$code(), "null")) { 13776 if ($ne(method.parameters.$index(i).get$value().get$code(), "null")) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
13697 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke; 13829 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke;
13698 // ********** Code for top level ************** 13830 // ********** Code for top level **************
13699 function _otherOperator(jsname, op) { 13831 function _otherOperator(jsname, op) {
13700 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}"); 13832 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}");
13701 } 13833 }
13702 function map(source, mapper) { 13834 function map(source, mapper) {
13703 var result = new Array(); 13835 var result = new Array();
13704 if (!!(source && source.is$List())) { 13836 if (!!(source && source.is$List())) {
13705 var list = source; 13837 var list = source;
13706 result.set$length(list.get$length()); 13838 result.set$length(list.get$length());
13707 for (var i = 0; 13839 for (var i = (0);
13708 i < list.get$length(); i++) { 13840 i < list.get$length(); i++) {
13709 result.$setindex(i, mapper(list.$index(i))); 13841 result.$setindex(i, mapper(list.$index(i)));
13710 } 13842 }
13711 } 13843 }
13712 else { 13844 else {
13713 for (var $$i = source.iterator(); $$i.hasNext$0(); ) { 13845 for (var $$i = source.iterator(); $$i.hasNext$0(); ) {
13714 var item = $$i.next$0(); 13846 var item = $$i.next$0();
13715 result.add(mapper(item)); 13847 result.add(mapper(item));
13716 } 13848 }
13717 } 13849 }
(...skipping 16 matching lines...) Expand all
13734 return x.compareTo$1(y); 13866 return x.compareTo$1(y);
13735 }) 13867 })
13736 ); 13868 );
13737 var values = []; 13869 var values = [];
13738 for (var $$i = 0;$$i < keys.get$length(); $$i++) { 13870 for (var $$i = 0;$$i < keys.get$length(); $$i++) {
13739 var k = keys.$index($$i); 13871 var k = keys.$index($$i);
13740 values.add(map.$index(k)); 13872 values.add(map.$index(k));
13741 } 13873 }
13742 return values; 13874 return values;
13743 } 13875 }
13744 function _escapeForComment(text) {
13745 return text.replaceAll("/*", "/ *").replaceAll("*/", "* /");
13746 }
13747 var world; 13876 var world;
13748 var experimentalAwaitPhase; 13877 var experimentalAwaitPhase;
13749 var legCompile; 13878 var legCompile;
13750 function initializeWorld(files) { 13879 function initializeWorld(files) {
13751 $globals.world = new World(files); 13880 $globals.world = new World(files);
13752 $globals.world.init(); 13881 $globals.world.init();
13753 } 13882 }
13754 function compile(homedir, args, files) { 13883 function compile(homedir, args, files) {
13755 parseOptions(homedir, args, files); 13884 parseOptions(homedir, args, files);
13756 initializeWorld(files); 13885 initializeWorld(files);
(...skipping 12 matching lines...) Expand all
13769 if (name0.contains$1("$")) { 13898 if (name0.contains$1("$")) {
13770 nameBuilder.add(("" + name0.get$length())); 13899 nameBuilder.add(("" + name0.get$length()));
13771 } 13900 }
13772 nameBuilder.add(name0); 13901 nameBuilder.add(name0);
13773 } 13902 }
13774 return nameBuilder.toString(); 13903 return nameBuilder.toString();
13775 } 13904 }
13776 // ********** Library minfrog ************** 13905 // ********** Library minfrog **************
13777 // ********** Code for top level ************** 13906 // ********** Code for top level **************
13778 function main() { 13907 function main() {
13779 var homedir = path.dirname(fs.realpathSync(get$process().get$argv().$index(1)) ); 13908 var homedir = path.dirname(fs.realpathSync(get$process().get$argv().$index((1) )));
13780 var argv = []; 13909 var argv = [];
13781 for (var i = 0; 13910 for (var i = (0);
13782 i < get$process().get$argv().get$length(); i++) { 13911 i < get$process().get$argv().get$length(); i++) {
13783 argv.add$1(get$process().get$argv().$index(i)); 13912 argv.add$1(get$process().get$argv().$index(i));
13784 if (i == 1) { 13913 if (i == (1)) {
13785 var terminal = get$process().get$env().$index("TERM"); 13914 var terminal = get$process().get$env().$index("TERM");
13786 if (terminal == null || !terminal.startsWith$1("xterm")) { 13915 if (terminal == null || !terminal.startsWith$1("xterm")) {
13787 argv.add$1("--no_colors"); 13916 argv.add$1("--no_colors");
13788 } 13917 }
13789 } 13918 }
13790 } 13919 }
13791 if (compile(homedir, argv, new NodeFileSystem())) { 13920 if (compile(homedir, argv, new NodeFileSystem())) {
13792 var code = $globals.world.getGeneratedCode(); 13921 var code = $globals.world.getGeneratedCode();
13793 if ($globals.options.compileOnly) { 13922 if ($globals.options.compileOnly) {
13794 if ($globals.options.outfile != null) { 13923 if ($globals.options.outfile != null) {
13795 print(("Compilation succeded. Code generated in: " + $globals.options.ou tfile)); 13924 print(("Compilation succeded. Code generated in: " + $globals.options.ou tfile));
13796 } 13925 }
13797 else { 13926 else {
13798 print("Compilation succeded."); 13927 print("Compilation succeded.");
13799 } 13928 }
13800 } 13929 }
13801 else { 13930 else {
13802 get$process().set$argv([argv.$index(0), argv.$index(1)]); 13931 get$process().set$argv([argv.$index((0)), argv.$index((1))]);
13803 get$process().get$argv().addAll($globals.options.childArgs); 13932 get$process().get$argv().addAll($globals.options.childArgs);
13804 vm.runInNewContext(code, createSandbox()); 13933 vm.runInNewContext(code, createSandbox());
13805 } 13934 }
13806 } 13935 }
13807 else { 13936 else {
13808 get$process().exit(1); 13937 get$process().exit((1));
13809 } 13938 }
13810 } 13939 }
13811 // ********** Generic Type Inheritance ************** 13940 // ********** Generic Type Inheritance **************
13812 /** Implements extends for generic types. */ 13941 /** Implements extends for generic types. */
13813 function $inheritsMembers(child, parent) { 13942 function $inheritsMembers(child, parent) {
13814 child = child.prototype; 13943 child = child.prototype;
13815 parent = parent.prototype; 13944 parent = parent.prototype;
13816 Object.getOwnPropertyNames(parent).forEach(function(name) { 13945 Object.getOwnPropertyNames(parent).forEach(function(name) {
13817 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; 13946 if (typeof(child[name]) == 'undefined') child[name] = parent[name];
13818 }); 13947 });
(...skipping 11 matching lines...) Expand all
13830 $globals._RED_COLOR = "\x1b[31m"; 13959 $globals._RED_COLOR = "\x1b[31m";
13831 } 13960 }
13832 var const$1 = new EmptyQueueException(); 13961 var const$1 = new EmptyQueueException();
13833 var const$126 = new IllegalAccessException(); 13962 var const$126 = new IllegalAccessException();
13834 var const$127 = ImmutableList.ImmutableList$from$factory([]); 13963 var const$127 = ImmutableList.ImmutableList$from$factory([]);
13835 var const$2 = new _DeletedKeySentinel(); 13964 var const$2 = new _DeletedKeySentinel();
13836 var const$7 = new NoMoreElementsException(); 13965 var const$7 = new NoMoreElementsException();
13837 var $globals = {}; 13966 var $globals = {};
13838 $static_init(); 13967 $static_init();
13839 main(); 13968 main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698