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

Side by Side Diff: frog/minfrog

Issue 9121025: cleanup to Value - fix for StringEscapesTest (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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }; 258 };
259 Object.prototype.provideFieldSyntax$0 = function() { 259 Object.prototype.provideFieldSyntax$0 = function() {
260 return this.noSuchMethod("provideFieldSyntax", []); 260 return this.noSuchMethod("provideFieldSyntax", []);
261 }; 261 };
262 Object.prototype.providePropertySyntax$0 = function() { 262 Object.prototype.providePropertySyntax$0 = function() {
263 return this.noSuchMethod("providePropertySyntax", []); 263 return this.noSuchMethod("providePropertySyntax", []);
264 }; 264 };
265 Object.prototype.removeLast$0 = function() { 265 Object.prototype.removeLast$0 = function() {
266 return this.noSuchMethod("removeLast", []); 266 return this.noSuchMethod("removeLast", []);
267 }; 267 };
268 Object.prototype.replaceAll$2 = function($0, $1) {
269 return this.noSuchMethod("replaceAll", [$0, $1]);
270 };
271 Object.prototype.replaceFirst$2 = function($0, $1) { 268 Object.prototype.replaceFirst$2 = function($0, $1) {
272 return this.noSuchMethod("replaceFirst", [$0, $1]); 269 return this.noSuchMethod("replaceFirst", [$0, $1]);
273 }; 270 };
274 Object.prototype.resolve$0 = function() { 271 Object.prototype.resolve$0 = function() {
275 return this.noSuchMethod("resolve", []); 272 return this.noSuchMethod("resolve", []);
276 }; 273 };
277 Object.prototype.resolveTypeParams$1 = function($0) { 274 Object.prototype.resolveTypeParams$1 = function($0) {
278 return this.noSuchMethod("resolveTypeParams", [$0]); 275 return this.noSuchMethod("resolveTypeParams", [$0]);
279 }; 276 };
280 Object.prototype.setDefinition$1 = function($0) { 277 Object.prototype.setDefinition$1 = function($0) {
(...skipping 13 matching lines...) Expand all
294 }; 291 };
295 Object.prototype.startsWith$1 = function($0) { 292 Object.prototype.startsWith$1 = function($0) {
296 return this.noSuchMethod("startsWith", [$0]); 293 return this.noSuchMethod("startsWith", [$0]);
297 }; 294 };
298 Object.prototype.substring$1 = function($0) { 295 Object.prototype.substring$1 = function($0) {
299 return this.noSuchMethod("substring", [$0]); 296 return this.noSuchMethod("substring", [$0]);
300 }; 297 };
301 Object.prototype.substring$2 = function($0, $1) { 298 Object.prototype.substring$2 = function($0, $1) {
302 return this.noSuchMethod("substring", [$0, $1]); 299 return this.noSuchMethod("substring", [$0, $1]);
303 }; 300 };
301 Object.prototype.toRadixString$1 = function($0) {
302 return this.noSuchMethod("toRadixString", [$0]);
303 };
304 Object.prototype.toString$0 = function() { 304 Object.prototype.toString$0 = function() {
305 return this.toString(); 305 return this.toString();
306 }; 306 };
307 Object.prototype.visit$1 = function($0) { 307 Object.prototype.visit$1 = function($0) {
308 return this.noSuchMethod("visit", [$0]); 308 return this.noSuchMethod("visit", [$0]);
309 }; 309 };
310 Object.prototype.visitBinaryExpression$1 = function($0) { 310 Object.prototype.visitBinaryExpression$1 = function($0) {
311 return this.noSuchMethod("visitBinaryExpression", [$0]); 311 return this.noSuchMethod("visitBinaryExpression", [$0]);
312 }; 312 };
313 Object.prototype.visitPostfixExpression$1 = function($0) { 313 Object.prototype.visitPostfixExpression$1 = function($0) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 if (a == b) return a; 455 if (a == b) return a;
456 if (a < b) { 456 if (a < b) {
457 if (isNaN(b)) return b; 457 if (isNaN(b)) return b;
458 else return a; 458 else return a;
459 } 459 }
460 if (isNaN(a)) return a; 460 if (isNaN(a)) return a;
461 else return b; 461 else return b;
462 } 462 }
463 // ********** Code for Strings ************** 463 // ********** Code for Strings **************
464 function Strings() {} 464 function Strings() {}
465 Strings.String$fromCharCodes$factory = function(charCodes) {
466 return StringBase.createFromCharCodes(charCodes);
467 }
465 Strings.join = function(strings, separator) { 468 Strings.join = function(strings, separator) {
466 return StringBase.join(strings, separator); 469 return StringBase.join(strings, separator);
467 } 470 }
468 // ********** Code for top level ************** 471 // ********** Code for top level **************
469 function print(obj) { 472 function print(obj) {
470 return _print(obj); 473 return _print(obj);
471 } 474 }
472 function _print(obj) { 475 function _print(obj) {
473 if (typeof console == 'object') { 476 if (typeof console == 'object') {
474 if (obj) obj = obj.toString(); 477 if (obj) obj = obj.toString();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 ListFactory.prototype.iterator$0 = ListFactory.prototype.iterator; 601 ListFactory.prototype.iterator$0 = ListFactory.prototype.iterator;
599 ListFactory.prototype.last$0 = ListFactory.prototype.last; 602 ListFactory.prototype.last$0 = ListFactory.prototype.last;
600 ListFactory.prototype.removeLast$0 = ListFactory.prototype.removeLast; 603 ListFactory.prototype.removeLast$0 = ListFactory.prototype.removeLast;
601 ListFactory.prototype.some$1 = function($0) { 604 ListFactory.prototype.some$1 = function($0) {
602 return this.some(to$call$1($0)); 605 return this.some(to$call$1($0));
603 }; 606 };
604 ListFactory.prototype.sort$1 = function($0) { 607 ListFactory.prototype.sort$1 = function($0) {
605 return this.sort(to$call$2($0)); 608 return this.sort(to$call$2($0));
606 }; 609 };
607 ListFactory_E = ListFactory; 610 ListFactory_E = ListFactory;
611 ListFactory_Expression = ListFactory;
608 ListFactory_K = ListFactory; 612 ListFactory_K = ListFactory;
609 ListFactory_dart_core_String = ListFactory; 613 ListFactory_dart_core_String = ListFactory;
610 ListFactory_V = ListFactory; 614 ListFactory_V = ListFactory;
615 ListFactory_int = ListFactory;
611 // ********** Code for ListIterator ************** 616 // ********** Code for ListIterator **************
612 function ListIterator(array) { 617 function ListIterator(array) {
613 this._array = array; 618 this._array = array;
614 this._pos = 0; 619 this._pos = 0;
615 // Initializers done 620 // Initializers done
616 } 621 }
617 ListIterator.prototype.hasNext = function() { 622 ListIterator.prototype.hasNext = function() {
618 return this._array.get$length() > this._pos; 623 return this._array.get$length() > this._pos;
619 } 624 }
620 ListIterator.prototype.next = function() { 625 ListIterator.prototype.next = function() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 if ((this == Infinity) || (this == -Infinity)) { 717 if ((this == Infinity) || (this == -Infinity)) {
713 $throw(new BadNumberFormatException("Infinity")); 718 $throw(new BadNumberFormatException("Infinity"));
714 } 719 }
715 var truncated = (this < 0) ? Math.ceil(this) : Math.floor(this); 720 var truncated = (this < 0) ? Math.ceil(this) : Math.floor(this);
716 if (truncated == -0.0) return 0; 721 if (truncated == -0.0) return 0;
717 return truncated; 722 return truncated;
718 } 723 }
719 NumImplementation.prototype.toDouble = function() { 724 NumImplementation.prototype.toDouble = function() {
720 'use strict'; return this + 0; 725 'use strict'; return this + 0;
721 } 726 }
727 NumImplementation.prototype.toRadixString = function(radix) {
728 'use strict'; return this.toString(radix)
729 }
722 NumImplementation.prototype.compareTo = function(other) { 730 NumImplementation.prototype.compareTo = function(other) {
723 var thisValue = this.toDouble(); 731 var thisValue = this.toDouble();
724 if (thisValue < other) { 732 if (thisValue < other) {
725 return -1; 733 return -1;
726 } 734 }
727 else if (thisValue > other) { 735 else if (thisValue > other) {
728 return 1; 736 return 1;
729 } 737 }
730 else if (thisValue == other) { 738 else if (thisValue == other) {
731 if (thisValue == 0) { 739 if (thisValue == 0) {
(...skipping 10 matching lines...) Expand all
742 return 0; 750 return 0;
743 } 751 }
744 return 1; 752 return 1;
745 } 753 }
746 else { 754 else {
747 return -1; 755 return -1;
748 } 756 }
749 } 757 }
750 NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo; 758 NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo;
751 NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode; 759 NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode;
760 NumImplementation.prototype.toRadixString$1 = NumImplementation.prototype.toRadi xString;
752 // ********** Code for HashMapImplementation ************** 761 // ********** Code for HashMapImplementation **************
753 function HashMapImplementation() { 762 function HashMapImplementation() {
754 // Initializers done 763 // Initializers done
755 this._numberOfEntries = 0; 764 this._numberOfEntries = 0;
756 this._numberOfDeleted = 0; 765 this._numberOfDeleted = 0;
757 this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementa tion._INITIAL_CAPACITY*/); 766 this._loadLimit = HashMapImplementation._computeLoadLimit(8/*HashMapImplementa tion._INITIAL_CAPACITY*/);
758 this._keys = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 767 this._keys = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/);
759 this._values = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/); 768 this._values = new Array(8/*HashMapImplementation._INITIAL_CAPACITY*/);
760 } 769 }
761 HashMapImplementation.HashMapImplementation$from$factory = function(other) { 770 HashMapImplementation.HashMapImplementation$from$factory = function(other) {
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 this._buffer.clear(); 1649 this._buffer.clear();
1641 this._buffer.add(result); 1650 this._buffer.add(result);
1642 return result; 1651 return result;
1643 } 1652 }
1644 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add; 1653 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add;
1645 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll; 1654 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll;
1646 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty; 1655 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty;
1647 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString; 1656 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString;
1648 // ********** Code for StringBase ************** 1657 // ********** Code for StringBase **************
1649 function StringBase() {} 1658 function StringBase() {}
1659 StringBase.createFromCharCodes = function(charCodes) {
1660 if (Object.getPrototypeOf(charCodes) !== Array.prototype) {
1661 charCodes = new ListFactory.ListFactory$from$factory(charCodes);
1662 }
1663 return String.fromCharCode.apply(null, charCodes);
1664 }
1650 StringBase.join = function(strings, separator) { 1665 StringBase.join = function(strings, separator) {
1651 if (strings.get$length() == 0) return ''; 1666 if (strings.get$length() == 0) return "";
1652 var s = strings.$index(0); 1667 var s = strings.$index(0);
1653 for (var i = 1; 1668 for (var i = 1;
1654 i < strings.get$length(); i++) { 1669 i < strings.get$length(); i++) {
1655 s = s + separator + strings.$index(i); 1670 s = s + separator + strings.$index(i);
1656 } 1671 }
1657 return s; 1672 return s;
1658 } 1673 }
1659 StringBase.concatAll = function(strings) { 1674 StringBase.concatAll = function(strings) {
1660 return StringBase.join(strings, ""); 1675 return StringBase.join(strings, "");
1661 } 1676 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } 1743 }
1729 StringImplementation.prototype.compareTo = function(other) { 1744 StringImplementation.prototype.compareTo = function(other) {
1730 'use strict'; return this == other ? 0 : this < other ? -1 : 1; 1745 'use strict'; return this == other ? 0 : this < other ? -1 : 1;
1731 } 1746 }
1732 StringImplementation.prototype.compareTo$1 = StringImplementation.prototype.comp areTo; 1747 StringImplementation.prototype.compareTo$1 = StringImplementation.prototype.comp areTo;
1733 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta ins; 1748 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta ins;
1734 StringImplementation.prototype.endsWith$1 = StringImplementation.prototype.endsW ith; 1749 StringImplementation.prototype.endsWith$1 = StringImplementation.prototype.endsW ith;
1735 StringImplementation.prototype.hashCode$0 = StringImplementation.prototype.hashC ode; 1750 StringImplementation.prototype.hashCode$0 = StringImplementation.prototype.hashC ode;
1736 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO f; 1751 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO f;
1737 StringImplementation.prototype.isEmpty$0 = StringImplementation.prototype.isEmpt y; 1752 StringImplementation.prototype.isEmpty$0 = StringImplementation.prototype.isEmpt y;
1738 StringImplementation.prototype.replaceAll$2 = StringImplementation.prototype.rep laceAll;
1739 StringImplementation.prototype.replaceFirst$2 = StringImplementation.prototype.r eplaceFirst; 1753 StringImplementation.prototype.replaceFirst$2 = StringImplementation.prototype.r eplaceFirst;
1740 StringImplementation.prototype.startsWith$1 = StringImplementation.prototype.sta rtsWith; 1754 StringImplementation.prototype.startsWith$1 = StringImplementation.prototype.sta rtsWith;
1741 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs tring; 1755 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs tring;
1742 StringImplementation.prototype.substring$2 = StringImplementation.prototype.subs tring; 1756 StringImplementation.prototype.substring$2 = StringImplementation.prototype.subs tring;
1743 // ********** Code for Collections ************** 1757 // ********** Code for Collections **************
1744 function Collections() {} 1758 function Collections() {}
1745 Collections.forEach = function(iterable, f) { 1759 Collections.forEach = function(iterable, f) {
1746 for (var $$i = iterable.iterator(); $$i.hasNext$0(); ) { 1760 for (var $$i = iterable.iterator(); $$i.hasNext$0(); ) {
1747 var e = $$i.next$0(); 1761 var e = $$i.next$0();
1748 f(e); 1762 f(e);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 // Note: using Function instead of 'eval' to get a clean scope. 1858 // Note: using Function instead of 'eval' to get a clean scope.
1845 // TODO(jmesserly): evaluate the performance of these stubs. 1859 // TODO(jmesserly): evaluate the performance of these stubs.
1846 var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}'; 1860 var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}';
1847 return new Function('$f', 'return ' + f + '').call(null, this); 1861 return new Function('$f', 'return ' + f + '').call(null, this);
1848 1862
1849 } 1863 }
1850 // ********** Code for top level ************** 1864 // ********** Code for top level **************
1851 // ********** Library node ************** 1865 // ********** Library node **************
1852 // ********** Code for Process ************** 1866 // ********** Code for Process **************
1853 function Process(_process) { 1867 function Process(_process) {
1854 this.SIGHUP = 'SIGHUP' 1868 this.SIGHUP = "SIGHUP"
1855 this.SIGINT = 'SIGINT' 1869 this.SIGINT = "SIGINT"
1856 this.SIGQUIT = 'SIGQUIT' 1870 this.SIGQUIT = "SIGQUIT"
1857 this.SIGILL = 'SIGILL' 1871 this.SIGILL = "SIGILL"
1858 this.SIGTRAP = 'SIGTRAP' 1872 this.SIGTRAP = "SIGTRAP"
1859 this.SIGABRT = 'SIGABRT' 1873 this.SIGABRT = "SIGABRT"
1860 this.SIGEMT = 'SIGEMT' 1874 this.SIGEMT = "SIGEMT"
1861 this.SIGFPE = 'SIGFPE' 1875 this.SIGFPE = "SIGFPE"
1862 this.SIGKILL = 'SIGKILL' 1876 this.SIGKILL = "SIGKILL"
1863 this.SIGBUS = 'SIGBUS' 1877 this.SIGBUS = "SIGBUS"
1864 this.SIGSEGV = 'SIGSEGV' 1878 this.SIGSEGV = "SIGSEGV"
1865 this.SIGSYS = 'SIGSYS' 1879 this.SIGSYS = "SIGSYS"
1866 this.SIGPIPE = 'SIGPIPE' 1880 this.SIGPIPE = "SIGPIPE"
1867 this.SIGALRM = 'SIGALRM' 1881 this.SIGALRM = "SIGALRM"
1868 this.SIGTERM = 'SIGTERM' 1882 this.SIGTERM = "SIGTERM"
1869 this.SIGURG = 'SIGURG' 1883 this.SIGURG = "SIGURG"
1870 this.SIGSTOP = 'SIGSTOP' 1884 this.SIGSTOP = "SIGSTOP"
1871 this.SIGTSTP = 'SIGTSTP' 1885 this.SIGTSTP = "SIGTSTP"
1872 this.SIGCONT = 'SIGCONT' 1886 this.SIGCONT = "SIGCONT"
1873 this.SIGCHLD = 'SIGCHLD' 1887 this.SIGCHLD = "SIGCHLD"
1874 this.SIGTTIN = 'SIGTTIN' 1888 this.SIGTTIN = "SIGTTIN"
1875 this.SIGTTOU = 'SIGTTOU' 1889 this.SIGTTOU = "SIGTTOU"
1876 this.SIGIO = 'SIGIO' 1890 this.SIGIO = "SIGIO"
1877 this.SIGXCPU = 'SIGXCPU' 1891 this.SIGXCPU = "SIGXCPU"
1878 this.SIGXFSZ = 'SIGXFSZ' 1892 this.SIGXFSZ = "SIGXFSZ"
1879 this.SIGVTALRM = 'SIGVTALRM' 1893 this.SIGVTALRM = "SIGVTALRM"
1880 this.SIGPROF = 'SIGPROF' 1894 this.SIGPROF = "SIGPROF"
1881 this.SIGWINCH = 'SIGWINCH' 1895 this.SIGWINCH = "SIGWINCH"
1882 this.SIGINFO = 'SIGINFO' 1896 this.SIGINFO = "SIGINFO"
1883 this.SIGUSR1 = 'SIGUSR1' 1897 this.SIGUSR1 = "SIGUSR1"
1884 this.SIGUSR2 = 'SIGUSR2' 1898 this.SIGUSR2 = "SIGUSR2"
1885 this._process = _process; 1899 this._process = _process;
1886 // Initializers done 1900 // Initializers done
1887 } 1901 }
1888 Process.prototype.get$argv = function() { 1902 Process.prototype.get$argv = function() {
1889 return this._process.argv; 1903 return this._process.argv;
1890 } 1904 }
1891 Process.prototype.set$argv = function(value) { 1905 Process.prototype.set$argv = function(value) {
1892 this._process.argv = value; 1906 this._process.argv = value;
1893 } 1907 }
1894 Process.prototype.get$env = function() { 1908 Process.prototype.get$env = function() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 map[tagNames[j]] = true; 1982 map[tagNames[j]] = true;
1969 } 1983 }
1970 table.push({tag: tag, tags: tags, map: map}); 1984 table.push({tag: tag, tags: tags, map: map});
1971 } 1985 }
1972 $dynamicMetadata = table; 1986 $dynamicMetadata = table;
1973 } 1987 }
1974 $dynamic("get$end").WriteStream = function() { 1988 $dynamic("get$end").WriteStream = function() {
1975 return this.end.bind(this); 1989 return this.end.bind(this);
1976 } 1990 }
1977 $dynamic("end$0").WriteStream = function() { 1991 $dynamic("end$0").WriteStream = function() {
1978 return this.end(null, 'utf8'); 1992 return this.end(null, "utf8");
1979 }; 1993 };
1980 // ********** Code for vm ************** 1994 // ********** Code for vm **************
1981 vm = require('vm'); 1995 vm = require('vm');
1982 // ********** Code for fs ************** 1996 // ********** Code for fs **************
1983 fs = require('fs'); 1997 fs = require('fs');
1984 // ********** Code for path ************** 1998 // ********** Code for path **************
1985 path = require('path'); 1999 path = require('path');
1986 // ********** Code for top level ************** 2000 // ********** Code for top level **************
1987 function createSandbox() { 2001 function createSandbox() {
1988 return {'require': require, 'process': process, 'console': console, 2002 return {'require': require, 'process': process, 'console': console,
1989 'Buffer' : Buffer, 2003 'Buffer' : Buffer,
1990 'setTimeout': setTimeout, 'clearTimeout': clearTimeout}; 2004 'setTimeout': setTimeout, 'clearTimeout': clearTimeout};
1991 } 2005 }
1992 function get$_process() { 2006 function get$_process() {
1993 return process; 2007 return process;
1994 } 2008 }
1995 function get$process() { 2009 function get$process() {
1996 return new Process(get$_process()); 2010 return new Process(get$_process());
1997 } 2011 }
1998 // ********** Library file_system ************** 2012 // ********** Library file_system **************
1999 // ********** Code for top level ************** 2013 // ********** Code for top level **************
2000 function joinPaths(path1, path2) { 2014 function joinPaths(path1, path2) {
2001 var pieces = path1.split('/'); 2015 var pieces = path1.split("/");
2002 var $$list = path2.split('/'); 2016 var $$list = path2.split("/");
2003 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2017 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2004 var piece = $$list.$index($$i); 2018 var piece = $$list.$index($$i);
2005 if ($eq(piece, '..') && pieces.get$length() > 0 && $ne(pieces.last$0(), '.') && $ne(pieces.last$0(), '..')) { 2019 if ($eq(piece, "..") && pieces.get$length() > 0 && $ne(pieces.last$0(), ".") && $ne(pieces.last$0(), "..")) {
2006 pieces.removeLast$0(); 2020 pieces.removeLast$0();
2007 } 2021 }
2008 else if ($ne(piece, '')) { 2022 else if ($ne(piece, "")) {
2009 if (pieces.get$length() > 0 && $eq(pieces.last$0(), '.')) { 2023 if (pieces.get$length() > 0 && $eq(pieces.last$0(), ".")) {
2010 pieces.removeLast$0(); 2024 pieces.removeLast$0();
2011 } 2025 }
2012 pieces.add$1(piece); 2026 pieces.add$1(piece);
2013 } 2027 }
2014 } 2028 }
2015 return Strings.join(pieces, '/'); 2029 return Strings.join(pieces, "/");
2016 } 2030 }
2017 function dirname(path) { 2031 function dirname(path) {
2018 var lastSlash = path.lastIndexOf('/', path.length); 2032 var lastSlash = path.lastIndexOf("/", path.length);
2019 if (lastSlash == -1) { 2033 if (lastSlash == -1) {
2020 return '.'; 2034 return ".";
2021 } 2035 }
2022 else { 2036 else {
2023 return path.substring(0, lastSlash); 2037 return path.substring(0, lastSlash);
2024 } 2038 }
2025 } 2039 }
2026 function basename(path) { 2040 function basename(path) {
2027 var lastSlash = path.lastIndexOf('/', path.length); 2041 var lastSlash = path.lastIndexOf("/", path.length);
2028 if (lastSlash == -1) { 2042 if (lastSlash == -1) {
2029 return path; 2043 return path;
2030 } 2044 }
2031 else { 2045 else {
2032 return path.substring(lastSlash + 1); 2046 return path.substring(lastSlash + 1);
2033 } 2047 }
2034 } 2048 }
2035 // ********** Library file_system_node ************** 2049 // ********** Library file_system_node **************
2036 // ********** Code for NodeFileSystem ************** 2050 // ********** Code for NodeFileSystem **************
2037 function NodeFileSystem() { 2051 function NodeFileSystem() {
2038 // Initializers done 2052 // Initializers done
2039 } 2053 }
2040 NodeFileSystem.prototype.writeString = function(outfile, text) { 2054 NodeFileSystem.prototype.writeString = function(outfile, text) {
2041 fs.writeFileSync(outfile, text); 2055 fs.writeFileSync(outfile, text);
2042 } 2056 }
2043 NodeFileSystem.prototype.readAll = function(filename) { 2057 NodeFileSystem.prototype.readAll = function(filename) {
2044 return fs.readFileSync(filename, 'utf8'); 2058 return fs.readFileSync(filename, "utf8");
2045 } 2059 }
2046 NodeFileSystem.prototype.fileExists = function(filename) { 2060 NodeFileSystem.prototype.fileExists = function(filename) {
2047 return path.existsSync(filename); 2061 return path.existsSync(filename);
2048 } 2062 }
2049 // ********** Code for top level ************** 2063 // ********** Code for top level **************
2050 // ********** Library lang ************** 2064 // ********** Library lang **************
2051 // ********** Code for CodeWriter ************** 2065 // ********** Code for CodeWriter **************
2052 function CodeWriter() { 2066 function CodeWriter() {
2053 this._indentation = 0 2067 this._indentation = 0
2054 this._pendingIndent = false 2068 this._pendingIndent = false
2055 this.writeComments = true 2069 this.writeComments = true
2056 this._buf = new StringBufferImpl(""); 2070 this._buf = new StringBufferImpl("");
2057 // Initializers done 2071 // Initializers done
2058 } 2072 }
2059 CodeWriter.prototype.get$text = function() { 2073 CodeWriter.prototype.get$text = function() {
2060 return this._buf.toString(); 2074 return this._buf.toString();
2061 } 2075 }
2062 CodeWriter.prototype._indent = function() { 2076 CodeWriter.prototype._indent = function() {
2063 this._pendingIndent = false; 2077 this._pendingIndent = false;
2064 for (var i = 0; 2078 for (var i = 0;
2065 i < this._indentation; i++) { 2079 i < this._indentation; i++) {
2066 this._buf.add(' '/*CodeWriter.INDENTATION*/); 2080 this._buf.add(" "/*CodeWriter.INDENTATION*/);
2067 } 2081 }
2068 } 2082 }
2069 CodeWriter.prototype.comment = function(text) { 2083 CodeWriter.prototype.comment = function(text) {
2070 if (this.writeComments) { 2084 if (this.writeComments) {
2071 this.writeln(text); 2085 this.writeln(text);
2072 } 2086 }
2073 } 2087 }
2074 CodeWriter.prototype.write = function(text) { 2088 CodeWriter.prototype.write = function(text) {
2075 if (text.length == 0) return; 2089 if (text.length == 0) return;
2076 if (this._pendingIndent) this._indent(); 2090 if (this._pendingIndent) this._indent();
2077 if (text.indexOf('\n') != -1) { 2091 if (text.indexOf("\n") != -1) {
2078 var lines = text.split('\n'); 2092 var lines = text.split("\n");
2079 for (var i = 0; 2093 for (var i = 0;
2080 i < lines.get$length() - 1; i++) { 2094 i < lines.get$length() - 1; i++) {
2081 this.writeln(lines.$index(i)); 2095 this.writeln(lines.$index(i));
2082 } 2096 }
2083 this.write(lines.$index(lines.get$length() - 1)); 2097 this.write(lines.$index(lines.get$length() - 1));
2084 } 2098 }
2085 else { 2099 else {
2086 this._buf.add(text); 2100 this._buf.add(text);
2087 } 2101 }
2088 } 2102 }
2089 CodeWriter.prototype.writeln = function(text) { 2103 CodeWriter.prototype.writeln = function(text) {
2090 if (text != null) { 2104 if (text != null) {
2091 this.write(text); 2105 this.write(text);
2092 } 2106 }
2093 if (!text.endsWith('\n')) this._buf.add('\n'/*CodeWriter.NEWLINE*/); 2107 if (!text.endsWith("\n")) this._buf.add("\n"/*CodeWriter.NEWLINE*/);
2094 this._pendingIndent = true; 2108 this._pendingIndent = true;
2095 } 2109 }
2096 CodeWriter.prototype.enterBlock = function(text) { 2110 CodeWriter.prototype.enterBlock = function(text) {
2097 this.writeln(text); 2111 this.writeln(text);
2098 this._indentation++; 2112 this._indentation++;
2099 } 2113 }
2100 CodeWriter.prototype.exitBlock = function(text) { 2114 CodeWriter.prototype.exitBlock = function(text) {
2101 this._indentation--; 2115 this._indentation--;
2102 this.writeln(text); 2116 this.writeln(text);
2103 } 2117 }
(...skipping 16 matching lines...) Expand all
2120 this._generatedDynamicProto = false 2134 this._generatedDynamicProto = false
2121 this._generatedInherits = false 2135 this._generatedInherits = false
2122 this._usedOperators = new HashMapImplementation(); 2136 this._usedOperators = new HashMapImplementation();
2123 this.writer = new CodeWriter(); 2137 this.writer = new CodeWriter();
2124 // Initializers done 2138 // Initializers done
2125 } 2139 }
2126 CoreJs.prototype.useOperator = function(name) { 2140 CoreJs.prototype.useOperator = function(name) {
2127 if (this._usedOperators.$index(name) != null) return; 2141 if (this._usedOperators.$index(name) != null) return;
2128 var code; 2142 var code;
2129 switch (name) { 2143 switch (name) {
2130 case ':ne': 2144 case ":ne":
2131 2145
2132 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*/; 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*/;
2133 break; 2147 break;
2134 2148
2135 case ':eq': 2149 case ":eq":
2136 2150
2137 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*/; 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*/;
2138 break; 2152 break;
2139 2153
2140 case ':bit_not': 2154 case ":bit_not":
2141 2155
2142 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x. $bit_not();\n}"/*null._BIT_NOT_FUNCTION*/; 2156 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x. $bit_not();\n}"/*null._BIT_NOT_FUNCTION*/;
2143 break; 2157 break;
2144 2158
2145 case ':negate': 2159 case ":negate":
2146 2160
2147 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$ negate();\n}"/*null._NEGATE_FUNCTION*/; 2161 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$ negate();\n}"/*null._NEGATE_FUNCTION*/;
2148 break; 2162 break;
2149 2163
2150 case ':add': 2164 case ":add":
2151 2165
2152 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*/; 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*/;
2153 break; 2167 break;
2154 2168
2155 case ':truncdiv': 2169 case ":truncdiv":
2156 2170
2157 this.useThrow = true; 2171 this.useThrow = true;
2158 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*/; 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*/;
2159 break; 2173 break;
2160 2174
2161 case ':mod': 2175 case ":mod":
2162 2176
2163 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*/; 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*/;
2164 break; 2178 break;
2165 2179
2166 default: 2180 default:
2167 2181
2168 var op = TokenKind.rawOperatorFromMethod(name); 2182 var op = TokenKind.rawOperatorFromMethod(name);
2169 var jsname = $globals.world.toJsIdentifier(name); 2183 var jsname = $globals.world.toJsIdentifier(name);
2170 code = _otherOperator(jsname, op); 2184 code = _otherOperator(jsname, op);
2171 break; 2185 break;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L1_FUNCTION*/); 2236 w.writeln("function $wrap_call$1(fn) { return fn; }"/*null._EMPTY_WRAP_CAL L1_FUNCTION*/);
2223 } 2237 }
2224 } 2238 }
2225 var $$list = orderValuesByKeys(this._usedOperators); 2239 var $$list = orderValuesByKeys(this._usedOperators);
2226 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2240 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2227 var opImpl = $$list.$index($$i); 2241 var opImpl = $$list.$index($$i);
2228 w.writeln(opImpl); 2242 w.writeln(opImpl);
2229 } 2243 }
2230 if ($globals.world.dom != null) { 2244 if ($globals.world.dom != null) {
2231 this.ensureTypeNameOf(); 2245 this.ensureTypeNameOf();
2232 w.writeln('Object.prototype.get\$typeName = Object.prototype.\$typeNameOf;' /*'Object.prototype.get\$typeName = ' + 2246 w.writeln("Object.prototype.get$typeName = Object.prototype.$typeNameOf;");
2233 ' Object.prototype.\$typeNameOf;'*/);
2234 } 2247 }
2235 } 2248 }
2236 CoreJs.prototype.generate$1 = CoreJs.prototype.generate; 2249 CoreJs.prototype.generate$1 = CoreJs.prototype.generate;
2237 // ********** Code for Element ************** 2250 // ********** Code for Element **************
2238 function Element(name, _enclosingElement) { 2251 function Element(name, _enclosingElement) {
2239 this.name = name; 2252 this.name = name;
2240 this._enclosingElement = _enclosingElement; 2253 this._enclosingElement = _enclosingElement;
2241 // Initializers done 2254 // Initializers done
2242 this._jsname = $globals.world.toJsIdentifier(this.name); 2255 this._jsname = $globals.world.toJsIdentifier(this.name);
2243 } 2256 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2317 }
2305 if (typeRef.type != null) { 2318 if (typeRef.type != null) {
2306 return typeRef.type; 2319 return typeRef.type;
2307 } 2320 }
2308 return this.get$enclosingElement().resolveType(node, typeErrors); 2321 return this.get$enclosingElement().resolveType(node, typeErrors);
2309 } 2322 }
2310 else if ((node instanceof GenericTypeReference)) { 2323 else if ((node instanceof GenericTypeReference)) {
2311 var typeRef = node; 2324 var typeRef = node;
2312 var baseType = this.resolveType(typeRef.baseType, typeErrors); 2325 var baseType = this.resolveType(typeRef.baseType, typeErrors);
2313 if (!baseType.get$isGeneric()) { 2326 if (!baseType.get$isGeneric()) {
2314 $globals.world.error(('' + baseType.get$name() + ' is not generic'), typeR ef.span); 2327 $globals.world.error(("" + baseType.get$name() + " is not generic"), typeR ef.span);
2315 return null; 2328 return null;
2316 } 2329 }
2317 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$ length()) { 2330 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$ length()) {
2318 $globals.world.error('wrong number of type arguments', typeRef.span); 2331 $globals.world.error("wrong number of type arguments", typeRef.span);
2319 return null; 2332 return null;
2320 } 2333 }
2321 var typeArgs = []; 2334 var typeArgs = [];
2322 for (var i = 0; 2335 for (var i = 0;
2323 i < typeRef.typeArguments.get$length(); i++) { 2336 i < typeRef.typeArguments.get$length(); i++) {
2324 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s)); 2337 typeArgs.add$1(this.resolveType(typeRef.typeArguments.$index(i), typeError s));
2325 } 2338 }
2326 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs); 2339 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs);
2327 } 2340 }
2328 else if ((node instanceof FunctionTypeReference)) { 2341 else if ((node instanceof FunctionTypeReference)) {
2329 var typeRef = node; 2342 var typeRef = node;
2330 var name = ''; 2343 var name = "";
2331 if (typeRef.func.name != null) { 2344 if (typeRef.func.name != null) {
2332 name = typeRef.func.name.name; 2345 name = typeRef.func.name.name;
2333 } 2346 }
2334 typeRef.type = this.get$library().getOrAddFunctionType(this, name, typeRef.f unc); 2347 typeRef.type = this.get$library().getOrAddFunctionType(this, name, typeRef.f unc);
2335 } 2348 }
2336 else { 2349 else {
2337 $globals.world.internalError('unknown type reference', node.span); 2350 $globals.world.internalError("unknown type reference", node.span);
2338 } 2351 }
2339 return node.type; 2352 return node.type;
2340 } 2353 }
2341 Element.prototype.hashCode$0 = Element.prototype.hashCode; 2354 Element.prototype.hashCode$0 = Element.prototype.hashCode;
2342 Element.prototype.resolve$0 = Element.prototype.resolve; 2355 Element.prototype.resolve$0 = Element.prototype.resolve;
2343 // ********** Code for WorldGenerator ************** 2356 // ********** Code for WorldGenerator **************
2344 function WorldGenerator(main, writer) { 2357 function WorldGenerator(main, writer) {
2345 this.hasStatics = false 2358 this.hasStatics = false
2346 this.main = main; 2359 this.main = main;
2347 this.writer = writer; 2360 this.writer = writer;
2348 this.globals = new HashMapImplementation(); 2361 this.globals = new HashMapImplementation();
2349 this.corejs = new CoreJs(); 2362 this.corejs = new CoreJs();
2350 // Initializers done 2363 // Initializers done
2351 } 2364 }
2352 WorldGenerator.prototype.run = function() { 2365 WorldGenerator.prototype.run = function() {
2353 var metaGen = new MethodGenerator(this.main, null); 2366 var metaGen = new MethodGenerator(this.main, null);
2354 var mainTarget = new Value.type$ctor(this.main.declaringType, this.main.get$sp an()); 2367 var mainTarget = new Value.type$ctor(this.main.declaringType, this.main.get$sp an());
2355 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY (), false); 2368 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY (), false);
2356 this.main.declaringType.markUsed(); 2369 this.main.declaringType.markUsed();
2357 if ($globals.options.compileAll) { 2370 if ($globals.options.compileAll) {
2358 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]); 2371 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]);
2359 } 2372 }
2360 if ($globals.world.corelib.types.$index('Isolate').get$isUsed() || $globals.wo rld.coreimpl.types.$index('ReceivePortImpl').get$isUsed()) { 2373 $globals.world.numImplType.markUsed();
2374 $globals.world.stringImplType.markUsed();
2375 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) {
2361 if (this.corejs.useWrap0 || this.corejs.useWrap1) { 2376 if (this.corejs.useWrap0 || this.corejs.useWrap1) {
2362 this.genMethod($globals.world.coreimpl.types.$index('IsolateContext').getM ember$1('eval')); 2377 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM ember$1("eval"));
2363 this.genMethod($globals.world.coreimpl.types.$index('EventLoop').getMember $1('run')); 2378 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember $1("run"));
2364 } 2379 }
2365 this.corejs.useIsolates = true; 2380 this.corejs.useIsolates = true;
2366 var isolateMain = $globals.world.coreimpl.topType.resolveMember('startRootIs olate').members.$index(0); 2381 var isolateMain = $globals.world.coreimpl.topType.resolveMember("startRootIs olate").members.$index(0);
2367 var isolateMainTarget = new Value.type$ctor($globals.world.coreimpl.topType, this.main.get$span()); 2382 var isolateMainTarget = new Value.type$ctor($globals.world.coreimpl.topType, this.main.get$span());
2368 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); 2383 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false);
2369 } 2384 }
2370 this.writeTypes($globals.world.coreimpl); 2385 this.writeTypes($globals.world.coreimpl);
2371 this.writeTypes($globals.world.corelib); 2386 this.writeTypes($globals.world.corelib);
2372 this.writeTypes(this.main.declaringType.get$library()); 2387 this.writeTypes(this.main.declaringType.get$library());
2373 if (this._mixins != null) this.writer.write(this._mixins.get$text()); 2388 if (this._mixins != null) this.writer.write(this._mixins.get$text());
2374 this.writeDynamicDispatchMetadata(); 2389 this.writeDynamicDispatchMetadata();
2375 this.writeGlobals(); 2390 this.writeGlobals();
2376 this.writer.writeln(('' + mainCall.get$code() + ';')); 2391 this.writer.writeln(("" + mainCall.get$code() + ";"));
2377 } 2392 }
2378 WorldGenerator.prototype.markLibrariesUsed = function(libs) { 2393 WorldGenerator.prototype.markLibrariesUsed = function(libs) {
2379 return this.getAllTypes(libs).forEach(this.get$markTypeUsed()); 2394 return this.getAllTypes(libs).forEach(this.get$markTypeUsed());
2380 } 2395 }
2381 WorldGenerator.prototype.markTypeUsed = function(type) { 2396 WorldGenerator.prototype.markTypeUsed = function(type) {
2382 if (!type.get$isClass()) return; 2397 if (!type.get$isClass()) return;
2383 type.markUsed(); 2398 type.markUsed();
2384 type.isTested = true; 2399 type.isTested = true;
2385 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members ().getValues().every$1((function (m) { 2400 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members ().getValues().every$1((function (m) {
2386 return m.get$isStatic() && !m.get$isFactory(); 2401 return m.get$isStatic() && !m.get$isFactory();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 } 2443 }
2429 WorldGenerator.prototype.globalForStaticField = function(field, fieldValue, depe ndencies) { 2444 WorldGenerator.prototype.globalForStaticField = function(field, fieldValue, depe ndencies) {
2430 this.hasStatics = true; 2445 this.hasStatics = true;
2431 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ()); 2446 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ());
2432 if (!this.globals.containsKey(fullname)) { 2447 if (!this.globals.containsKey(fullname)) {
2433 this.globals.$setindex(fullname, GlobalValue.GlobalValue$fromStatic$factory( field, fieldValue, dependencies)); 2448 this.globals.$setindex(fullname, GlobalValue.GlobalValue$fromStatic$factory( field, fieldValue, dependencies));
2434 } 2449 }
2435 return this.globals.$index(fullname); 2450 return this.globals.$index(fullname);
2436 } 2451 }
2437 WorldGenerator.prototype.globalForConst = function(exp, dependencies) { 2452 WorldGenerator.prototype.globalForConst = function(exp, dependencies) {
2438 var key = exp.get$type().get$jsname() + ':' + exp.canonicalCode; 2453 var key = exp.get$type().get$jsname() + ":" + exp.canonicalCode;
2439 if (!this.globals.containsKey(key)) { 2454 if (!this.globals.containsKey(key)) {
2440 this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.g lobals.get$length(), exp, dependencies)); 2455 this.globals.$setindex(key, GlobalValue.GlobalValue$fromConst$factory(this.g lobals.get$length(), exp, dependencies));
2441 } 2456 }
2442 return this.globals.$index(key); 2457 return this.globals.$index(key);
2443 } 2458 }
2444 WorldGenerator.prototype.writeTypes = function(lib) { 2459 WorldGenerator.prototype.writeTypes = function(lib) {
2445 if (lib.isWritten) return; 2460 if (lib.isWritten) return;
2446 lib.isWritten = true; 2461 lib.isWritten = true;
2447 var $$list = lib.imports; 2462 var $$list = lib.imports;
2448 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2463 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2449 var import_ = $$list.$index($$i); 2464 var import_ = $$list.$index($$i);
2450 this.writeTypes(import_.get$library()); 2465 this.writeTypes(import_.get$library());
2451 } 2466 }
2452 for (var i = 0; 2467 for (var i = 0;
2453 i < lib.sources.get$length(); i++) { 2468 i < lib.sources.get$length(); i++) {
2454 lib.sources.$index(i).set$orderInLibrary(i); 2469 lib.sources.$index(i).set$orderInLibrary(i);
2455 } 2470 }
2456 this.writer.comment(('// ********** Library ' + lib.name + ' **************') ); 2471 this.writer.comment(("// ********** Library " + lib.name + " **************") );
2457 if (lib.get$isCore()) { 2472 if (lib.get$isCore()) {
2458 this.writer.comment('// ********** Natives dart:core **************'); 2473 this.writer.comment("// ********** Natives dart:core **************");
2459 this.corejs.generate(this.writer); 2474 this.corejs.generate(this.writer);
2460 } 2475 }
2461 var $$list = lib.natives; 2476 var $$list = lib.natives;
2462 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2477 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2463 var file = $$list.$index($$i); 2478 var file = $$list.$index($$i);
2464 var filename = basename(file.get$filename()); 2479 var filename = basename(file.get$filename());
2465 this.writer.comment(('// ********** Natives ' + filename + ' ************** ')); 2480 this.writer.comment(("// ********** Natives " + filename + " ************** "));
2466 this.writer.writeln(file.get$text()); 2481 this.writer.writeln(file.get$text());
2467 } 2482 }
2468 lib.topType.markUsed(); 2483 lib.topType.markUsed();
2469 var $$list = this._orderValues(lib.types); 2484 var $$list = this._orderValues(lib.types);
2470 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2485 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2471 var type = $$list.$index($$i); 2486 var type = $$list.$index($$i);
2472 if ((type.get$isUsed() || type.get$library().get$isDom() || type.get$isHidde nNativeType()) && type.get$isClass()) { 2487 if ((type.get$isUsed() || type.get$library().get$isDom() || type.get$isHidde nNativeType()) && type.get$isClass()) {
2473 this.writeType(type); 2488 this.writeType(type);
2474 if (type.get$isGeneric()) { 2489 if (type.get$isGeneric()) {
2475 var $list0 = this._orderValues(type.get$_concreteTypes()); 2490 var $list0 = this._orderValues(type.get$_concreteTypes());
2476 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) { 2491 for (var $i0 = 0;$i0 < $list0.get$length(); $i0++) {
2477 var ct = $list0.$index($i0); 2492 var ct = $list0.$index($i0);
2478 this.writeType(ct); 2493 this.writeType(ct);
2479 } 2494 }
2480 } 2495 }
2481 } 2496 }
2482 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) { 2497 else if (type.get$isFunction() && type.get$varStubs().get$length() > 0) {
2483 this.writer.comment(('// ********** Code for ' + type.get$jsname() + ' *** ***********')); 2498 this.writer.comment(("// ********** Code for " + type.get$jsname() + " *** ***********"));
2484 this._writeDynamicStubs(type); 2499 this._writeDynamicStubs(type);
2485 } 2500 }
2486 if (type.get$typeCheckCode() != null) { 2501 if (type.get$typeCheckCode() != null) {
2487 this.writer.writeln(type.get$typeCheckCode()); 2502 this.writer.writeln(type.get$typeCheckCode());
2488 } 2503 }
2489 } 2504 }
2490 } 2505 }
2491 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) { 2506 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) {
2492 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) { 2507 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu ll) {
2493 new MethodGenerator(meth, enclosingMethod).run(); 2508 new MethodGenerator(meth, enclosingMethod).run();
2494 } 2509 }
2495 } 2510 }
2496 WorldGenerator.prototype._prototypeOf = function(type, name) { 2511 WorldGenerator.prototype._prototypeOf = function(type, name) {
2497 if (type.get$isSingletonNative()) { 2512 if (type.get$isSingletonNative()) {
2498 return ('' + type.get$jsname() + '.' + name); 2513 return ("" + type.get$jsname() + "." + name);
2499 } 2514 }
2500 else if (type.get$isHiddenNativeType()) { 2515 else if (type.get$isHiddenNativeType()) {
2501 this.corejs.ensureDynamicProto(); 2516 this.corejs.ensureDynamicProto();
2502 this._usedDynamicDispatchOnType(type); 2517 this._usedDynamicDispatchOnType(type);
2503 return ('\$dynamic("' + name + '").' + type.get$definition().get$nativeType( ).get$name()); 2518 return ("$dynamic(\"" + name + "\")." + type.get$definition().get$nativeType ().get$name());
2504 } 2519 }
2505 else { 2520 else {
2506 return ('' + type.get$jsname() + '.prototype.' + name); 2521 return ("" + type.get$jsname() + ".prototype." + name);
2507 } 2522 }
2508 } 2523 }
2509 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) { 2524 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) {
2510 var isSubtype = onType.isSubtypeOf(checkType); 2525 var isSubtype = onType.isSubtypeOf(checkType);
2511 if (checkType.isTested) { 2526 if (checkType.isTested) {
2512 this.writer.writeln(this._prototypeOf(onType, ('is\$' + checkType.get$jsname ())) + (' = function(){return ' + isSubtype + '};')); 2527 this.writer.writeln(this._prototypeOf(onType, ("is$" + checkType.get$jsname( ))) + (" = function(){return " + isSubtype + "};"));
2513 } 2528 }
2514 if (checkType.isChecked) { 2529 if (checkType.isChecked) {
2515 var body = 'return this'; 2530 var body = "return this";
2516 var checkName = ('assert\$' + checkType.get$jsname()); 2531 var checkName = ("assert$" + checkType.get$jsname());
2517 if (!isSubtype) { 2532 if (!isSubtype) {
2518 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); 2533 body = $globals.world.objectType.varStubs.$index(checkName).get$body();
2519 } 2534 }
2520 else if ($eq(onType, $globals.world.stringImplType) || $eq(onType, $globals. world.numImplType)) { 2535 else if ($eq(onType, $globals.world.stringImplType) || $eq(onType, $globals. world.numImplType)) {
2521 body = ('return ' + onType.get$nativeType().name + '(this)'); 2536 body = ("return " + onType.get$nativeType().name + "(this)");
2522 } 2537 }
2523 this.writer.writeln(this._prototypeOf(onType, checkName) + (' = function(){' + body + '};')); 2538 this.writer.writeln(this._prototypeOf(onType, checkName) + (" = function(){" + body + "};"));
2524 } 2539 }
2525 } 2540 }
2526 WorldGenerator.prototype.writeType = function(type) { 2541 WorldGenerator.prototype.writeType = function(type) {
2527 if (type.isWritten) return; 2542 if (type.isWritten) return;
2528 type.isWritten = true; 2543 type.isWritten = true;
2529 if (type.get$parent() != null && !type.get$isNative()) { 2544 if (type.get$parent() != null && !type.get$isNative()) {
2530 this.writeType(type.get$parent()); 2545 this.writeType(type.get$parent());
2531 } 2546 }
2532 if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$librar y(), $globals.world.coreimpl) && type.name.startsWith('ListFactory')) { 2547 if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$librar y(), $globals.world.coreimpl) && type.name.startsWith("ListFactory")) {
2533 this.writer.writeln(('' + type.get$jsname() + ' = ' + type.get$genericType() .get$jsname() + ';')); 2548 this.writer.writeln(("" + type.get$jsname() + " = " + type.get$genericType() .get$jsname() + ";"));
2534 return; 2549 return;
2535 } 2550 }
2536 var typeName = type.get$jsname() != null ? type.get$jsname() : 'top level'; 2551 var typeName = type.get$jsname() != null ? type.get$jsname() : "top level";
2537 this.writer.comment(('// ********** Code for ' + typeName + ' **************') ); 2552 this.writer.comment(("// ********** Code for " + typeName + " **************") );
2538 if (type.get$isNative() && !type.get$isTop()) { 2553 if (type.get$isNative() && !type.get$isTop()) {
2539 var nativeName = type.get$definition().get$nativeType().get$name(); 2554 var nativeName = type.get$definition().get$nativeType().get$name();
2540 if ($eq(nativeName, '')) { 2555 if ($eq(nativeName, "")) {
2541 this.writer.writeln(('function ' + type.get$jsname() + '() {}')); 2556 this.writer.writeln(("function " + type.get$jsname() + "() {}"));
2542 } 2557 }
2543 else if (type.get$jsname() != nativeName) { 2558 else if (type.get$jsname() != nativeName) {
2544 if (type.get$isHiddenNativeType()) { 2559 if (type.get$isHiddenNativeType()) {
2545 if (this._typeNeedsHolderForStaticMethods(type)) { 2560 if (this._typeNeedsHolderForStaticMethods(type)) {
2546 this.writer.writeln(('var ' + type.get$jsname() + ' = {};')); 2561 this.writer.writeln(("var " + type.get$jsname() + " = {};"));
2547 } 2562 }
2548 } 2563 }
2549 else { 2564 else {
2550 this.writer.writeln(('' + type.get$jsname() + ' = ' + nativeName + ';')) ; 2565 this.writer.writeln(("" + type.get$jsname() + " = " + nativeName + ";")) ;
2551 } 2566 }
2552 } 2567 }
2553 } 2568 }
2554 if (!type.get$isTop()) { 2569 if (!type.get$isTop()) {
2555 if ((type instanceof ConcreteType)) { 2570 if ((type instanceof ConcreteType)) {
2556 var c = type; 2571 var c = type;
2557 this.corejs.ensureInheritsHelper(); 2572 this.corejs.ensureInheritsHelper();
2558 this.writer.writeln(('\$inherits(' + c.get$jsname() + ', ' + c.genericType .get$jsname() + ');')); 2573 this.writer.writeln(("$inherits(" + c.get$jsname() + ", " + c.genericType. get$jsname() + ");"));
2559 for (var p = c._parent; 2574 for (var p = c._parent;
2560 (p instanceof ConcreteType); p = p.get$_parent()) { 2575 (p instanceof ConcreteType); p = p.get$_parent()) {
2561 this._ensureInheritMembersHelper(); 2576 this._ensureInheritMembersHelper();
2562 this._mixins.writeln(('\$inheritsMembers(' + c.get$jsname() + ', ' + p.g et$jsname() + ');')); 2577 this._mixins.writeln(("$inheritsMembers(" + c.get$jsname() + ", " + p.ge t$jsname() + ");"));
2563 } 2578 }
2564 } 2579 }
2565 else if (!type.get$isNative()) { 2580 else if (!type.get$isNative()) {
2566 if (type.get$parent() != null && !type.get$parent().get$isObject()) { 2581 if (type.get$parent() != null && !type.get$parent().get$isObject()) {
2567 this.corejs.ensureInheritsHelper(); 2582 this.corejs.ensureInheritsHelper();
2568 this.writer.writeln(('\$inherits(' + type.get$jsname() + ', ' + type.get $parent().get$jsname() + ');')); 2583 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$ parent().get$jsname() + ");"));
2569 } 2584 }
2570 } 2585 }
2571 } 2586 }
2572 if (type.get$isTop()) { 2587 if (type.get$isTop()) {
2573 } 2588 }
2574 else if (type.get$constructors().get$length() == 0) { 2589 else if (type.get$constructors().get$length() == 0) {
2575 if (!type.get$isNative()) { 2590 if (!type.get$isNative()) {
2576 this.writer.writeln(('function ' + type.get$jsname() + '() {}')); 2591 this.writer.writeln(("function " + type.get$jsname() + "() {}"));
2577 } 2592 }
2578 } 2593 }
2579 else { 2594 else {
2580 var standardConstructor = type.get$constructors().$index(''); 2595 var standardConstructor = type.get$constructors().$index("");
2581 if (standardConstructor == null || standardConstructor.generator == null) { 2596 if (standardConstructor == null || standardConstructor.generator == null) {
2582 if (!type.get$isNative()) { 2597 if (!type.get$isNative()) {
2583 this.writer.writeln(('function ' + type.get$jsname() + '() {}')); 2598 this.writer.writeln(("function " + type.get$jsname() + "() {}"));
2584 } 2599 }
2585 } 2600 }
2586 else { 2601 else {
2587 standardConstructor.generator.writeDefinition(this.writer, null); 2602 standardConstructor.generator.writeDefinition(this.writer, null);
2588 } 2603 }
2589 var $$list = type.get$constructors().getValues(); 2604 var $$list = type.get$constructors().getValues();
2590 for (var $$i = type.get$constructors().getValues().iterator$0(); $$i.hasNext $0(); ) { 2605 for (var $$i = type.get$constructors().getValues().iterator$0(); $$i.hasNext $0(); ) {
2591 var c = $$i.next$0(); 2606 var c = $$i.next$0();
2592 if (c.get$generator() != null && $ne(c, standardConstructor)) { 2607 if (c.get$generator() != null && $ne(c, standardConstructor)) {
2593 c.get$generator().writeDefinition$2(this.writer); 2608 c.get$generator().writeDefinition$2(this.writer);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 return true; 2670 return true;
2656 } 2671 }
2657 } 2672 }
2658 } 2673 }
2659 } 2674 }
2660 return false; 2675 return false;
2661 } 2676 }
2662 WorldGenerator.prototype._ensureInheritMembersHelper = function() { 2677 WorldGenerator.prototype._ensureInheritMembersHelper = function() {
2663 if (this._mixins != null) return; 2678 if (this._mixins != null) return;
2664 this._mixins = new CodeWriter(); 2679 this._mixins = new CodeWriter();
2665 this._mixins.comment('// ********** Generic Type Inheritance **************'); 2680 this._mixins.comment("// ********** Generic Type Inheritance **************");
2666 this._mixins.writeln("/** Implements extends for generic types. */\nfunction $ inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent. prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n i f (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}"); 2681 this._mixins.writeln("/** Implements extends for generic types. */\nfunction $ inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent. prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n i f (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}");
2667 } 2682 }
2668 WorldGenerator.prototype._writeDynamicStubs = function(type) { 2683 WorldGenerator.prototype._writeDynamicStubs = function(type) {
2669 var $$list = orderValuesByKeys(type.varStubs); 2684 var $$list = orderValuesByKeys(type.varStubs);
2670 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2685 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2671 var stub = $$list.$index($$i); 2686 var stub = $$list.$index($$i);
2672 if (!stub.get$isGenerated()) stub.generate$1(this.writer); 2687 if (!stub.get$isGenerated()) stub.generate$1(this.writer);
2673 } 2688 }
2674 } 2689 }
2675 WorldGenerator.prototype._writeStaticField = function(field) { 2690 WorldGenerator.prototype._writeStaticField = function(field) {
2676 if (field.isFinal) return; 2691 if (field.isFinal) return;
2677 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ()); 2692 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname ());
2678 if (this.globals.containsKey(fullname)) { 2693 if (this.globals.containsKey(fullname)) {
2679 var value = this.globals.$index(fullname); 2694 var value = this.globals.$index(fullname);
2680 if (field.declaringType.get$isTop() && !field.isNative) { 2695 if (field.declaringType.get$isTop() && !field.isNative) {
2681 this.writer.writeln(('\$globals.' + field.get$jsname() + ' = ' + value.get $exp().get$code() + ';')); 2696 this.writer.writeln(("$globals." + field.get$jsname() + " = " + value.get$ exp().get$code() + ";"));
2682 } 2697 }
2683 else { 2698 else {
2684 this.writer.writeln(('\$globals.' + field.declaringType.get$jsname() + '_' + field.get$jsname()) + (' = ' + value.get$exp().get$code() + ';')); 2699 this.writer.writeln(("$globals." + field.declaringType.get$jsname() + "_" + field.get$jsname()) + (" = " + value.get$exp().get$code() + ";"));
2685 } 2700 }
2686 } 2701 }
2687 } 2702 }
2688 WorldGenerator.prototype._writeField = function(field) { 2703 WorldGenerator.prototype._writeField = function(field) {
2689 if (field.declaringType.get$isTop() && !field.isNative && field.value == null) { 2704 if (field.declaringType.get$isTop() && !field.isNative && field.value == null) {
2690 this.writer.writeln(('var ' + field.get$jsname() + ';')); 2705 this.writer.writeln(("var " + field.get$jsname() + ";"));
2691 } 2706 }
2692 if (field._providePropertySyntax) { 2707 if (field._providePropertySyntax) {
2693 this.writer.writeln(this._prototypeOf(field.declaringType, ('get\$' + field. get$jsname())) + (' = function() { return this.' + field.get$jsname() + '; };')) ; 2708 this.writer.writeln(this._prototypeOf(field.declaringType, ("get$" + field.g et$jsname())) + (" = function() { return this." + field.get$jsname() + "; };"));
2694 if (!field.isFinal) { 2709 if (!field.isFinal) {
2695 this.writer.writeln(this._prototypeOf(field.declaringType, ('set\$' + fiel d.get$jsname())) + (' = function(value) { return this.' + field.get$jsname() + ' = value; };')); 2710 this.writer.writeln(this._prototypeOf(field.declaringType, ("set$" + field .get$jsname())) + (" = function(value) { return this." + field.get$jsname() + " = value; };"));
2696 } 2711 }
2697 } 2712 }
2698 } 2713 }
2699 WorldGenerator.prototype._writeProperty = function(property) { 2714 WorldGenerator.prototype._writeProperty = function(property) {
2700 if (property.getter != null) this._writeMethod(property.getter); 2715 if (property.getter != null) this._writeMethod(property.getter);
2701 if (property.setter != null) this._writeMethod(property.setter); 2716 if (property.setter != null) this._writeMethod(property.setter);
2702 if (property._provideFieldSyntax) { 2717 if (property._provideFieldSyntax) {
2703 this.writer.enterBlock('Object.defineProperty(' + ('' + property.declaringTy pe.get$jsname() + '.prototype, "' + property.get$jsname() + '", {')); 2718 this.writer.enterBlock("Object.defineProperty(" + ("" + property.declaringTy pe.get$jsname() + ".prototype, \"" + property.get$jsname() + "\", {"));
2704 if (property.getter != null) { 2719 if (property.getter != null) {
2705 this.writer.write(('get: ' + property.declaringType.get$jsname() + '.proto type.' + property.getter.get$jsname())); 2720 this.writer.write(("get: " + property.declaringType.get$jsname() + ".proto type." + property.getter.get$jsname()));
2706 this.writer.writeln(property.setter == null ? '' : ','); 2721 this.writer.writeln(property.setter == null ? "" : ",");
2707 } 2722 }
2708 if (property.setter != null) { 2723 if (property.setter != null) {
2709 this.writer.writeln(('set: ' + property.declaringType.get$jsname() + '.pro totype.' + property.setter.get$jsname())); 2724 this.writer.writeln(("set: " + property.declaringType.get$jsname() + ".pro totype." + property.setter.get$jsname()));
2710 } 2725 }
2711 this.writer.exitBlock('});'); 2726 this.writer.exitBlock("});");
2712 } 2727 }
2713 } 2728 }
2714 WorldGenerator.prototype._writeMethod = function(m) { 2729 WorldGenerator.prototype._writeMethod = function(m) {
2715 if (m.generator != null) { 2730 if (m.generator != null) {
2716 m.generator.writeDefinition(this.writer, null); 2731 m.generator.writeDefinition(this.writer, null);
2717 } 2732 }
2718 else if ((m instanceof MethodMember) && m.get$isNative() && m._provideProperty Syntax && !m._provideFieldSyntax) { 2733 else if ((m instanceof MethodMember) && m.get$isNative() && m._provideProperty Syntax && !m._provideFieldSyntax) {
2719 MethodGenerator._maybeGenerateBoundGetter(m, this.writer); 2734 MethodGenerator._maybeGenerateBoundGetter(m, this.writer);
2720 } 2735 }
2721 } 2736 }
2722 WorldGenerator.prototype.get$_writeMethod = function() { 2737 WorldGenerator.prototype.get$_writeMethod = function() {
2723 return this._writeMethod.bind(this); 2738 return this._writeMethod.bind(this);
2724 } 2739 }
2725 WorldGenerator.prototype.writeGlobals = function() { 2740 WorldGenerator.prototype.writeGlobals = function() {
2726 if (this.globals.get$length() > 0) { 2741 if (this.globals.get$length() > 0) {
2727 this.writer.comment('// ********** Globals **************'); 2742 this.writer.comment("// ********** Globals **************");
2728 var list = this.globals.getValues(); 2743 var list = this.globals.getValues();
2729 list.sort$1((function (a, b) { 2744 list.sort$1((function (a, b) {
2730 return a.compareTo$1(b); 2745 return a.compareTo$1(b);
2731 }) 2746 })
2732 ); 2747 );
2733 this.writer.enterBlock('function \$static_init(){'); 2748 this.writer.enterBlock("function $static_init(){");
2734 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { 2749 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
2735 var global = $$i.next$0(); 2750 var global = $$i.next$0();
2736 if (global.get$field() != null) { 2751 if (global.get$field() != null) {
2737 this._writeStaticField(global.get$field()); 2752 this._writeStaticField(global.get$field());
2738 } 2753 }
2739 } 2754 }
2740 this.writer.exitBlock('}'); 2755 this.writer.exitBlock("}");
2741 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { 2756 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) {
2742 var global = $$i.next$0(); 2757 var global = $$i.next$0();
2743 if (global.get$field() == null) { 2758 if (global.get$field() == null) {
2744 this.writer.writeln(('var ' + global.get$name() + ' = ' + global.get$exp ().get$code() + ';')); 2759 this.writer.writeln(("var " + global.get$name() + " = " + global.get$exp ().get$code() + ";"));
2745 } 2760 }
2746 } 2761 }
2747 } 2762 }
2748 if (!this.corejs.useIsolates) { 2763 if (!this.corejs.useIsolates) {
2749 if (this.hasStatics) { 2764 if (this.hasStatics) {
2750 this.writer.writeln('var \$globals = {};'); 2765 this.writer.writeln("var $globals = {};");
2751 } 2766 }
2752 if (this.globals.get$length() > 0) { 2767 if (this.globals.get$length() > 0) {
2753 this.writer.writeln('\$static_init();'); 2768 this.writer.writeln("$static_init();");
2754 } 2769 }
2755 } 2770 }
2756 } 2771 }
2757 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { 2772 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) {
2758 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new HashSetImplementation(); 2773 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new HashSetImplementation();
2759 this.typesWithDynamicDispatch.add(type); 2774 this.typesWithDynamicDispatch.add(type);
2760 } 2775 }
2761 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { 2776 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() {
2762 var $this = this; // closure support 2777 var $this = this; // closure support
2763 if (this.typesWithDynamicDispatch == null) return; 2778 if (this.typesWithDynamicDispatch == null) return;
2764 this.writer.comment(('// ' + this.typesWithDynamicDispatch.get$length() + ' dy namic types.')); 2779 this.writer.comment(("// " + this.typesWithDynamicDispatch.get$length() + " dy namic types."));
2765 var seen = new HashSetImplementation(); 2780 var seen = new HashSetImplementation();
2766 var types = []; 2781 var types = [];
2767 function visit(type) { 2782 function visit(type) {
2768 if (seen.contains$1(type)) return; 2783 if (seen.contains$1(type)) return;
2769 seen.add$1(type); 2784 seen.add$1(type);
2770 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); 2785 var $$list = $this._orderCollectionValues(type.get$directSubtypes());
2771 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2786 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2772 var subtype = $$list.$index($$i); 2787 var subtype = $$list.$index($$i);
2773 visit(subtype); 2788 visit(subtype);
2774 } 2789 }
2775 types.add$1(type); 2790 types.add$1(type);
2776 } 2791 }
2777 var $$list = this._orderCollectionValues(this.typesWithDynamicDispatch); 2792 var $$list = this._orderCollectionValues(this.typesWithDynamicDispatch);
2778 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2793 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2779 var type = $$list.$index($$i); 2794 var type = $$list.$index($$i);
2780 visit(type); 2795 visit(type);
2781 } 2796 }
2782 var dispatchTypes = types.filter$1((function (type) { 2797 var dispatchTypes = types.filter$1((function (type) {
2783 return !type.get$directSubtypes().isEmpty$0() && $this.typesWithDynamicDispa tch.contains(type); 2798 return !type.get$directSubtypes().isEmpty$0() && $this.typesWithDynamicDispa tch.contains(type);
2784 }) 2799 })
2785 ); 2800 );
2786 this.writer.comment(('// ' + types.get$length() + ' types')); 2801 this.writer.comment(("// " + types.get$length() + " types"));
2787 this.writer.comment(('// ' + types.filter$1((function (t) { 2802 this.writer.comment(("// " + types.filter$1((function (t) {
2788 return !t.get$directSubtypes().isEmpty$0(); 2803 return !t.get$directSubtypes().isEmpty$0();
2789 }) 2804 })
2790 ).get$length() + ' !leaf')); 2805 ).get$length() + " !leaf"));
2791 var varNames = []; 2806 var varNames = [];
2792 var varDefns = new HashMapImplementation(); 2807 var varDefns = new HashMapImplementation();
2793 var tagDefns = new HashMapImplementation(); 2808 var tagDefns = new HashMapImplementation();
2794 function makeExpression(type) { 2809 function makeExpression(type) {
2795 var expressions = []; 2810 var expressions = [];
2796 var subtags = [type.get$nativeName()]; 2811 var subtags = [type.get$nativeName()];
2797 function walk(type) { 2812 function walk(type) {
2798 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); 2813 var $$list = $this._orderCollectionValues(type.get$directSubtypes());
2799 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 2814 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
2800 var subtype = $$list.$index($$i); 2815 var subtype = $$list.$index($$i);
2801 var tag = subtype.get$nativeName(); 2816 var tag = subtype.get$nativeName();
2802 var existing = tagDefns.$index(tag); 2817 var existing = tagDefns.$index(tag);
2803 if (existing == null) { 2818 if (existing == null) {
2804 subtags.add$1(tag); 2819 subtags.add$1(tag);
2805 walk(subtype); 2820 walk(subtype);
2806 } 2821 }
2807 else { 2822 else {
2808 if (varDefns.containsKey$1(existing)) { 2823 if (varDefns.containsKey$1(existing)) {
2809 expressions.add$1(existing); 2824 expressions.add$1(existing);
2810 } 2825 }
2811 else { 2826 else {
2812 var varName = ('v' + varNames.get$length() + '/*' + tag + '*/'); 2827 var varName = ("v" + varNames.get$length() + "/*" + tag + "*/");
2813 varNames.add$1(varName); 2828 varNames.add$1(varName);
2814 varDefns.$setindex(varName, existing); 2829 varDefns.$setindex(varName, existing);
2815 tagDefns.$setindex(tag, varName); 2830 tagDefns.$setindex(tag, varName);
2816 expressions.add$1(varName); 2831 expressions.add$1(varName);
2817 } 2832 }
2818 } 2833 }
2819 } 2834 }
2820 } 2835 }
2821 walk(type); 2836 walk(type);
2822 var constantPart = ("'" + Strings.join(subtags, '|') + "'"); 2837 var constantPart = ("'" + Strings.join(subtags, "|") + "'");
2823 if ($ne(constantPart, "''")) expressions.add$1(constantPart); 2838 if ($ne(constantPart, "''")) expressions.add$1(constantPart);
2824 var expression; 2839 var expression;
2825 if ($eq(expressions.get$length(), 1)) { 2840 if ($eq(expressions.get$length(), 1)) {
2826 expression = expressions.$index(0); 2841 expression = expressions.$index(0);
2827 } 2842 }
2828 else { 2843 else {
2829 expression = ("[" + Strings.join(expressions, ',') + "].join('|')"); 2844 expression = ("[" + Strings.join(expressions, ",") + "].join('|')");
2830 } 2845 }
2831 return expression; 2846 return expression;
2832 } 2847 }
2833 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { 2848 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) {
2834 var type = $$i.next$0(); 2849 var type = $$i.next$0();
2835 tagDefns.$setindex(type.get$nativeName(), makeExpression(type)); 2850 tagDefns.$setindex(type.get$nativeName(), makeExpression(type));
2836 } 2851 }
2837 if (!tagDefns.isEmpty$0()) { 2852 if (!tagDefns.isEmpty$0()) {
2838 this.writer.enterBlock('(function(){'); 2853 this.writer.enterBlock("(function(){");
2839 for (var $$i = varNames.iterator$0(); $$i.hasNext$0(); ) { 2854 for (var $$i = varNames.iterator$0(); $$i.hasNext$0(); ) {
2840 var varName = $$i.next$0(); 2855 var varName = $$i.next$0();
2841 this.writer.writeln(('var ' + varName + ' = ' + varDefns.$index(varName) + ';')); 2856 this.writer.writeln(("var " + varName + " = " + varDefns.$index(varName) + ";"));
2842 } 2857 }
2843 this.writer.enterBlock('var table = ['); 2858 this.writer.enterBlock("var table = [");
2844 this.writer.comment('// [dynamic-dispatch-tag, tags of classes implementing dynamic-dispatch-tag]'/*'// [dynamic-dispatch-tag, ' 2859 this.writer.comment("// [dynamic-dispatch-tag, tags of classes implementing dynamic-dispatch-tag]");
2845 + 'tags of classes implementing dynamic-dispatch-tag]'*/);
2846 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { 2860 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) {
2847 var type = $$i.next$0(); 2861 var type = $$i.next$0();
2848 this.writer.writeln(("['" + type.get$nativeName() + "', " + tagDefns.$inde x(type.get$nativeName()) + "],")); 2862 this.writer.writeln(("['" + type.get$nativeName() + "', " + tagDefns.$inde x(type.get$nativeName()) + "],"));
2849 } 2863 }
2850 this.writer.exitBlock('];'); 2864 this.writer.exitBlock("];");
2851 this.writer.writeln('\$dynamicSetMetadata(table);'); 2865 this.writer.writeln("$dynamicSetMetadata(table);");
2852 this.writer.exitBlock('})();'); 2866 this.writer.exitBlock("})();");
2853 } 2867 }
2854 } 2868 }
2855 WorldGenerator.prototype._orderValues = function(map) { 2869 WorldGenerator.prototype._orderValues = function(map) {
2856 var values = map.getValues(); 2870 var values = map.getValues();
2857 values.sort(this.get$_compareMembers()); 2871 values.sort(this.get$_compareMembers());
2858 return values; 2872 return values;
2859 } 2873 }
2860 WorldGenerator.prototype._orderCollectionValues = function(collection) { 2874 WorldGenerator.prototype._orderCollectionValues = function(collection) {
2861 var values = ListFactory.ListFactory$from$factory(collection); 2875 var values = ListFactory.ListFactory$from$factory(collection);
2862 values.sort(this.get$_compareMembers()); 2876 values.sort(this.get$_compareMembers());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 if (s.get$_jsNames().contains$1(name)) return true; 2950 if (s.get$_jsNames().contains$1(name)) return true;
2937 if (s.get$isMethodScope() && s.get$_closedOver().contains$1(name)) return tr ue; 2951 if (s.get$isMethodScope() && s.get$_closedOver().contains$1(name)) return tr ue;
2938 } 2952 }
2939 var type = this.enclosingMethod.method.declaringType; 2953 var type = this.enclosingMethod.method.declaringType;
2940 if (type.get$library().lookup(name, null) != null) return true; 2954 if (type.get$library().lookup(name, null) != null) return true;
2941 return false; 2955 return false;
2942 } 2956 }
2943 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) { 2957 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) {
2944 var jsName = $globals.world.toJsIdentifier(name); 2958 var jsName = $globals.world.toJsIdentifier(name);
2945 if (this._vars.containsKey(name)) { 2959 if (this._vars.containsKey(name)) {
2946 $globals.world.error(('duplicate name "' + name + '"'), span); 2960 $globals.world.error(("duplicate name \"" + name + "\""), span);
2947 } 2961 }
2948 if (!isParameter) { 2962 if (!isParameter) {
2949 var index = 0; 2963 var index = 0;
2950 while (this._isDefinedInParent(jsName)) { 2964 while (this._isDefinedInParent(jsName)) {
2951 jsName = ('' + name + (index++)); 2965 jsName = ("" + name + (index++));
2952 } 2966 }
2953 } 2967 }
2954 var ret = new Value(type, jsName, span, false); 2968 var ret = new Value(type, jsName, span, false);
2955 ret.set$isFinal(isFinal); 2969 ret.set$isFinal(isFinal);
2956 this._vars.$setindex(name, ret); 2970 this._vars.$setindex(name, ret);
2957 if (name != jsName) this._jsNames.add(jsName); 2971 if (name != jsName) this._jsNames.add(jsName);
2958 return ret; 2972 return ret;
2959 } 2973 }
2960 BlockScope.prototype.declareParameter = function(p) { 2974 BlockScope.prototype.declareParameter = function(p) {
2961 return this.create(p.name, p.type, p.definition.span, false, true); 2975 return this.create(p.name, p.type, p.definition.span, false, true);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 } 3022 }
3009 MethodGenerator.prototype.getTemp = function(value) { 3023 MethodGenerator.prototype.getTemp = function(value) {
3010 return value.needsTemp ? this.forceTemp(value) : value; 3024 return value.needsTemp ? this.forceTemp(value) : value;
3011 } 3025 }
3012 MethodGenerator.prototype.forceTemp = function(value) { 3026 MethodGenerator.prototype.forceTemp = function(value) {
3013 var name; 3027 var name;
3014 if (this._freeTemps.get$length() > 0) { 3028 if (this._freeTemps.get$length() > 0) {
3015 name = this._freeTemps.removeLast(); 3029 name = this._freeTemps.removeLast();
3016 } 3030 }
3017 else { 3031 else {
3018 name = '\$' + this._usedTemps.get$length(); 3032 name = "$" + this._usedTemps.get$length();
3019 } 3033 }
3020 this._usedTemps.add(name); 3034 this._usedTemps.add(name);
3021 return new Value(value.get$type(), name, value.span, false); 3035 return new Value(value.get$type(), name, value.span, false);
3022 } 3036 }
3023 MethodGenerator.prototype.assignTemp = function(tmp, v) { 3037 MethodGenerator.prototype.assignTemp = function(tmp, v) {
3024 if ($eq(tmp, v)) { 3038 if ($eq(tmp, v)) {
3025 return v; 3039 return v;
3026 } 3040 }
3027 else { 3041 else {
3028 return new Value(v.get$type(), ('(' + tmp.code + ' = ' + v.code + ')'), v.sp an, true); 3042 return new Value(v.get$type(), ("(" + tmp.code + " = " + v.code + ")"), v.sp an, true);
3029 } 3043 }
3030 } 3044 }
3031 MethodGenerator.prototype.freeTemp = function(value) { 3045 MethodGenerator.prototype.freeTemp = function(value) {
3032 if (this._usedTemps.remove(value.code)) { 3046 if (this._usedTemps.remove(value.code)) {
3033 this._freeTemps.add(value.code); 3047 this._freeTemps.add(value.code);
3034 } 3048 }
3035 else { 3049 else {
3036 $globals.world.internalError(('tried to free unused value or non-temp "' + v alue.code + '"')); 3050 $globals.world.internalError(("tried to free unused value or non-temp \"" + value.code + "\""));
3037 } 3051 }
3038 } 3052 }
3039 MethodGenerator.prototype.run = function() { 3053 MethodGenerator.prototype.run = function() {
3040 if (this.method.isGenerated) return; 3054 if (this.method.isGenerated) return;
3041 this.method.isGenerated = true; 3055 this.method.isGenerated = true;
3042 this.method.generator = this; 3056 this.method.generator = this;
3043 this.writeBody(); 3057 this.writeBody();
3044 if (this.method.get$definition().get$nativeBody() != null) { 3058 if (this.method.get$definition().get$nativeBody() != null) {
3045 this.writer = new CodeWriter(); 3059 this.writer = new CodeWriter();
3046 if ($eq(this.method.get$definition().get$nativeBody(), '')) { 3060 if ($eq(this.method.get$definition().get$nativeBody(), "")) {
3047 this.method.generator = null; 3061 this.method.generator = null;
3048 } 3062 }
3049 else { 3063 else {
3050 this._paramCode = map(this.method.get$parameters(), (function (p) { 3064 this._paramCode = map(this.method.get$parameters(), (function (p) {
3051 return p.get$name(); 3065 return p.get$name();
3052 }) 3066 })
3053 ); 3067 );
3054 this.writer.write(this.method.get$definition().get$nativeBody()); 3068 this.writer.write(this.method.get$definition().get$nativeBody());
3055 } 3069 }
3056 } 3070 }
3057 } 3071 }
3058 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) { 3072 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) {
3059 var paramCode = this._paramCode; 3073 var paramCode = this._paramCode;
3060 var names = null; 3074 var names = null;
3061 if (this.captures != null && this.captures.get$length() > 0) { 3075 if (this.captures != null && this.captures.get$length() > 0) {
3062 names = ListFactory.ListFactory$from$factory(this.captures); 3076 names = ListFactory.ListFactory$from$factory(this.captures);
3063 names.sort$1((function (x, y) { 3077 names.sort$1((function (x, y) {
3064 return x.compareTo$1(y); 3078 return x.compareTo$1(y);
3065 }) 3079 })
3066 ); 3080 );
3067 paramCode = ListFactory.ListFactory$from$factory(names); 3081 paramCode = ListFactory.ListFactory$from$factory(names);
3068 paramCode.addAll$1(this._paramCode); 3082 paramCode.addAll$1(this._paramCode);
3069 } 3083 }
3070 var _params = ('(' + Strings.join(this._paramCode, ", ") + ')'); 3084 var _params = ("(" + Strings.join(this._paramCode, ", ") + ")");
3071 var params = ('(' + Strings.join(paramCode, ", ") + ')'); 3085 var params = ("(" + Strings.join(paramCode, ", ") + ")");
3072 if (this.method.declaringType.get$isTop() && !this.get$isClosure()) { 3086 if (this.method.declaringType.get$isTop() && !this.get$isClosure()) {
3073 defWriter.enterBlock(('function ' + this.method.get$jsname() + params + ' {' )); 3087 defWriter.enterBlock(("function " + this.method.get$jsname() + params + " {" ));
3074 } 3088 }
3075 else if (this.get$isClosure()) { 3089 else if (this.get$isClosure()) {
3076 if (this.method.name == '') { 3090 if (this.method.name == "") {
3077 defWriter.enterBlock(('(function ' + params + ' {')); 3091 defWriter.enterBlock(("(function " + params + " {"));
3078 } 3092 }
3079 else if (names != null) { 3093 else if (names != null) {
3080 if (lambda == null) { 3094 if (lambda == null) {
3081 defWriter.enterBlock(('var ' + this.method.get$jsname() + ' = (function' + params + ' {')); 3095 defWriter.enterBlock(("var " + this.method.get$jsname() + " = (function" + params + " {"));
3082 } 3096 }
3083 else { 3097 else {
3084 defWriter.enterBlock(('(function ' + this.method.get$jsname() + params + ' {')); 3098 defWriter.enterBlock(("(function " + this.method.get$jsname() + params + " {"));
3085 } 3099 }
3086 } 3100 }
3087 else { 3101 else {
3088 defWriter.enterBlock(('function ' + this.method.get$jsname() + params + ' {')); 3102 defWriter.enterBlock(("function " + this.method.get$jsname() + params + " {"));
3089 } 3103 }
3090 } 3104 }
3091 else if (this.method.get$isConstructor()) { 3105 else if (this.method.get$isConstructor()) {
3092 if (this.method.get$constructorName() == '') { 3106 if (this.method.get$constructorName() == "") {
3093 defWriter.enterBlock(('function ' + this.method.declaringType.get$jsname() + params + ' {')); 3107 defWriter.enterBlock(("function " + this.method.declaringType.get$jsname() + params + " {"));
3094 } 3108 }
3095 else { 3109 else {
3096 defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + this.method.get$constructorName() + '\$ctor = function' + params + ' {')); 3110 defWriter.enterBlock(("" + this.method.declaringType.get$jsname() + "." + this.method.get$constructorName() + "$ctor = function" + params + " {"));
3097 } 3111 }
3098 } 3112 }
3099 else if (this.method.get$isFactory()) { 3113 else if (this.method.get$isFactory()) {
3100 defWriter.enterBlock(('' + this.method.get$generatedFactoryName() + ' = func tion' + _params + ' {')); 3114 defWriter.enterBlock(("" + this.method.get$generatedFactoryName() + " = func tion" + _params + " {"));
3101 } 3115 }
3102 else if (this.method.get$isStatic()) { 3116 else if (this.method.get$isStatic()) {
3103 defWriter.enterBlock(('' + this.method.declaringType.get$jsname() + '.' + th is.method.get$jsname() + ' = function' + _params + ' {')); 3117 defWriter.enterBlock(("" + this.method.declaringType.get$jsname() + "." + th is.method.get$jsname() + " = function" + _params + " {"));
3104 } 3118 }
3105 else { 3119 else {
3106 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (' = function' + _params + ' {')); 3120 defWriter.enterBlock($globals.world.gen._prototypeOf(this.method.declaringTy pe, this.method.get$jsname()) + (" = function" + _params + " {"));
3107 } 3121 }
3108 if (this.needsThis) { 3122 if (this.needsThis) {
3109 defWriter.writeln('var \$this = this; // closure support'); 3123 defWriter.writeln("var $this = this; // closure support");
3110 } 3124 }
3111 if (this._usedTemps.get$length() > 0 || this._freeTemps.get$length() > 0) { 3125 if (this._usedTemps.get$length() > 0 || this._freeTemps.get$length() > 0) {
3112 this._freeTemps.addAll(this._usedTemps); 3126 this._freeTemps.addAll(this._usedTemps);
3113 this._freeTemps.sort((function (x, y) { 3127 this._freeTemps.sort((function (x, y) {
3114 return x.compareTo$1(y); 3128 return x.compareTo$1(y);
3115 }) 3129 })
3116 ); 3130 );
3117 defWriter.writeln(('var ' + Strings.join(this._freeTemps, ", ") + ';')); 3131 defWriter.writeln(("var " + Strings.join(this._freeTemps, ", ") + ";"));
3118 } 3132 }
3119 defWriter.writeln(this.writer.get$text()); 3133 defWriter.writeln(this.writer.get$text());
3120 if (names != null) { 3134 if (names != null) {
3121 defWriter.exitBlock(('}).bind(null, ' + Strings.join(names, ", ") + ')')); 3135 defWriter.exitBlock(("}).bind(null, " + Strings.join(names, ", ") + ")"));
3122 } 3136 }
3123 else if (this.get$isClosure() && this.method.name == '') { 3137 else if (this.get$isClosure() && this.method.name == "") {
3124 defWriter.exitBlock('})'); 3138 defWriter.exitBlock("})");
3125 } 3139 }
3126 else { 3140 else {
3127 defWriter.exitBlock('}'); 3141 defWriter.exitBlock("}");
3128 } 3142 }
3129 if (this.method.get$isConstructor() && this.method.get$constructorName() != '' ) { 3143 if (this.method.get$isConstructor() && this.method.get$constructorName() != "" ) {
3130 defWriter.writeln(('' + this.method.declaringType.get$jsname() + '.' + this. method.get$constructorName() + '\$ctor.prototype = ') + ('' + this.method.declar ingType.get$jsname() + '.prototype;')); 3144 defWriter.writeln(("" + this.method.declaringType.get$jsname() + "." + this. method.get$constructorName() + "$ctor.prototype = ") + ("" + this.method.declari ngType.get$jsname() + ".prototype;"));
3131 } 3145 }
3132 this._provideOptionalParamInfo(defWriter); 3146 this._provideOptionalParamInfo(defWriter);
3133 if ((this.method instanceof MethodMember)) { 3147 if ((this.method instanceof MethodMember)) {
3134 MethodGenerator._maybeGenerateBoundGetter(this.method, defWriter); 3148 MethodGenerator._maybeGenerateBoundGetter(this.method, defWriter);
3135 } 3149 }
3136 } 3150 }
3137 MethodGenerator._maybeGenerateBoundGetter = function(m, defWriter) { 3151 MethodGenerator._maybeGenerateBoundGetter = function(m, defWriter) {
3138 if (m._providePropertySyntax) { 3152 if (m._providePropertySyntax) {
3139 defWriter.enterBlock($globals.world.gen._prototypeOf(m.declaringType, "get\$ " + m.get$jsname()) + ' = function() {'); 3153 defWriter.enterBlock($globals.world.gen._prototypeOf(m.declaringType, "get$" + m.get$jsname()) + " = function() {");
3140 defWriter.writeln(('return this.' + m.get$jsname() + '.bind(this);')); 3154 defWriter.writeln(("return this." + m.get$jsname() + ".bind(this);"));
3141 defWriter.exitBlock('}'); 3155 defWriter.exitBlock("}");
3142 if (m._provideFieldSyntax) { 3156 if (m._provideFieldSyntax) {
3143 $globals.world.internalError(('bound "' + m.name + '" accessed with field syntax'), m.definition.span); 3157 $globals.world.internalError(("bound \"" + m.name + "\" accessed with fiel d syntax"), m.definition.span);
3144 } 3158 }
3145 } 3159 }
3146 } 3160 }
3147 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) { 3161 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) {
3148 if ((this.method instanceof MethodMember)) { 3162 if ((this.method instanceof MethodMember)) {
3149 var meth = this.method; 3163 var meth = this.method;
3150 if (meth._provideOptionalParamInfo) { 3164 if (meth._provideOptionalParamInfo) {
3151 var optNames = []; 3165 var optNames = [];
3152 var optValues = []; 3166 var optValues = [];
3153 meth.genParameterValues(); 3167 meth.genParameterValues();
3154 var $$list = meth.parameters; 3168 var $$list = meth.parameters;
3155 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3169 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3156 var param = $$list.$index($$i); 3170 var param = $$list.$index($$i);
3157 if (param.get$isOptional()) { 3171 if (param.get$isOptional()) {
3158 optNames.add$1(param.get$name()); 3172 optNames.add$1(param.get$name());
3159 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de())); 3173 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co de()));
3160 } 3174 }
3161 } 3175 }
3162 if (optNames.get$length() > 0) { 3176 if (optNames.get$length() > 0) {
3163 var start = ''; 3177 var start = "";
3164 if (meth.isStatic) { 3178 if (meth.isStatic) {
3165 if (!meth.declaringType.get$isTop()) { 3179 if (!meth.declaringType.get$isTop()) {
3166 start = meth.declaringType.get$jsname() + '.'; 3180 start = meth.declaringType.get$jsname() + ".";
3167 } 3181 }
3168 } 3182 }
3169 else { 3183 else {
3170 start = meth.declaringType.get$jsname() + '.prototype.'; 3184 start = meth.declaringType.get$jsname() + ".prototype.";
3171 } 3185 }
3172 optNames.addAll$1(optValues); 3186 optNames.addAll$1(optValues);
3173 var optional = "['" + Strings.join(optNames, "', '") + "']"; 3187 var optional = "['" + Strings.join(optNames, "', '") + "']";
3174 defWriter.writeln(('' + start + meth.get$jsname() + '.\$optional = ' + o ptional)); 3188 defWriter.writeln(("" + start + meth.get$jsname() + ".$optional = " + op tional));
3175 } 3189 }
3176 } 3190 }
3177 } 3191 }
3178 } 3192 }
3179 MethodGenerator.prototype.writeBody = function() { 3193 MethodGenerator.prototype.writeBody = function() {
3180 var initializers = null; 3194 var initializers = null;
3181 var initializedFields = null; 3195 var initializedFields = null;
3182 var allMembers = null; 3196 var allMembers = null;
3183 if (this.method.get$isConstructor()) { 3197 if (this.method.get$isConstructor()) {
3184 initializers = []; 3198 initializers = [];
3185 initializedFields = new HashSetImplementation(); 3199 initializedFields = new HashSetImplementation();
3186 allMembers = $globals.world.gen._orderValues(this.method.declaringType.getAl lMembers()); 3200 allMembers = $globals.world.gen._orderValues(this.method.declaringType.getAl lMembers());
3187 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) { 3201 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
3188 var f = $$i.next$0(); 3202 var f = $$i.next$0();
3189 if (f.get$isField() && !f.get$isStatic()) { 3203 if (f.get$isField() && !f.get$isStatic()) {
3190 var cv = f.computeValue$0(); 3204 var cv = f.computeValue$0();
3191 if (cv != null) { 3205 if (cv != null) {
3192 initializers.add$1(('this.' + f.get$jsname() + ' = ' + cv.get$code())) ; 3206 initializers.add$1(("this." + f.get$jsname() + " = " + cv.get$code())) ;
3193 initializedFields.add$1(f.get$name()); 3207 initializedFields.add$1(f.get$name());
3194 } 3208 }
3195 } 3209 }
3196 } 3210 }
3197 } 3211 }
3198 this._paramCode = []; 3212 this._paramCode = [];
3199 var $$list = this.method.get$parameters(); 3213 var $$list = this.method.get$parameters();
3200 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3214 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3201 var p = $$list.$index($$i); 3215 var p = $$list.$index($$i);
3202 if (initializers != null && p.get$isInitializer()) { 3216 if (initializers != null && p.get$isInitializer()) {
3203 var field = this.method.declaringType.getMember(p.get$name()); 3217 var field = this.method.declaringType.getMember(p.get$name());
3204 if (field == null) { 3218 if (field == null) {
3205 $globals.world.error('bad this parameter - no matching field', p.get$def inition().get$span()); 3219 $globals.world.error("bad this parameter - no matching field", p.get$def inition().get$span());
3206 } 3220 }
3207 if (!field.get$isField()) { 3221 if (!field.get$isField()) {
3208 $globals.world.error(('"this.' + p.get$name() + '" does not refer to a f ield'), p.get$definition().get$span()); 3222 $globals.world.error(("\"this." + p.get$name() + "\" does not refer to a field"), p.get$definition().get$span());
3209 } 3223 }
3210 var paramValue = new Value(field.get$returnType(), p.get$name(), p.get$def inition().get$span(), false); 3224 var paramValue = new Value(field.get$returnType(), p.get$name(), p.get$def inition().get$span(), false);
3211 this._paramCode.add(paramValue.get$code()); 3225 this._paramCode.add(paramValue.get$code());
3212 initializers.add$1(('this.' + field.get$jsname() + ' = ' + paramValue.get$ code() + ';')); 3226 initializers.add$1(("this." + field.get$jsname() + " = " + paramValue.get$ code() + ";"));
3213 initializedFields.add$1(p.get$name()); 3227 initializedFields.add$1(p.get$name());
3214 } 3228 }
3215 else { 3229 else {
3216 var paramValue = this._scope.declareParameter(p); 3230 var paramValue = this._scope.declareParameter(p);
3217 this._paramCode.add(paramValue.get$code()); 3231 this._paramCode.add(paramValue.get$code());
3218 } 3232 }
3219 } 3233 }
3220 var body = this.method.get$definition().get$body(); 3234 var body = this.method.get$definition().get$body();
3221 if (body == null && !this.method.get$isConstructor() && !this.method.get$isNat ive()) { 3235 if (body == null && !this.method.get$isConstructor() && !this.method.get$isNat ive()) {
3222 $globals.world.error(('unexpected empty body for ' + this.method.name), this .method.get$definition().get$span()); 3236 $globals.world.error(("unexpected empty body for " + this.method.name), this .method.get$definition().get$span());
3223 } 3237 }
3224 var initializerCall = null; 3238 var initializerCall = null;
3225 var declaredInitializers = this.method.get$definition().get$initializers(); 3239 var declaredInitializers = this.method.get$definition().get$initializers();
3226 if (initializers != null) { 3240 if (initializers != null) {
3227 for (var $$i = initializers.iterator$0(); $$i.hasNext$0(); ) { 3241 for (var $$i = initializers.iterator$0(); $$i.hasNext$0(); ) {
3228 var i = $$i.next$0(); 3242 var i = $$i.next$0();
3229 this.writer.writeln(i); 3243 this.writer.writeln(i);
3230 } 3244 }
3231 if (declaredInitializers != null) { 3245 if (declaredInitializers != null) {
3232 for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) { 3246 for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) {
3233 var init = $$i.next$0(); 3247 var init = $$i.next$0();
3234 if ((init instanceof CallExpression)) { 3248 if ((init instanceof CallExpression)) {
3235 if (initializerCall != null) { 3249 if (initializerCall != null) {
3236 $globals.world.error('only one initializer redirecting call is allow ed', init.get$span()); 3250 $globals.world.error("only one initializer redirecting call is allow ed", init.get$span());
3237 } 3251 }
3238 initializerCall = init; 3252 initializerCall = init;
3239 } 3253 }
3240 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign( init.get$op().get$kind()) == 0) { 3254 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign( init.get$op().get$kind()) == 0) {
3241 var left = init.get$x(); 3255 var left = init.get$x();
3242 if (!((left instanceof DotExpression) && (left.get$self() instanceof T hisExpression) || (left instanceof VarExpression))) { 3256 if (!((left instanceof DotExpression) && (left.get$self() instanceof T hisExpression) || (left instanceof VarExpression))) {
3243 $globals.world.error('invalid left side of initializer', left.get$sp an()); 3257 $globals.world.error("invalid left side of initializer", left.get$sp an());
3244 continue; 3258 continue;
3245 } 3259 }
3246 var f = this.method.declaringType.getMember(left.get$name().get$name() ); 3260 var f = this.method.declaringType.getMember(left.get$name().get$name() );
3247 if (f == null) { 3261 if (f == null) {
3248 $globals.world.error('bad initializer - no matching field', left.get $span()); 3262 $globals.world.error("bad initializer - no matching field", left.get $span());
3249 continue; 3263 continue;
3250 } 3264 }
3251 else if (!f.get$isField()) { 3265 else if (!f.get$isField()) {
3252 $globals.world.error(('"' + left.get$name().get$name() + '" does not refer to a field'), left.get$span()); 3266 $globals.world.error(("\"" + left.get$name().get$name() + "\" does n ot refer to a field"), left.get$span());
3253 continue; 3267 continue;
3254 } 3268 }
3255 initializedFields.add$1(f.get$name()); 3269 initializedFields.add$1(f.get$name());
3256 this.writer.writeln(('this.' + f.get$jsname() + ' = ' + this.visitValu e(init.get$y()).get$code() + ';')); 3270 this.writer.writeln(("this." + f.get$jsname() + " = " + this.visitValu e(init.get$y()).get$code() + ";"));
3257 } 3271 }
3258 else { 3272 else {
3259 $globals.world.error('invalid initializer', init.get$span()); 3273 $globals.world.error("invalid initializer", init.get$span());
3260 } 3274 }
3261 } 3275 }
3262 } 3276 }
3263 this.writer.comment('// Initializers done'); 3277 this.writer.comment("// Initializers done");
3264 } 3278 }
3265 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) { 3279 if (this.method.get$isConstructor() && initializerCall == null && !this.method .get$isNative()) {
3266 var parentType = this.method.declaringType.get$parent(); 3280 var parentType = this.method.declaringType.get$parent();
3267 if (parentType != null && !parentType.get$isObject()) { 3281 if (parentType != null && !parentType.get$isObject()) {
3268 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span()); 3282 initializerCall = new CallExpression(new SuperExpression(this.method.get$s pan()), [], this.method.get$span());
3269 } 3283 }
3270 } 3284 }
3271 if (initializerCall != null) { 3285 if (initializerCall != null) {
3272 var target = this._writeInitializerCall(initializerCall); 3286 var target = this._writeInitializerCall(initializerCall);
3273 if (!target.get$isSuper()) { 3287 if (!target.get$isSuper()) {
3274 if (initializers.get$length() > 0) { 3288 if (initializers.get$length() > 0) {
3275 var $$list = this.method.get$parameters(); 3289 var $$list = this.method.get$parameters();
3276 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3290 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3277 var p = $$list.$index($$i); 3291 var p = $$list.$index($$i);
3278 if (p.get$isInitializer()) { 3292 if (p.get$isInitializer()) {
3279 $globals.world.error('no initialization allowed on redirecting const ructors', p.get$definition().get$span()); 3293 $globals.world.error("no initialization allowed on redirecting const ructors", p.get$definition().get$span());
3280 break; 3294 break;
3281 } 3295 }
3282 } 3296 }
3283 } 3297 }
3284 if (declaredInitializers != null && declaredInitializers.get$length() > 1) { 3298 if (declaredInitializers != null && declaredInitializers.get$length() > 1) {
3285 var init = $eq(declaredInitializers.$index(0), initializerCall) ? declar edInitializers.$index(1) : declaredInitializers.$index(0); 3299 var init = $eq(declaredInitializers.$index(0), initializerCall) ? declar edInitializers.$index(1) : declaredInitializers.$index(0);
3286 $globals.world.error('no initialization allowed on redirecting construct ors', init.get$span()); 3300 $globals.world.error("no initialization allowed on redirecting construct ors", init.get$span());
3287 } 3301 }
3288 initializedFields = null; 3302 initializedFields = null;
3289 } 3303 }
3290 } 3304 }
3291 if (initializedFields != null) { 3305 if (initializedFields != null) {
3292 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) { 3306 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) {
3293 var member = $$i.next$0(); 3307 var member = $$i.next$0();
3294 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) { 3308 if (member.get$isField() && member.get$isFinal() && !member.get$isStatic() && !this.method.get$isNative() && !initializedFields.contains$1(member.get$name ())) {
3295 $globals.world.error(('Field "' + member.get$name() + '" is final and wa s not initialized'), this.method.get$definition().get$span()); 3309 $globals.world.error(("Field \"" + member.get$name() + "\" is final and was not initialized"), this.method.get$definition().get$span());
3296 } 3310 }
3297 } 3311 }
3298 } 3312 }
3299 this.visitStatementsInBlock(body); 3313 this.visitStatementsInBlock(body);
3300 } 3314 }
3301 MethodGenerator.prototype._writeInitializerCall = function(node) { 3315 MethodGenerator.prototype._writeInitializerCall = function(node) {
3302 var contructorName = ''; 3316 var contructorName = "";
3303 var targetExp = node.target; 3317 var targetExp = node.target;
3304 if ((targetExp instanceof DotExpression)) { 3318 if ((targetExp instanceof DotExpression)) {
3305 var dot = targetExp; 3319 var dot = targetExp;
3306 targetExp = dot.self; 3320 targetExp = dot.self;
3307 contructorName = dot.name.name; 3321 contructorName = dot.name.name;
3308 } 3322 }
3309 var target = null; 3323 var target = null;
3310 if ((targetExp instanceof SuperExpression)) { 3324 if ((targetExp instanceof SuperExpression)) {
3311 target = this._makeSuperValue(targetExp); 3325 target = this._makeSuperValue(targetExp);
3312 } 3326 }
3313 else if ((targetExp instanceof ThisExpression)) { 3327 else if ((targetExp instanceof ThisExpression)) {
3314 target = this._makeThisValue(targetExp); 3328 target = this._makeThisValue(targetExp);
3315 } 3329 }
3316 else { 3330 else {
3317 $globals.world.error('bad call in initializers', node.span); 3331 $globals.world.error("bad call in initializers", node.span);
3318 } 3332 }
3319 target.set$allowDynamic(false); 3333 target.set$allowDynamic(false);
3320 var m = target.get$type().getConstructor$1(contructorName); 3334 var m = target.get$type().getConstructor$1(contructorName);
3321 if (m == null) { 3335 if (m == null) {
3322 $globals.world.error(('no matching constructor for ' + target.get$type().get $name()), node.span); 3336 $globals.world.error(("no matching constructor for " + target.get$type().get $name()), node.span);
3323 } 3337 }
3324 this.method.set$initDelegate(m); 3338 this.method.set$initDelegate(m);
3325 var other = m; 3339 var other = m;
3326 while (other != null) { 3340 while (other != null) {
3327 if ($eq(other, this.method)) { 3341 if ($eq(other, this.method)) {
3328 $globals.world.error('initialization cycle', node.span); 3342 $globals.world.error("initialization cycle", node.span);
3329 break; 3343 break;
3330 } 3344 }
3331 other = other.get$initDelegate(); 3345 other = other.get$initDelegate();
3332 } 3346 }
3333 $globals.world.gen.genMethod(m); 3347 $globals.world.gen.genMethod(m);
3334 var value = m.invoke$4(this, node, target, this._makeArgs(node.arguments)); 3348 var value = m.invoke$4(this, node, target, this._makeArgs(node.arguments));
3335 if ($ne(target.get$type(), $globals.world.objectType)) { 3349 if ($ne(target.get$type(), $globals.world.objectType)) {
3336 this.writer.writeln(('' + value.get$code() + ';')); 3350 this.writer.writeln(("" + value.get$code() + ";"));
3337 } 3351 }
3338 return target; 3352 return target;
3339 } 3353 }
3340 MethodGenerator.prototype._makeArgs = function(arguments) { 3354 MethodGenerator.prototype._makeArgs = function(arguments) {
3341 var args = []; 3355 var args = [];
3342 var seenLabel = false; 3356 var seenLabel = false;
3343 for (var $$i = 0;$$i < arguments.get$length(); $$i++) { 3357 for (var $$i = 0;$$i < arguments.get$length(); $$i++) {
3344 var arg = arguments.$index($$i); 3358 var arg = arguments.$index($$i);
3345 if (arg.get$label() != null) { 3359 if (arg.get$label() != null) {
3346 seenLabel = true; 3360 seenLabel = true;
3347 } 3361 }
3348 else if (seenLabel) { 3362 else if (seenLabel) {
3349 $globals.world.error('bare argument can not follow named arguments', arg.g et$span()); 3363 $globals.world.error("bare argument can not follow named arguments", arg.g et$span());
3350 } 3364 }
3351 args.add$1(this.visitValue(arg.get$value())); 3365 args.add$1(this.visitValue(arg.get$value()));
3352 } 3366 }
3353 return new Arguments(arguments, args); 3367 return new Arguments(arguments, args);
3354 } 3368 }
3355 MethodGenerator.prototype._invokeNative = function(name, arguments) { 3369 MethodGenerator.prototype._invokeNative = function(name, arguments) {
3356 var args = Arguments.get$EMPTY(); 3370 var args = Arguments.get$EMPTY();
3357 if (arguments.get$length() > 0) { 3371 if (arguments.get$length() > 0) {
3358 args = new Arguments(null, arguments); 3372 args = new Arguments(null, arguments);
3359 } 3373 }
3360 var method = $globals.world.corelib.topType.members.$index(name); 3374 var method = $globals.world.corelib.topType.members.$index(name);
3361 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args); 3375 return method.invoke$4(this, method.get$definition(), new Value($globals.world .corelib.topType, null, null, true), args);
3362 } 3376 }
3363 MethodGenerator._escapeString = function(text) { 3377 MethodGenerator._escapeString = function(text) {
3364 return text.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', ' \\n').replaceAll('\r', '\\r'); 3378 return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n").replaceAll("\r", "\\r");
3365 } 3379 }
3366 MethodGenerator.prototype.visitStatementsInBlock = function(body) { 3380 MethodGenerator.prototype.visitStatementsInBlock = function(body) {
3367 if ((body instanceof BlockStatement)) { 3381 if ((body instanceof BlockStatement)) {
3368 var block = body; 3382 var block = body;
3369 var $$list = block.body; 3383 var $$list = block.body;
3370 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3384 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3371 var stmt = $$list.$index($$i); 3385 var stmt = $$list.$index($$i);
3372 stmt.visit$1(this); 3386 stmt.visit$1(this);
3373 } 3387 }
3374 } 3388 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 MethodGenerator.prototype.visitDietStatement = function(node) { 3433 MethodGenerator.prototype.visitDietStatement = function(node) {
3420 var parser = new Parser(node.span.file, false, false, false, node.span.start); 3434 var parser = new Parser(node.span.file, false, false, false, node.span.start);
3421 this.visitStatementsInBlock(parser.block$0()); 3435 this.visitStatementsInBlock(parser.block$0());
3422 return false; 3436 return false;
3423 } 3437 }
3424 MethodGenerator.prototype.visitVariableDefinition = function(node) { 3438 MethodGenerator.prototype.visitVariableDefinition = function(node) {
3425 var isFinal = false; 3439 var isFinal = false;
3426 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) { 3440 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) {
3427 isFinal = true; 3441 isFinal = true;
3428 } 3442 }
3429 this.writer.write('var '); 3443 this.writer.write("var ");
3430 var type = this.method.resolveType(node.type, false); 3444 var type = this.method.resolveType(node.type, false);
3431 for (var i = 0; 3445 for (var i = 0;
3432 i < node.names.get$length(); i++) { 3446 i < node.names.get$length(); i++) {
3433 var thisType = type; 3447 var thisType = type;
3434 if (i > 0) { 3448 if (i > 0) {
3435 this.writer.write(', '); 3449 this.writer.write(", ");
3436 } 3450 }
3437 var name = node.names.$index(i).get$name(); 3451 var name = node.names.$index(i).get$name();
3438 var value = this.visitValue(node.values.$index(i)); 3452 var value = this.visitValue(node.values.$index(i));
3439 if (isFinal) { 3453 if (isFinal) {
3440 if (value == null) { 3454 if (value == null) {
3441 $globals.world.error('no value specified for final variable', node.span) ; 3455 $globals.world.error("no value specified for final variable", node.span) ;
3442 } 3456 }
3443 else { 3457 else {
3444 if (thisType.get$isVar()) thisType = value.get$type(); 3458 if (thisType.get$isVar()) thisType = value.get$type();
3445 } 3459 }
3446 } 3460 }
3447 var val = this._scope.create(name, thisType, node.names.$index(i).get$span() , isFinal, false); 3461 var val = this._scope.create(name, thisType, node.names.$index(i).get$span() , isFinal, false);
3448 if (value == null) { 3462 if (value == null) {
3449 if (this._scope.reentrant) { 3463 if (this._scope.reentrant) {
3450 this.writer.write(('' + val.get$code() + ' = null')); 3464 this.writer.write(("" + val.get$code() + " = null"));
3451 } 3465 }
3452 else { 3466 else {
3453 this.writer.write(('' + val.get$code())); 3467 this.writer.write(("" + val.get$code()));
3454 } 3468 }
3455 } 3469 }
3456 else { 3470 else {
3457 value = value.convertTo$2(this, type); 3471 value = value.convertTo$2(this, type);
3458 this.writer.write(('' + val.get$code() + ' = ' + value.get$code())); 3472 this.writer.write(("" + val.get$code() + " = " + value.get$code()));
3459 } 3473 }
3460 } 3474 }
3461 this.writer.writeln(';'); 3475 this.writer.writeln(";");
3462 return false; 3476 return false;
3463 } 3477 }
3464 MethodGenerator.prototype.visitFunctionDefinition = function(node) { 3478 MethodGenerator.prototype.visitFunctionDefinition = function(node) {
3465 var meth = this._makeLambdaMethod(node.name.name, node); 3479 var meth = this._makeLambdaMethod(node.name.name, node);
3466 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t his.method.get$definition().get$span(), true, false); 3480 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t his.method.get$definition().get$span(), true, false);
3467 $globals.world.gen.genMethod(meth, this); 3481 $globals.world.gen.genMethod(meth, this);
3468 meth.get$generator().writeDefinition$2(this.writer); 3482 meth.get$generator().writeDefinition$2(this.writer);
3469 return false; 3483 return false;
3470 } 3484 }
3471 MethodGenerator.prototype.visitReturnStatement = function(node) { 3485 MethodGenerator.prototype.visitReturnStatement = function(node) {
3472 if (node.value == null) { 3486 if (node.value == null) {
3473 this.writer.writeln('return;'); 3487 this.writer.writeln("return;");
3474 } 3488 }
3475 else { 3489 else {
3476 if (this.method.get$isConstructor()) { 3490 if (this.method.get$isConstructor()) {
3477 $globals.world.error('return of value not allowed from constructor', node. span); 3491 $globals.world.error("return of value not allowed from constructor", node. span);
3478 } 3492 }
3479 var value = this.visitTypedValue(node.value, this.method.get$returnType()); 3493 var value = this.visitTypedValue(node.value, this.method.get$returnType());
3480 this.writer.writeln(('return ' + value.get$code() + ';')); 3494 this.writer.writeln(("return " + value.get$code() + ";"));
3481 } 3495 }
3482 return true; 3496 return true;
3483 } 3497 }
3484 MethodGenerator.prototype.visitThrowStatement = function(node) { 3498 MethodGenerator.prototype.visitThrowStatement = function(node) {
3485 if (node.value != null) { 3499 if (node.value != null) {
3486 var value = this.visitValue(node.value); 3500 var value = this.visitValue(node.value);
3487 value.invoke$4(this, 'toString', node, Arguments.get$EMPTY()); 3501 value.invoke$4(this, "toString", node, Arguments.get$EMPTY());
3488 this.writer.writeln(('\$throw(' + value.get$code() + ');')); 3502 this.writer.writeln(("$throw(" + value.get$code() + ");"));
3489 $globals.world.gen.corejs.useThrow = true; 3503 $globals.world.gen.corejs.useThrow = true;
3490 } 3504 }
3491 else { 3505 else {
3492 var rethrow = this._scope.getRethrow(); 3506 var rethrow = this._scope.getRethrow();
3493 if (rethrow == null) { 3507 if (rethrow == null) {
3494 $globals.world.error('rethrow outside of catch', node.span); 3508 $globals.world.error("rethrow outside of catch", node.span);
3495 } 3509 }
3496 else { 3510 else {
3497 this.writer.writeln(('throw ' + rethrow.get$code() + ';')); 3511 this.writer.writeln(("throw " + rethrow.get$code() + ";"));
3498 } 3512 }
3499 } 3513 }
3500 return true; 3514 return true;
3501 } 3515 }
3502 MethodGenerator.prototype.visitAssertStatement = function(node) { 3516 MethodGenerator.prototype.visitAssertStatement = function(node) {
3503 var test = this.visitValue(node.test); 3517 var test = this.visitValue(node.test);
3504 if ($globals.options.enableAsserts) { 3518 if ($globals.options.enableAsserts) {
3505 var span = node.test.span; 3519 var span = node.test.span;
3506 var line = span.get$file().getLine$1(span.get$start()) + 1; 3520 var line = span.get$file().getLine$1(span.get$start()) + 1;
3507 var column = span.get$file().getColumn$2(line - 1, span.get$start()) + 1; 3521 var column = span.get$file().getColumn$2(line - 1, span.get$start()) + 1;
3508 var args = [test, EvaluatedValue.EvaluatedValue$factory($globals.world.strin gType, MethodGenerator._escapeString(span.get$text()), ('"' + MethodGenerator._e scapeString(span.get$text()) + '"'), null), EvaluatedValue.EvaluatedValue$factor y($globals.world.stringType, MethodGenerator._escapeString(span.get$file().get$f ilename()), ('"' + MethodGenerator._escapeString(span.get$file().get$filename()) + '"'), null), EvaluatedValue.EvaluatedValue$factory($globals.world.intType, li ne, line.toString$0(), null), EvaluatedValue.EvaluatedValue$factory($globals.wor ld.intType, column, column.toString$0(), null)]; 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)];
3509 var tp = $globals.world.corelib.topType; 3523 var tp = $globals.world.corelib.topType;
3510 var f = tp.getMember$1('_assert'); 3524 var f = tp.getMember$1("_assert");
3511 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Argument s(null, args), false); 3525 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Argument s(null, args), false);
3512 this.writer.writeln(('' + value.get$code() + ';')); 3526 this.writer.writeln(("" + value.get$code() + ";"));
3513 } 3527 }
3514 return false; 3528 return false;
3515 } 3529 }
3516 MethodGenerator.prototype.visitBreakStatement = function(node) { 3530 MethodGenerator.prototype.visitBreakStatement = function(node) {
3517 if (node.label == null) { 3531 if (node.label == null) {
3518 this.writer.writeln('break;'); 3532 this.writer.writeln("break;");
3519 } 3533 }
3520 else { 3534 else {
3521 this.writer.writeln(('break ' + node.label.name + ';')); 3535 this.writer.writeln(("break " + node.label.name + ";"));
3522 } 3536 }
3523 return true; 3537 return true;
3524 } 3538 }
3525 MethodGenerator.prototype.visitContinueStatement = function(node) { 3539 MethodGenerator.prototype.visitContinueStatement = function(node) {
3526 if (node.label == null) { 3540 if (node.label == null) {
3527 this.writer.writeln('continue;'); 3541 this.writer.writeln("continue;");
3528 } 3542 }
3529 else { 3543 else {
3530 this.writer.writeln(('continue ' + node.label.name + ';')); 3544 this.writer.writeln(("continue " + node.label.name + ";"));
3531 } 3545 }
3532 return true; 3546 return true;
3533 } 3547 }
3534 MethodGenerator.prototype.visitIfStatement = function(node) { 3548 MethodGenerator.prototype.visitIfStatement = function(node) {
3535 var test = this.visitBool(node.test); 3549 var test = this.visitBool(node.test);
3536 this.writer.write(('if (' + test.get$code() + ') ')); 3550 this.writer.write(("if (" + test.get$code() + ") "));
3537 var exit1 = node.trueBranch.visit(this); 3551 var exit1 = node.trueBranch.visit(this);
3538 if (node.falseBranch != null) { 3552 if (node.falseBranch != null) {
3539 this.writer.write('else '); 3553 this.writer.write("else ");
3540 if (node.falseBranch.visit(this) && exit1) { 3554 if (node.falseBranch.visit(this) && exit1) {
3541 return true; 3555 return true;
3542 } 3556 }
3543 } 3557 }
3544 return false; 3558 return false;
3545 } 3559 }
3546 MethodGenerator.prototype.visitWhileStatement = function(node) { 3560 MethodGenerator.prototype.visitWhileStatement = function(node) {
3547 var test = this.visitBool(node.test); 3561 var test = this.visitBool(node.test);
3548 this.writer.write(('while (' + test.get$code() + ') ')); 3562 this.writer.write(("while (" + test.get$code() + ") "));
3549 this._pushBlock(true); 3563 this._pushBlock(true);
3550 node.body.visit(this); 3564 node.body.visit(this);
3551 this._popBlock(); 3565 this._popBlock();
3552 return false; 3566 return false;
3553 } 3567 }
3554 MethodGenerator.prototype.visitDoStatement = function(node) { 3568 MethodGenerator.prototype.visitDoStatement = function(node) {
3555 this.writer.write('do '); 3569 this.writer.write("do ");
3556 this._pushBlock(true); 3570 this._pushBlock(true);
3557 node.body.visit(this); 3571 node.body.visit(this);
3558 this._popBlock(); 3572 this._popBlock();
3559 var test = this.visitBool(node.test); 3573 var test = this.visitBool(node.test);
3560 this.writer.writeln(('while (' + test.get$code() + ')')); 3574 this.writer.writeln(("while (" + test.get$code() + ")"));
3561 return false; 3575 return false;
3562 } 3576 }
3563 MethodGenerator.prototype.visitForStatement = function(node) { 3577 MethodGenerator.prototype.visitForStatement = function(node) {
3564 this._pushBlock(false); 3578 this._pushBlock(false);
3565 this.writer.write('for ('); 3579 this.writer.write("for (");
3566 if (node.init != null) node.init.visit(this); 3580 if (node.init != null) node.init.visit(this);
3567 else this.writer.write(';'); 3581 else this.writer.write(";");
3568 if (node.test != null) { 3582 if (node.test != null) {
3569 var test = this.visitBool(node.test); 3583 var test = this.visitBool(node.test);
3570 this.writer.write((' ' + test.get$code() + '; ')); 3584 this.writer.write((" " + test.get$code() + "; "));
3571 } 3585 }
3572 else { 3586 else {
3573 this.writer.write('; '); 3587 this.writer.write("; ");
3574 } 3588 }
3575 var needsComma = false; 3589 var needsComma = false;
3576 var $$list = node.step; 3590 var $$list = node.step;
3577 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3591 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3578 var s = $$list.$index($$i); 3592 var s = $$list.$index($$i);
3579 if (needsComma) this.writer.write(', '); 3593 if (needsComma) this.writer.write(", ");
3580 var sv = this.visitVoid(s); 3594 var sv = this.visitVoid(s);
3581 this.writer.write(sv.get$code()); 3595 this.writer.write(sv.get$code());
3582 needsComma = true; 3596 needsComma = true;
3583 } 3597 }
3584 this.writer.write(') '); 3598 this.writer.write(") ");
3585 this._pushBlock(true); 3599 this._pushBlock(true);
3586 node.body.visit(this); 3600 node.body.visit(this);
3587 this._popBlock(); 3601 this._popBlock();
3588 this._popBlock(); 3602 this._popBlock();
3589 return false; 3603 return false;
3590 } 3604 }
3591 MethodGenerator.prototype._isFinal = function(typeRef) { 3605 MethodGenerator.prototype._isFinal = function(typeRef) {
3592 if ((typeRef instanceof GenericTypeReference)) { 3606 if ((typeRef instanceof GenericTypeReference)) {
3593 typeRef = typeRef.get$baseType(); 3607 typeRef = typeRef.get$baseType();
3594 } 3608 }
3595 return typeRef != null && typeRef.get$isFinal(); 3609 return typeRef != null && typeRef.get$isFinal();
3596 } 3610 }
3597 MethodGenerator.prototype.visitForInStatement = function(node) { 3611 MethodGenerator.prototype.visitForInStatement = function(node) {
3598 var itemType = this.method.resolveType(node.item.type, false); 3612 var itemType = this.method.resolveType(node.item.type, false);
3599 var itemName = node.item.name.name; 3613 var itemName = node.item.name.name;
3600 var list = node.list.visit(this); 3614 var list = node.list.visit(this);
3601 this._pushBlock(true); 3615 this._pushBlock(true);
3602 var isFinal = this._isFinal(node.item.type); 3616 var isFinal = this._isFinal(node.item.type);
3603 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false); 3617 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal , false);
3604 var listVar = list; 3618 var listVar = list;
3605 if (list.get$needsTemp()) { 3619 if (list.get$needsTemp()) {
3606 listVar = this._scope.create('\$list', list.get$type(), null, false, false); 3620 listVar = this._scope.create("$list", list.get$type(), null, false, false);
3607 this.writer.writeln(('var ' + listVar.code + ' = ' + list.get$code() + ';')) ; 3621 this.writer.writeln(("var " + listVar.code + " = " + list.get$code() + ";")) ;
3608 } 3622 }
3609 if (list.get$type().get$isList()) { 3623 if (list.get$type().get$isList()) {
3610 var tmpi = this._scope.create('\$i', $globals.world.numType, null, false, fa lse); 3624 var tmpi = this._scope.create("$i", $globals.world.numType, null, false, fal se);
3611 var listLength = listVar.get_(this, 'length', node.list); 3625 var listLength = listVar.get_(this, "length", node.list);
3612 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = 0;') + ('' + tmp i.get$code() + ' < ' + listLength.get$code() + '; ' + tmpi.get$code() + '++) {') ); 3626 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = 0;") + ("" + tmp i.get$code() + " < " + listLength.get$code() + "; " + tmpi.get$code() + "++) {") );
3613 var value = listVar.invoke(this, ':index', node.list, new Arguments(null, [t mpi]), false); 3627 var value = listVar.invoke(this, ":index", node.list, new Arguments(null, [t mpi]), false);
3614 this.writer.writeln(('var ' + item.get$code() + ' = ' + value.get$code() + ' ;')); 3628 this.writer.writeln(("var " + item.get$code() + " = " + value.get$code() + " ;"));
3615 } 3629 }
3616 else { 3630 else {
3617 var iterator = list.invoke$4(this, 'iterator', node.list, Arguments.get$EMPT Y()); 3631 var iterator = list.invoke$4(this, "iterator", node.list, Arguments.get$EMPT Y());
3618 var tmpi = this._scope.create('\$i', iterator.get$type(), null, false, false ); 3632 var tmpi = this._scope.create("$i", iterator.get$type(), null, false, false) ;
3619 var hasNext = tmpi.invoke$4(this, 'hasNext', node.list, Arguments.get$EMPTY( )); 3633 var hasNext = tmpi.invoke$4(this, "hasNext", node.list, Arguments.get$EMPTY( ));
3620 var next = tmpi.invoke$4(this, 'next', node.list, Arguments.get$EMPTY()); 3634 var next = tmpi.invoke$4(this, "next", node.list, Arguments.get$EMPTY());
3621 this.writer.enterBlock(('for (var ' + tmpi.get$code() + ' = ' + iterator.get $code() + '; ' + hasNext.get$code() + '; ) {')); 3635 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = " + iterator.get $code() + "; " + hasNext.get$code() + "; ) {"));
3622 this.writer.writeln(('var ' + item.get$code() + ' = ' + next.get$code() + '; ')); 3636 this.writer.writeln(("var " + item.get$code() + " = " + next.get$code() + "; "));
3623 } 3637 }
3624 this.visitStatementsInBlock(node.body); 3638 this.visitStatementsInBlock(node.body);
3625 this.writer.exitBlock('}'); 3639 this.writer.exitBlock("}");
3626 this._popBlock(); 3640 this._popBlock();
3627 return false; 3641 return false;
3628 } 3642 }
3629 MethodGenerator.prototype._genToDartException = function(ex) { 3643 MethodGenerator.prototype._genToDartException = function(ex) {
3630 var result = this._invokeNative("_toDartException", [ex]); 3644 var result = this._invokeNative("_toDartException", [ex]);
3631 this.writer.writeln(('' + ex.code + ' = ' + result.get$code() + ';')); 3645 this.writer.writeln(("" + ex.code + " = " + result.get$code() + ";"));
3632 } 3646 }
3633 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) { 3647 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) {
3634 var result = this._invokeNative("_stackTraceOf", [ex]); 3648 var result = this._invokeNative("_stackTraceOf", [ex]);
3635 this.writer.writeln(('var ' + trace.code + ' = ' + result.get$code() + ';')); 3649 this.writer.writeln(("var " + trace.code + " = " + result.get$code() + ";"));
3636 } 3650 }
3637 MethodGenerator.prototype.visitTryStatement = function(node) { 3651 MethodGenerator.prototype.visitTryStatement = function(node) {
3638 this.writer.enterBlock('try {'); 3652 this.writer.enterBlock("try {");
3639 this._pushBlock(false); 3653 this._pushBlock(false);
3640 this.visitStatementsInBlock(node.body); 3654 this.visitStatementsInBlock(node.body);
3641 this._popBlock(); 3655 this._popBlock();
3642 if (node.catches.get$length() == 1) { 3656 if (node.catches.get$length() == 1) {
3643 var catch_ = node.catches.$index(0); 3657 var catch_ = node.catches.$index(0);
3644 this._pushBlock(false); 3658 this._pushBlock(false);
3645 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e); 3659 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals e);
3646 var ex = this._scope.declare(catch_.get$exception()); 3660 var ex = this._scope.declare(catch_.get$exception());
3647 this._scope.rethrow = ex; 3661 this._scope.rethrow = ex;
3648 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {')); 3662 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {"));
3649 if (catch_.get$trace() != null) { 3663 if (catch_.get$trace() != null) {
3650 var trace = this._scope.declare(catch_.get$trace()); 3664 var trace = this._scope.declare(catch_.get$trace());
3651 this._genStackTraceOf(trace, ex); 3665 this._genStackTraceOf(trace, ex);
3652 } 3666 }
3653 this._genToDartException(ex); 3667 this._genToDartException(ex);
3654 if (!exType.get$isVarOrObject()) { 3668 if (!exType.get$isVarOrObject()) {
3655 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true); 3669 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce ption().get$span(), false, true);
3656 this.writer.writeln(('if (' + test.get$code() + ') throw ' + ex.get$code() + ';')); 3670 this.writer.writeln(("if (" + test.get$code() + ") throw " + ex.get$code() + ";"));
3657 } 3671 }
3658 this.visitStatementsInBlock(node.catches.$index(0).get$body()); 3672 this.visitStatementsInBlock(node.catches.$index(0).get$body());
3659 this._popBlock(); 3673 this._popBlock();
3660 } 3674 }
3661 else if (node.catches.get$length() > 0) { 3675 else if (node.catches.get$length() > 0) {
3662 this._pushBlock(false); 3676 this._pushBlock(false);
3663 var ex = this._scope.create('\$ex', $globals.world.varType, null, false, fal se); 3677 var ex = this._scope.create("$ex", $globals.world.varType, null, false, fals e);
3664 this._scope.rethrow = ex; 3678 this._scope.rethrow = ex;
3665 this.writer.nextBlock(('} catch (' + ex.get$code() + ') {')); 3679 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {"));
3666 var trace = null; 3680 var trace = null;
3667 if (node.catches.some((function (c) { 3681 if (node.catches.some((function (c) {
3668 return c.get$trace() != null; 3682 return c.get$trace() != null;
3669 }) 3683 })
3670 )) { 3684 )) {
3671 trace = this._scope.create('\$trace', $globals.world.varType, null, false, false); 3685 trace = this._scope.create("$trace", $globals.world.varType, null, false, false);
3672 this._genStackTraceOf(trace, ex); 3686 this._genStackTraceOf(trace, ex);
3673 } 3687 }
3674 this._genToDartException(ex); 3688 this._genToDartException(ex);
3675 var needsRethrow = true; 3689 var needsRethrow = true;
3676 for (var i = 0; 3690 for (var i = 0;
3677 i < node.catches.get$length(); i++) { 3691 i < node.catches.get$length(); i++) {
3678 var catch_ = node.catches.$index(i); 3692 var catch_ = node.catches.$index(i);
3679 this._pushBlock(false); 3693 this._pushBlock(false);
3680 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse); 3694 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f alse);
3681 var tmp = this._scope.declare(catch_.get$exception()); 3695 var tmp = this._scope.declare(catch_.get$exception());
3682 if (!tmpType.get$isVarOrObject()) { 3696 if (!tmpType.get$isVarOrObject()) {
3683 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true); 3697 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e xception().get$span(), true, true);
3684 if (i == 0) { 3698 if (i == 0) {
3685 this.writer.enterBlock(('if (' + test.get$code() + ') {')); 3699 this.writer.enterBlock(("if (" + test.get$code() + ") {"));
3686 } 3700 }
3687 else { 3701 else {
3688 this.writer.nextBlock(('} else if (' + test.get$code() + ') {')); 3702 this.writer.nextBlock(("} else if (" + test.get$code() + ") {"));
3689 } 3703 }
3690 } 3704 }
3691 else if (i > 0) { 3705 else if (i > 0) {
3692 this.writer.nextBlock('} else {'); 3706 this.writer.nextBlock("} else {");
3693 } 3707 }
3694 this.writer.writeln(('var ' + tmp.get$code() + ' = ' + ex.get$code() + ';' )); 3708 this.writer.writeln(("var " + tmp.get$code() + " = " + ex.get$code() + ";" ));
3695 if (catch_.get$trace() != null) { 3709 if (catch_.get$trace() != null) {
3696 var tmptrace = this._scope.declare(catch_.get$trace()); 3710 var tmptrace = this._scope.declare(catch_.get$trace());
3697 this.writer.writeln(('var ' + tmptrace.get$code() + ' = ' + trace.get$co de() + ';')); 3711 this.writer.writeln(("var " + tmptrace.get$code() + " = " + trace.get$co de() + ";"));
3698 } 3712 }
3699 this.visitStatementsInBlock(catch_.get$body()); 3713 this.visitStatementsInBlock(catch_.get$body());
3700 this._popBlock(); 3714 this._popBlock();
3701 if (tmpType.get$isVarOrObject()) { 3715 if (tmpType.get$isVarOrObject()) {
3702 if (i + 1 < node.catches.get$length()) { 3716 if (i + 1 < node.catches.get$length()) {
3703 $globals.world.error('Unreachable catch clause', node.catches.$index(i + 1).get$span()); 3717 $globals.world.error("Unreachable catch clause", node.catches.$index(i + 1).get$span());
3704 } 3718 }
3705 if (i > 0) { 3719 if (i > 0) {
3706 this.writer.exitBlock('}'); 3720 this.writer.exitBlock("}");
3707 } 3721 }
3708 needsRethrow = false; 3722 needsRethrow = false;
3709 break; 3723 break;
3710 } 3724 }
3711 } 3725 }
3712 if (needsRethrow) { 3726 if (needsRethrow) {
3713 this.writer.nextBlock('} else {'); 3727 this.writer.nextBlock("} else {");
3714 this.writer.writeln(('throw ' + ex.get$code() + ';')); 3728 this.writer.writeln(("throw " + ex.get$code() + ";"));
3715 this.writer.exitBlock('}'); 3729 this.writer.exitBlock("}");
3716 } 3730 }
3717 this._popBlock(); 3731 this._popBlock();
3718 } 3732 }
3719 if (node.finallyBlock != null) { 3733 if (node.finallyBlock != null) {
3720 this.writer.nextBlock('} finally {'); 3734 this.writer.nextBlock("} finally {");
3721 this._pushBlock(false); 3735 this._pushBlock(false);
3722 this.visitStatementsInBlock(node.finallyBlock); 3736 this.visitStatementsInBlock(node.finallyBlock);
3723 this._popBlock(); 3737 this._popBlock();
3724 } 3738 }
3725 this.writer.exitBlock('}'); 3739 this.writer.exitBlock("}");
3726 return false; 3740 return false;
3727 } 3741 }
3728 MethodGenerator.prototype.visitSwitchStatement = function(node) { 3742 MethodGenerator.prototype.visitSwitchStatement = function(node) {
3729 var test = this.visitValue(node.test); 3743 var test = this.visitValue(node.test);
3730 this.writer.enterBlock(('switch (' + test.get$code() + ') {')); 3744 this.writer.enterBlock(("switch (" + test.get$code() + ") {"));
3731 var $$list = node.cases; 3745 var $$list = node.cases;
3732 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 3746 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
3733 var case_ = $$list.$index($$i); 3747 var case_ = $$list.$index($$i);
3734 if (case_.get$label() != null) { 3748 if (case_.get$label() != null) {
3735 $globals.world.error('unimplemented: labeled case statement', case_.get$sp an()); 3749 $globals.world.error("unimplemented: labeled case statement", case_.get$sp an());
3736 } 3750 }
3737 this._pushBlock(false); 3751 this._pushBlock(false);
3738 for (var i = 0; 3752 for (var i = 0;
3739 i < case_.get$cases().get$length(); i++) { 3753 i < case_.get$cases().get$length(); i++) {
3740 var expr = case_.get$cases().$index(i); 3754 var expr = case_.get$cases().$index(i);
3741 if (expr == null) { 3755 if (expr == null) {
3742 if (i < case_.get$cases().get$length() - 1) { 3756 if (i < case_.get$cases().get$length() - 1) {
3743 $globals.world.error('default clause must be the last case', case_.get $span()); 3757 $globals.world.error("default clause must be the last case", case_.get $span());
3744 } 3758 }
3745 this.writer.writeln('default:'); 3759 this.writer.writeln("default:");
3746 } 3760 }
3747 else { 3761 else {
3748 var value = this.visitValue(expr); 3762 var value = this.visitValue(expr);
3749 this.writer.writeln(('case ' + value.get$code() + ':')); 3763 this.writer.writeln(("case " + value.get$code() + ":"));
3750 } 3764 }
3751 } 3765 }
3752 this.writer.enterBlock(''); 3766 this.writer.enterBlock("");
3753 var caseExits = this._visitAllStatements(case_.get$statements(), false); 3767 var caseExits = this._visitAllStatements(case_.get$statements(), false);
3754 if ($ne(case_, node.cases.$index(node.cases.get$length() - 1)) && !caseExits ) { 3768 if ($ne(case_, node.cases.$index(node.cases.get$length() - 1)) && !caseExits ) {
3755 var span = case_.get$statements().$index(case_.get$statements().get$length () - 1).get$span(); 3769 var span = case_.get$statements().$index(case_.get$statements().get$length () - 1).get$span();
3756 this.writer.writeln('\$throw(new FallThroughError());'); 3770 this.writer.writeln("$throw(new FallThroughError());");
3757 $globals.world.gen.corejs.useThrow = true; 3771 $globals.world.gen.corejs.useThrow = true;
3758 } 3772 }
3759 this.writer.exitBlock(''); 3773 this.writer.exitBlock("");
3760 this._popBlock(); 3774 this._popBlock();
3761 } 3775 }
3762 this.writer.exitBlock('}'); 3776 this.writer.exitBlock("}");
3763 return false; 3777 return false;
3764 } 3778 }
3765 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) { 3779 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) {
3766 for (var i = 0; 3780 for (var i = 0;
3767 i < statementList.get$length(); i++) { 3781 i < statementList.get$length(); i++) {
3768 var stmt = statementList.$index(i); 3782 var stmt = statementList.$index(i);
3769 exits = stmt.visit$1(this); 3783 exits = stmt.visit$1(this);
3770 if ($ne(stmt, statementList.$index(statementList.get$length() - 1)) && exits ) { 3784 if ($ne(stmt, statementList.$index(statementList.get$length() - 1)) && exits ) {
3771 $globals.world.warning('unreachable code', statementList.$index(i + 1).get $span()); 3785 $globals.world.warning("unreachable code", statementList.$index(i + 1).get $span());
3772 } 3786 }
3773 } 3787 }
3774 return exits; 3788 return exits;
3775 } 3789 }
3776 MethodGenerator.prototype.visitBlockStatement = function(node) { 3790 MethodGenerator.prototype.visitBlockStatement = function(node) {
3777 this._pushBlock(false); 3791 this._pushBlock(false);
3778 this.writer.enterBlock('{'); 3792 this.writer.enterBlock("{");
3779 var exits = this._visitAllStatements(node.body, false); 3793 var exits = this._visitAllStatements(node.body, false);
3780 this.writer.exitBlock('}'); 3794 this.writer.exitBlock("}");
3781 this._popBlock(); 3795 this._popBlock();
3782 return exits; 3796 return exits;
3783 } 3797 }
3784 MethodGenerator.prototype.visitLabeledStatement = function(node) { 3798 MethodGenerator.prototype.visitLabeledStatement = function(node) {
3785 this.writer.writeln(('' + node.name.name + ':')); 3799 this.writer.writeln(("" + node.name.name + ":"));
3786 node.body.visit(this); 3800 node.body.visit(this);
3787 return false; 3801 return false;
3788 } 3802 }
3789 MethodGenerator.prototype.visitExpressionStatement = function(node) { 3803 MethodGenerator.prototype.visitExpressionStatement = function(node) {
3790 if ((node.body instanceof VarExpression) || (node.body instanceof ThisExpressi on)) { 3804 if ((node.body instanceof VarExpression) || (node.body instanceof ThisExpressi on)) {
3791 $globals.world.warning('variable used as statement', node.span); 3805 $globals.world.warning("variable used as statement", node.span);
3792 } 3806 }
3793 var value = this.visitVoid(node.body); 3807 var value = this.visitVoid(node.body);
3794 this.writer.writeln(('' + value.get$code() + ';')); 3808 this.writer.writeln(("" + value.get$code() + ";"));
3795 return false; 3809 return false;
3796 } 3810 }
3797 MethodGenerator.prototype.visitEmptyStatement = function(node) { 3811 MethodGenerator.prototype.visitEmptyStatement = function(node) {
3798 this.writer.writeln(';'); 3812 this.writer.writeln(";");
3799 return false; 3813 return false;
3800 } 3814 }
3801 MethodGenerator.prototype._checkNonStatic = function(node) { 3815 MethodGenerator.prototype._checkNonStatic = function(node) {
3802 if (this.get$isStatic()) { 3816 if (this.get$isStatic()) {
3803 $globals.world.warning('not allowed in static method', node.span); 3817 $globals.world.warning("not allowed in static method", node.span);
3804 } 3818 }
3805 } 3819 }
3806 MethodGenerator.prototype._makeSuperValue = function(node) { 3820 MethodGenerator.prototype._makeSuperValue = function(node) {
3807 var parentType = this.method.declaringType.get$parent(); 3821 var parentType = this.method.declaringType.get$parent();
3808 this._checkNonStatic(node); 3822 this._checkNonStatic(node);
3809 if (parentType == null) { 3823 if (parentType == null) {
3810 $globals.world.error('no super class', node.span); 3824 $globals.world.error("no super class", node.span);
3811 } 3825 }
3812 var ret = new Value(parentType, 'this', node.span, false); 3826 var ret = new Value(parentType, "this", node.span, false);
3813 ret.set$isSuper(true); 3827 ret.set$isSuper(true);
3814 return ret; 3828 return ret;
3815 } 3829 }
3816 MethodGenerator.prototype._getOutermostMethod = function() { 3830 MethodGenerator.prototype._getOutermostMethod = function() {
3817 var result = this; 3831 var result = this;
3818 while (result.get$enclosingMethod() != null) { 3832 while (result.get$enclosingMethod() != null) {
3819 result = result.get$enclosingMethod(); 3833 result = result.get$enclosingMethod();
3820 } 3834 }
3821 return result; 3835 return result;
3822 } 3836 }
3823 MethodGenerator.prototype._makeThisCode = function() { 3837 MethodGenerator.prototype._makeThisCode = function() {
3824 if (this.enclosingMethod != null) { 3838 if (this.enclosingMethod != null) {
3825 this._getOutermostMethod().set$needsThis(true); 3839 this._getOutermostMethod().set$needsThis(true);
3826 return '\$this'; 3840 return "$this";
3827 } 3841 }
3828 else { 3842 else {
3829 return 'this'; 3843 return "this";
3830 } 3844 }
3831 } 3845 }
3832 MethodGenerator.prototype._makeThisValue = function(node) { 3846 MethodGenerator.prototype._makeThisValue = function(node) {
3833 if (this.enclosingMethod != null) { 3847 if (this.enclosingMethod != null) {
3834 var outermostMethod = this._getOutermostMethod(); 3848 var outermostMethod = this._getOutermostMethod();
3835 outermostMethod._checkNonStatic$1(node); 3849 outermostMethod._checkNonStatic$1(node);
3836 outermostMethod.set$needsThis(true); 3850 outermostMethod.set$needsThis(true);
3837 return new Value(outermostMethod.get$method().get$declaringType(), '\$this', node != null ? node.span : null, false); 3851 return new Value(outermostMethod.get$method().get$declaringType(), "$this", node != null ? node.span : null, false);
3838 } 3852 }
3839 else { 3853 else {
3840 this._checkNonStatic(node); 3854 this._checkNonStatic(node);
3841 return new Value(this.method.declaringType, 'this', node != null ? node.span : null, false); 3855 return new Value(this.method.declaringType, "this", node != null ? node.span : null, false);
3842 } 3856 }
3843 } 3857 }
3844 MethodGenerator.prototype.visitLambdaExpression = function(node) { 3858 MethodGenerator.prototype.visitLambdaExpression = function(node) {
3845 var name = (node.func.name != null) ? node.func.name.name : ''; 3859 var name = (node.func.name != null) ? node.func.name.name : "";
3846 var meth = this._makeLambdaMethod(name, node.func); 3860 var meth = this._makeLambdaMethod(name, node.func);
3847 var lambdaGen = new MethodGenerator(meth, this); 3861 var lambdaGen = new MethodGenerator(meth, this);
3848 if ($ne(name, '')) { 3862 if ($ne(name, "")) {
3849 lambdaGen._scope.create(name, meth.get$functionType(), meth.definition.span, true, false); 3863 lambdaGen._scope.create(name, meth.get$functionType(), meth.definition.span, true, false);
3850 lambdaGen._pushBlock(false); 3864 lambdaGen._pushBlock(false);
3851 } 3865 }
3852 lambdaGen.run(); 3866 lambdaGen.run();
3853 var w = new CodeWriter(); 3867 var w = new CodeWriter();
3854 meth.generator.writeDefinition(w, node); 3868 meth.generator.writeDefinition(w, node);
3855 return new Value(meth.get$functionType(), w.get$text(), node.span, true); 3869 return new Value(meth.get$functionType(), w.get$text(), node.span, true);
3856 } 3870 }
3857 MethodGenerator.prototype.visitCallExpression = function(node) { 3871 MethodGenerator.prototype.visitCallExpression = function(node) {
3858 var target; 3872 var target;
3859 var position = node.target; 3873 var position = node.target;
3860 var name = ':call'; 3874 var name = ":call";
3861 if ((node.target instanceof DotExpression)) { 3875 if ((node.target instanceof DotExpression)) {
3862 var dot = node.target; 3876 var dot = node.target;
3863 if ((dot.self instanceof LiteralExpression)) { 3877 if ((dot.self instanceof LiteralExpression)) {
3864 target = (new ParenExpression(dot.self, dot.self.span)).visit(this); 3878 target = (new ParenExpression(dot.self, dot.self.span)).visit(this);
3865 } 3879 }
3866 else { 3880 else {
3867 target = dot.self.visit(this); 3881 target = dot.self.visit(this);
3868 } 3882 }
3869 name = dot.name.name; 3883 name = dot.name.name;
3870 position = dot.name; 3884 position = dot.name;
3871 } 3885 }
3872 else if ((node.target instanceof VarExpression)) { 3886 else if ((node.target instanceof VarExpression)) {
3873 var varExpr = node.target; 3887 var varExpr = node.target;
3874 name = varExpr.name.name; 3888 name = varExpr.name.name;
3875 target = this._scope.lookup(name); 3889 target = this._scope.lookup(name);
3876 if (target != null) { 3890 if (target != null) {
3877 return target.invoke$4(this, ':call', node, this._makeArgs(node.arguments) ); 3891 return target.invoke$4(this, ":call", node, this._makeArgs(node.arguments) );
3878 } 3892 }
3879 target = this._makeThisOrType(varExpr.span); 3893 target = this._makeThisOrType(varExpr.span);
3880 return target.invoke$4(this, name, node, this._makeArgs(node.arguments)); 3894 return target.invoke$4(this, name, node, this._makeArgs(node.arguments));
3881 } 3895 }
3882 else { 3896 else {
3883 target = node.target.visit(this); 3897 target = node.target.visit(this);
3884 } 3898 }
3885 return target.invoke$4(this, name, position, this._makeArgs(node.arguments)); 3899 return target.invoke$4(this, name, position, this._makeArgs(node.arguments));
3886 } 3900 }
3887 MethodGenerator.prototype.visitIndexExpression = function(node) { 3901 MethodGenerator.prototype.visitIndexExpression = function(node) {
3888 var target = this.visitValue(node.target); 3902 var target = this.visitValue(node.target);
3889 var index = this.visitValue(node.index); 3903 var index = this.visitValue(node.index);
3890 return target.invoke$4(this, ':index', node, new Arguments(null, [index])); 3904 return target.invoke$4(this, ":index", node, new Arguments(null, [index]));
3891 } 3905 }
3892 MethodGenerator.prototype._expressionNeedsParens = function(e) { 3906 MethodGenerator.prototype._expressionNeedsParens = function(e) {
3893 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression ) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e)); 3907 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression ) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e));
3894 } 3908 }
3895 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) { 3909 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
3896 var kind = node.op.kind; 3910 var kind = node.op.kind;
3897 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) { 3911 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) {
3898 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); 3912 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool);
3899 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); 3913 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool);
3900 var code = ('' + x.get$code() + ' ' + node.op + ' ' + y.get$code()); 3914 var code = ("" + x.get$code() + " " + node.op + " " + y.get$code());
3901 if (x.get$isConst() && y.get$isConst()) { 3915 if (x.get$isConst() && y.get$isConst()) {
3902 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue(); 3916 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue();
3903 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ('' + value), node.span); 3917 return Value.fromBool(value, node.span);
3904 } 3918 }
3905 return new Value($globals.world.nonNullBool, code, node.span, true); 3919 return new Value($globals.world.nonNullBool, code, node.span, true);
3906 } 3920 }
3907 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT* /) { 3921 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT* /) {
3908 var x = this.visitValue(node.x); 3922 var x = this.visitValue(node.x);
3909 var y = this.visitValue(node.y); 3923 var y = this.visitValue(node.y);
3910 if (x.get$isConst() && y.get$isConst()) { 3924 if (x.get$isConst() && y.get$isConst()) {
3911 var xVal = x.get$actualValue(); 3925 var xVal = x.get$actualValue();
3912 var yVal = y.get$actualValue(); 3926 var yVal = y.get$actualValue();
3913 if (x.get$type().get$isString() && y.get$type().get$isString() && $ne(xVal .$index(0), yVal.$index(0))) {
3914 if ($eq(xVal.$index(0), '"')) {
3915 xVal = xVal.substring$2(1, xVal.get$length() - 1);
3916 yVal = toDoubleQuote(yVal.substring$2(1, yVal.get$length() - 1));
3917 }
3918 else {
3919 xVal = toDoubleQuote(xVal.substring$2(1, xVal.get$length() - 1));
3920 yVal = yVal.substring$2(1, yVal.get$length() - 1);
3921 }
3922 }
3923 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal , yVal); 3927 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal , yVal);
3924 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ("" + value), node.span); 3928 return Value.fromBool(value, node.span);
3925 } 3929 }
3926 if ($eq(x.get$code(), 'null') || $eq(y.get$code(), 'null')) { 3930 if ($eq(x.get$code(), "null") || $eq(y.get$code(), "null")) {
3927 var op = node.op.toString().substring(0, 2); 3931 var op = node.op.toString().substring(0, 2);
3928 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + op + ' ' + y.get$code()), node.span, true); 3932 return new Value($globals.world.nonNullBool, ("" + x.get$code() + " " + op + " " + y.get$code()), node.span, true);
3929 } 3933 }
3930 else { 3934 else {
3931 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + no de.op + ' ' + y.get$code()), node.span, true); 3935 return new Value($globals.world.nonNullBool, ("" + x.get$code() + " " + no de.op + " " + y.get$code()), node.span, true);
3932 } 3936 }
3933 } 3937 }
3934 var assignKind = TokenKind.kindFromAssign(node.op.kind); 3938 var assignKind = TokenKind.kindFromAssign(node.op.kind);
3935 if (assignKind == -1) { 3939 if (assignKind == -1) {
3936 var x = this.visitValue(node.x); 3940 var x = this.visitValue(node.x);
3937 var y = this.visitValue(node.y); 3941 var y = this.visitValue(node.y);
3938 var name = TokenKind.binaryMethodName(node.op.kind); 3942 var name = TokenKind.binaryMethodName(node.op.kind);
3939 if (node.op.kind == 49/*TokenKind.NE*/) { 3943 if (node.op.kind == 49/*TokenKind.NE*/) {
3940 name = ':ne'; 3944 name = ":ne";
3941 } 3945 }
3942 if (name == null) { 3946 if (name == null) {
3943 $globals.world.internalError(('unimplemented binary op ' + node.op), node. span); 3947 $globals.world.internalError(("unimplemented binary op " + node.op), node. span);
3944 return; 3948 return;
3945 } 3949 }
3946 return x.invoke$4(this, name, node, new Arguments(null, [y])); 3950 return x.invoke$4(this, name, node, new Arguments(null, [y]));
3947 } 3951 }
3948 else if ((assignKind != 0) && this._expressionNeedsParens(node.y)) { 3952 else if ((assignKind != 0) && this._expressionNeedsParens(node.y)) {
3949 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod e.y.span), node, to$call$1(null), isVoid); 3953 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod e.y.span), node, to$call$1(null), isVoid);
3950 } 3954 }
3951 else { 3955 else {
3952 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid); 3956 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
3953 } 3957 }
3954 } 3958 }
3955 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) { 3959 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) {
3956 if (captureOriginal == null) { 3960 if (captureOriginal == null) {
3957 captureOriginal = (function (x) { 3961 captureOriginal = (function (x) {
3958 return x; 3962 return x;
3959 }) 3963 })
3960 ; 3964 ;
3961 } 3965 }
3962 if ((xn instanceof VarExpression)) { 3966 if ((xn instanceof VarExpression)) {
3963 return this._visitVarAssign(kind, xn, yn, position, captureOriginal); 3967 return this._visitVarAssign(kind, xn, yn, position, captureOriginal);
3964 } 3968 }
3965 else if ((xn instanceof IndexExpression)) { 3969 else if ((xn instanceof IndexExpression)) {
3966 return this._visitIndexAssign(kind, xn, yn, position, captureOriginal, isVoi d); 3970 return this._visitIndexAssign(kind, xn, yn, position, captureOriginal, isVoi d);
3967 } 3971 }
3968 else if ((xn instanceof DotExpression)) { 3972 else if ((xn instanceof DotExpression)) {
3969 return this._visitDotAssign(kind, xn, yn, position, captureOriginal); 3973 return this._visitDotAssign(kind, xn, yn, position, captureOriginal);
3970 } 3974 }
3971 else { 3975 else {
3972 $globals.world.error('illegal lhs', xn.span); 3976 $globals.world.error("illegal lhs", xn.span);
3973 } 3977 }
3974 } 3978 }
3975 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, cap tureOriginal) { 3979 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, cap tureOriginal) {
3976 var name = xn.name.name; 3980 var name = xn.name.name;
3977 var x = this._scope.lookup(name); 3981 var x = this._scope.lookup(name);
3978 var y = this.visitValue(yn); 3982 var y = this.visitValue(yn);
3979 if (x == null) { 3983 if (x == null) {
3980 var members = this.method.declaringType.resolveMember(name); 3984 var members = this.method.declaringType.resolveMember(name);
3981 x = this._makeThisOrType(position.span); 3985 x = this._makeThisOrType(position.span);
3982 if (members != null) { 3986 if (members != null) {
3983 if ($globals.options.forceDynamic && !members.get$isStatic()) { 3987 if ($globals.options.forceDynamic && !members.get$isStatic()) {
3984 members = this.findMembers(xn.name.name); 3988 members = this.findMembers(xn.name.name);
3985 } 3989 }
3986 if (kind == 0) { 3990 if (kind == 0) {
3987 return x.set_$4(this, name, position, y); 3991 return x.set_$4(this, name, position, y);
3988 } 3992 }
3989 else if (!members.get$treatAsField() || members.get$containsMethods()) { 3993 else if (!members.get$treatAsField() || members.get$containsMethods()) {
3990 var right = x.get_$3(this, name, position); 3994 var right = x.get_$3(this, name, position);
3991 right = captureOriginal(right); 3995 right = captureOriginal(right);
3992 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y])); 3996 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arguments(null, [y]));
3993 return x.set_$4(this, name, position, y); 3997 return x.set_$4(this, name, position, y);
3994 } 3998 }
3995 else { 3999 else {
3996 x = x.get_$3(this, name, position); 4000 x = x.get_$3(this, name, position);
3997 } 4001 }
3998 } 4002 }
3999 else { 4003 else {
4000 var member = this.get$library().lookup(name, xn.name.span); 4004 var member = this.get$library().lookup(name, xn.name.span);
4001 if (member == null) { 4005 if (member == null) {
4002 $globals.world.warning(('can not resolve ' + name), xn.span); 4006 $globals.world.warning(("can not resolve " + name), xn.span);
4003 return this._makeMissingValue(name); 4007 return this._makeMissingValue(name);
4004 } 4008 }
4005 members = new MemberSet(member, false); 4009 members = new MemberSet(member, false);
4006 if (!members.get$treatAsField() || members.get$containsMethods()) { 4010 if (!members.get$treatAsField() || members.get$containsMethods()) {
4007 if (kind != 0) { 4011 if (kind != 0) {
4008 var right = members._get$3(this, position, x); 4012 var right = members._get$3(this, position, x);
4009 right = captureOriginal(right); 4013 right = captureOriginal(right);
4010 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, n ew Arguments(null, [y])); 4014 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, n ew Arguments(null, [y]));
4011 } 4015 }
4012 return members._set$4(this, position, x, y); 4016 return members._set$4(this, position, x, y);
4013 } 4017 }
4014 else { 4018 else {
4015 x = members._get$3(this, position, x); 4019 x = members._get$3(this, position, x);
4016 } 4020 }
4017 } 4021 }
4018 } 4022 }
4019 if (x.get$isFinal()) { 4023 if (x.get$isFinal()) {
4020 $globals.world.error(('final variable "' + x.get$code() + '" is not assignab le'), position.span); 4024 $globals.world.error(("final variable \"" + x.get$code() + "\" is not assign able"), position.span);
4021 } 4025 }
4022 y = y.convertTo$2(this, x.get$type()); 4026 y = y.convertTo$2(this, x.get$type());
4023 if (kind == 0) { 4027 if (kind == 0) {
4024 x = captureOriginal(x); 4028 x = captureOriginal(x);
4025 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p osition.span, true); 4029 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true);
4026 } 4030 }
4027 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != 46/* TokenKind.TRUNCDIV*/)) { 4031 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != 46/* TokenKind.TRUNCDIV*/)) {
4028 x = captureOriginal(x); 4032 x = captureOriginal(x);
4029 var op = TokenKind.kindToString(kind); 4033 var op = TokenKind.kindToString(kind);
4030 return new Value(y.get$type(), ('' + x.get$code() + ' ' + op + '= ' + y.get$ code()), position.span, true); 4034 return new Value(y.get$type(), ("" + x.get$code() + " " + op + "= " + y.get$ code()), position.span, true);
4031 } 4035 }
4032 else { 4036 else {
4033 var right = x; 4037 var right = x;
4034 right = captureOriginal(right); 4038 right = captureOriginal(right);
4035 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4039 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4036 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p osition.span, true); 4040 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()), p osition.span, true);
4037 } 4041 }
4038 } 4042 }
4039 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal, isVoid) { 4043 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal, isVoid) {
4040 var target = this.visitValue(xn.target); 4044 var target = this.visitValue(xn.target);
4041 var index = this.visitValue(xn.index); 4045 var index = this.visitValue(xn.index);
4042 var y = this.visitValue(yn); 4046 var y = this.visitValue(yn);
4043 var tmptarget = target; 4047 var tmptarget = target;
4044 var tmpindex = index; 4048 var tmpindex = index;
4045 if (kind != 0) { 4049 if (kind != 0) {
4046 tmptarget = this.getTemp(target); 4050 tmptarget = this.getTemp(target);
4047 tmpindex = this.getTemp(index); 4051 tmpindex = this.getTemp(index);
4048 index = this.assignTemp(tmpindex, index); 4052 index = this.assignTemp(tmpindex, index);
4049 var right = tmptarget.invoke$4(this, ':index', position, new Arguments(null, [tmpindex])); 4053 var right = tmptarget.invoke$4(this, ":index", position, new Arguments(null, [tmpindex]));
4050 right = captureOriginal(right); 4054 right = captureOriginal(right);
4051 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4055 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4052 } 4056 }
4053 var tmpy = null; 4057 var tmpy = null;
4054 if (!isVoid) { 4058 if (!isVoid) {
4055 tmpy = this.getTemp(y); 4059 tmpy = this.getTemp(y);
4056 y = this.assignTemp(tmpy, y); 4060 y = this.assignTemp(tmpy, y);
4057 } 4061 }
4058 var ret = this.assignTemp(tmptarget, target).invoke(this, ':setindex', positio n, new Arguments(null, [index, y]), false); 4062 var ret = this.assignTemp(tmptarget, target).invoke(this, ":setindex", positio n, new Arguments(null, [index, y]), false);
4059 if (tmpy != null) { 4063 if (tmpy != null) {
4060 ret = new Value(ret.get$type(), ('(' + ret.get$code() + ', ' + tmpy.get$code () + ')'), ret.get$span(), true); 4064 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpy.get$code () + ")"), ret.get$span(), true);
4061 if ($ne(tmpy, y)) this.freeTemp(tmpy); 4065 if ($ne(tmpy, y)) this.freeTemp(tmpy);
4062 } 4066 }
4063 if ($ne(tmptarget, target)) this.freeTemp(tmptarget); 4067 if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
4064 if ($ne(tmpindex, index)) this.freeTemp(tmpindex); 4068 if ($ne(tmpindex, index)) this.freeTemp(tmpindex);
4065 return ret; 4069 return ret;
4066 } 4070 }
4067 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) { 4071 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) {
4068 var target = xn.self.visit(this); 4072 var target = xn.self.visit(this);
4069 var y = this.visitValue(yn); 4073 var y = this.visitValue(yn);
4070 var tmptarget = target; 4074 var tmptarget = target;
4071 if (kind != 0) { 4075 if (kind != 0) {
4072 tmptarget = this.getTemp(target); 4076 tmptarget = this.getTemp(target);
4073 var right = tmptarget.get_$3(this, xn.name.name, xn.name); 4077 var right = tmptarget.get_$3(this, xn.name.name, xn.name);
4074 right = captureOriginal(right); 4078 right = captureOriginal(right);
4075 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 4079 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
4076 } 4080 }
4077 var ret = this.assignTemp(tmptarget, target).set_(this, xn.name.name, xn.name, y, false); 4081 var ret = this.assignTemp(tmptarget, target).set_(this, xn.name.name, xn.name, y, false);
4078 if ($ne(tmptarget, target)) this.freeTemp(tmptarget); 4082 if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
4079 return ret; 4083 return ret;
4080 } 4084 }
4081 MethodGenerator.prototype.visitUnaryExpression = function(node) { 4085 MethodGenerator.prototype.visitUnaryExpression = function(node) {
4082 var value = this.visitValue(node.self); 4086 var value = this.visitValue(node.self);
4083 switch (node.op.kind) { 4087 switch (node.op.kind) {
4084 case 16/*TokenKind.INCR*/: 4088 case 16/*TokenKind.INCR*/:
4085 case 17/*TokenKind.DECR*/: 4089 case 17/*TokenKind.DECR*/:
4086 4090
4087 if (value.get$type().get$isNum()) { 4091 if (value.get$type().get$isNum()) {
4088 return new Value(value.get$type(), ('' + node.op + value.get$code()), no de.span, true); 4092 return new Value(value.get$type(), ("" + node.op + value.get$code()), no de.span, true);
4089 } 4093 }
4090 else { 4094 else {
4091 var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/); 4095 var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/);
4092 var operand = new LiteralExpression(1, new TypeReference(node.span, $glo bals.world.numType), '1', node.span); 4096 var operand = new LiteralExpression(Value.fromInt(1, node.span), node.sp an);
4093 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null), false); 4097 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null), false);
4094 return new Value(assignValue.get$type(), ('(' + assignValue.get$code() + ')'), node.span, true); 4098 return new Value(assignValue.get$type(), ("(" + assignValue.get$code() + ")"), node.span, true);
4095 } 4099 }
4096 4100
4097 case 19/*TokenKind.NOT*/: 4101 case 19/*TokenKind.NOT*/:
4098 4102
4099 if (value.get$type().get$isBool() && value.get$isConst()) { 4103 if (value.get$type().get$isBool() && value.get$isConst()) {
4100 var newVal = !value.get$actualValue(); 4104 var newVal = !value.get$actualValue();
4101 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, ( '' + newVal), node.span); 4105 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, ( "" + newVal), node.span);
4102 } 4106 }
4103 else { 4107 else {
4104 var newVal = value.convertTo$2(this, $globals.world.nonNullBool); 4108 var newVal = value.convertTo$2(this, $globals.world.nonNullBool);
4105 return new Value(newVal.get$type(), ('!' + newVal.get$code()), node.span , true); 4109 return new Value(newVal.get$type(), ("!" + newVal.get$code()), node.span , true);
4106 } 4110 }
4107 4111
4108 case 42/*TokenKind.ADD*/: 4112 case 42/*TokenKind.ADD*/:
4109 4113
4110 return value.convertTo$2(this, $globals.world.numType); 4114 return value.convertTo$2(this, $globals.world.numType);
4111 4115
4112 case 43/*TokenKind.SUB*/: 4116 case 43/*TokenKind.SUB*/:
4113 case 18/*TokenKind.BIT_NOT*/: 4117 case 18/*TokenKind.BIT_NOT*/:
4114 4118
4115 if (node.op.kind == 18/*TokenKind.BIT_NOT*/) { 4119 if (node.op.kind == 18/*TokenKind.BIT_NOT*/) {
4116 return value.invoke$4(this, ':bit_not', node, Arguments.get$EMPTY()); 4120 return value.invoke$4(this, ":bit_not", node, Arguments.get$EMPTY());
4117 } 4121 }
4118 else if (node.op.kind == 43/*TokenKind.SUB*/) { 4122 else if (node.op.kind == 43/*TokenKind.SUB*/) {
4119 return value.invoke$4(this, ':negate', node, Arguments.get$EMPTY()); 4123 return value.invoke$4(this, ":negate", node, Arguments.get$EMPTY());
4120 } 4124 }
4121 else { 4125 else {
4122 $globals.world.internalError(('unimplemented: unary ' + node.op), node.s pan); 4126 $globals.world.internalError(("unimplemented: unary " + node.op), node.s pan);
4123 } 4127 }
4124 $throw(new FallThroughError()); 4128 $throw(new FallThroughError());
4125 4129
4126 default: 4130 default:
4127 4131
4128 $globals.world.internalError(('unimplemented: ' + node.op), node.span); 4132 $globals.world.internalError(("unimplemented: " + node.op), node.span);
4129 4133
4130 } 4134 }
4131 } 4135 }
4132 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) { 4136 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) {
4133 $globals.world.error('Expected expression', node.span); 4137 $globals.world.error("Expected expression", node.span);
4134 } 4138 }
4135 MethodGenerator.prototype.visitAwaitExpression = function(node) { 4139 MethodGenerator.prototype.visitAwaitExpression = function(node) {
4136 $globals.world.internalError('Await expressions should have been eliminated be fore code generation', node.span); 4140 $globals.world.internalError("Await expressions should have been eliminated be fore code generation", node.span);
4137 } 4141 }
4138 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) { 4142 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) {
4139 var $this = this; // closure support 4143 var $this = this; // closure support
4140 var value = this.visitValue(node.body); 4144 var value = this.visitValue(node.body);
4141 if (value.get$type().get$isNum() && !value.get$isFinal()) { 4145 if (value.get$type().get$isNum() && !value.get$isFinal()) {
4142 return new Value(value.get$type(), ('' + value.get$code() + node.op), node.s pan, true); 4146 return new Value(value.get$type(), ("" + value.get$code() + node.op), node.s pan, true);
4143 } 4147 }
4144 var kind = (16/*TokenKind.INCR*/ == node.op.kind) ? 42/*TokenKind.ADD*/ : 43/* TokenKind.SUB*/; 4148 var kind = (16/*TokenKind.INCR*/ == node.op.kind) ? 42/*TokenKind.ADD*/ : 43/* TokenKind.SUB*/;
4145 var operand = new LiteralExpression(1, new TypeReference(node.span, $globals.w orld.numType), '1', node.span); 4149 var operand = new LiteralExpression(Value.fromInt(1, node.span), node.span);
4146 var tmpleft = null, left = null; 4150 var tmpleft = null, left = null;
4147 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) { 4151 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) {
4148 if (isVoid) { 4152 if (isVoid) {
4149 return l; 4153 return l;
4150 } 4154 }
4151 else { 4155 else {
4152 left = l; 4156 left = l;
4153 tmpleft = $this.forceTemp(l); 4157 tmpleft = $this.forceTemp(l);
4154 return $this.assignTemp(tmpleft, left); 4158 return $this.assignTemp(tmpleft, left);
4155 } 4159 }
4156 }) 4160 })
4157 , false); 4161 , false);
4158 if (tmpleft != null) { 4162 if (tmpleft != null) {
4159 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true); 4163 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true);
4160 } 4164 }
4161 if ($ne(tmpleft, left)) { 4165 if ($ne(tmpleft, left)) {
4162 this.freeTemp(tmpleft); 4166 this.freeTemp(tmpleft);
4163 } 4167 }
4164 return ret; 4168 return ret;
4165 } 4169 }
4166 MethodGenerator.prototype.visitNewExpression = function(node) { 4170 MethodGenerator.prototype.visitNewExpression = function(node) {
4167 var typeRef = node.type; 4171 var typeRef = node.type;
4168 var constructorName = ''; 4172 var constructorName = "";
4169 if (node.name != null) { 4173 if (node.name != null) {
4170 constructorName = node.name.name; 4174 constructorName = node.name.name;
4171 } 4175 }
4172 if ($eq(constructorName, '') && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) { 4176 if ($eq(constructorName, "") && !(typeRef instanceof GenericTypeReference) && typeRef.get$names() != null) {
4173 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); 4177 var names = ListFactory.ListFactory$from$factory(typeRef.get$names());
4174 constructorName = names.removeLast$0().get$name(); 4178 constructorName = names.removeLast$0().get$name();
4175 if ($eq(names.get$length(), 0)) names = null; 4179 if ($eq(names.get$length(), 0)) names = null;
4176 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span()); 4180 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n ames, typeRef.get$span());
4177 } 4181 }
4178 var type = this.method.resolveType(typeRef, true); 4182 var type = this.method.resolveType(typeRef, true);
4179 if (type.get$isTop()) { 4183 if (type.get$isTop()) {
4180 type = type.get$library().findTypeByName$1(constructorName); 4184 type = type.get$library().findTypeByName$1(constructorName);
4181 constructorName = ''; 4185 constructorName = "";
4182 } 4186 }
4183 if ((type instanceof ParameterType)) { 4187 if ((type instanceof ParameterType)) {
4184 $globals.world.error('cannot instantiate a type parameter', node.span); 4188 $globals.world.error("cannot instantiate a type parameter", node.span);
4185 return this._makeMissingValue(constructorName); 4189 return this._makeMissingValue(constructorName);
4186 } 4190 }
4187 var m = type.getConstructor$1(constructorName); 4191 var m = type.getConstructor$1(constructorName);
4188 if (m == null) { 4192 if (m == null) {
4189 var name = type.get$jsname(); 4193 var name = type.get$jsname();
4190 if (type.get$isVar()) { 4194 if (type.get$isVar()) {
4191 name = typeRef.get$name().get$name(); 4195 name = typeRef.get$name().get$name();
4192 } 4196 }
4193 $globals.world.error(('no matching constructor for ' + name), node.span); 4197 $globals.world.error(("no matching constructor for " + name), node.span);
4194 return this._makeMissingValue(name); 4198 return this._makeMissingValue(name);
4195 } 4199 }
4196 if (node.isConst) { 4200 if (node.isConst) {
4197 if (!m.get$isConst()) { 4201 if (!m.get$isConst()) {
4198 $globals.world.error('can\'t use const on a non-const constructor', node.s pan); 4202 $globals.world.error("can't use const on a non-const constructor", node.sp an);
4199 } 4203 }
4200 var $$list = node.arguments; 4204 var $$list = node.arguments;
4201 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4205 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4202 var arg = $$list.$index($$i); 4206 var arg = $$list.$index($$i);
4203 if (!this.visitValue(arg.get$value()).get$isConst()) { 4207 if (!this.visitValue(arg.get$value()).get$isConst()) {
4204 $globals.world.error('const constructor expects const arguments', arg.ge t$span()); 4208 $globals.world.error("const constructor expects const arguments", arg.ge t$span());
4205 } 4209 }
4206 } 4210 }
4207 } 4211 }
4208 var target = new Value.type$ctor(type, typeRef.get$span()); 4212 var target = new Value.type$ctor(type, typeRef.get$span());
4209 return m.invoke$4(this, node, target, this._makeArgs(node.arguments)); 4213 return m.invoke$4(this, node, target, this._makeArgs(node.arguments));
4210 } 4214 }
4211 MethodGenerator.prototype.visitListExpression = function(node) { 4215 MethodGenerator.prototype.visitListExpression = function(node) {
4212 var argsCode = []; 4216 var argsCode = [];
4213 var argValues = []; 4217 var argValues = [];
4214 var type = null; 4218 var type = null;
4215 if (node.type != null) { 4219 if (node.type != null) {
4216 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (0); 4220 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (0);
4217 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 4221 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) {
4218 $globals.world.error('type parameter cannot be used in const list literals '); 4222 $globals.world.error("type parameter cannot be used in const list literals ");
4219 } 4223 }
4220 } 4224 }
4221 var $$list = node.values; 4225 var $$list = node.values;
4222 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4226 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4223 var item = $$list.$index($$i); 4227 var item = $$list.$index($$i);
4224 var arg = this.visitTypedValue(item, type); 4228 var arg = this.visitTypedValue(item, type);
4225 argValues.add$1(arg); 4229 argValues.add$1(arg);
4226 if (node.isConst) { 4230 if (node.isConst) {
4227 if (!arg.get$isConst()) { 4231 if (!arg.get$isConst()) {
4228 $globals.world.error('const list can only contain const values', item.ge t$span()); 4232 $globals.world.error("const list can only contain const values", item.ge t$span());
4229 argsCode.add$1(arg.get$code()); 4233 argsCode.add$1(arg.get$code());
4230 } 4234 }
4231 else { 4235 else {
4232 argsCode.add$1(arg.get$canonicalCode()); 4236 argsCode.add$1(arg.get$canonicalCode());
4233 } 4237 }
4234 } 4238 }
4235 else { 4239 else {
4236 argsCode.add$1(arg.get$code()); 4240 argsCode.add$1(arg.get$code());
4237 } 4241 }
4238 } 4242 }
4239 $globals.world.listFactoryType.markUsed(); 4243 $globals.world.listFactoryType.markUsed();
4240 var code = ('[' + Strings.join(argsCode, ", ") + ']'); 4244 var code = ("[" + Strings.join(argsCode, ", ") + "]");
4241 var value = new Value($globals.world.listType, code, node.span, true); 4245 var value = new Value($globals.world.listType, code, node.span, true);
4242 if (node.isConst) { 4246 if (node.isConst) {
4243 var immutableList = $globals.world.immutableListType; 4247 var immutableList = $globals.world.immutableListType;
4244 var immutableListCtor = immutableList.getConstructor('from'); 4248 var immutableListCtor = immutableList.getConstructor("from");
4245 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu e.get$type(), node.span), new Arguments(null, [value])); 4249 var result = immutableListCtor.invoke$4(this, node, new Value.type$ctor(valu e.get$type(), node.span), new Arguments(null, [value]));
4246 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact ory(immutableList, argValues, ('const ' + code), result.get$code(), node.span), argValues); 4250 value = $globals.world.gen.globalForConst(ConstListValue.ConstListValue$fact ory(immutableList, argValues, ("const " + code), result.get$code(), node.span), argValues);
4247 } 4251 }
4248 return value; 4252 return value;
4249 } 4253 }
4250 MethodGenerator.prototype.visitMapExpression = function(node) { 4254 MethodGenerator.prototype.visitMapExpression = function(node) {
4251 if (node.items.get$length() == 0 && !node.isConst) { 4255 if (node.items.get$length() == 0 && !node.isConst) {
4252 return $globals.world.mapType.getConstructor('').invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY()); 4256 return $globals.world.mapType.getConstructor("").invoke$4(this, node, new Va lue.type$ctor($globals.world.mapType, node.span), Arguments.get$EMPTY());
4253 } 4257 }
4254 var argValues = []; 4258 var argValues = [];
4255 var argsCode = []; 4259 var argsCode = [];
4256 var type = null; 4260 var type = null;
4257 if (node.type != null) { 4261 if (node.type != null) {
4258 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (1); 4262 type = this.method.resolveType(node.type, true).get$typeArgsInOrder().$index (1);
4259 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) { 4263 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara ms())) {
4260 $globals.world.error('type parameter cannot be used in const map literals' ); 4264 $globals.world.error("type parameter cannot be used in const map literals" );
4261 } 4265 }
4262 } 4266 }
4263 for (var i = 0; 4267 for (var i = 0;
4264 i < node.items.get$length(); i += 2) { 4268 i < node.items.get$length(); i += 2) {
4265 var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringTy pe); 4269 var key = this.visitTypedValue(node.items.$index(i), $globals.world.stringTy pe);
4266 var valueItem = node.items.$index(i + 1); 4270 var valueItem = node.items.$index(i + 1);
4267 var value = this.visitTypedValue(valueItem, type); 4271 var value = this.visitTypedValue(valueItem, type);
4268 argValues.add$1(key); 4272 argValues.add$1(key);
4269 argValues.add$1(value); 4273 argValues.add$1(value);
4270 if (node.isConst) { 4274 if (node.isConst) {
4271 if (!key.get$isConst() || !value.get$isConst()) { 4275 if (!key.get$isConst() || !value.get$isConst()) {
4272 $globals.world.error('const map can only contain const values', valueIte m.get$span()); 4276 $globals.world.error("const map can only contain const values", valueIte m.get$span());
4273 argsCode.add$1(key.get$code()); 4277 argsCode.add$1(key.get$code());
4274 argsCode.add$1(value.get$code()); 4278 argsCode.add$1(value.get$code());
4275 } 4279 }
4276 else { 4280 else {
4277 argsCode.add$1(key.get$canonicalCode()); 4281 argsCode.add$1(key.get$canonicalCode());
4278 argsCode.add$1(value.get$canonicalCode()); 4282 argsCode.add$1(value.get$canonicalCode());
4279 } 4283 }
4280 } 4284 }
4281 else { 4285 else {
4282 argsCode.add$1(key.get$code()); 4286 argsCode.add$1(key.get$code());
4283 argsCode.add$1(value.get$code()); 4287 argsCode.add$1(value.get$code());
4284 } 4288 }
4285 } 4289 }
4286 var argList = ('[' + Strings.join(argsCode, ", ") + ']'); 4290 var argList = ("[" + Strings.join(argsCode, ", ") + "]");
4287 var items = new Value($globals.world.listType, argList, node.span, true); 4291 var items = new Value($globals.world.listType, argList, node.span, true);
4288 var tp = $globals.world.corelib.topType; 4292 var tp = $globals.world.corelib.topType;
4289 var f = node.isConst ? tp.getMember$1('_constMap') : tp.getMember$1('_map'); 4293 var f = node.isConst ? tp.getMember$1("_constMap") : tp.getMember$1("_map");
4290 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Arguments( null, [items]), false); 4294 var value = f.invoke(this, node, new Value.type$ctor(tp, null), new Arguments( null, [items]), false);
4291 if (node.isConst) { 4295 if (node.isConst) {
4292 value = ConstMapValue.ConstMapValue$factory(value.get$type(), argValues, val ue.get$code(), value.get$code(), value.get$span()); 4296 value = ConstMapValue.ConstMapValue$factory(value.get$type(), argValues, val ue.get$code(), value.get$code(), value.get$span());
4293 return $globals.world.gen.globalForConst(value, argValues); 4297 return $globals.world.gen.globalForConst(value, argValues);
4294 } 4298 }
4295 else { 4299 else {
4296 return value; 4300 return value;
4297 } 4301 }
4298 } 4302 }
4299 MethodGenerator.prototype.visitConditionalExpression = function(node) { 4303 MethodGenerator.prototype.visitConditionalExpression = function(node) {
4300 var test = this.visitBool(node.test); 4304 var test = this.visitBool(node.test);
4301 var trueBranch = this.visitValue(node.trueBranch); 4305 var trueBranch = this.visitValue(node.trueBranch);
4302 var falseBranch = this.visitValue(node.falseBranch); 4306 var falseBranch = this.visitValue(node.falseBranch);
4303 var code = ('' + test.get$code() + ' ? ' + trueBranch.get$code() + ' : ' + fal seBranch.get$code()); 4307 var code = ("" + test.get$code() + " ? " + trueBranch.get$code() + " : " + fal seBranch.get$code());
4304 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), co de, node.span, true); 4308 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), co de, node.span, true);
4305 } 4309 }
4306 MethodGenerator.prototype.visitIsExpression = function(node) { 4310 MethodGenerator.prototype.visitIsExpression = function(node) {
4307 var value = this.visitValue(node.x); 4311 var value = this.visitValue(node.x);
4308 var type = this.method.resolveType(node.type, false); 4312 var type = this.method.resolveType(node.type, false);
4309 return value.instanceOf$4(this, type, node.span, node.isTrue); 4313 return value.instanceOf$4(this, type, node.span, node.isTrue);
4310 } 4314 }
4311 MethodGenerator.prototype.visitParenExpression = function(node) { 4315 MethodGenerator.prototype.visitParenExpression = function(node) {
4312 var body = this.visitValue(node.body); 4316 var body = this.visitValue(node.body);
4313 if (body.get$isConst()) { 4317 if (body.get$isConst()) {
4314 return EvaluatedValue.EvaluatedValue$factory(body.get$type(), body.get$actua lValue(), ('(' + body.get$canonicalCode() + ')'), node.span); 4318 return EvaluatedValue.EvaluatedValue$factory(body.get$type(), body.get$actua lValue(), ("(" + body.get$canonicalCode() + ")"), node.span);
4315 } 4319 }
4316 return new Value(body.get$type(), ('(' + body.get$code() + ')'), node.span, tr ue); 4320 return new Value(body.get$type(), ("(" + body.get$code() + ")"), node.span, tr ue);
4317 } 4321 }
4318 MethodGenerator.prototype.visitDotExpression = function(node) { 4322 MethodGenerator.prototype.visitDotExpression = function(node) {
4319 var target = node.self.visit(this); 4323 var target = node.self.visit(this);
4320 return target.get_$3(this, node.name.name, node.name); 4324 return target.get_$3(this, node.name.name, node.name);
4321 } 4325 }
4322 MethodGenerator.prototype.visitVarExpression = function(node) { 4326 MethodGenerator.prototype.visitVarExpression = function(node) {
4323 var name = node.name.name; 4327 var name = node.name.name;
4324 var ret = this._scope.lookup(name); 4328 var ret = this._scope.lookup(name);
4325 if (ret != null) return ret; 4329 if (ret != null) return ret;
4326 return this._makeThisOrType(node.span).get_$3(this, name, node); 4330 return this._makeThisOrType(node.span).get_$3(this, name, node);
4327 } 4331 }
4328 MethodGenerator.prototype._makeMissingValue = function(name) { 4332 MethodGenerator.prototype._makeMissingValue = function(name) {
4329 return new Value($globals.world.varType, ('' + name + '()/*NotFound*/'), null, true); 4333 return new Value($globals.world.varType, ("" + name + "()/*NotFound*/"), null, true);
4330 } 4334 }
4331 MethodGenerator.prototype._makeThisOrType = function(span) { 4335 MethodGenerator.prototype._makeThisOrType = function(span) {
4332 return new BareValue(this, this._getOutermostMethod(), span); 4336 return new BareValue(this, this._getOutermostMethod(), span);
4333 } 4337 }
4334 MethodGenerator.prototype.visitThisExpression = function(node) { 4338 MethodGenerator.prototype.visitThisExpression = function(node) {
4335 return this._makeThisValue(node); 4339 return this._makeThisValue(node);
4336 } 4340 }
4337 MethodGenerator.prototype.visitSuperExpression = function(node) { 4341 MethodGenerator.prototype.visitSuperExpression = function(node) {
4338 return this._makeSuperValue(node); 4342 return this._makeSuperValue(node);
4339 } 4343 }
4340 MethodGenerator.prototype.visitNullExpression = function(node) { 4344 MethodGenerator.prototype.visitLiteralExpression = function(node) {
4341 return EvaluatedValue.EvaluatedValue$factory($globals.world.varType, null, 'nu ll', null); 4345 return node.value;
4342 } 4346 }
4343 MethodGenerator.prototype._isUnaryIncrement = function(item) { 4347 MethodGenerator.prototype._isUnaryIncrement = function(item) {
4344 if ((item instanceof UnaryExpression)) { 4348 if ((item instanceof UnaryExpression)) {
4345 var u = item; 4349 var u = item;
4346 return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR* /; 4350 return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR* /;
4347 } 4351 }
4348 else { 4352 else {
4349 return false; 4353 return false;
4350 } 4354 }
4351 } 4355 }
4352 MethodGenerator.prototype.visitLiteralExpression = function(node) { 4356 MethodGenerator.prototype.visitStringInterpExpression = function(node) {
4353 var $0; 4357 var items = [];
4354 var type = node.type.type; 4358 var $$list = node.pieces;
4355 if (!!(($0 = node.value) && $0.is$List())) { 4359 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4356 var items = []; 4360 var item = $$list.$index($$i);
4357 var $$list = node.value; 4361 var val = this.visitValue(item);
4358 for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) { 4362 val.invoke$4(this, "toString", item, Arguments.get$EMPTY());
4359 var item = $$i.next$0(); 4363 var code = val.get$code();
4360 var val = this.visitValue(item); 4364 if (this._expressionNeedsParens(item)) {
4361 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY()); 4365 code = ("(" + code + ")");
4362 var code = val.get$code();
4363 if (this._expressionNeedsParens(item)) {
4364 code = ('(' + code + ')');
4365 }
4366 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) {
4367 items.add$1(code);
4368 }
4369 } 4366 }
4370 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true); 4367 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, "\"\""))) {
4371 } 4368 items.add$1(code);
4372 if ((typeof(node.value) == 'number')) {
4373 $globals.world.numImplType.markUsed();
4374 }
4375 var text = node.text;
4376 if (type.get$isString()) {
4377 $globals.world.stringImplType.markUsed();
4378 if (text.startsWith$1('@')) {
4379 text = MethodGenerator._escapeString(parseStringLiteral(text));
4380 text = ('"' + text + '"');
4381 }
4382 else if (isMultilineString(text)) {
4383 text = parseStringLiteral(text);
4384 text = text.replaceAll$2('\n', '\\n');
4385 text = toDoubleQuote(text);
4386 text = ('"' + text + '"');
4387 }
4388 if (text !== node.text) {
4389 node.value = text;
4390 node.text = text;
4391 } 4369 }
4392 } 4370 }
4393 return EvaluatedValue.EvaluatedValue$factory(type, node.value, node.text, null ); 4371 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ") + ")"), node.span, true);
4394 } 4372 }
4395 MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNo nStatic; 4373 MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNo nStatic;
4396 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) { 4374 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) {
4397 return this.visitBinaryExpression($0, false); 4375 return this.visitBinaryExpression($0, false);
4398 }; 4376 };
4399 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { 4377 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) {
4400 return this.visitPostfixExpression($0, false); 4378 return this.visitPostfixExpression($0, false);
4401 }; 4379 };
4402 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition; 4380 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition;
4403 // ********** Code for Arguments ************** 4381 // ********** Code for Arguments **************
4404 function Arguments(nodes, values) { 4382 function Arguments(nodes, values) {
4405 this.nodes = nodes; 4383 this.nodes = nodes;
4406 this.values = values; 4384 this.values = values;
4407 // Initializers done 4385 // Initializers done
4408 } 4386 }
4409 Arguments.Arguments$bare$factory = function(arity) { 4387 Arguments.Arguments$bare$factory = function(arity) {
4410 var values = []; 4388 var values = [];
4411 for (var i = 0; 4389 for (var i = 0;
4412 i < arity; i++) { 4390 i < arity; i++) {
4413 values.add$1(new Value($globals.world.varType, ('\$' + i), null, false)); 4391 values.add$1(new Value($globals.world.varType, ("$" + i), null, false));
4414 } 4392 }
4415 return new Arguments(null, values); 4393 return new Arguments(null, values);
4416 } 4394 }
4417 Arguments.get$EMPTY = function() { 4395 Arguments.get$EMPTY = function() {
4418 if ($globals.Arguments__empty == null) { 4396 if ($globals.Arguments__empty == null) {
4419 $globals.Arguments__empty = new Arguments(null, []); 4397 $globals.Arguments__empty = new Arguments(null, []);
4420 } 4398 }
4421 return $globals.Arguments__empty; 4399 return $globals.Arguments__empty;
4422 } 4400 }
4423 Arguments.prototype.get$values = function() { return this.values; }; 4401 Arguments.prototype.get$values = function() { return this.values; };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 Arguments.prototype.getCode = function() { 4443 Arguments.prototype.getCode = function() {
4466 var argsCode = []; 4444 var argsCode = [];
4467 for (var i = 0; 4445 for (var i = 0;
4468 i < this.get$length(); i++) { 4446 i < this.get$length(); i++) {
4469 argsCode.add$1(this.values.$index(i).get$code()); 4447 argsCode.add$1(this.values.$index(i).get$code());
4470 } 4448 }
4471 Arguments.removeTrailingNulls(argsCode); 4449 Arguments.removeTrailingNulls(argsCode);
4472 return Strings.join(argsCode, ", "); 4450 return Strings.join(argsCode, ", ");
4473 } 4451 }
4474 Arguments.removeTrailingNulls = function(argsCode) { 4452 Arguments.removeTrailingNulls = function(argsCode) {
4475 while (argsCode.get$length() > 0 && $eq(argsCode.last(), 'null')) { 4453 while (argsCode.get$length() > 0 && $eq(argsCode.last(), "null")) {
4476 argsCode.removeLast(); 4454 argsCode.removeLast();
4477 } 4455 }
4478 } 4456 }
4479 Arguments.prototype.getNames = function() { 4457 Arguments.prototype.getNames = function() {
4480 var names = []; 4458 var names = [];
4481 for (var i = this.get$bareCount(); 4459 for (var i = this.get$bareCount();
4482 i < this.get$length(); i++) { 4460 i < this.get$length(); i++) {
4483 names.add$1(this.getName(i)); 4461 names.add$1(this.getName(i));
4484 } 4462 }
4485 return names; 4463 return names;
4486 } 4464 }
4487 Arguments.prototype.toCallStubArgs = function() { 4465 Arguments.prototype.toCallStubArgs = function() {
4488 var result = []; 4466 var result = [];
4489 for (var i = 0; 4467 for (var i = 0;
4490 i < this.get$bareCount(); i++) { 4468 i < this.get$bareCount(); i++) {
4491 result.add$1(new Value($globals.world.varType, ('\$' + i), null, false)); 4469 result.add$1(new Value($globals.world.varType, ("$" + i), null, false));
4492 } 4470 }
4493 for (var i = this.get$bareCount(); 4471 for (var i = this.get$bareCount();
4494 i < this.get$length(); i++) { 4472 i < this.get$length(); i++) {
4495 var name = this.getName(i); 4473 var name = this.getName(i);
4496 if (name == null) name = ('\$' + i); 4474 if (name == null) name = ("$" + i);
4497 result.add$1(new Value($globals.world.varType, name, null, false)); 4475 result.add$1(new Value($globals.world.varType, name, null, false));
4498 } 4476 }
4499 return new Arguments(this.nodes, result); 4477 return new Arguments(this.nodes, result);
4500 } 4478 }
4501 // ********** Code for LibraryImport ************** 4479 // ********** Code for LibraryImport **************
4502 function LibraryImport(library, prefix) { 4480 function LibraryImport(library, prefix) {
4503 this.library = library; 4481 this.library = library;
4504 this.prefix = prefix; 4482 this.prefix = prefix;
4505 // Initializers done 4483 // Initializers done
4506 } 4484 }
4507 LibraryImport.prototype.get$prefix = function() { return this.prefix; }; 4485 LibraryImport.prototype.get$prefix = function() { return this.prefix; };
4508 LibraryImport.prototype.set$prefix = function(value) { return this.prefix = valu e; }; 4486 LibraryImport.prototype.set$prefix = function(value) { return this.prefix = valu e; };
4509 LibraryImport.prototype.get$library = function() { return this.library; }; 4487 LibraryImport.prototype.get$library = function() { return this.library; };
4510 LibraryImport.prototype.set$library = function(value) { return this.library = va lue; }; 4488 LibraryImport.prototype.set$library = function(value) { return this.library = va lue; };
4511 // ********** Code for Library ************** 4489 // ********** Code for Library **************
4512 $inherits(Library, Element); 4490 $inherits(Library, Element);
4513 function Library(baseSource) { 4491 function Library(baseSource) {
4514 this.isWritten = false 4492 this.isWritten = false
4515 this.baseSource = baseSource; 4493 this.baseSource = baseSource;
4516 // Initializers done 4494 // Initializers done
4517 Element.call(this, null, null); 4495 Element.call(this, null, null);
4518 this.sourceDir = dirname(this.baseSource.filename); 4496 this.sourceDir = dirname(this.baseSource.filename);
4519 this.topType = new DefinedType(null, this, null, true); 4497 this.topType = new DefinedType(null, this, null, true);
4520 this.types = _map(['', this.topType]); 4498 this.types = _map(["", this.topType]);
4521 this.imports = []; 4499 this.imports = [];
4522 this.natives = []; 4500 this.natives = [];
4523 this.sources = []; 4501 this.sources = [];
4524 this._privateMembers = new HashMapImplementation(); 4502 this._privateMembers = new HashMapImplementation();
4525 } 4503 }
4526 Library.prototype.get$baseSource = function() { return this.baseSource; }; 4504 Library.prototype.get$baseSource = function() { return this.baseSource; };
4527 Library.prototype.get$types = function() { return this.types; }; 4505 Library.prototype.get$types = function() { return this.types; };
4528 Library.prototype.set$types = function(value) { return this.types = value; }; 4506 Library.prototype.set$types = function(value) { return this.types = value; };
4529 Library.prototype.get$imports = function() { return this.imports; }; 4507 Library.prototype.get$imports = function() { return this.imports; };
4530 Library.prototype.set$imports = function(value) { return this.imports = value; } ; 4508 Library.prototype.set$imports = function(value) { return this.imports = value; } ;
(...skipping 16 matching lines...) Expand all
4547 Library.prototype.get$isCoreImpl = function() { 4525 Library.prototype.get$isCoreImpl = function() {
4548 return $eq(this, $globals.world.coreimpl); 4526 return $eq(this, $globals.world.coreimpl);
4549 } 4527 }
4550 Library.prototype.get$isDom = function() { 4528 Library.prototype.get$isDom = function() {
4551 return $eq(this, $globals.world.dom); 4529 return $eq(this, $globals.world.dom);
4552 } 4530 }
4553 Library.prototype.get$span = function() { 4531 Library.prototype.get$span = function() {
4554 return new SourceSpan(this.baseSource, 0, 0); 4532 return new SourceSpan(this.baseSource, 0, 0);
4555 } 4533 }
4556 Library.prototype.makeFullPath = function(filename) { 4534 Library.prototype.makeFullPath = function(filename) {
4557 if (filename.startsWith('dart:')) return filename; 4535 if (filename.startsWith("dart:")) return filename;
4558 if (filename.startsWith('/')) return filename; 4536 if (filename.startsWith("/")) return filename;
4559 if (filename.startsWith('file:///')) return filename; 4537 if (filename.startsWith("file:///")) return filename;
4560 if (filename.startsWith('http://')) return filename; 4538 if (filename.startsWith("http://")) return filename;
4561 return joinPaths(this.sourceDir, filename); 4539 return joinPaths(this.sourceDir, filename);
4562 } 4540 }
4563 Library.prototype.addImport = function(fullname, prefix) { 4541 Library.prototype.addImport = function(fullname, prefix) {
4564 var newLib = $globals.world.getOrAddLibrary(fullname); 4542 var newLib = $globals.world.getOrAddLibrary(fullname);
4565 this.imports.add(new LibraryImport(newLib, prefix)); 4543 this.imports.add(new LibraryImport(newLib, prefix));
4566 return newLib; 4544 return newLib;
4567 } 4545 }
4568 Library.prototype.addNative = function(fullname) { 4546 Library.prototype.addNative = function(fullname) {
4569 this.natives.add($globals.world.reader.readFile(fullname)); 4547 this.natives.add($globals.world.reader.readFile(fullname));
4570 } 4548 }
4571 Library.prototype._findMembers = function(name) { 4549 Library.prototype._findMembers = function(name) {
4572 if (name.startsWith('_')) { 4550 if (name.startsWith("_")) {
4573 return this._privateMembers.$index(name); 4551 return this._privateMembers.$index(name);
4574 } 4552 }
4575 else { 4553 else {
4576 return $globals.world._members.$index(name); 4554 return $globals.world._members.$index(name);
4577 } 4555 }
4578 } 4556 }
4579 Library.prototype._addMember = function(member) { 4557 Library.prototype._addMember = function(member) {
4580 if (member.get$isPrivate()) { 4558 if (member.get$isPrivate()) {
4581 if (member.get$isStatic()) { 4559 if (member.get$isStatic()) {
4582 if (member.declaringType.get$isTop()) { 4560 if (member.declaringType.get$isTop()) {
4583 $globals.world._addTopName(member); 4561 $globals.world._addTopName(member);
4584 } 4562 }
4585 return; 4563 return;
4586 } 4564 }
4587 var mset = this._privateMembers.$index(member.name); 4565 var mset = this._privateMembers.$index(member.name);
4588 if (mset == null) { 4566 if (mset == null) {
4589 var $$list = $globals.world.libraries.getValues(); 4567 var $$list = $globals.world.libraries.getValues();
4590 for (var $$i = $globals.world.libraries.getValues().iterator$0(); $$i.hasN ext$0(); ) { 4568 for (var $$i = $globals.world.libraries.getValues().iterator$0(); $$i.hasN ext$0(); ) {
4591 var lib = $$i.next$0(); 4569 var lib = $$i.next$0();
4592 if (lib.get$_privateMembers().containsKey$1(member.get$jsname())) { 4570 if (lib.get$_privateMembers().containsKey$1(member.get$jsname())) {
4593 member._jsname = ('_' + this.get$jsname() + member.get$jsname()); 4571 member._jsname = ("_" + this.get$jsname() + member.get$jsname());
4594 break; 4572 break;
4595 } 4573 }
4596 } 4574 }
4597 mset = new MemberSet(member, true); 4575 mset = new MemberSet(member, true);
4598 this._privateMembers.$setindex(member.name, mset); 4576 this._privateMembers.$setindex(member.name, mset);
4599 } 4577 }
4600 else { 4578 else {
4601 mset.get$members().add$1(member); 4579 mset.get$members().add$1(member);
4602 } 4580 }
4603 } 4581 }
4604 else { 4582 else {
4605 $globals.world._addMember(member); 4583 $globals.world._addMember(member);
4606 } 4584 }
4607 } 4585 }
4608 Library.prototype.getOrAddFunctionType = function(enclosingElement, name, func) { 4586 Library.prototype.getOrAddFunctionType = function(enclosingElement, name, func) {
4609 var def = new FunctionTypeDefinition(func, null, func.span); 4587 var def = new FunctionTypeDefinition(func, null, func.span);
4610 var type = new DefinedType(name, this, def, false); 4588 var type = new DefinedType(name, this, def, false);
4611 type.addMethod(':call', func); 4589 type.addMethod(":call", func);
4612 var m = type.members.$index(':call'); 4590 var m = type.members.$index(":call");
4613 m.set$enclosingElement(enclosingElement); 4591 m.set$enclosingElement(enclosingElement);
4614 m.resolve$0(); 4592 m.resolve$0();
4615 type.interfaces = [$globals.world.functionType]; 4593 type.interfaces = [$globals.world.functionType];
4616 return type; 4594 return type;
4617 } 4595 }
4618 Library.prototype.addType = function(name, definition, isClass) { 4596 Library.prototype.addType = function(name, definition, isClass) {
4619 if (this.types.containsKey(name)) { 4597 if (this.types.containsKey(name)) {
4620 var existingType = this.types.$index(name); 4598 var existingType = this.types.$index(name);
4621 if ((this.get$isCore() || this.get$isCoreImpl()) && existingType.get$definit ion() == null) { 4599 if ((this.get$isCore() || this.get$isCoreImpl()) && existingType.get$definit ion() == null) {
4622 existingType.setDefinition$1(definition); 4600 existingType.setDefinition$1(definition);
4623 } 4601 }
4624 else { 4602 else {
4625 $globals.world.warning(('duplicate definition of ' + name), definition.spa n, existingType.get$span()); 4603 $globals.world.warning(("duplicate definition of " + name), definition.spa n, existingType.get$span());
4626 } 4604 }
4627 } 4605 }
4628 else { 4606 else {
4629 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ; 4607 this.types.$setindex(name, new DefinedType(name, this, definition, isClass)) ;
4630 } 4608 }
4631 return this.types.$index(name); 4609 return this.types.$index(name);
4632 } 4610 }
4633 Library.prototype.findType = function(type) { 4611 Library.prototype.findType = function(type) {
4634 var result = this.findTypeByName(type.name.name); 4612 var result = this.findTypeByName(type.name.name);
4635 if (result == null) return null; 4613 if (result == null) return null;
(...skipping 15 matching lines...) Expand all
4651 var imported = $$list.$index($$i); 4629 var imported = $$list.$index($$i);
4652 var newRet = null; 4630 var newRet = null;
4653 if (imported.get$prefix() == null) { 4631 if (imported.get$prefix() == null) {
4654 newRet = imported.get$library().get$types().$index(name); 4632 newRet = imported.get$library().get$types().$index(name);
4655 } 4633 }
4656 else if ($eq(imported.get$prefix(), name)) { 4634 else if ($eq(imported.get$prefix(), name)) {
4657 newRet = imported.get$library().get$topType(); 4635 newRet = imported.get$library().get$topType();
4658 } 4636 }
4659 if (newRet != null) { 4637 if (newRet != null) {
4660 if (ret != null && $ne(ret, newRet)) { 4638 if (ret != null && $ne(ret, newRet)) {
4661 $globals.world.error(('conflicting types for "' + name + '"'), ret.get$s pan(), newRet.get$span()); 4639 $globals.world.error(("conflicting types for \"" + name + "\""), ret.get $span(), newRet.get$span());
4662 } 4640 }
4663 else { 4641 else {
4664 ret = newRet; 4642 ret = newRet;
4665 } 4643 }
4666 } 4644 }
4667 } 4645 }
4668 return ret; 4646 return ret;
4669 } 4647 }
4670 Library.prototype.resolveType = function(node, typeErrors) { 4648 Library.prototype.resolveType = function(node, typeErrors) {
4671 if (node == null) return $globals.world.varType; 4649 if (node == null) return $globals.world.varType;
4672 if (node.type != null) return node.type; 4650 if (node.type != null) return node.type;
4673 node.type = this.findType(node); 4651 node.type = this.findType(node);
4674 if (node.type == null) { 4652 if (node.type == null) {
4675 var message = ('cannot find type ' + Library._getDottedName(node)); 4653 var message = ("cannot find type " + Library._getDottedName(node));
4676 if (typeErrors) { 4654 if (typeErrors) {
4677 $globals.world.error(message, node.span); 4655 $globals.world.error(message, node.span);
4678 node.type = $globals.world.objectType; 4656 node.type = $globals.world.objectType;
4679 } 4657 }
4680 else { 4658 else {
4681 $globals.world.warning(message, node.span); 4659 $globals.world.warning(message, node.span);
4682 node.type = $globals.world.varType; 4660 node.type = $globals.world.varType;
4683 } 4661 }
4684 } 4662 }
4685 return node.type; 4663 return node.type;
4686 } 4664 }
4687 Library._getDottedName = function(type) { 4665 Library._getDottedName = function(type) {
4688 if (type.names != null) { 4666 if (type.names != null) {
4689 var names = map(type.names, (function (n) { 4667 var names = map(type.names, (function (n) {
4690 return n.get$name(); 4668 return n.get$name();
4691 }) 4669 })
4692 ); 4670 );
4693 return type.name.name + '.' + Strings.join(names, '.'); 4671 return type.name.name + "." + Strings.join(names, ".");
4694 } 4672 }
4695 else { 4673 else {
4696 return type.name.name; 4674 return type.name.name;
4697 } 4675 }
4698 } 4676 }
4699 Library.prototype.lookup = function(name, span) { 4677 Library.prototype.lookup = function(name, span) {
4700 var retType = this.findTypeByName(name); 4678 var retType = this.findTypeByName(name);
4701 var ret = null; 4679 var ret = null;
4702 if (retType != null) { 4680 if (retType != null) {
4703 ret = retType.get$typeMember(); 4681 ret = retType.get$typeMember();
4704 } 4682 }
4705 var newRet = this.topType.getMember(name); 4683 var newRet = this.topType.getMember(name);
4706 if (newRet != null) { 4684 if (newRet != null) {
4707 if (ret != null && $ne(ret, newRet)) { 4685 if (ret != null && $ne(ret, newRet)) {
4708 $globals.world.error(('conflicting members for "' + name + '"'), span, ret .get$span(), newRet.get$span()); 4686 $globals.world.error(("conflicting members for \"" + name + "\""), span, r et.get$span(), newRet.get$span());
4709 } 4687 }
4710 else { 4688 else {
4711 ret = newRet; 4689 ret = newRet;
4712 } 4690 }
4713 } 4691 }
4714 var $$list = this.imports; 4692 var $$list = this.imports;
4715 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4693 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4716 var imported = $$list.$index($$i); 4694 var imported = $$list.$index($$i);
4717 if (imported.get$prefix() == null) { 4695 if (imported.get$prefix() == null) {
4718 newRet = imported.get$library().get$topType().getMember$1(name); 4696 newRet = imported.get$library().get$topType().getMember$1(name);
4719 if (newRet != null) { 4697 if (newRet != null) {
4720 if (ret != null && $ne(ret, newRet)) { 4698 if (ret != null && $ne(ret, newRet)) {
4721 $globals.world.error(('conflicting members for "' + name + '"'), span, ret.get$span(), newRet.get$span()); 4699 $globals.world.error(("conflicting members for \"" + name + "\""), spa n, ret.get$span(), newRet.get$span());
4722 } 4700 }
4723 else { 4701 else {
4724 ret = newRet; 4702 ret = newRet;
4725 } 4703 }
4726 } 4704 }
4727 } 4705 }
4728 } 4706 }
4729 return ret; 4707 return ret;
4730 } 4708 }
4731 Library.prototype.resolve = function() { 4709 Library.prototype.resolve = function() {
4732 if (this.name == null) { 4710 if (this.name == null) {
4733 this.name = this.baseSource.filename; 4711 this.name = this.baseSource.filename;
4734 var index = this.name.lastIndexOf('/', this.name.length); 4712 var index = this.name.lastIndexOf("/", this.name.length);
4735 if (index >= 0) { 4713 if (index >= 0) {
4736 this.name = this.name.substring(index + 1); 4714 this.name = this.name.substring(index + 1);
4737 } 4715 }
4738 index = this.name.indexOf('.'); 4716 index = this.name.indexOf(".");
4739 if (index > 0) { 4717 if (index > 0) {
4740 this.name = this.name.substring(0, index); 4718 this.name = this.name.substring(0, index);
4741 } 4719 }
4742 } 4720 }
4743 this._jsname = this.name.replaceAll('.', '_').replaceAll(':', '_').replaceAll( ' ', '_'); 4721 this._jsname = this.name.replaceAll(".", "_").replaceAll(":", "_").replaceAll( " ", "_");
4744 var $$list = this.types.getValues(); 4722 var $$list = this.types.getValues();
4745 for (var $$i = this.types.getValues().iterator$0(); $$i.hasNext$0(); ) { 4723 for (var $$i = this.types.getValues().iterator$0(); $$i.hasNext$0(); ) {
4746 var type = $$i.next$0(); 4724 var type = $$i.next$0();
4747 type.resolve$0(); 4725 type.resolve$0();
4748 } 4726 }
4749 } 4727 }
4750 Library.prototype.visitSources = function() { 4728 Library.prototype.visitSources = function() {
4751 var visitor = new _LibraryVisitor(this); 4729 var visitor = new _LibraryVisitor(this);
4752 visitor.addSource$1(this.baseSource); 4730 visitor.addSource$1(this.baseSource);
4753 } 4731 }
(...skipping 21 matching lines...) Expand all
4775 // Initializers done 4753 // Initializers done
4776 this.currentType = this.library.topType; 4754 this.currentType = this.library.topType;
4777 this.sources = []; 4755 this.sources = [];
4778 } 4756 }
4779 _LibraryVisitor.prototype.get$library = function() { return this.library; }; 4757 _LibraryVisitor.prototype.get$library = function() { return this.library; };
4780 _LibraryVisitor.prototype.get$isTop = function() { return this.isTop; }; 4758 _LibraryVisitor.prototype.get$isTop = function() { return this.isTop; };
4781 _LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = valu e; }; 4759 _LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = valu e; };
4782 _LibraryVisitor.prototype.addSourceFromName = function(name, span) { 4760 _LibraryVisitor.prototype.addSourceFromName = function(name, span) {
4783 var filename = this.library.makeFullPath(name); 4761 var filename = this.library.makeFullPath(name);
4784 if ($eq(filename, this.library.baseSource.filename)) { 4762 if ($eq(filename, this.library.baseSource.filename)) {
4785 $globals.world.error('library can not source itself', span); 4763 $globals.world.error("library can not source itself", span);
4786 return; 4764 return;
4787 } 4765 }
4788 else if (this.sources.some((function (s) { 4766 else if (this.sources.some((function (s) {
4789 return $eq(s.get$filename(), filename); 4767 return $eq(s.get$filename(), filename);
4790 }) 4768 })
4791 )) { 4769 )) {
4792 $globals.world.error(('file "' + filename + '" has already been sourced'), s pan); 4770 $globals.world.error(("file \"" + filename + "\" has already been sourced"), span);
4793 return; 4771 return;
4794 } 4772 }
4795 var source = $globals.world.readFile(this.library.makeFullPath(name)); 4773 var source = $globals.world.readFile(this.library.makeFullPath(name));
4796 this.sources.add(source); 4774 this.sources.add(source);
4797 } 4775 }
4798 _LibraryVisitor.prototype.addSource = function(source) { 4776 _LibraryVisitor.prototype.addSource = function(source) {
4799 var $this = this; // closure support 4777 var $this = this; // closure support
4800 if (this.library.sources.some((function (s) { 4778 if (this.library.sources.some((function (s) {
4801 return $eq(s.get$filename(), source.filename); 4779 return $eq(s.get$filename(), source.filename);
4802 }) 4780 })
4803 )) { 4781 )) {
4804 $globals.world.error(('duplicate source file "' + source.filename + '"')); 4782 $globals.world.error(("duplicate source file \"" + source.filename + "\""));
4805 return; 4783 return;
4806 } 4784 }
4807 this.library.sources.add(source); 4785 this.library.sources.add(source);
4808 var parser = new Parser(source, $globals.options.dietParse, false, false, 0); 4786 var parser = new Parser(source, $globals.options.dietParse, false, false, 0);
4809 var unit = parser.compilationUnit(); 4787 var unit = parser.compilationUnit();
4810 unit.forEach((function (def) { 4788 unit.forEach((function (def) {
4811 return def.visit$1($this); 4789 return def.visit$1($this);
4812 }) 4790 })
4813 ); 4791 );
4814 this.isTop = false; 4792 this.isTop = false;
4815 var newSources = this.sources; 4793 var newSources = this.sources;
4816 this.sources = []; 4794 this.sources = [];
4817 for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) { 4795 for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) {
4818 var source0 = $$i.next$0(); 4796 var source0 = $$i.next$0();
4819 this.addSource(source0); 4797 this.addSource(source0);
4820 } 4798 }
4821 } 4799 }
4822 _LibraryVisitor.prototype.visitDirectiveDefinition = function(node) { 4800 _LibraryVisitor.prototype.visitDirectiveDefinition = function(node) {
4823 if (!this.isTop) { 4801 if (!this.isTop) {
4824 $globals.world.error('directives not allowed in sourced file', node.span); 4802 $globals.world.error("directives not allowed in sourced file", node.span);
4825 return; 4803 return;
4826 } 4804 }
4827 var name; 4805 var name;
4828 switch (node.name.name) { 4806 switch (node.name.name) {
4829 case "library": 4807 case "library":
4830 4808
4831 name = this.getSingleStringArg(node); 4809 name = this.getSingleStringArg(node);
4832 if (this.library.name == null) { 4810 if (this.library.name == null) {
4833 this.library.name = name; 4811 this.library.name = name;
4834 if ($eq(name, 'node') || $eq(name, 'dom')) { 4812 if ($eq(name, "node") || $eq(name, "dom")) {
4835 this.library.topType.isNative = true; 4813 this.library.topType.isNative = true;
4836 } 4814 }
4837 if (this.seenImport || this.seenSource || this.seenResource) { 4815 if (this.seenImport || this.seenSource || this.seenResource) {
4838 $globals.world.error('#library must be first directive in file', node. span); 4816 $globals.world.error("#library must be first directive in file", node. span);
4839 } 4817 }
4840 } 4818 }
4841 else { 4819 else {
4842 $globals.world.error('already specified library name', node.span); 4820 $globals.world.error("already specified library name", node.span);
4843 } 4821 }
4844 break; 4822 break;
4845 4823
4846 case "import": 4824 case "import":
4847 4825
4848 this.seenImport = true; 4826 this.seenImport = true;
4849 name = this.getFirstStringArg(node); 4827 name = this.getFirstStringArg(node);
4850 var prefix = this.tryGetNamedStringArg(node, 'prefix'); 4828 var prefix = this.tryGetNamedStringArg(node, "prefix");
4851 if (node.arguments.get$length() > 2 || node.arguments.get$length() == 2 && prefix == null) { 4829 if (node.arguments.get$length() > 2 || node.arguments.get$length() == 2 && prefix == null) {
4852 $globals.world.error('expected at most one "name" argument and one optio nal "prefix"' + (' but found ' + node.arguments.get$length()), node.span); 4830 $globals.world.error("expected at most one \"name\" argument and one opt ional \"prefix\"" + (" but found " + node.arguments.get$length()), node.span);
4853 } 4831 }
4854 else if (prefix != null && prefix.indexOf$1('.') >= 0) { 4832 else if (prefix != null && prefix.indexOf$1(".") >= 0) {
4855 $globals.world.error('library prefix canot contain "."', node.span); 4833 $globals.world.error("library prefix canot contain \".\"", node.span);
4856 } 4834 }
4857 else if (this.seenSource || this.seenResource) { 4835 else if (this.seenSource || this.seenResource) {
4858 $globals.world.error('#imports must come before any #source or #resource ', node.span); 4836 $globals.world.error("#imports must come before any #source or #resource ", node.span);
4859 } 4837 }
4860 if ($eq(prefix, '')) prefix = null; 4838 if ($eq(prefix, "")) prefix = null;
4861 var filename = this.library.makeFullPath(name); 4839 var filename = this.library.makeFullPath(name);
4862 if (this.library.imports.some((function (li) { 4840 if (this.library.imports.some((function (li) {
4863 return $eq(li.get$library().get$baseSource(), filename); 4841 return $eq(li.get$library().get$baseSource(), filename);
4864 }) 4842 })
4865 )) { 4843 )) {
4866 $globals.world.error(('duplicate import of "' + name + '"'), node.span); 4844 $globals.world.error(("duplicate import of \"" + name + "\""), node.span );
4867 return; 4845 return;
4868 } 4846 }
4869 var newLib = this.library.addImport(filename, prefix); 4847 var newLib = this.library.addImport(filename, prefix);
4870 break; 4848 break;
4871 4849
4872 case "source": 4850 case "source":
4873 4851
4874 this.seenSource = true; 4852 this.seenSource = true;
4875 name = this.getSingleStringArg(node); 4853 name = this.getSingleStringArg(node);
4876 this.addSourceFromName(name, node.span); 4854 this.addSourceFromName(name, node.span);
4877 if (this.seenResource) { 4855 if (this.seenResource) {
4878 $globals.world.error('#sources must come before any #resource', node.spa n); 4856 $globals.world.error("#sources must come before any #resource", node.spa n);
4879 } 4857 }
4880 break; 4858 break;
4881 4859
4882 case "native": 4860 case "native":
4883 4861
4884 name = this.getSingleStringArg(node); 4862 name = this.getSingleStringArg(node);
4885 this.library.addNative(this.library.makeFullPath(name)); 4863 this.library.addNative(this.library.makeFullPath(name));
4886 break; 4864 break;
4887 4865
4888 case "resource": 4866 case "resource":
4889 4867
4890 this.seenResource = true; 4868 this.seenResource = true;
4891 this.getFirstStringArg(node); 4869 this.getFirstStringArg(node);
4892 break; 4870 break;
4893 4871
4894 default: 4872 default:
4895 4873
4896 $globals.world.error(('unknown directive: ' + node.name.name), node.span); 4874 $globals.world.error(("unknown directive: " + node.name.name), node.span);
4897 4875
4898 } 4876 }
4899 } 4877 }
4900 _LibraryVisitor.prototype.getSingleStringArg = function(node) { 4878 _LibraryVisitor.prototype.getSingleStringArg = function(node) {
4901 if (node.arguments.get$length() != 1) { 4879 if (node.arguments.get$length() != 1) {
4902 $globals.world.error(('expected exactly one argument but found ' + node.argu ments.get$length()), node.span); 4880 $globals.world.error(("expected exactly one argument but found " + node.argu ments.get$length()), node.span);
4903 } 4881 }
4904 return this.getFirstStringArg(node); 4882 return this.getFirstStringArg(node);
4905 } 4883 }
4906 _LibraryVisitor.prototype.getFirstStringArg = function(node) { 4884 _LibraryVisitor.prototype.getFirstStringArg = function(node) {
4907 if (node.arguments.get$length() < 1) { 4885 if (node.arguments.get$length() < 1) {
4908 $globals.world.error(('expected at least one argument but found ' + node.arg uments.get$length()), node.span); 4886 $globals.world.error(("expected at least one argument but found " + node.arg uments.get$length()), node.span);
4909 } 4887 }
4910 var arg = node.arguments.$index(0); 4888 var arg = node.arguments.$index(0);
4911 if (arg.get$label() != null) { 4889 if (arg.get$label() != null) {
4912 $globals.world.error('label not allowed for directive', node.span); 4890 $globals.world.error("label not allowed for directive", node.span);
4913 } 4891 }
4914 return this._parseStringArgument(arg); 4892 return this._parseStringArgument(arg);
4915 } 4893 }
4916 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { 4894 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) {
4917 var args = node.arguments.filter((function (a) { 4895 var args = node.arguments.filter((function (a) {
4918 return a.get$label() != null && $eq(a.get$label().get$name(), argName); 4896 return a.get$label() != null && $eq(a.get$label().get$name(), argName);
4919 }) 4897 })
4920 ); 4898 );
4921 if ($eq(args.get$length(), 0)) { 4899 if ($eq(args.get$length(), 0)) {
4922 return null; 4900 return null;
4923 } 4901 }
4924 if (args.get$length() > 1) { 4902 if (args.get$length() > 1) {
4925 $globals.world.error(('expected at most one "' + argName + '" argument but f ound ') + node.arguments.get$length(), node.span); 4903 $globals.world.error(("expected at most one \"" + argName + "\" argument but found ") + node.arguments.get$length(), node.span);
4926 } 4904 }
4927 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) { 4905 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) {
4928 var arg = $$i.next$0(); 4906 var arg = $$i.next$0();
4929 return this._parseStringArgument(arg); 4907 return this._parseStringArgument(arg);
4930 } 4908 }
4931 } 4909 }
4932 _LibraryVisitor.prototype._parseStringArgument = function(arg) { 4910 _LibraryVisitor.prototype._parseStringArgument = function(arg) {
4933 var expr = arg.value; 4911 var expr = arg.value;
4934 if (!(expr instanceof LiteralExpression) || !expr.get$type().get$type().get$is String()) { 4912 if (!(expr instanceof LiteralExpression) || !expr.get$value().get$type().get$i sString()) {
4935 $globals.world.error('expected string', expr.get$span()); 4913 $globals.world.error("expected string literal", expr.get$span());
4936 } 4914 }
4937 return parseStringLiteral(expr.get$value()); 4915 return expr.get$value().get$actualValue();
4938 } 4916 }
4939 _LibraryVisitor.prototype.visitTypeDefinition = function(node) { 4917 _LibraryVisitor.prototype.visitTypeDefinition = function(node) {
4940 var oldType = this.currentType; 4918 var oldType = this.currentType;
4941 this.currentType = this.library.addType(node.name.name, node, node.isClass); 4919 this.currentType = this.library.addType(node.name.name, node, node.isClass);
4942 var $$list = node.body; 4920 var $$list = node.body;
4943 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 4921 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
4944 var member = $$list.$index($$i); 4922 var member = $$list.$index($$i);
4945 member.visit$1(this); 4923 member.visit$1(this);
4946 } 4924 }
4947 this.currentType = oldType; 4925 this.currentType = oldType;
4948 } 4926 }
4949 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { 4927 _LibraryVisitor.prototype.visitVariableDefinition = function(node) {
4950 this.currentType.addField(node); 4928 this.currentType.addField(node);
4951 } 4929 }
4952 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { 4930 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) {
4953 this.currentType.addMethod(node.name.name, node); 4931 this.currentType.addMethod(node.name.name, node);
4954 } 4932 }
4955 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { 4933 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) {
4956 var type = this.library.addType(node.func.name.name, node, false); 4934 var type = this.library.addType(node.func.name.name, node, false);
4957 type.addMethod$2(':call', node.func); 4935 type.addMethod$2(":call", node.func);
4958 } 4936 }
4959 _LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource; 4937 _LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource;
4960 // ********** Code for Parameter ************** 4938 // ********** Code for Parameter **************
4961 function Parameter(definition, method) { 4939 function Parameter(definition, method) {
4962 this.isInitializer = false 4940 this.isInitializer = false
4963 this.definition = definition; 4941 this.definition = definition;
4964 this.method = method; 4942 this.method = method;
4965 // Initializers done 4943 // Initializers done
4966 } 4944 }
4967 Parameter.prototype.get$definition = function() { return this.definition; }; 4945 Parameter.prototype.get$definition = function() { return this.definition; };
4968 Parameter.prototype.set$definition = function(value) { return this.definition = value; }; 4946 Parameter.prototype.set$definition = function(value) { return this.definition = value; };
4969 Parameter.prototype.get$method = function() { return this.method; }; 4947 Parameter.prototype.get$method = function() { return this.method; };
4970 Parameter.prototype.set$method = function(value) { return this.method = value; } ; 4948 Parameter.prototype.set$method = function(value) { return this.method = value; } ;
4971 Parameter.prototype.get$name = function() { return this.name; }; 4949 Parameter.prototype.get$name = function() { return this.name; };
4972 Parameter.prototype.set$name = function(value) { return this.name = value; }; 4950 Parameter.prototype.set$name = function(value) { return this.name = value; };
4973 Parameter.prototype.get$type = function() { return this.type; }; 4951 Parameter.prototype.get$type = function() { return this.type; };
4974 Parameter.prototype.set$type = function(value) { return this.type = value; }; 4952 Parameter.prototype.set$type = function(value) { return this.type = value; };
4975 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; }; 4953 Parameter.prototype.get$isInitializer = function() { return this.isInitializer; };
4976 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; }; 4954 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali zer = value; };
4977 Parameter.prototype.get$value = function() { return this.value; }; 4955 Parameter.prototype.get$value = function() { return this.value; };
4978 Parameter.prototype.set$value = function(value) { return this.value = value; }; 4956 Parameter.prototype.set$value = function(value) { return this.value = value; };
4979 Parameter.prototype.resolve = function() { 4957 Parameter.prototype.resolve = function() {
4980 this.name = this.definition.name.name; 4958 this.name = this.definition.name.name;
4981 if (this.name.startsWith('this.')) { 4959 if (this.name.startsWith("this.")) {
4982 this.name = this.name.substring(5); 4960 this.name = this.name.substring(5);
4983 this.isInitializer = true; 4961 this.isInitializer = true;
4984 } 4962 }
4985 this.type = this.method.resolveType(this.definition.type, false); 4963 this.type = this.method.resolveType(this.definition.type, false);
4986 if (this.definition.value != null) { 4964 if (this.definition.value != null) {
4987 if (!this.get$hasDefaultValue()) return; 4965 if (this.definition.value.span.start == this.definition.span.start) {
4988 if (this.method.name == ':call') { 4966 return;
4967 }
4968 if (this.method.name == ":call") {
4989 if (this.method.get$definition().get$body() == null && !this.method.get$is Native()) { 4969 if (this.method.get$definition().get$body() == null && !this.method.get$is Native()) {
4990 $globals.world.error('default value not allowed on function type', this. definition.span); 4970 $globals.world.error("default value not allowed on function type", this. definition.span);
4991 } 4971 }
4992 } 4972 }
4993 else if (this.method.get$isAbstract()) { 4973 else if (this.method.get$isAbstract()) {
4994 $globals.world.error('default value not allowed on abstract methods', this .definition.span); 4974 $globals.world.error("default value not allowed on abstract methods", this .definition.span);
4995 } 4975 }
4996 } 4976 }
4997 else if (this.isInitializer && !this.method.get$isConstructor()) { 4977 else if (this.isInitializer && !this.method.get$isConstructor()) {
4998 $globals.world.error('initializer parameters only allowed on constructors', this.definition.span); 4978 $globals.world.error("initializer parameters only allowed on constructors", this.definition.span);
4999 } 4979 }
5000 } 4980 }
5001 Parameter.prototype.genValue = function(method, context) { 4981 Parameter.prototype.genValue = function(method, context) {
5002 if (this.definition.value == null || this.value != null) return; 4982 if (this.definition.value == null || this.value != null) return;
5003 if (context == null) { 4983 if (context == null) {
5004 context = new MethodGenerator(method, null); 4984 context = new MethodGenerator(method, null);
5005 } 4985 }
5006 this.value = this.definition.value.visit(context); 4986 this.value = this.definition.value.visit(context);
5007 if (!this.value.get$isConst()) { 4987 if (!this.value.get$isConst()) {
5008 $globals.world.error('default parameter values must be constant', this.value .span); 4988 $globals.world.error("default parameter values must be constant", this.value .span);
5009 } 4989 }
5010 this.value = this.value.convertTo(context, this.type, false); 4990 this.value = this.value.convertTo(context, this.type, false);
5011 } 4991 }
5012 Parameter.prototype.copyWithNewType = function(newMethod, newType) { 4992 Parameter.prototype.copyWithNewType = function(newMethod, newType) {
5013 var ret = new Parameter(this.definition, newMethod); 4993 var ret = new Parameter(this.definition, newMethod);
5014 ret.set$type(newType); 4994 ret.set$type(newType);
5015 ret.set$name(this.name); 4995 ret.set$name(this.name);
5016 ret.set$isInitializer(this.isInitializer); 4996 ret.set$isInitializer(this.isInitializer);
5017 return ret; 4997 return ret;
5018 } 4998 }
5019 Parameter.prototype.get$isOptional = function() { 4999 Parameter.prototype.get$isOptional = function() {
5020 return this.definition != null && this.definition.value != null; 5000 return this.definition != null && this.definition.value != null;
5021 } 5001 }
5022 Parameter.prototype.get$hasDefaultValue = function() {
5023 return !(this.definition.value instanceof NullExpression) || (this.definition. value.span.start != this.definition.span.start);
5024 }
5025 Parameter.prototype.copyWithNewType$2 = Parameter.prototype.copyWithNewType; 5002 Parameter.prototype.copyWithNewType$2 = Parameter.prototype.copyWithNewType;
5026 Parameter.prototype.genValue$2 = Parameter.prototype.genValue; 5003 Parameter.prototype.genValue$2 = Parameter.prototype.genValue;
5027 Parameter.prototype.resolve$0 = Parameter.prototype.resolve; 5004 Parameter.prototype.resolve$0 = Parameter.prototype.resolve;
5028 // ********** Code for Member ************** 5005 // ********** Code for Member **************
5029 $inherits(Member, Element); 5006 $inherits(Member, Element);
5030 function Member(name, declaringType) { 5007 function Member(name, declaringType) {
5031 this._providePropertySyntax = false 5008 this._providePropertySyntax = false
5032 this._provideFieldSyntax = false 5009 this._provideFieldSyntax = false
5033 this.isGenerated = false; 5010 this.isGenerated = false;
5034 this.declaringType = declaringType; 5011 this.declaringType = declaringType;
5035 // Initializers done 5012 // Initializers done
5036 Element.call(this, name, declaringType); 5013 Element.call(this, name, declaringType);
5037 } 5014 }
5038 Member.prototype.get$declaringType = function() { return this.declaringType; }; 5015 Member.prototype.get$declaringType = function() { return this.declaringType; };
5039 Member.prototype.get$isGenerated = function() { return this.isGenerated; }; 5016 Member.prototype.get$isGenerated = function() { return this.isGenerated; };
5040 Member.prototype.set$isGenerated = function(value) { return this.isGenerated = v alue; }; 5017 Member.prototype.set$isGenerated = function(value) { return this.isGenerated = v alue; };
5041 Member.prototype.get$generator = function() { return this.generator; }; 5018 Member.prototype.get$generator = function() { return this.generator; };
5042 Member.prototype.set$generator = function(value) { return this.generator = value ; }; 5019 Member.prototype.set$generator = function(value) { return this.generator = value ; };
5043 Member.prototype.get$library = function() { 5020 Member.prototype.get$library = function() {
5044 return this.declaringType.get$library(); 5021 return this.declaringType.get$library();
5045 } 5022 }
5046 Member.prototype.get$isPrivate = function() { 5023 Member.prototype.get$isPrivate = function() {
5047 return this.name.startsWith('_'); 5024 return this.name.startsWith("_");
5048 } 5025 }
5049 Member.prototype.get$isConstructor = function() { 5026 Member.prototype.get$isConstructor = function() {
5050 return false; 5027 return false;
5051 } 5028 }
5052 Member.prototype.get$isField = function() { 5029 Member.prototype.get$isField = function() {
5053 return false; 5030 return false;
5054 } 5031 }
5055 Member.prototype.get$isMethod = function() { 5032 Member.prototype.get$isMethod = function() {
5056 return false; 5033 return false;
5057 } 5034 }
5058 Member.prototype.get$isProperty = function() { 5035 Member.prototype.get$isProperty = function() {
5059 return false; 5036 return false;
5060 } 5037 }
5061 Member.prototype.get$isAbstract = function() { 5038 Member.prototype.get$isAbstract = function() {
5062 return false; 5039 return false;
5063 } 5040 }
5064 Member.prototype.get$isFinal = function() { 5041 Member.prototype.get$isFinal = function() {
5065 return false; 5042 return false;
5066 } 5043 }
5067 Member.prototype.get$isConst = function() { 5044 Member.prototype.get$isConst = function() {
5068 return false; 5045 return false;
5069 } 5046 }
5070 Member.prototype.get$isFactory = function() { 5047 Member.prototype.get$isFactory = function() {
5071 return false; 5048 return false;
5072 } 5049 }
5073 Member.prototype.get$isOperator = function() { 5050 Member.prototype.get$isOperator = function() {
5074 return this.name.startsWith(':'); 5051 return this.name.startsWith(":");
5075 } 5052 }
5076 Member.prototype.get$isCallMethod = function() { 5053 Member.prototype.get$isCallMethod = function() {
5077 return this.name == ':call'; 5054 return this.name == ":call";
5078 } 5055 }
5079 Member.prototype.get$requiresPropertySyntax = function() { 5056 Member.prototype.get$requiresPropertySyntax = function() {
5080 return false; 5057 return false;
5081 } 5058 }
5082 Member.prototype.get$requiresFieldSyntax = function() { 5059 Member.prototype.get$requiresFieldSyntax = function() {
5083 return false; 5060 return false;
5084 } 5061 }
5085 Member.prototype.get$isNative = function() { 5062 Member.prototype.get$isNative = function() {
5086 return false; 5063 return false;
5087 } 5064 }
5088 Member.prototype.get$constructorName = function() { 5065 Member.prototype.get$constructorName = function() {
5089 $globals.world.internalError('can not be a constructor', this.get$span()); 5066 $globals.world.internalError("can not be a constructor", this.get$span());
5090 } 5067 }
5091 Member.prototype.provideFieldSyntax = function() { 5068 Member.prototype.provideFieldSyntax = function() {
5092 5069
5093 } 5070 }
5094 Member.prototype.providePropertySyntax = function() { 5071 Member.prototype.providePropertySyntax = function() {
5095 5072
5096 } 5073 }
5097 Member.prototype.get$initDelegate = function() { 5074 Member.prototype.get$initDelegate = function() {
5098 $globals.world.internalError('cannot have initializers', this.get$span()); 5075 $globals.world.internalError("cannot have initializers", this.get$span());
5099 } 5076 }
5100 Member.prototype.set$initDelegate = function(ctor) { 5077 Member.prototype.set$initDelegate = function(ctor) {
5101 $globals.world.internalError('cannot have initializers', this.get$span()); 5078 $globals.world.internalError("cannot have initializers", this.get$span());
5102 } 5079 }
5103 Member.prototype.computeValue = function() { 5080 Member.prototype.computeValue = function() {
5104 $globals.world.internalError('cannot have value', this.get$span()); 5081 $globals.world.internalError("cannot have value", this.get$span());
5105 } 5082 }
5106 Member.prototype.get$inferredResult = function() { 5083 Member.prototype.get$inferredResult = function() {
5107 var t = this.get$returnType(); 5084 var t = this.get$returnType();
5108 if (t.get$isBool() && (this.get$library().get$isCore() || this.get$library().g et$isCoreImpl())) { 5085 if (t.get$isBool() && (this.get$library().get$isCore() || this.get$library().g et$isCoreImpl())) {
5109 return $globals.world.nonNullBool; 5086 return $globals.world.nonNullBool;
5110 } 5087 }
5111 return t; 5088 return t;
5112 } 5089 }
5113 Member.prototype.get$definition = function() { 5090 Member.prototype.get$definition = function() {
5114 return null; 5091 return null;
5115 } 5092 }
5116 Member.prototype.get$parameters = function() { 5093 Member.prototype.get$parameters = function() {
5117 return []; 5094 return [];
5118 } 5095 }
5119 Member.prototype.canInvoke = function(context, args) { 5096 Member.prototype.canInvoke = function(context, args) {
5120 return this.get$canGet() && new Value(this.get$returnType(), null, null, true) .canInvoke(context, ':call', args); 5097 return this.get$canGet() && new Value(this.get$returnType(), null, null, true) .canInvoke(context, ":call", args);
5121 } 5098 }
5122 Member.prototype.invoke = function(context, node, target, args, isDynamic) { 5099 Member.prototype.invoke = function(context, node, target, args, isDynamic) {
5123 var newTarget = this._get(context, node, target, isDynamic); 5100 var newTarget = this._get(context, node, target, isDynamic);
5124 return newTarget.invoke$5(context, ':call', node, args, isDynamic); 5101 return newTarget.invoke$5(context, ":call", node, args, isDynamic);
5125 } 5102 }
5126 Member.prototype.override = function(other) { 5103 Member.prototype.override = function(other) {
5127 if (this.get$isStatic()) { 5104 if (this.get$isStatic()) {
5128 $globals.world.error('static members can not hide parent members', this.get$ span(), other.get$span()); 5105 $globals.world.error("static members can not hide parent members", this.get$ span(), other.get$span());
5129 return false; 5106 return false;
5130 } 5107 }
5131 else if (other.get$isStatic()) { 5108 else if (other.get$isStatic()) {
5132 $globals.world.error('can not override static member', this.get$span(), othe r.get$span()); 5109 $globals.world.error("can not override static member", this.get$span(), othe r.get$span());
5133 return false; 5110 return false;
5134 } 5111 }
5135 return true; 5112 return true;
5136 } 5113 }
5137 Member.prototype.get$generatedFactoryName = function() { 5114 Member.prototype.get$generatedFactoryName = function() {
5138 var prefix = ('' + this.declaringType.get$jsname() + '.' + this.get$constructo rName() + '\$'); 5115 var prefix = ("" + this.declaringType.get$jsname() + "." + this.get$constructo rName() + "$");
5139 if (this.name == '') { 5116 if (this.name == "") {
5140 return ('' + prefix + 'factory'); 5117 return ("" + prefix + "factory");
5141 } 5118 }
5142 else { 5119 else {
5143 return ('' + prefix + this.name + '\$factory'); 5120 return ("" + prefix + this.name + "$factory");
5144 } 5121 }
5145 } 5122 }
5146 Member.prototype.hashCode = function() { 5123 Member.prototype.hashCode = function() {
5147 var typeCode = this.declaringType == null ? 1 : this.declaringType.hashCode(); 5124 var typeCode = this.declaringType == null ? 1 : this.declaringType.hashCode();
5148 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode( ) : this.name.hashCode(); 5125 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode( ) : this.name.hashCode();
5149 return (typeCode << 4) ^ nameCode; 5126 return (typeCode << 4) ^ nameCode;
5150 } 5127 }
5151 Member.prototype.$eq = function(other) { 5128 Member.prototype.$eq = function(other) {
5152 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()); 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());
5153 } 5130 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5193 TypeMember.prototype.get$canSet = function() { 5170 TypeMember.prototype.get$canSet = function() {
5194 return false; 5171 return false;
5195 } 5172 }
5196 TypeMember.prototype.get$requiresFieldSyntax = function() { 5173 TypeMember.prototype.get$requiresFieldSyntax = function() {
5197 return true; 5174 return true;
5198 } 5175 }
5199 TypeMember.prototype._get = function(context, node, target, isDynamic) { 5176 TypeMember.prototype._get = function(context, node, target, isDynamic) {
5200 return new Value.type$ctor(this.type, node.span); 5177 return new Value.type$ctor(this.type, node.span);
5201 } 5178 }
5202 TypeMember.prototype._set = function(context, node, target, value, isDynamic) { 5179 TypeMember.prototype._set = function(context, node, target, value, isDynamic) {
5203 $globals.world.error('cannot set type', node.span); 5180 $globals.world.error("cannot set type", node.span);
5204 } 5181 }
5205 TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) { 5182 TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) {
5206 $globals.world.error('cannot invoke type', node.span); 5183 $globals.world.error("cannot invoke type", node.span);
5207 } 5184 }
5208 TypeMember.prototype._get$3 = function($0, $1, $2) { 5185 TypeMember.prototype._get$3 = function($0, $1, $2) {
5209 return this._get($0, $1, $2, false); 5186 return this._get($0, $1, $2, false);
5210 }; 5187 };
5211 TypeMember.prototype._get$3$isDynamic = TypeMember.prototype._get; 5188 TypeMember.prototype._get$3$isDynamic = TypeMember.prototype._get;
5212 TypeMember.prototype._get$4 = TypeMember.prototype._get; 5189 TypeMember.prototype._get$4 = TypeMember.prototype._get;
5213 TypeMember.prototype._set$4 = function($0, $1, $2, $3) { 5190 TypeMember.prototype._set$4 = function($0, $1, $2, $3) {
5214 return this._set($0, $1, $2, $3, false); 5191 return this._set($0, $1, $2, $3, false);
5215 }; 5192 };
5216 TypeMember.prototype._set$4$isDynamic = TypeMember.prototype._set; 5193 TypeMember.prototype._set$4$isDynamic = TypeMember.prototype._set;
(...skipping 23 matching lines...) Expand all
5240 FieldMember.prototype.get$isFinal = function() { return this.isFinal; }; 5217 FieldMember.prototype.get$isFinal = function() { return this.isFinal; };
5241 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu e; }; 5218 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu e; };
5242 FieldMember.prototype.get$isNative = function() { return this.isNative; }; 5219 FieldMember.prototype.get$isNative = function() { return this.isNative; };
5243 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va lue; }; 5220 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va lue; };
5244 FieldMember.prototype.override = function(other) { 5221 FieldMember.prototype.override = function(other) {
5245 if (!Member.prototype.override.call(this, other)) return false; 5222 if (!Member.prototype.override.call(this, other)) return false;
5246 if (other.get$isProperty()) { 5223 if (other.get$isProperty()) {
5247 return true; 5224 return true;
5248 } 5225 }
5249 else { 5226 else {
5250 $globals.world.error('field can not override anything but property', this.ge t$span(), other.get$span()); 5227 $globals.world.error("field can not override anything but property", this.ge t$span(), other.get$span());
5251 return false; 5228 return false;
5252 } 5229 }
5253 } 5230 }
5254 FieldMember.prototype.provideFieldSyntax = function() { 5231 FieldMember.prototype.provideFieldSyntax = function() {
5255 5232
5256 } 5233 }
5257 FieldMember.prototype.providePropertySyntax = function() { 5234 FieldMember.prototype.providePropertySyntax = function() {
5258 this._providePropertySyntax = true; 5235 this._providePropertySyntax = true;
5259 } 5236 }
5260 FieldMember.prototype.get$span = function() { 5237 FieldMember.prototype.get$span = function() {
(...skipping 13 matching lines...) Expand all
5274 } 5251 }
5275 FieldMember.prototype.resolve = function() { 5252 FieldMember.prototype.resolve = function() {
5276 this.isStatic = this.declaringType.get$isTop(); 5253 this.isStatic = this.declaringType.get$isTop();
5277 this.isFinal = false; 5254 this.isFinal = false;
5278 if (this.definition.modifiers != null) { 5255 if (this.definition.modifiers != null) {
5279 var $$list = this.definition.modifiers; 5256 var $$list = this.definition.modifiers;
5280 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 5257 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5281 var mod = $$list.$index($$i); 5258 var mod = $$list.$index($$i);
5282 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) { 5259 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) {
5283 if (this.isStatic) { 5260 if (this.isStatic) {
5284 $globals.world.error('duplicate static modifier', mod.get$span()); 5261 $globals.world.error("duplicate static modifier", mod.get$span());
5285 } 5262 }
5286 this.isStatic = true; 5263 this.isStatic = true;
5287 } 5264 }
5288 else if ($eq(mod.get$kind(), 98/*TokenKind.FINAL*/)) { 5265 else if ($eq(mod.get$kind(), 98/*TokenKind.FINAL*/)) {
5289 if (this.isFinal) { 5266 if (this.isFinal) {
5290 $globals.world.error('duplicate final modifier', mod.get$span()); 5267 $globals.world.error("duplicate final modifier", mod.get$span());
5291 } 5268 }
5292 this.isFinal = true; 5269 this.isFinal = true;
5293 } 5270 }
5294 else { 5271 else {
5295 $globals.world.error(('' + mod + ' modifier not allowed on field'), mod. get$span()); 5272 $globals.world.error(("" + mod + " modifier not allowed on field"), mod. get$span());
5296 } 5273 }
5297 } 5274 }
5298 } 5275 }
5299 this.type = this.resolveType(this.definition.type, false); 5276 this.type = this.resolveType(this.definition.type, false);
5300 if (this.isStatic && !this.get$isFactory() && this.type.get$hasTypeParams()) { 5277 if (this.isStatic && !this.get$isFactory() && this.type.get$hasTypeParams()) {
5301 $globals.world.error('using type parameter in static context', this.definiti on.type.span); 5278 $globals.world.error("using type parameter in static context", this.definiti on.type.span);
5302 } 5279 }
5303 if (this.isStatic && this.isFinal && this.value == null) { 5280 if (this.isStatic && this.isFinal && this.value == null) {
5304 $globals.world.error('static final field is missing initializer', this.get$s pan()); 5281 $globals.world.error("static final field is missing initializer", this.get$s pan());
5305 } 5282 }
5306 this.get$library()._addMember(this); 5283 this.get$library()._addMember(this);
5307 } 5284 }
5308 FieldMember.prototype.computeValue = function() { 5285 FieldMember.prototype.computeValue = function() {
5309 if (this.value == null) return null; 5286 if (this.value == null) return null;
5310 if (this._computedValue == null) { 5287 if (this._computedValue == null) {
5311 if (this._computing) { 5288 if (this._computing) {
5312 $globals.world.error('circular reference', this.value.span); 5289 $globals.world.error("circular reference", this.value.span);
5313 return null; 5290 return null;
5314 } 5291 }
5315 this._computing = true; 5292 this._computing = true;
5316 var finalMethod = new MethodMember('final_context', this.declaringType, null ); 5293 var finalMethod = new MethodMember("final_context", this.declaringType, null );
5317 finalMethod.set$isStatic(true); 5294 finalMethod.set$isStatic(true);
5318 var finalGen = new MethodGenerator(finalMethod, null); 5295 var finalGen = new MethodGenerator(finalMethod, null);
5319 this._computedValue = this.value.visit(finalGen); 5296 this._computedValue = this.value.visit(finalGen);
5320 if (!this._computedValue.get$isConst()) { 5297 if (!this._computedValue.get$isConst()) {
5321 if (this.isStatic) { 5298 if (this.isStatic) {
5322 $globals.world.error('non constant static field must be initialized in f unctions', this.value.span); 5299 $globals.world.error("non constant static field must be initialized in f unctions", this.value.span);
5323 } 5300 }
5324 else { 5301 else {
5325 $globals.world.error('non constant field must be initialized in construc tor', this.value.span); 5302 $globals.world.error("non constant field must be initialized in construc tor", this.value.span);
5326 } 5303 }
5327 } 5304 }
5328 if (this.isStatic) { 5305 if (this.isStatic) {
5329 this._computedValue = $globals.world.gen.globalForStaticField(this, this._ computedValue, [this._computedValue]); 5306 this._computedValue = $globals.world.gen.globalForStaticField(this, this._ computedValue, [this._computedValue]);
5330 } 5307 }
5331 this._computing = false; 5308 this._computing = false;
5332 } 5309 }
5333 return this._computedValue; 5310 return this._computedValue;
5334 } 5311 }
5335 FieldMember.prototype._get = function(context, node, target, isDynamic) { 5312 FieldMember.prototype._get = function(context, node, target, isDynamic) {
5336 if (this.isNative && this.get$returnType() != null) { 5313 if (this.isNative && this.get$returnType() != null) {
5337 this.get$returnType().markUsed(); 5314 this.get$returnType().markUsed();
5338 if ((this.get$returnType() instanceof DefinedType)) { 5315 if ((this.get$returnType() instanceof DefinedType)) {
5339 var defaultType = this.get$returnType().get$genericType().defaultType; 5316 var defaultType = this.get$returnType().get$genericType().defaultType;
5340 if (defaultType != null && defaultType.get$isNative()) { 5317 if (defaultType != null && defaultType.get$isNative()) {
5341 defaultType.markUsed$0(); 5318 defaultType.markUsed$0();
5342 } 5319 }
5343 } 5320 }
5344 } 5321 }
5345 if (this.isStatic) { 5322 if (this.isStatic) {
5346 this.declaringType.markUsed(); 5323 this.declaringType.markUsed();
5347 var cv = this.computeValue(); 5324 var cv = this.computeValue();
5348 if (this.isFinal) { 5325 if (this.isFinal) {
5349 return cv; 5326 return cv;
5350 } 5327 }
5351 $globals.world.gen.hasStatics = true; 5328 $globals.world.gen.hasStatics = true;
5352 if (this.declaringType.get$isTop()) { 5329 if (this.declaringType.get$isTop()) {
5353 if (this.declaringType.get$library().get$isDom()) { 5330 if (this.declaringType.get$library().get$isDom()) {
5354 return new Value(this.type, ('' + this.get$jsname()), node.span, true); 5331 return new Value(this.type, ("" + this.get$jsname()), node.span, true);
5355 } 5332 }
5356 else { 5333 else {
5357 return new Value(this.type, ('\$globals.' + this.get$jsname()), node.spa n, true); 5334 return new Value(this.type, ("$globals." + this.get$jsname()), node.span , true);
5358 } 5335 }
5359 } 5336 }
5360 else if (this.declaringType.get$isNative()) { 5337 else if (this.declaringType.get$isNative()) {
5361 if (this.declaringType.get$isHiddenNativeType()) { 5338 if (this.declaringType.get$isHiddenNativeType()) {
5362 $globals.world.error('static field of hidden native type is inaccessible ', node.span); 5339 $globals.world.error("static field of hidden native type is inaccessible ", node.span);
5363 } 5340 }
5364 return new Value(this.type, ('' + this.declaringType.get$jsname() + '.' + this.get$jsname()), node.span, true); 5341 return new Value(this.type, ("" + this.declaringType.get$jsname() + "." + this.get$jsname()), node.span, true);
5365 } 5342 }
5366 else { 5343 else {
5367 return new Value(this.type, ('\$globals.' + this.declaringType.get$jsname( ) + '_' + this.get$jsname()), node.span, true); 5344 return new Value(this.type, ("$globals." + this.declaringType.get$jsname() + "_" + this.get$jsname()), node.span, true);
5368 } 5345 }
5369 } 5346 }
5370 else if (target.get$isConst() && this.isFinal) { 5347 else if (target.get$isConst() && this.isFinal) {
5371 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get $exp() : target; 5348 var constTarget = (target instanceof GlobalValue) ? target.get$dynamic().get $exp() : target;
5372 if ((constTarget instanceof ConstObjectValue)) { 5349 if ((constTarget instanceof ConstObjectValue)) {
5373 return constTarget.get$fields().$index(this.name); 5350 return constTarget.get$fields().$index(this.name);
5374 } 5351 }
5375 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name == 'length') { 5352 else if ($eq(constTarget.get$type(), $globals.world.stringType) && this.name == "length") {
5376 return new Value(this.type, ('' + constTarget.get$actualValue().get$length ()), node.span, true); 5353 return new Value(this.type, ("" + constTarget.get$actualValue().get$length ()), node.span, true);
5377 } 5354 }
5378 } 5355 }
5379 return new Value(this.type, ('' + target.code + '.' + this.get$jsname()), node .span, true); 5356 return new Value(this.type, ("" + target.code + "." + this.get$jsname()), node .span, true);
5380 } 5357 }
5381 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { 5358 FieldMember.prototype._set = function(context, node, target, value, isDynamic) {
5382 var lhs = this._get(context, node, target, isDynamic); 5359 var lhs = this._get(context, node, target, isDynamic);
5383 value = value.convertTo(context, this.type, isDynamic); 5360 value = value.convertTo(context, this.type, isDynamic);
5384 return new Value(this.type, ('' + lhs.get$code() + ' = ' + value.code), node.s pan, true); 5361 return new Value(this.type, ("" + lhs.get$code() + " = " + value.code), node.s pan, true);
5385 } 5362 }
5386 FieldMember.prototype._get$3 = function($0, $1, $2) { 5363 FieldMember.prototype._get$3 = function($0, $1, $2) {
5387 return this._get($0, $1, $2, false); 5364 return this._get($0, $1, $2, false);
5388 }; 5365 };
5389 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get; 5366 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get;
5390 FieldMember.prototype._get$4 = FieldMember.prototype._get; 5367 FieldMember.prototype._get$4 = FieldMember.prototype._get;
5391 FieldMember.prototype._set$4 = function($0, $1, $2, $3) { 5368 FieldMember.prototype._set$4 = function($0, $1, $2, $3) {
5392 return this._set($0, $1, $2, $3, false); 5369 return this._set($0, $1, $2, $3, false);
5393 }; 5370 };
5394 FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set; 5371 FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 return this.getter == null ? this.setter.returnType : this.getter.returnType; 5414 return this.getter == null ? this.setter.returnType : this.getter.returnType;
5438 } 5415 }
5439 PropertyMember.prototype.override = function(other) { 5416 PropertyMember.prototype.override = function(other) {
5440 if (!Member.prototype.override.call(this, other)) return false; 5417 if (!Member.prototype.override.call(this, other)) return false;
5441 if (other.get$isProperty() || other.get$isField()) { 5418 if (other.get$isProperty() || other.get$isField()) {
5442 if (other.get$isProperty()) this.addFromParent(other); 5419 if (other.get$isProperty()) this.addFromParent(other);
5443 else this._overriddenField = other; 5420 else this._overriddenField = other;
5444 return true; 5421 return true;
5445 } 5422 }
5446 else { 5423 else {
5447 $globals.world.error('property can only override field or property', this.ge t$span(), other.get$span()); 5424 $globals.world.error("property can only override field or property", this.ge t$span(), other.get$span());
5448 return false; 5425 return false;
5449 } 5426 }
5450 } 5427 }
5451 PropertyMember.prototype._get = function(context, node, target, isDynamic) { 5428 PropertyMember.prototype._get = function(context, node, target, isDynamic) {
5452 if (this.getter == null) { 5429 if (this.getter == null) {
5453 if (this._overriddenField != null) { 5430 if (this._overriddenField != null) {
5454 return this._overriddenField._get(context, node, target, isDynamic); 5431 return this._overriddenField._get(context, node, target, isDynamic);
5455 } 5432 }
5456 return target.invokeNoSuchMethod(context, ('get:' + this.name), node); 5433 return target.invokeNoSuchMethod(context, ("get:" + this.name), node);
5457 } 5434 }
5458 return this.getter.invoke(context, node, target, Arguments.get$EMPTY(), false) ; 5435 return this.getter.invoke(context, node, target, Arguments.get$EMPTY(), false) ;
5459 } 5436 }
5460 PropertyMember.prototype._set = function(context, node, target, value, isDynamic ) { 5437 PropertyMember.prototype._set = function(context, node, target, value, isDynamic ) {
5461 if (this.setter == null) { 5438 if (this.setter == null) {
5462 if (this._overriddenField != null) { 5439 if (this._overriddenField != null) {
5463 return this._overriddenField._set(context, node, target, value, isDynamic) ; 5440 return this._overriddenField._set(context, node, target, value, isDynamic) ;
5464 } 5441 }
5465 return target.invokeNoSuchMethod(context, ('set:' + this.name), node, new Ar guments(null, [value])); 5442 return target.invokeNoSuchMethod(context, ("set:" + this.name), node, new Ar guments(null, [value]));
5466 } 5443 }
5467 return this.setter.invoke(context, node, target, new Arguments(null, [value]), isDynamic); 5444 return this.setter.invoke(context, node, target, new Arguments(null, [value]), isDynamic);
5468 } 5445 }
5469 PropertyMember.prototype.addFromParent = function(parentMember) { 5446 PropertyMember.prototype.addFromParent = function(parentMember) {
5470 var parent; 5447 var parent;
5471 if ((parentMember instanceof ConcreteMember)) { 5448 if ((parentMember instanceof ConcreteMember)) {
5472 var c = parentMember; 5449 var c = parentMember;
5473 parent = c.baseMember; 5450 parent = c.baseMember;
5474 } 5451 }
5475 else { 5452 else {
5476 parent = parentMember; 5453 parent = parentMember;
5477 } 5454 }
5478 if (this.getter == null) this.getter = parent.getter; 5455 if (this.getter == null) this.getter = parent.getter;
5479 if (this.setter == null) this.setter = parent.setter; 5456 if (this.setter == null) this.setter = parent.setter;
5480 } 5457 }
5481 PropertyMember.prototype.resolve = function() { 5458 PropertyMember.prototype.resolve = function() {
5482 if (this.getter != null) { 5459 if (this.getter != null) {
5483 this.getter.resolve(); 5460 this.getter.resolve();
5484 if (this.getter.parameters.get$length() != 0) { 5461 if (this.getter.parameters.get$length() != 0) {
5485 $globals.world.error('getter methods should take no arguments', this.gette r.definition.span); 5462 $globals.world.error("getter methods should take no arguments", this.gette r.definition.span);
5486 } 5463 }
5487 if (this.getter.returnType.get$isVoid()) { 5464 if (this.getter.returnType.get$isVoid()) {
5488 $globals.world.warning('getter methods should not be void', this.getter.de finition.returnType.span); 5465 $globals.world.warning("getter methods should not be void", this.getter.de finition.returnType.span);
5489 } 5466 }
5490 } 5467 }
5491 if (this.setter != null) { 5468 if (this.setter != null) {
5492 this.setter.resolve(); 5469 this.setter.resolve();
5493 if (this.setter.parameters.get$length() != 1) { 5470 if (this.setter.parameters.get$length() != 1) {
5494 $globals.world.error('setter methods should take a single argument', this. setter.definition.span); 5471 $globals.world.error("setter methods should take a single argument", this. setter.definition.span);
5495 } 5472 }
5496 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) { 5473 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp e != null) {
5497 $globals.world.warning('setter methods should be void', this.setter.defini tion.returnType.span); 5474 $globals.world.warning("setter methods should be void", this.setter.defini tion.returnType.span);
5498 } 5475 }
5499 } 5476 }
5500 this.get$library()._addMember(this); 5477 this.get$library()._addMember(this);
5501 } 5478 }
5502 PropertyMember.prototype._get$3 = function($0, $1, $2) { 5479 PropertyMember.prototype._get$3 = function($0, $1, $2) {
5503 return this._get($0, $1, $2, false); 5480 return this._get($0, $1, $2, false);
5504 }; 5481 };
5505 PropertyMember.prototype._get$3$isDynamic = PropertyMember.prototype._get; 5482 PropertyMember.prototype._get$3$isDynamic = PropertyMember.prototype._get;
5506 PropertyMember.prototype._get$4 = PropertyMember.prototype._get; 5483 PropertyMember.prototype._get$4 = PropertyMember.prototype._get;
5507 PropertyMember.prototype._set$4 = function($0, $1, $2, $3) { 5484 PropertyMember.prototype._set$4 = function($0, $1, $2, $3) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
5700 return false; 5677 return false;
5701 } 5678 }
5702 MethodMember.prototype.get$requiresPropertySyntax = function() { 5679 MethodMember.prototype.get$requiresPropertySyntax = function() {
5703 return true; 5680 return true;
5704 } 5681 }
5705 MethodMember.prototype.get$span = function() { 5682 MethodMember.prototype.get$span = function() {
5706 return this.definition == null ? null : this.definition.span; 5683 return this.definition == null ? null : this.definition.span;
5707 } 5684 }
5708 MethodMember.prototype.get$constructorName = function() { 5685 MethodMember.prototype.get$constructorName = function() {
5709 var returnType = this.definition.returnType; 5686 var returnType = this.definition.returnType;
5710 if (returnType == null) return ''; 5687 if (returnType == null) return "";
5711 if ((returnType instanceof GenericTypeReference)) { 5688 if ((returnType instanceof GenericTypeReference)) {
5712 return ''; 5689 return "";
5713 } 5690 }
5714 if (returnType.get$names() != null) { 5691 if (returnType.get$names() != null) {
5715 return returnType.get$names().$index(0).get$name(); 5692 return returnType.get$names().$index(0).get$name();
5716 } 5693 }
5717 else if (returnType.get$name() != null) { 5694 else if (returnType.get$name() != null) {
5718 return returnType.get$name().get$name(); 5695 return returnType.get$name().get$name();
5719 } 5696 }
5720 $globals.world.internalError('no valid constructor name', this.definition.span ); 5697 $globals.world.internalError("no valid constructor name", this.definition.span );
5721 } 5698 }
5722 MethodMember.prototype.get$functionType = function() { 5699 MethodMember.prototype.get$functionType = function() {
5723 if (this._functionType == null) { 5700 if (this._functionType == null) {
5724 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT ype, this.name, this.definition); 5701 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT ype, this.name, this.definition);
5725 if (this.parameters == null) { 5702 if (this.parameters == null) {
5726 this.resolve(); 5703 this.resolve();
5727 } 5704 }
5728 } 5705 }
5729 return this._functionType; 5706 return this._functionType;
5730 } 5707 }
5731 MethodMember.prototype.override = function(other) { 5708 MethodMember.prototype.override = function(other) {
5732 if (!Member.prototype.override.call(this, other)) return false; 5709 if (!Member.prototype.override.call(this, other)) return false;
5733 if (other.get$isMethod()) { 5710 if (other.get$isMethod()) {
5734 return true; 5711 return true;
5735 } 5712 }
5736 else { 5713 else {
5737 $globals.world.error('method can only override methods', this.get$span(), ot her.get$span()); 5714 $globals.world.error("method can only override methods", this.get$span(), ot her.get$span());
5738 return false; 5715 return false;
5739 } 5716 }
5740 } 5717 }
5741 MethodMember.prototype.canInvoke = function(context, args) { 5718 MethodMember.prototype.canInvoke = function(context, args) {
5742 var bareCount = args.get$bareCount(); 5719 var bareCount = args.get$bareCount();
5743 if (bareCount > this.parameters.get$length()) return false; 5720 if (bareCount > this.parameters.get$length()) return false;
5744 if (bareCount == this.parameters.get$length()) { 5721 if (bareCount == this.parameters.get$length()) {
5745 if (bareCount != args.get$length()) return false; 5722 if (bareCount != args.get$length()) return false;
5746 } 5723 }
5747 else { 5724 else {
(...skipping 17 matching lines...) Expand all
5765 } 5742 }
5766 return -1; 5743 return -1;
5767 } 5744 }
5768 MethodMember.prototype.provideFieldSyntax = function() { 5745 MethodMember.prototype.provideFieldSyntax = function() {
5769 this._provideFieldSyntax = true; 5746 this._provideFieldSyntax = true;
5770 } 5747 }
5771 MethodMember.prototype.providePropertySyntax = function() { 5748 MethodMember.prototype.providePropertySyntax = function() {
5772 this._providePropertySyntax = true; 5749 this._providePropertySyntax = true;
5773 } 5750 }
5774 MethodMember.prototype._set = function(context, node, target, value, isDynamic) { 5751 MethodMember.prototype._set = function(context, node, target, value, isDynamic) {
5775 $globals.world.error('cannot set method', node.span); 5752 $globals.world.error("cannot set method", node.span);
5776 } 5753 }
5777 MethodMember.prototype._get = function(context, node, target, isDynamic) { 5754 MethodMember.prototype._get = function(context, node, target, isDynamic) {
5778 this.declaringType.genMethod(this); 5755 this.declaringType.genMethod(this);
5779 this._provideOptionalParamInfo = true; 5756 this._provideOptionalParamInfo = true;
5780 if (this.isStatic) { 5757 if (this.isStatic) {
5781 this.declaringType.markUsed(); 5758 this.declaringType.markUsed();
5782 var type = this.declaringType.get$isTop() ? '' : ('' + this.declaringType.ge t$jsname() + '.'); 5759 var type = this.declaringType.get$isTop() ? "" : ("" + this.declaringType.ge t$jsname() + ".");
5783 return new Value(this.get$functionType(), ('' + type + this.get$jsname()), n ode.span, true); 5760 return new Value(this.get$functionType(), ("" + type + this.get$jsname()), n ode.span, true);
5784 } 5761 }
5785 this._providePropertySyntax = true; 5762 this._providePropertySyntax = true;
5786 return new Value(this.get$functionType(), ('' + target.code + '.get\$' + this. get$jsname() + '()'), node.span, true); 5763 return new Value(this.get$functionType(), ("" + target.code + ".get$" + this.g et$jsname() + "()"), node.span, true);
5787 } 5764 }
5788 MethodMember.prototype.namesInHomePositions = function(args) { 5765 MethodMember.prototype.namesInHomePositions = function(args) {
5789 if (!args.get$hasNames()) return true; 5766 if (!args.get$hasNames()) return true;
5790 for (var i = args.get$bareCount(); 5767 for (var i = args.get$bareCount();
5791 i < args.values.get$length(); i++) { 5768 i < args.values.get$length(); i++) {
5792 if (i >= this.parameters.get$length()) { 5769 if (i >= this.parameters.get$length()) {
5793 return false; 5770 return false;
5794 } 5771 }
5795 if (args.getName(i) != this.parameters.$index(i).get$name()) { 5772 if (args.getName(i) != this.parameters.$index(i).get$name()) {
5796 return false; 5773 return false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5828 i < this.parameters.get$length(); i++) { 5805 i < this.parameters.get$length(); i++) {
5829 var arg = args.getValue(this.parameters.$index(i).get$name()); 5806 var arg = args.getValue(this.parameters.$index(i).get$name());
5830 if (arg != null && arg.needsConversion$1(this.parameters.$index(i).get$typ e())) { 5807 if (arg != null && arg.needsConversion$1(this.parameters.$index(i).get$typ e())) {
5831 return true; 5808 return true;
5832 } 5809 }
5833 } 5810 }
5834 } 5811 }
5835 return false; 5812 return false;
5836 } 5813 }
5837 MethodMember._argCountMsg = function(actual, expected, atLeast) { 5814 MethodMember._argCountMsg = function(actual, expected, atLeast) {
5838 return 'wrong number of positional arguments, expected ' + ('' + (atLeast ? "a t least " : "") + expected + ' but found ' + actual); 5815 return "wrong number of positional arguments, expected " + ("" + (atLeast ? "a t least " : "") + expected + " but found " + actual);
5839 } 5816 }
5840 MethodMember.prototype._argError = function(context, node, target, args, msg, ar gIndex) { 5817 MethodMember.prototype._argError = function(context, node, target, args, msg, ar gIndex) {
5841 var span; 5818 var span;
5842 if ((args.nodes == null) || (argIndex >= args.nodes.get$length())) { 5819 if ((args.nodes == null) || (argIndex >= args.nodes.get$length())) {
5843 span = node.span; 5820 span = node.span;
5844 } 5821 }
5845 else { 5822 else {
5846 span = args.nodes.$index(argIndex).get$span(); 5823 span = args.nodes.$index(argIndex).get$span();
5847 } 5824 }
5848 if (this.isStatic || this.get$isConstructor()) { 5825 if (this.isStatic || this.get$isConstructor()) {
5849 $globals.world.error(msg, span); 5826 $globals.world.error(msg, span);
5850 } 5827 }
5851 else { 5828 else {
5852 $globals.world.warning(msg, span); 5829 $globals.world.warning(msg, span);
5853 } 5830 }
5854 return target.invokeNoSuchMethod(context, this.name, node, args); 5831 return target.invokeNoSuchMethod(context, this.name, node, args);
5855 } 5832 }
5856 MethodMember.prototype.genParameterValues = function() { 5833 MethodMember.prototype.genParameterValues = function() {
5857 var $$list = this.parameters; 5834 var $$list = this.parameters;
5858 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 5835 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
5859 var p = $$list.$index($$i); 5836 var p = $$list.$index($$i);
5860 p.genValue$2(this, this.generator); 5837 p.genValue$2(this, this.generator);
5861 } 5838 }
5862 } 5839 }
5863 MethodMember.prototype.invoke = function(context, node, target, args, isDynamic) { 5840 MethodMember.prototype.invoke = function(context, node, target, args, isDynamic) {
5864 if (this.parameters == null) { 5841 if (this.parameters == null) {
5865 $globals.world.info(('surprised to need to resolve: ' + this.declaringType.n ame + '.' + this.name)); 5842 $globals.world.info(("surprised to need to resolve: " + this.declaringType.n ame + "." + this.name));
5866 this.resolve(); 5843 this.resolve();
5867 } 5844 }
5868 this.declaringType.genMethod(this); 5845 this.declaringType.genMethod(this);
5869 if (this.isStatic || this.isFactory) { 5846 if (this.isStatic || this.isFactory) {
5870 this.declaringType.markUsed(); 5847 this.declaringType.markUsed();
5871 } 5848 }
5872 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ; 5849 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed() ;
5873 if (!this.namesInOrder(args)) { 5850 if (!this.namesInOrder(args)) {
5874 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s); 5851 return context.findMembers(this.name).invokeOnVar(context, node, target, arg s);
5875 } 5852 }
5876 var argsCode = []; 5853 var argsCode = [];
5877 if (!target.isType && (this.get$isConstructor() || target.isSuper)) { 5854 if (!target.isType && (this.get$isConstructor() || target.isSuper)) {
5878 argsCode.add$1('this'); 5855 argsCode.add$1("this");
5879 } 5856 }
5880 var bareCount = args.get$bareCount(); 5857 var bareCount = args.get$bareCount();
5881 for (var i = 0; 5858 for (var i = 0;
5882 i < bareCount; i++) { 5859 i < bareCount; i++) {
5883 var arg = args.values.$index(i); 5860 var arg = args.values.$index(i);
5884 if (i >= this.parameters.get$length()) { 5861 if (i >= this.parameters.get$length()) {
5885 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get $length(), false); 5862 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get $length(), false);
5886 return this._argError(context, node, target, args, msg, i); 5863 return this._argError(context, node, target, args, msg, i);
5887 } 5864 }
5888 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isDynam ic); 5865 arg = arg.convertTo$3(context, this.parameters.$index(i).get$type(), isDynam ic);
(...skipping 26 matching lines...) Expand all
5915 } 5892 }
5916 } 5893 }
5917 Arguments.removeTrailingNulls(argsCode); 5894 Arguments.removeTrailingNulls(argsCode);
5918 } 5895 }
5919 if (namedArgsUsed < args.get$nameCount()) { 5896 if (namedArgsUsed < args.get$nameCount()) {
5920 var seen = new HashSetImplementation(); 5897 var seen = new HashSetImplementation();
5921 for (var i = bareCount; 5898 for (var i = bareCount;
5922 i < args.get$length(); i++) { 5899 i < args.get$length(); i++) {
5923 var name = args.getName(i); 5900 var name = args.getName(i);
5924 if (seen.contains$1(name)) { 5901 if (seen.contains$1(name)) {
5925 return this._argError(context, node, target, args, ('duplicate argument "' + name + '"'), i); 5902 return this._argError(context, node, target, args, ("duplicate argument \"" + name + "\""), i);
5926 } 5903 }
5927 seen.add$1(name); 5904 seen.add$1(name);
5928 var p = this.indexOfParameter(name); 5905 var p = this.indexOfParameter(name);
5929 if (p < 0) { 5906 if (p < 0) {
5930 return this._argError(context, node, target, args, ('method does not hav e optional parameter "' + name + '"'), i); 5907 return this._argError(context, node, target, args, ("method does not hav e optional parameter \"" + name + "\""), i);
5931 } 5908 }
5932 else if (p < bareCount) { 5909 else if (p < bareCount) {
5933 return this._argError(context, node, target, args, ('argument "' + name + '" passed as positional and named'), p); 5910 return this._argError(context, node, target, args, ("argument \"" + name + "\" passed as positional and named"), p);
5934 } 5911 }
5935 } 5912 }
5936 $globals.world.internalError(('wrong named arguments calling ' + this.name), node.span); 5913 $globals.world.internalError(("wrong named arguments calling " + this.name), node.span);
5937 } 5914 }
5938 var argsString = Strings.join(argsCode, ', '); 5915 var argsString = Strings.join(argsCode, ", ");
5939 if (this.get$isConstructor()) { 5916 if (this.get$isConstructor()) {
5940 return this._invokeConstructor(context, node, target, args, argsString); 5917 return this._invokeConstructor(context, node, target, args, argsString);
5941 } 5918 }
5942 if (target.isSuper) { 5919 if (target.isSuper) {
5943 return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsn ame() + '.prototype.' + this.get$jsname() + '.call(' + argsString + ')'), node.s pan, true); 5920 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + ".prototype." + this.get$jsname() + ".call(" + argsString + ")"), node.s pan, true);
5944 } 5921 }
5945 if (this.get$isOperator()) { 5922 if (this.get$isOperator()) {
5946 return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic) ; 5923 return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic) ;
5947 } 5924 }
5948 if (this.isFactory) { 5925 if (this.isFactory) {
5949 return new Value(target.get$type(), ('' + this.get$generatedFactoryName() + '(' + argsString + ')'), node.span, true); 5926 return new Value(target.get$type(), ("" + this.get$generatedFactoryName() + "(" + argsString + ")"), node.span, true);
5950 } 5927 }
5951 if (this.isStatic) { 5928 if (this.isStatic) {
5952 if (this.declaringType.get$isTop()) { 5929 if (this.declaringType.get$isTop()) {
5953 return new Value(this.get$inferredResult(), ('' + this.get$jsname() + '(' + argsString + ')'), node != null ? node.span : node, true); 5930 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + argsString + ")"), node != null ? node.span : node, true);
5954 } 5931 }
5955 return new Value(this.get$inferredResult(), ('' + this.declaringType.get$jsn ame() + '.' + this.get$jsname() + '(' + argsString + ')'), node.span, true); 5932 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn ame() + "." + this.get$jsname() + "(" + argsString + ")"), node.span, true);
5956 } 5933 }
5957 var code = ('' + target.code + '.' + this.get$jsname() + '(' + argsString + ') '); 5934 var code = ("" + target.code + "." + this.get$jsname() + "(" + argsString + ") ");
5958 if (target.get$isConst()) { 5935 if (target.get$isConst()) {
5959 if ((target instanceof GlobalValue)) { 5936 if ((target instanceof GlobalValue)) {
5960 target = target.get$dynamic().get$exp(); 5937 target = target.get$dynamic().get$exp();
5961 } 5938 }
5962 if (this.name == 'get:length') { 5939 if (this.name == "get:length") {
5963 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) { 5940 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5964 code = ('' + target.get$dynamic().get$values().get$length()); 5941 code = ("" + target.get$dynamic().get$values().get$length());
5965 } 5942 }
5966 } 5943 }
5967 else if (this.name == 'isEmpty') { 5944 else if (this.name == "isEmpty") {
5968 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) { 5945 if ((target instanceof ConstListValue) || (target instanceof ConstMapValue )) {
5969 code = ('' + target.get$dynamic().get$values().isEmpty$0()); 5946 code = ("" + target.get$dynamic().get$values().isEmpty$0());
5970 } 5947 }
5971 } 5948 }
5972 } 5949 }
5973 if (this.name == 'get:typeName' && this.declaringType.get$library().get$isDom( )) { 5950 if (this.name == "get:typeName" && this.declaringType.get$library().get$isDom( )) {
5974 $globals.world.gen.corejs.ensureTypeNameOf(); 5951 $globals.world.gen.corejs.ensureTypeNameOf();
5975 } 5952 }
5976 return new Value(this.get$inferredResult(), code, node.span, true); 5953 return new Value(this.get$inferredResult(), code, node.span, true);
5977 } 5954 }
5978 MethodMember.prototype._invokeConstructor = function(context, node, target, args , argsString) { 5955 MethodMember.prototype._invokeConstructor = function(context, node, target, args , argsString) {
5979 this.declaringType.markUsed(); 5956 this.declaringType.markUsed();
5980 var ctor = this.get$constructorName(); 5957 var ctor = this.get$constructorName();
5981 if (ctor != '') ctor = ('.' + ctor + '\$ctor'); 5958 if (ctor != "") ctor = ("." + ctor + "$ctor");
5982 if (!target.isType) { 5959 if (!target.isType) {
5983 var code = ('' + this.declaringType.get$nativeName() + ctor + '.call(' + arg sString + ')'); 5960 var code = ("" + this.declaringType.get$nativeName() + ctor + ".call(" + arg sString + ")");
5984 return new Value(target.get$type(), code, node.span, true); 5961 return new Value(target.get$type(), code, node.span, true);
5985 } 5962 }
5986 else { 5963 else {
5987 var code = ('new ' + this.declaringType.get$nativeName() + ctor + '(' + args String + ')'); 5964 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" + args String + ")");
5988 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge t$isConst()) { 5965 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge t$isConst()) {
5989 return this._invokeConstConstructor(node, code, target, args); 5966 return this._invokeConstConstructor(node, code, target, args);
5990 } 5967 }
5991 else { 5968 else {
5992 var span = node != null ? node.span : target.span; 5969 var span = node != null ? node.span : target.span;
5993 return new Value(target.get$type(), code, span, true); 5970 return new Value(target.get$type(), code, span, true);
5994 } 5971 }
5995 } 5972 }
5996 } 5973 }
5997 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) { 5974 MethodMember.prototype._invokeConstConstructor = function(node, code, target, ar gs) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6047 fields.$setindex(fname, value.get$fields().$index(fname)); 6024 fields.$setindex(fname, value.get$fields().$index(fname));
6048 } 6025 }
6049 } 6026 }
6050 } 6027 }
6051 else { 6028 else {
6052 var assign = init; 6029 var assign = init;
6053 var x = assign.x; 6030 var x = assign.x;
6054 var fname = x.get$name().get$name(); 6031 var fname = x.get$name().get$name();
6055 var val = this.generator.visitValue(assign.y); 6032 var val = this.generator.visitValue(assign.y);
6056 if (!val.get$isConst()) { 6033 if (!val.get$isConst()) {
6057 $globals.world.error('invalid non-const initializer in const construct or', assign.y.span); 6034 $globals.world.error("invalid non-const initializer in const construct or", assign.y.span);
6058 } 6035 }
6059 fields.$setindex(fname, val); 6036 fields.$setindex(fname, val);
6060 } 6037 }
6061 } 6038 }
6062 this.generator._popBlock(); 6039 this.generator._popBlock();
6063 } 6040 }
6064 var $$list = this.declaringType.get$members().getValues(); 6041 var $$list = this.declaringType.get$members().getValues();
6065 for (var $$i = this.declaringType.get$members().getValues().iterator$0(); $$i. hasNext$0(); ) { 6042 for (var $$i = this.declaringType.get$members().getValues().iterator$0(); $$i. hasNext$0(); ) {
6066 var f = $$i.next$0(); 6043 var f = $$i.next$0();
6067 if ((f instanceof FieldMember) && !f.get$isStatic() && !fields.containsKey(f .get$name())) { 6044 if ((f instanceof FieldMember) && !f.get$isStatic() && !fields.containsKey(f .get$name())) {
6068 if (!f.get$isFinal()) { 6045 if (!f.get$isFinal()) {
6069 $globals.world.error(('const class "' + this.declaringType.name + '" has non-final ') + ('field "' + f.get$name() + '"'), f.get$span()); 6046 $globals.world.error(("const class \"" + this.declaringType.name + "\" h as non-final ") + ("field \"" + f.get$name() + "\""), f.get$span());
6070 } 6047 }
6071 if (f.get$value() != null) { 6048 if (f.get$value() != null) {
6072 fields.$setindex(f.get$name(), f.computeValue$0()); 6049 fields.$setindex(f.get$name(), f.computeValue$0());
6073 } 6050 }
6074 } 6051 }
6075 } 6052 }
6076 return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$fac tory(target.get$type(), fields, code, node.span), args.values); 6053 return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$fac tory(target.get$type(), fields, code, node.span), args.values);
6077 } 6054 }
6078 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar gsCode, isDynamic) { 6055 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar gsCode, isDynamic) {
6079 var allConst = target.get$isConst() && args.values.every((function (arg) { 6056 var allConst = target.get$isConst() && args.values.every((function (arg) {
6080 return arg.get$isConst(); 6057 return arg.get$isConst();
6081 }) 6058 })
6082 ); 6059 );
6083 if (this.declaringType.get$isNum()) { 6060 if (this.declaringType.get$isNum()) {
6084 if (!allConst) { 6061 if (!allConst) {
6085 var code; 6062 var code;
6086 if (this.name == ':negate') { 6063 if (this.name == ":negate") {
6087 code = ('-' + target.code); 6064 code = ("-" + target.code);
6088 } 6065 }
6089 else if (this.name == ':bit_not') { 6066 else if (this.name == ":bit_not") {
6090 code = ('~' + target.code); 6067 code = ("~" + target.code);
6091 } 6068 }
6092 else if (this.name == ':truncdiv' || this.name == ':mod') { 6069 else if (this.name == ":truncdiv" || this.name == ":mod") {
6093 $globals.world.gen.corejs.useOperator(this.name); 6070 $globals.world.gen.corejs.useOperator(this.name);
6094 code = ('' + this.get$jsname() + '(' + target.code + ', ' + argsCode.$in dex(0) + ')'); 6071 code = ("" + this.get$jsname() + "(" + target.code + ", " + argsCode.$in dex(0) + ")");
6095 } 6072 }
6096 else { 6073 else {
6097 var op = TokenKind.rawOperatorFromMethod(this.name); 6074 var op = TokenKind.rawOperatorFromMethod(this.name);
6098 code = ('' + target.code + ' ' + op + ' ' + argsCode.$index(0)); 6075 code = ("" + target.code + " " + op + " " + argsCode.$index(0));
6099 } 6076 }
6100 return new Value(this.get$inferredResult(), code, node.span, true); 6077 return new Value(this.get$inferredResult(), code, node.span, true);
6101 } 6078 }
6102 else { 6079 else {
6103 var value; 6080 var value;
6104 var val0, val1, ival0, ival1; 6081 var val0, val1, ival0, ival1;
6105 val0 = target.get$dynamic().get$actualValue(); 6082 val0 = target.get$dynamic().get$actualValue();
6106 ival0 = val0.toInt(); 6083 ival0 = val0.toInt();
6107 if (args.values.get$length() > 0) { 6084 if (args.values.get$length() > 0) {
6108 val1 = args.values.$index(0).get$dynamic().get$actualValue(); 6085 val1 = args.values.$index(0).get$dynamic().get$actualValue();
6109 ival1 = val1.toInt(); 6086 ival1 = val1.toInt();
6110 } 6087 }
6111 switch (this.name) { 6088 switch (this.name) {
6112 case ':negate': 6089 case ":negate":
6113 6090
6114 value = -val0; 6091 value = -val0;
6115 break; 6092 break;
6116 6093
6117 case ':add': 6094 case ":add":
6118 6095
6119 value = val0 + val1; 6096 value = val0 + val1;
6120 break; 6097 break;
6121 6098
6122 case ':sub': 6099 case ":sub":
6123 6100
6124 value = val0 - val1; 6101 value = val0 - val1;
6125 break; 6102 break;
6126 6103
6127 case ':mul': 6104 case ":mul":
6128 6105
6129 value = val0 * val1; 6106 value = val0 * val1;
6130 break; 6107 break;
6131 6108
6132 case ':div': 6109 case ":div":
6133 6110
6134 value = val0 / val1; 6111 value = val0 / val1;
6135 break; 6112 break;
6136 6113
6137 case ':truncdiv': 6114 case ":truncdiv":
6138 6115
6139 value = $truncdiv(val0, val1); 6116 value = $truncdiv(val0, val1);
6140 break; 6117 break;
6141 6118
6142 case ':mod': 6119 case ":mod":
6143 6120
6144 value = $mod(val0, val1); 6121 value = $mod(val0, val1);
6145 break; 6122 break;
6146 6123
6147 case ':eq': 6124 case ":eq":
6148 6125
6149 value = val0 == val1; 6126 value = val0 == val1;
6150 break; 6127 break;
6151 6128
6152 case ':lt': 6129 case ":lt":
6153 6130
6154 value = val0 < val1; 6131 value = val0 < val1;
6155 break; 6132 break;
6156 6133
6157 case ':gt': 6134 case ":gt":
6158 6135
6159 value = val0 > val1; 6136 value = val0 > val1;
6160 break; 6137 break;
6161 6138
6162 case ':lte': 6139 case ":lte":
6163 6140
6164 value = val0 <= val1; 6141 value = val0 <= val1;
6165 break; 6142 break;
6166 6143
6167 case ':gte': 6144 case ":gte":
6168 6145
6169 value = val0 >= val1; 6146 value = val0 >= val1;
6170 break; 6147 break;
6171 6148
6172 case ':ne': 6149 case ":ne":
6173 6150
6174 value = val0 != val1; 6151 value = val0 != val1;
6175 break; 6152 break;
6176 6153
6177 case ':bit_not': 6154 case ":bit_not":
6178 6155
6179 value = (~ival0).toDouble(); 6156 value = (~ival0).toDouble();
6180 break; 6157 break;
6181 6158
6182 case ':bit_or': 6159 case ":bit_or":
6183 6160
6184 value = (ival0 | ival1).toDouble(); 6161 value = (ival0 | ival1).toDouble();
6185 break; 6162 break;
6186 6163
6187 case ':bit_xor': 6164 case ":bit_xor":
6188 6165
6189 value = (ival0 ^ ival1).toDouble(); 6166 value = (ival0 ^ ival1).toDouble();
6190 break; 6167 break;
6191 6168
6192 case ':bit_and': 6169 case ":bit_and":
6193 6170
6194 value = (ival0 & ival1).toDouble(); 6171 value = (ival0 & ival1).toDouble();
6195 break; 6172 break;
6196 6173
6197 case ':shl': 6174 case ":shl":
6198 6175
6199 value = (ival0 << ival1).toDouble(); 6176 value = (ival0 << ival1).toDouble();
6200 break; 6177 break;
6201 6178
6202 case ':sar': 6179 case ":sar":
6203 6180
6204 value = (ival0 >> ival1).toDouble(); 6181 value = (ival0 >> ival1).toDouble();
6205 break; 6182 break;
6206 6183
6207 case ':shr': 6184 case ":shr":
6208 6185
6209 value = (ival0 >>> ival1).toDouble(); 6186 value = (ival0 >>> ival1).toDouble();
6210 break; 6187 break;
6211 6188
6212 } 6189 }
6213 return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), va lue, ("" + value), node.span); 6190 return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), va lue, ("" + value), node.span);
6214 } 6191 }
6215 } 6192 }
6216 else if (this.declaringType.get$isString()) { 6193 else if (this.declaringType.get$isString()) {
6217 if (this.name == ':index') { 6194 if (this.name == ":index") {
6218 return new Value(this.declaringType, ('' + target.code + '[' + argsCode.$i ndex(0) + ']'), node.span, true); 6195 return new Value(this.declaringType, ("" + target.code + "[" + argsCode.$i ndex(0) + "]"), node.span, true);
6219 } 6196 }
6220 else if (this.name == ':add') { 6197 else if (this.name == ":add") {
6221 if (allConst) { 6198 if (allConst) {
6222 var value = this._normConcat(target, args.values.$index(0)); 6199 var value = target.get$dynamic().get$actualValue() + args.values.$index( 0).get$dynamic().get$actualValue();
6223 return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, value, value, node.span); 6200 return Value.fromString(value, node.span);
6224 } 6201 }
6225 return new Value(this.declaringType, ('' + target.code + ' + ' + argsCode. $index(0)), node.span, true); 6202 return new Value(this.declaringType, ("" + target.code + " + " + argsCode. $index(0)), node.span, true);
6226 } 6203 }
6227 } 6204 }
6228 else if (this.declaringType.get$isNative()) { 6205 else if (this.declaringType.get$isNative()) {
6229 if (this.name == ':index') { 6206 if (this.name == ":index") {
6230 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde x(0) + ']'), node.span, true); 6207 return new Value(this.returnType, ("" + target.code + "[" + argsCode.$inde x(0) + "]"), node.span, true);
6231 } 6208 }
6232 else if (this.name == ':setindex') { 6209 else if (this.name == ":setindex") {
6233 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde x(0) + '] = ' + argsCode.$index(1)), node.span, true); 6210 return new Value(this.returnType, ("" + target.code + "[" + argsCode.$inde x(0) + "] = " + argsCode.$index(1)), node.span, true);
6234 } 6211 }
6235 } 6212 }
6236 if (this.name == ':eq' || this.name == ':ne') { 6213 if (this.name == ":eq" || this.name == ":ne") {
6237 var op = this.name == ':eq' ? '==' : '!='; 6214 var op = this.name == ":eq" ? "==" : "!=";
6238 if (this.name == ':ne') { 6215 if (this.name == ":ne") {
6239 target.invoke(context, ':eq', node, args, isDynamic); 6216 target.invoke(context, ":eq", node, args, isDynamic);
6240 } 6217 }
6241 if (allConst) { 6218 if (allConst) {
6242 var val0 = target.get$dynamic().get$actualValue(); 6219 var val0 = target.get$dynamic().get$actualValue();
6243 var val1 = args.values.$index(0).get$dynamic().get$actualValue(); 6220 var val1 = args.values.$index(0).get$dynamic().get$actualValue();
6244 var newVal = this.name == ':eq' ? $eq(val0, val1) : $ne(val0, val1); 6221 var newVal = this.name == ":eq" ? $eq(val0, val1) : $ne(val0, val1);
6245 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, n ewVal, ("" + newVal), node.span); 6222 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, n ewVal, ("" + newVal), node.span);
6246 } 6223 }
6247 if ($eq(argsCode.$index(0), 'null')) { 6224 if ($eq(argsCode.$index(0), "null")) {
6248 return new Value(this.get$inferredResult(), ('' + target.code + ' ' + op + ' null'), node.span, true); 6225 return new Value(this.get$inferredResult(), ("" + target.code + " " + op + " null"), node.span, true);
6249 } 6226 }
6250 else if (target.get$type().get$isNum() || target.get$type().get$isString()) { 6227 else if (target.get$type().get$isNum() || target.get$type().get$isString()) {
6251 return new Value(this.get$inferredResult(), ('' + target.code + ' ' + op + ' ' + argsCode.$index(0)), node.span, true); 6228 return new Value(this.get$inferredResult(), ("" + target.code + " " + op + " " + argsCode.$index(0)), node.span, true);
6252 } 6229 }
6253 $globals.world.gen.corejs.useOperator(this.name); 6230 $globals.world.gen.corejs.useOperator(this.name);
6254 return new Value(this.get$inferredResult(), ('' + this.get$jsname() + '(' + target.code + ', ' + argsCode.$index(0) + ')'), node.span, true); 6231 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" + target.code + ", " + argsCode.$index(0) + ")"), node.span, true);
6255 } 6232 }
6256 if (this.get$isCallMethod()) { 6233 if (this.get$isCallMethod()) {
6257 this.declaringType.markUsed(); 6234 this.declaringType.markUsed();
6258 return new Value(this.get$inferredResult(), ('' + target.code + '(' + String s.join(argsCode, ", ") + ')'), node.span, true); 6235 return new Value(this.get$inferredResult(), ("" + target.code + "(" + String s.join(argsCode, ", ") + ")"), node.span, true);
6259 } 6236 }
6260 if (this.name == ':index') { 6237 if (this.name == ":index") {
6261 $globals.world.gen.corejs.useIndex = true; 6238 $globals.world.gen.corejs.useIndex = true;
6262 } 6239 }
6263 else if (this.name == ':setindex') { 6240 else if (this.name == ":setindex") {
6264 $globals.world.gen.corejs.useSetIndex = true; 6241 $globals.world.gen.corejs.useSetIndex = true;
6265 } 6242 }
6266 var argsString = Strings.join(argsCode, ', '); 6243 var argsString = Strings.join(argsCode, ", ");
6267 return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get $jsname() + '(' + argsString + ')'), node.span, true); 6244 return new Value(this.get$inferredResult(), ("" + target.code + "." + this.get $jsname() + "(" + argsString + ")"), node.span, true);
6268 }
6269 MethodMember.prototype._normConcat = function(a, b) {
6270 var val0 = a.get$dynamic().get$actualValue();
6271 var quote0 = val0.$index(0);
6272 val0 = val0.substring$2(1, val0.get$length() - 1);
6273 var val1 = b.get$dynamic().get$actualValue();
6274 var quote1 = null;
6275 if (b.get$type().get$isString()) {
6276 quote1 = val1.$index(0);
6277 val1 = val1.substring$2(1, val1.get$length() - 1);
6278 }
6279 var value;
6280 if ($eq(quote0, quote1) || quote1 == null) {
6281 value = ('' + quote0 + val0 + val1 + quote0);
6282 }
6283 else if ($eq(quote0, '"')) {
6284 value = ('' + quote0 + val0 + toDoubleQuote(val1) + quote0);
6285 }
6286 else {
6287 value = ('' + quote1 + toDoubleQuote(val0) + val1 + quote1);
6288 }
6289 return value;
6290 } 6245 }
6291 MethodMember.prototype.resolve = function() { 6246 MethodMember.prototype.resolve = function() {
6292 this.isStatic = this.declaringType.get$isTop(); 6247 this.isStatic = this.declaringType.get$isTop();
6293 this.isConst = false; 6248 this.isConst = false;
6294 this.isFactory = false; 6249 this.isFactory = false;
6295 this.isAbstract = !this.declaringType.get$isClass(); 6250 this.isAbstract = !this.declaringType.get$isClass();
6296 if (this.definition.modifiers != null) { 6251 if (this.definition.modifiers != null) {
6297 var $$list = this.definition.modifiers; 6252 var $$list = this.definition.modifiers;
6298 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 6253 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
6299 var mod = $$list.$index($$i); 6254 var mod = $$list.$index($$i);
6300 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) { 6255 if ($eq(mod.get$kind(), 84/*TokenKind.STATIC*/)) {
6301 if (this.isStatic) { 6256 if (this.isStatic) {
6302 $globals.world.error('duplicate static modifier', mod.get$span()); 6257 $globals.world.error("duplicate static modifier", mod.get$span());
6303 } 6258 }
6304 this.isStatic = true; 6259 this.isStatic = true;
6305 } 6260 }
6306 else if (this.get$isConstructor() && $eq(mod.get$kind(), 91/*TokenKind.CON ST*/)) { 6261 else if (this.get$isConstructor() && $eq(mod.get$kind(), 91/*TokenKind.CON ST*/)) {
6307 if (this.isConst) { 6262 if (this.isConst) {
6308 $globals.world.error('duplicate const modifier', mod.get$span()); 6263 $globals.world.error("duplicate const modifier", mod.get$span());
6309 } 6264 }
6310 this.isConst = true; 6265 this.isConst = true;
6311 } 6266 }
6312 else if ($eq(mod.get$kind(), 73/*TokenKind.FACTORY*/)) { 6267 else if ($eq(mod.get$kind(), 73/*TokenKind.FACTORY*/)) {
6313 if (this.isFactory) { 6268 if (this.isFactory) {
6314 $globals.world.error('duplicate factory modifier', mod.get$span()); 6269 $globals.world.error("duplicate factory modifier", mod.get$span());
6315 } 6270 }
6316 this.isFactory = true; 6271 this.isFactory = true;
6317 } 6272 }
6318 else if ($eq(mod.get$kind(), 71/*TokenKind.ABSTRACT*/)) { 6273 else if ($eq(mod.get$kind(), 71/*TokenKind.ABSTRACT*/)) {
6319 if (this.isAbstract) { 6274 if (this.isAbstract) {
6320 if (this.declaringType.get$isClass()) { 6275 if (this.declaringType.get$isClass()) {
6321 $globals.world.error('duplicate abstract modifier', mod.get$span()); 6276 $globals.world.error("duplicate abstract modifier", mod.get$span());
6322 } 6277 }
6323 else if (!this.get$isCallMethod()) { 6278 else if (!this.get$isCallMethod()) {
6324 $globals.world.error('abstract modifier not allowed on interface mem bers', mod.get$span()); 6279 $globals.world.error("abstract modifier not allowed on interface mem bers", mod.get$span());
6325 } 6280 }
6326 } 6281 }
6327 this.isAbstract = true; 6282 this.isAbstract = true;
6328 } 6283 }
6329 else { 6284 else {
6330 $globals.world.error(('' + mod + ' modifier not allowed on method'), mod .get$span()); 6285 $globals.world.error(("" + mod + " modifier not allowed on method"), mod .get$span());
6331 } 6286 }
6332 } 6287 }
6333 } 6288 }
6334 if (this.isFactory) { 6289 if (this.isFactory) {
6335 this.isStatic = true; 6290 this.isStatic = true;
6336 } 6291 }
6337 if (this.get$isOperator() && this.isStatic && !this.get$isCallMethod()) { 6292 if (this.get$isOperator() && this.isStatic && !this.get$isCallMethod()) {
6338 $globals.world.error(('operator method may not be static "' + this.name + '" '), this.get$span()); 6293 $globals.world.error(("operator method may not be static \"" + this.name + " \""), this.get$span());
6339 } 6294 }
6340 if (this.isAbstract) { 6295 if (this.isAbstract) {
6341 if (this.definition.body != null && !(this.declaringType.get$definition() in stanceof FunctionTypeDefinition)) { 6296 if (this.definition.body != null && !(this.declaringType.get$definition() in stanceof FunctionTypeDefinition)) {
6342 $globals.world.error('abstract method can not have a body', this.get$span( )); 6297 $globals.world.error("abstract method can not have a body", this.get$span( ));
6343 } 6298 }
6344 if (this.isStatic && !(this.declaringType.get$definition() instanceof Functi onTypeDefinition)) { 6299 if (this.isStatic && !(this.declaringType.get$definition() instanceof Functi onTypeDefinition)) {
6345 $globals.world.error('static method can not be abstract', this.get$span()) ; 6300 $globals.world.error("static method can not be abstract", this.get$span()) ;
6346 } 6301 }
6347 } 6302 }
6348 else { 6303 else {
6349 if (this.definition.body == null && !this.get$isConstructor() && !this.get$i sNative()) { 6304 if (this.definition.body == null && !this.get$isConstructor() && !this.get$i sNative()) {
6350 $globals.world.error('method needs a body', this.get$span()); 6305 $globals.world.error("method needs a body", this.get$span());
6351 } 6306 }
6352 } 6307 }
6353 if (this.get$isConstructor() && !this.isFactory) { 6308 if (this.get$isConstructor() && !this.isFactory) {
6354 this.returnType = this.declaringType; 6309 this.returnType = this.declaringType;
6355 } 6310 }
6356 else { 6311 else {
6357 this.returnType = this.resolveType(this.definition.returnType, false); 6312 this.returnType = this.resolveType(this.definition.returnType, false);
6358 } 6313 }
6359 this.parameters = []; 6314 this.parameters = [];
6360 var $$list = this.definition.formals; 6315 var $$list = this.definition.formals;
6361 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 6316 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
6362 var formal = $$list.$index($$i); 6317 var formal = $$list.$index($$i);
6363 var param = new Parameter(formal, this); 6318 var param = new Parameter(formal, this);
6364 param.resolve$0(); 6319 param.resolve$0();
6365 this.parameters.add(param); 6320 this.parameters.add(param);
6366 } 6321 }
6367 if (!this.isLambda) { 6322 if (!this.isLambda) {
6368 this.get$library()._addMember(this); 6323 this.get$library()._addMember(this);
6369 } 6324 }
6370 } 6325 }
6371 MethodMember.prototype.resolveType = function(node, typeErrors) { 6326 MethodMember.prototype.resolveType = function(node, typeErrors) {
6372 var t = Element.prototype.resolveType.call(this, node, typeErrors); 6327 var t = Element.prototype.resolveType.call(this, node, typeErrors);
6373 if (this.isStatic && !this.isFactory && (t instanceof ParameterType)) { 6328 if (this.isStatic && !this.isFactory && (t instanceof ParameterType)) {
6374 $globals.world.error('using type parameter in static context.', node.span); 6329 $globals.world.error("using type parameter in static context.", node.span);
6375 } 6330 }
6376 return t; 6331 return t;
6377 } 6332 }
6378 MethodMember.prototype._get$3 = function($0, $1, $2) { 6333 MethodMember.prototype._get$3 = function($0, $1, $2) {
6379 return this._get($0, $1, $2, false); 6334 return this._get($0, $1, $2, false);
6380 }; 6335 };
6381 MethodMember.prototype._get$3$isDynamic = MethodMember.prototype._get; 6336 MethodMember.prototype._get$3$isDynamic = MethodMember.prototype._get;
6382 MethodMember.prototype._get$4 = MethodMember.prototype._get; 6337 MethodMember.prototype._get$4 = MethodMember.prototype._get;
6383 MethodMember.prototype._set$4 = function($0, $1, $2, $3) { 6338 MethodMember.prototype._set$4 = function($0, $1, $2, $3) {
6384 return this._set($0, $1, $2, $3, false); 6339 return this._set($0, $1, $2, $3, false);
(...skipping 16 matching lines...) Expand all
6401 this.members = [member]; 6356 this.members = [member];
6402 this.jsname = member.get$jsname(); 6357 this.jsname = member.get$jsname();
6403 this.isVar = isVar; 6358 this.isVar = isVar;
6404 // Initializers done 6359 // Initializers done
6405 } 6360 }
6406 MemberSet.prototype.get$name = function() { return this.name; }; 6361 MemberSet.prototype.get$name = function() { return this.name; };
6407 MemberSet.prototype.get$members = function() { return this.members; }; 6362 MemberSet.prototype.get$members = function() { return this.members; };
6408 MemberSet.prototype.get$jsname = function() { return this.jsname; }; 6363 MemberSet.prototype.get$jsname = function() { return this.jsname; };
6409 MemberSet.prototype.get$isVar = function() { return this.isVar; }; 6364 MemberSet.prototype.get$isVar = function() { return this.isVar; };
6410 MemberSet.prototype.toString = function() { 6365 MemberSet.prototype.toString = function() {
6411 return ('' + this.name + ':' + this.members.get$length()); 6366 return ("" + this.name + ":" + this.members.get$length());
6412 } 6367 }
6413 MemberSet.prototype.get$containsMethods = function() { 6368 MemberSet.prototype.get$containsMethods = function() {
6414 return this.members.some((function (m) { 6369 return this.members.some((function (m) {
6415 return (m instanceof MethodMember); 6370 return (m instanceof MethodMember);
6416 }) 6371 })
6417 ); 6372 );
6418 } 6373 }
6419 MemberSet.prototype.add = function(member) { 6374 MemberSet.prototype.add = function(member) {
6420 return this.members.add(member); 6375 return this.members.add(member);
6421 } 6376 }
6422 MemberSet.prototype.get$isStatic = function() { 6377 MemberSet.prototype.get$isStatic = function() {
6423 return this.members.get$length() == 1 && this.members.$index(0).get$isStatic() ; 6378 return this.members.get$length() == 1 && this.members.$index(0).get$isStatic() ;
6424 } 6379 }
6425 MemberSet.prototype.get$isOperator = function() { 6380 MemberSet.prototype.get$isOperator = function() {
6426 return this.members.$index(0).get$isOperator(); 6381 return this.members.$index(0).get$isOperator();
6427 } 6382 }
6428 MemberSet.prototype.canInvoke = function(context, args) { 6383 MemberSet.prototype.canInvoke = function(context, args) {
6429 return this.members.some((function (m) { 6384 return this.members.some((function (m) {
6430 return m.canInvoke$2(context, args); 6385 return m.canInvoke$2(context, args);
6431 }) 6386 })
6432 ); 6387 );
6433 } 6388 }
6434 MemberSet.prototype._makeError = function(node, target, action) { 6389 MemberSet.prototype._makeError = function(node, target, action) {
6435 if (!target.get$type().get$isVar()) { 6390 if (!target.get$type().get$isVar()) {
6436 $globals.world.warning(('could not find applicable ' + action + ' for "' + t his.name + '"'), node.span); 6391 $globals.world.warning(("could not find applicable " + action + " for \"" + this.name + "\""), node.span);
6437 } 6392 }
6438 return new Value($globals.world.varType, ('' + target.code + '.' + this.jsname + '() /*no applicable ' + action + '*/'), node.span, true); 6393 return new Value($globals.world.varType, ("" + target.code + "." + this.jsname + "() /*no applicable " + action + "*/"), node.span, true);
6439 } 6394 }
6440 MemberSet.prototype.get$treatAsField = function() { 6395 MemberSet.prototype.get$treatAsField = function() {
6441 if (this._treatAsField == null) { 6396 if (this._treatAsField == null) {
6442 this._treatAsField = !this.isVar && (this.members.some((function (m) { 6397 this._treatAsField = !this.isVar && (this.members.some((function (m) {
6443 return m.get$requiresFieldSyntax(); 6398 return m.get$requiresFieldSyntax();
6444 }) 6399 })
6445 ) || this.members.every((function (m) { 6400 ) || this.members.every((function (m) {
6446 return !m.get$requiresPropertySyntax(); 6401 return !m.get$requiresPropertySyntax();
6447 }) 6402 })
6448 )); 6403 ));
(...skipping 29 matching lines...) Expand all
6478 } 6433 }
6479 else if ($eq(targets.get$length(), 1)) { 6434 else if ($eq(targets.get$length(), 1)) {
6480 return targets.$index(0)._get$4(context, node, target, isDynamic); 6435 return targets.$index(0)._get$4(context, node, target, isDynamic);
6481 } 6436 }
6482 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6437 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6483 var member = $$i.next$0(); 6438 var member = $$i.next$0();
6484 var value = member._get$3$isDynamic(context, node, target, true); 6439 var value = member._get$3$isDynamic(context, node, target, true);
6485 returnValue = this._tryUnion(returnValue, value, node); 6440 returnValue = this._tryUnion(returnValue, value, node);
6486 } 6441 }
6487 if (returnValue == null) { 6442 if (returnValue == null) {
6488 return this._makeError(node, target, 'getter'); 6443 return this._makeError(node, target, "getter");
6489 } 6444 }
6490 } 6445 }
6491 if (returnValue.code == null) { 6446 if (returnValue.code == null) {
6492 if (this.get$treatAsField()) { 6447 if (this.get$treatAsField()) {
6493 return new Value(returnValue.get$type(), ('' + target.code + '.' + this.js name), node.span, true); 6448 return new Value(returnValue.get$type(), ("" + target.code + "." + this.js name), node.span, true);
6494 } 6449 }
6495 else { 6450 else {
6496 return new Value(returnValue.get$type(), ('' + target.code + '.get\$' + th is.jsname + '()'), node.span, true); 6451 return new Value(returnValue.get$type(), ("" + target.code + ".get$" + thi s.jsname + "()"), node.span, true);
6497 } 6452 }
6498 } 6453 }
6499 return returnValue; 6454 return returnValue;
6500 } 6455 }
6501 MemberSet.prototype._set = function(context, node, target, value, isDynamic) { 6456 MemberSet.prototype._set = function(context, node, target, value, isDynamic) {
6502 var returnValue; 6457 var returnValue;
6503 var targets = this.members.filter((function (m) { 6458 var targets = this.members.filter((function (m) {
6504 return m.get$canSet(); 6459 return m.get$canSet();
6505 }) 6460 })
6506 ); 6461 );
(...skipping 10 matching lines...) Expand all
6517 } 6472 }
6518 else if ($eq(targets.get$length(), 1)) { 6473 else if ($eq(targets.get$length(), 1)) {
6519 return targets.$index(0)._set$5(context, node, target, value, isDynamic); 6474 return targets.$index(0)._set$5(context, node, target, value, isDynamic);
6520 } 6475 }
6521 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6476 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6522 var member = $$i.next$0(); 6477 var member = $$i.next$0();
6523 var res = member._set$4$isDynamic(context, node, target, value, true); 6478 var res = member._set$4$isDynamic(context, node, target, value, true);
6524 returnValue = this._tryUnion(returnValue, res, node); 6479 returnValue = this._tryUnion(returnValue, res, node);
6525 } 6480 }
6526 if (returnValue == null) { 6481 if (returnValue == null) {
6527 return this._makeError(node, target, 'setter'); 6482 return this._makeError(node, target, "setter");
6528 } 6483 }
6529 } 6484 }
6530 if (returnValue.code == null) { 6485 if (returnValue.code == null) {
6531 if (this.get$treatAsField()) { 6486 if (this.get$treatAsField()) {
6532 return new Value(returnValue.get$type(), ('' + target.code + '.' + this.js name + ' = ' + value.code), node.span, true); 6487 return new Value(returnValue.get$type(), ("" + target.code + "." + this.js name + " = " + value.code), node.span, true);
6533 } 6488 }
6534 else { 6489 else {
6535 return new Value(returnValue.get$type(), ('' + target.code + '.set\$' + th is.jsname + '(' + value.code + ')'), node.span, true); 6490 return new Value(returnValue.get$type(), ("" + target.code + ".set$" + thi s.jsname + "(" + value.code + ")"), node.span, true);
6536 } 6491 }
6537 } 6492 }
6538 return returnValue; 6493 return returnValue;
6539 } 6494 }
6540 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) { 6495 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) {
6541 if (this.isVar && !this.get$isOperator()) { 6496 if (this.isVar && !this.get$isOperator()) {
6542 return this.invokeOnVar(context, node, target, args); 6497 return this.invokeOnVar(context, node, target, args);
6543 } 6498 }
6544 if (this.members.get$length() == 1) { 6499 if (this.members.get$length() == 1) {
6545 return this.members.$index(0).invoke$5(context, node, target, args, isDynami c); 6500 return this.members.$index(0).invoke$5(context, node, target, args, isDynami c);
6546 } 6501 }
6547 var targets = this.members.filter((function (m) { 6502 var targets = this.members.filter((function (m) {
6548 return m.canInvoke$2(context, args); 6503 return m.canInvoke$2(context, args);
6549 }) 6504 })
6550 ); 6505 );
6551 if ($eq(targets.get$length(), 1)) { 6506 if ($eq(targets.get$length(), 1)) {
6552 return targets.$index(0).invoke$5(context, node, target, args, isDynamic); 6507 return targets.$index(0).invoke$5(context, node, target, args, isDynamic);
6553 } 6508 }
6554 var returnValue = null; 6509 var returnValue = null;
6555 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { 6510 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) {
6556 var member = $$i.next$0(); 6511 var member = $$i.next$0();
6557 var res = member.invoke$4$isDynamic(context, node, target, args, true); 6512 var res = member.invoke$4$isDynamic(context, node, target, args, true);
6558 returnValue = this._tryUnion(returnValue, res, node); 6513 returnValue = this._tryUnion(returnValue, res, node);
6559 } 6514 }
6560 if (returnValue == null) { 6515 if (returnValue == null) {
6561 return this._makeError(node, target, 'method'); 6516 return this._makeError(node, target, "method");
6562 } 6517 }
6563 if (returnValue.code == null) { 6518 if (returnValue.code == null) {
6564 if (this.name == ':call') { 6519 if (this.name == ":call") {
6565 return target._varCall(context, node, args); 6520 return target._varCall(context, node, args);
6566 } 6521 }
6567 else if (this.get$isOperator()) { 6522 else if (this.get$isOperator()) {
6568 return this.invokeSpecial(target, args, returnValue.get$type()); 6523 return this.invokeSpecial(target, args, returnValue.get$type());
6569 } 6524 }
6570 else { 6525 else {
6571 return this.invokeOnVar(context, node, target, args); 6526 return this.invokeOnVar(context, node, target, args);
6572 } 6527 }
6573 } 6528 }
6574 return returnValue; 6529 return returnValue;
6575 } 6530 }
6576 MemberSet.prototype.invokeSpecial = function(target, args, returnType) { 6531 MemberSet.prototype.invokeSpecial = function(target, args, returnType) {
6577 var argsString = args.getCode(); 6532 var argsString = args.getCode();
6578 if (this.name == ':index' || this.name == ':setindex') { 6533 if (this.name == ":index" || this.name == ":setindex") {
6579 return new Value(returnType, ('' + target.code + '.' + this.jsname + '(' + a rgsString + ')'), target.span, true); 6534 return new Value(returnType, ("" + target.code + "." + this.jsname + "(" + a rgsString + ")"), target.span, true);
6580 } 6535 }
6581 else { 6536 else {
6582 if (argsString.get$length() > 0) argsString = (', ' + argsString); 6537 if (argsString.get$length() > 0) argsString = (", " + argsString);
6583 $globals.world.gen.corejs.useOperator(this.name); 6538 $globals.world.gen.corejs.useOperator(this.name);
6584 return new Value(returnType, ('' + this.jsname + '(' + target.code + argsStr ing + ')'), target.span, true); 6539 return new Value(returnType, ("" + this.jsname + "(" + target.code + argsStr ing + ")"), target.span, true);
6585 } 6540 }
6586 } 6541 }
6587 MemberSet.prototype.invokeOnVar = function(context, node, target, args) { 6542 MemberSet.prototype.invokeOnVar = function(context, node, target, args) {
6588 var member = this.getVarMember(context, node, args); 6543 var member = this.getVarMember(context, node, args);
6589 return member.invoke$4(context, node, target, args); 6544 return member.invoke$4(context, node, target, args);
6590 } 6545 }
6591 MemberSet.prototype._tryUnion = function(x, y, node) { 6546 MemberSet.prototype._tryUnion = function(x, y, node) {
6592 if (x == null) return y; 6547 if (x == null) return y;
6593 var type = Type.union(x.get$type(), y.get$type()); 6548 var type = Type.union(x.get$type(), y.get$type());
6594 if (x.code == y.code) { 6549 if (x.code == y.code) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6695 Token.prototype.get$end = function() { return this.end; }; 6650 Token.prototype.get$end = function() { return this.end; };
6696 Token.prototype.get$start = function() { return this.start; }; 6651 Token.prototype.get$start = function() { return this.start; };
6697 Token.prototype.get$text = function() { 6652 Token.prototype.get$text = function() {
6698 return this.source.get$text().substring(this.start, this.end); 6653 return this.source.get$text().substring(this.start, this.end);
6699 } 6654 }
6700 Token.prototype.toString = function() { 6655 Token.prototype.toString = function() {
6701 var kindText = TokenKind.kindToString(this.kind); 6656 var kindText = TokenKind.kindToString(this.kind);
6702 var actualText = this.get$text(); 6657 var actualText = this.get$text();
6703 if ($ne(kindText, actualText)) { 6658 if ($ne(kindText, actualText)) {
6704 if (actualText.get$length() > 10) { 6659 if (actualText.get$length() > 10) {
6705 actualText = actualText.substring$2(0, 8) + '...'; 6660 actualText = actualText.substring$2(0, 8) + "...";
6706 } 6661 }
6707 return ('' + kindText + '(' + actualText + ')'); 6662 return ("" + kindText + "(" + actualText + ")");
6708 } 6663 }
6709 else { 6664 else {
6710 return kindText; 6665 return kindText;
6711 } 6666 }
6712 } 6667 }
6713 Token.prototype.get$span = function() { 6668 Token.prototype.get$span = function() {
6714 return new SourceSpan(this.source, this.start, this.end); 6669 return new SourceSpan(this.source, this.start, this.end);
6715 } 6670 }
6716 Token.prototype.end$0 = function() { 6671 Token.prototype.end$0 = function() {
6717 return this.end(); 6672 return this.end.call$0();
6718 }; 6673 };
6719 Token.prototype.start$0 = function() { 6674 Token.prototype.start$0 = function() {
6720 return this.start(); 6675 return this.start.call$0();
6721 }; 6676 };
6722 Token.prototype.toString$0 = Token.prototype.toString; 6677 Token.prototype.toString$0 = Token.prototype.toString;
6678 // ********** Code for LiteralToken **************
6679 $inherits(LiteralToken, Token);
6680 function LiteralToken(kind, source, start, end, value) {
6681 this.value = value;
6682 // Initializers done
6683 Token.call(this, kind, source, start, end);
6684 }
6685 LiteralToken.prototype.get$value = function() { return this.value; };
6686 LiteralToken.prototype.set$value = function(value) { return this.value = value; };
6723 // ********** Code for ErrorToken ************** 6687 // ********** Code for ErrorToken **************
6724 $inherits(ErrorToken, Token); 6688 $inherits(ErrorToken, Token);
6725 function ErrorToken(kind, source, start, end, message) { 6689 function ErrorToken(kind, source, start, end, message) {
6726 this.message = message; 6690 this.message = message;
6727 // Initializers done 6691 // Initializers done
6728 Token.call(this, kind, source, start, end); 6692 Token.call(this, kind, source, start, end);
6729 } 6693 }
6730 ErrorToken.prototype.get$message = function() { return this.message; }; 6694 ErrorToken.prototype.get$message = function() { return this.message; };
6731 ErrorToken.prototype.set$message = function(value) { return this.message = value ; }; 6695 ErrorToken.prototype.set$message = function(value) { return this.message = value ; };
6732 // ********** Code for SourceFile ************** 6696 // ********** Code for SourceFile **************
6733 function SourceFile(filename, _text) { 6697 function SourceFile(filename, _text) {
6734 this.filename = filename; 6698 this.filename = filename;
6735 this._text = _text; 6699 this._text = _text;
6736 // Initializers done 6700 // Initializers done
6737 } 6701 }
6738 SourceFile.prototype.get$filename = function() { return this.filename; }; 6702 SourceFile.prototype.get$filename = function() { return this.filename; };
6739 SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrar y; }; 6703 SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrar y; };
6740 SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInL ibrary = value; }; 6704 SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInL ibrary = value; };
6741 SourceFile.prototype.get$text = function() { 6705 SourceFile.prototype.get$text = function() {
6742 return this._text; 6706 return this._text;
6743 } 6707 }
6744 SourceFile.prototype.get$lineStarts = function() { 6708 SourceFile.prototype.get$lineStarts = function() {
6745 if (this._lineStarts == null) { 6709 if (this._lineStarts == null) {
6746 var starts = [0]; 6710 var starts = [0];
6747 var index = 0; 6711 var index = 0;
6748 while (index < this.get$text().length) { 6712 while (index < this.get$text().length) {
6749 index = this.get$text().indexOf('\n', index) + 1; 6713 index = this.get$text().indexOf("\n", index) + 1;
6750 if (index <= 0) break; 6714 if (index <= 0) break;
6751 starts.add$1(index); 6715 starts.add$1(index);
6752 } 6716 }
6753 starts.add$1(this.get$text().length + 1); 6717 starts.add$1(this.get$text().length + 1);
6754 this._lineStarts = starts; 6718 this._lineStarts = starts;
6755 } 6719 }
6756 return this._lineStarts; 6720 return this._lineStarts;
6757 } 6721 }
6758 SourceFile.prototype.getLine = function(position) { 6722 SourceFile.prototype.getLine = function(position) {
6759 var starts = this.get$lineStarts(); 6723 var starts = this.get$lineStarts();
6760 for (var i = 0; 6724 for (var i = 0;
6761 i < starts.get$length(); i++) { 6725 i < starts.get$length(); i++) {
6762 if (starts.$index(i) > position) return i - 1; 6726 if (starts.$index(i) > position) return i - 1;
6763 } 6727 }
6764 $globals.world.internalError('bad position'); 6728 $globals.world.internalError("bad position");
6765 } 6729 }
6766 SourceFile.prototype.getColumn = function(line, position) { 6730 SourceFile.prototype.getColumn = function(line, position) {
6767 return position - this.get$lineStarts().$index(line); 6731 return position - this.get$lineStarts().$index(line);
6768 } 6732 }
6769 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) { 6733 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT ext) {
6770 var line = this.getLine(start); 6734 var line = this.getLine(start);
6771 var column = this.getColumn(line, start); 6735 var column = this.getColumn(line, start);
6772 var buf = new StringBufferImpl(('' + this.filename + ':' + (line + 1) + ':' + (column + 1) + ': ' + message)); 6736 var buf = new StringBufferImpl(("" + this.filename + ":" + (line + 1) + ":" + (column + 1) + ": " + message));
6773 if (includeText) { 6737 if (includeText) {
6774 buf.add$1('\n'); 6738 buf.add$1("\n");
6775 var textLine; 6739 var textLine;
6776 if ((line + 2) < this._lineStarts.get$length()) { 6740 if ((line + 2) < this._lineStarts.get$length()) {
6777 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + 1)); 6741 textLine = this.get$text().substring(this._lineStarts.$index(line), this._ lineStarts.$index(line + 1));
6778 } 6742 }
6779 else { 6743 else {
6780 textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n' ; 6744 textLine = this.get$text().substring(this._lineStarts.$index(line)) + "\n" ;
6781 } 6745 }
6782 var toColumn = Math.min(column + (end - start), textLine.get$length()); 6746 var toColumn = Math.min(column + (end - start), textLine.get$length());
6783 if ($globals.options.useColors) { 6747 if ($globals.options.useColors) {
6784 buf.add$1(textLine.substring$2(0, column)); 6748 buf.add$1(textLine.substring$2(0, column));
6785 buf.add$1($globals._RED_COLOR); 6749 buf.add$1($globals._RED_COLOR);
6786 buf.add$1(textLine.substring$2(column, toColumn)); 6750 buf.add$1(textLine.substring$2(column, toColumn));
6787 buf.add$1($globals._NO_COLOR); 6751 buf.add$1($globals._NO_COLOR);
6788 buf.add$1(textLine.substring$1(toColumn)); 6752 buf.add$1(textLine.substring$1(toColumn));
6789 } 6753 }
6790 else { 6754 else {
6791 buf.add$1(textLine); 6755 buf.add$1(textLine);
6792 } 6756 }
6793 var i = 0; 6757 var i = 0;
6794 for (; i < column; i++) { 6758 for (; i < column; i++) {
6795 buf.add$1(' '); 6759 buf.add$1(" ");
6796 } 6760 }
6797 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR); 6761 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR);
6798 for (; i < toColumn; i++) { 6762 for (; i < toColumn; i++) {
6799 buf.add$1('^'); 6763 buf.add$1("^");
6800 } 6764 }
6801 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR); 6765 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR);
6802 } 6766 }
6803 return buf.toString$0(); 6767 return buf.toString$0();
6804 } 6768 }
6805 SourceFile.prototype.compareTo = function(other) { 6769 SourceFile.prototype.compareTo = function(other) {
6806 if (this.orderInLibrary != null && other.orderInLibrary != null) { 6770 if (this.orderInLibrary != null && other.orderInLibrary != null) {
6807 return this.orderInLibrary - other.orderInLibrary; 6771 return this.orderInLibrary - other.orderInLibrary;
6808 } 6772 }
6809 else { 6773 else {
(...skipping 15 matching lines...) Expand all
6825 SourceSpan.prototype.get$end = function() { return this.end; }; 6789 SourceSpan.prototype.get$end = function() { return this.end; };
6826 SourceSpan.prototype.get$text = function() { 6790 SourceSpan.prototype.get$text = function() {
6827 return this.file.get$text().substring(this.start, this.end); 6791 return this.file.get$text().substring(this.start, this.end);
6828 } 6792 }
6829 SourceSpan.prototype.toMessageString = function(message) { 6793 SourceSpan.prototype.toMessageString = function(message) {
6830 return this.file.getLocationMessage(message, this.start, this.end, true); 6794 return this.file.getLocationMessage(message, this.start, this.end, true);
6831 } 6795 }
6832 SourceSpan.prototype.get$locationText = function() { 6796 SourceSpan.prototype.get$locationText = function() {
6833 var line = this.file.getLine(this.start); 6797 var line = this.file.getLine(this.start);
6834 var column = this.file.getColumn(line, this.start); 6798 var column = this.file.getColumn(line, this.start);
6835 return ('' + this.file.filename + ':' + (line + 1) + ':' + (column + 1)); 6799 return ("" + this.file.filename + ":" + (line + 1) + ":" + (column + 1));
6836 } 6800 }
6837 SourceSpan.prototype.compareTo = function(other) { 6801 SourceSpan.prototype.compareTo = function(other) {
6838 if ($eq(this.file, other.file)) { 6802 if ($eq(this.file, other.file)) {
6839 var d = this.start - other.start; 6803 var d = this.start - other.start;
6840 return d == 0 ? (this.end - other.end) : d; 6804 return d == 0 ? (this.end - other.end) : d;
6841 } 6805 }
6842 return this.file.compareTo(other.file); 6806 return this.file.compareTo(other.file);
6843 } 6807 }
6844 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo; 6808 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo;
6845 SourceSpan.prototype.end$0 = function() { 6809 SourceSpan.prototype.end$0 = function() {
6846 return this.end(); 6810 return this.end.call$0();
6847 }; 6811 };
6848 SourceSpan.prototype.start$0 = function() { 6812 SourceSpan.prototype.start$0 = function() {
6849 return this.start(); 6813 return this.start.call$0();
6850 }; 6814 };
6851 // ********** Code for InterpStack ************** 6815 // ********** Code for InterpStack **************
6852 function InterpStack(previous, quote, isMultiline) { 6816 function InterpStack(previous, quote, isMultiline) {
6853 this.previous = previous; 6817 this.previous = previous;
6854 this.quote = quote; 6818 this.quote = quote;
6855 this.isMultiline = isMultiline; 6819 this.isMultiline = isMultiline;
6856 this.depth = -1; 6820 this.depth = -1;
6857 // Initializers done 6821 // Initializers done
6858 } 6822 }
6859 InterpStack.prototype.get$previous = function() { return this.previous; }; 6823 InterpStack.prototype.get$previous = function() { return this.previous; };
(...skipping 16 matching lines...) Expand all
6876 // ********** Code for TokenizerHelpers ************** 6840 // ********** Code for TokenizerHelpers **************
6877 function TokenizerHelpers() { 6841 function TokenizerHelpers() {
6878 // Initializers done 6842 // Initializers done
6879 } 6843 }
6880 TokenizerHelpers.isIdentifierStart = function(c) { 6844 TokenizerHelpers.isIdentifierStart = function(c) {
6881 return ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95); 6845 return ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95);
6882 } 6846 }
6883 TokenizerHelpers.isDigit = function(c) { 6847 TokenizerHelpers.isDigit = function(c) {
6884 return (c >= 48 && c <= 57); 6848 return (c >= 48 && c <= 57);
6885 } 6849 }
6886 TokenizerHelpers.isHexDigit = function(c) {
6887 return (TokenizerHelpers.isDigit(c) || (c >= 97 && c <= 102) || (c >= 65 && c <= 70));
6888 }
6889 TokenizerHelpers.isIdentifierPart = function(c) { 6850 TokenizerHelpers.isIdentifierPart = function(c) {
6890 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c) | | c == 36); 6851 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c) | | c == 36);
6891 } 6852 }
6892 TokenizerHelpers.isInterpIdentifierPart = function(c) { 6853 TokenizerHelpers.isInterpIdentifierPart = function(c) {
6893 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c)); 6854 return (TokenizerHelpers.isIdentifierStart(c) || TokenizerHelpers.isDigit(c));
6894 } 6855 }
6895 // ********** Code for TokenizerBase ************** 6856 // ********** Code for TokenizerBase **************
6896 $inherits(TokenizerBase, TokenizerHelpers); 6857 $inherits(TokenizerBase, TokenizerHelpers);
6897 function TokenizerBase(_source, _skipWhitespace, index) { 6858 function TokenizerBase(_source, _skipWhitespace, index) {
6898 this._source = _source; 6859 this._source = _source;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6980 return this._finishToken(64/*TokenKind.COMMENT*/); 6941 return this._finishToken(64/*TokenKind.COMMENT*/);
6981 } 6942 }
6982 } 6943 }
6983 } 6944 }
6984 } 6945 }
6985 TokenizerBase.prototype.finishMultiLineComment = function() { 6946 TokenizerBase.prototype.finishMultiLineComment = function() {
6986 var nesting = 1; 6947 var nesting = 1;
6987 do { 6948 do {
6988 var ch = this._nextChar(); 6949 var ch = this._nextChar();
6989 if (ch == 0) { 6950 if (ch == 0) {
6990 return this._finishToken(67/*TokenKind.INCOMPLETE_COMMENT*/); 6951 return this._errorToken();
6991 } 6952 }
6992 else if (ch == 42) { 6953 else if (ch == 42) {
6993 if (this._maybeEatChar(47)) { 6954 if (this._maybeEatChar(47)) {
6994 nesting--; 6955 nesting--;
6995 } 6956 }
6996 } 6957 }
6997 else if (ch == 47) { 6958 else if (ch == 47) {
6998 if (this._maybeEatChar(42)) { 6959 if (this._maybeEatChar(42)) {
6999 nesting++; 6960 nesting++;
7000 } 6961 }
(...skipping 10 matching lines...) Expand all
7011 TokenizerBase.prototype.eatDigits = function() { 6972 TokenizerBase.prototype.eatDigits = function() {
7012 while (this._lang_index < this._text.length) { 6973 while (this._lang_index < this._text.length) {
7013 if (TokenizerHelpers.isDigit(this._text.charCodeAt(this._lang_index))) { 6974 if (TokenizerHelpers.isDigit(this._text.charCodeAt(this._lang_index))) {
7014 this._lang_index++; 6975 this._lang_index++;
7015 } 6976 }
7016 else { 6977 else {
7017 return; 6978 return;
7018 } 6979 }
7019 } 6980 }
7020 } 6981 }
7021 TokenizerBase.prototype.eatHexDigits = function() { 6982 TokenizerBase._hexDigit = function(c) {
7022 while (this._lang_index < this._text.length) { 6983 if (c >= 48 && c <= 57) {
7023 if (TokenizerHelpers.isHexDigit(this._text.charCodeAt(this._lang_index))) { 6984 return c - 48;
7024 this._lang_index++; 6985 }
7025 } 6986 else if (c >= 97 && c <= 102) {
7026 else { 6987 return c - 87;
7027 return; 6988 }
7028 } 6989 else if (c >= 65 && c <= 70) {
6990 return c - 55;
6991 }
6992 else {
6993 return -1;
7029 } 6994 }
7030 } 6995 }
7031 TokenizerBase.prototype.maybeEatHexDigit = function() { 6996 TokenizerBase.prototype.readHex = function(hexLength) {
7032 if (this._lang_index < this._text.length && TokenizerHelpers.isHexDigit(this._ text.charCodeAt(this._lang_index))) { 6997 var maxIndex;
6998 if (hexLength == null) {
6999 maxIndex = this._text.length - 1;
7000 }
7001 else {
7002 maxIndex = this._lang_index + hexLength;
7003 if (maxIndex >= this._text.length) return -1;
7004 }
7005 var result = 0;
7006 while (this._lang_index < maxIndex) {
7007 var digit = TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)) ;
7008 if (digit == -1) {
7009 if (hexLength == null) {
7010 return result;
7011 }
7012 else {
7013 return -1;
7014 }
7015 }
7016 TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index));
7017 result = (result * 16) + digit;
7033 this._lang_index++; 7018 this._lang_index++;
7034 return true;
7035 } 7019 }
7036 return false; 7020 return result;
7037 } 7021 }
7038 TokenizerBase.prototype.finishHex = function() { 7022 TokenizerBase.prototype.finishHex = function() {
7039 this.eatHexDigits(); 7023 var value = this.readHex();
7040 return this._finishToken(61/*TokenKind.HEX_INTEGER*/); 7024 return new LiteralToken(61/*TokenKind.HEX_INTEGER*/, this._source, this._start Index, this._lang_index, value);
7041 } 7025 }
7042 TokenizerBase.prototype.finishNumber = function() { 7026 TokenizerBase.prototype.finishNumber = function() {
7043 this.eatDigits(); 7027 this.eatDigits();
7044 if (this._peekChar() == 46) { 7028 if (this._peekChar() == 46) {
7045 this._nextChar(); 7029 this._nextChar();
7046 if (TokenizerHelpers.isDigit(this._peekChar())) { 7030 if (TokenizerHelpers.isDigit(this._peekChar())) {
7047 this.eatDigits(); 7031 this.eatDigits();
7048 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/); 7032 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/);
7049 } 7033 }
7050 else { 7034 else {
7051 this._lang_index--; 7035 this._lang_index--;
7052 } 7036 }
7053 } 7037 }
7054 return this.finishNumberExtra(60/*TokenKind.INTEGER*/); 7038 return this.finishNumberExtra(60/*TokenKind.INTEGER*/);
7055 } 7039 }
7056 TokenizerBase.prototype.finishNumberExtra = function(kind) { 7040 TokenizerBase.prototype.finishNumberExtra = function(kind) {
7057 if (this._maybeEatChar(101) || this._maybeEatChar(69)) { 7041 if (this._maybeEatChar(101) || this._maybeEatChar(69)) {
7058 kind = 62/*TokenKind.DOUBLE*/; 7042 kind = 62/*TokenKind.DOUBLE*/;
7059 this._maybeEatChar(45); 7043 this._maybeEatChar(45);
7060 this._maybeEatChar(43); 7044 this._maybeEatChar(43);
7061 this.eatDigits(); 7045 this.eatDigits();
7062 } 7046 }
7063 if (this._peekChar() != 0 && TokenizerHelpers.isIdentifierStart(this._peekChar ())) { 7047 if (this._peekChar() != 0 && TokenizerHelpers.isIdentifierStart(this._peekChar ())) {
7064 this._nextChar(); 7048 this._nextChar();
7065 return this._errorToken("illegal character in number"); 7049 return this._errorToken("illegal character in number");
7066 } 7050 }
7067 return this._finishToken(kind); 7051 return this._finishToken(kind);
7068 } 7052 }
7053 TokenizerBase.prototype._makeStringToken = function(buf, isPart) {
7054 var s = Strings.String$fromCharCodes$factory(buf);
7055 var kind = isPart ? 59/*TokenKind.STRING_PART*/ : 58/*TokenKind.STRING*/;
7056 return new LiteralToken(kind, this._source, this._startIndex, this._lang_index , s);
7057 }
7058 TokenizerBase.prototype._makeRawStringToken = function(isMultiline) {
7059 var s;
7060 if (isMultiline) {
7061 if (this._source.get$text()[this._startIndex + 4] == "\n") {
7062 s = this._source.get$text().substring(this._startIndex + 5, this._lang_ind ex - 3);
7063 }
7064 else {
7065 s = this._source.get$text().substring(this._startIndex + 4, this._lang_ind ex - 3);
7066 }
7067 }
7068 else {
7069 s = this._source.get$text().substring(this._startIndex + 2, this._lang_index - 1);
7070 }
7071 return new LiteralToken(58/*TokenKind.STRING*/, this._source, this._startIndex , this._lang_index, s);
7072 }
7069 TokenizerBase.prototype.finishMultilineString = function(quote) { 7073 TokenizerBase.prototype.finishMultilineString = function(quote) {
7074 var buf = new Array();
7070 while (true) { 7075 while (true) {
7071 var ch = this._nextChar(); 7076 var ch = this._nextChar();
7072 if (ch == 0) { 7077 if (ch == 0) {
7073 var kind = quote == 34 ? 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/ : 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/; 7078 return this._errorToken();
7074 return this._finishToken(kind);
7075 } 7079 }
7076 else if (ch == quote) { 7080 else if (ch == quote) {
7077 if (this._maybeEatChar(quote)) { 7081 if (this._maybeEatChar(quote)) {
7078 if (this._maybeEatChar(quote)) { 7082 if (this._maybeEatChar(quote)) {
7079 return this._finishToken(58/*TokenKind.STRING*/); 7083 return this._makeStringToken(buf, false);
7080 } 7084 }
7085 buf.add$1(quote);
7081 } 7086 }
7087 buf.add$1(quote);
7082 } 7088 }
7083 else if (ch == 36) { 7089 else if (ch == 36) {
7084 this._interpStack = InterpStack.push(this._interpStack, quote, true); 7090 this._interpStack = InterpStack.push(this._interpStack, quote, true);
7085 return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/); 7091 return this._makeStringToken(buf, true);
7086 } 7092 }
7087 else if (ch == 92) { 7093 else if (ch == 92) {
7088 if (!this.eatEscapeSequence()) { 7094 var escapeVal = this.readEscapeSequence();
7095 if ($eq(escapeVal, -1)) {
7089 return this._errorToken("invalid hex escape sequence"); 7096 return this._errorToken("invalid hex escape sequence");
7090 } 7097 }
7098 else {
7099 buf.add$1(escapeVal);
7100 }
7101 }
7102 else {
7103 buf.add$1(ch);
7091 } 7104 }
7092 } 7105 }
7093 } 7106 }
7094 TokenizerBase.prototype._finishOpenBrace = function() { 7107 TokenizerBase.prototype._finishOpenBrace = function() {
7095 var $0; 7108 var $0;
7096 if (this._interpStack != null) { 7109 if (this._interpStack != null) {
7097 if (this._interpStack.depth == -1) { 7110 if (this._interpStack.depth == -1) {
7098 this._interpStack.depth = 1; 7111 this._interpStack.depth = 1;
7099 } 7112 }
7100 else { 7113 else {
7101 ($0 = this._interpStack).depth = $0.depth + 1; 7114 ($0 = this._interpStack).depth = $0.depth + 1;
7102 } 7115 }
7103 } 7116 }
7104 return this._finishToken(6/*TokenKind.LBRACE*/); 7117 return this._finishToken(6/*TokenKind.LBRACE*/);
7105 } 7118 }
7106 TokenizerBase.prototype._finishCloseBrace = function() { 7119 TokenizerBase.prototype._finishCloseBrace = function() {
7107 var $0; 7120 var $0;
7108 if (this._interpStack != null) { 7121 if (this._interpStack != null) {
7109 ($0 = this._interpStack).depth = $0.depth - 1; 7122 ($0 = this._interpStack).depth = $0.depth - 1;
7110 } 7123 }
7111 return this._finishToken(7/*TokenKind.RBRACE*/); 7124 return this._finishToken(7/*TokenKind.RBRACE*/);
7112 } 7125 }
7113 TokenizerBase.prototype.finishString = function(quote) { 7126 TokenizerBase.prototype.finishString = function(quote) {
7114 if (this._maybeEatChar(quote)) { 7127 if (this._maybeEatChar(quote)) {
7115 if (this._maybeEatChar(quote)) { 7128 if (this._maybeEatChar(quote)) {
7129 this._maybeEatChar(10);
7116 return this.finishMultilineString(quote); 7130 return this.finishMultilineString(quote);
7117 } 7131 }
7118 else { 7132 else {
7119 return this._finishToken(58/*TokenKind.STRING*/); 7133 return this._makeStringToken(new Array(), false);
7120 } 7134 }
7121 } 7135 }
7122 return this.finishStringBody(quote); 7136 return this.finishStringBody(quote);
7123 } 7137 }
7124 TokenizerBase.prototype.finishRawString = function(quote) { 7138 TokenizerBase.prototype.finishRawString = function(quote) {
7125 if (this._maybeEatChar(quote)) { 7139 if (this._maybeEatChar(quote)) {
7126 if (this._maybeEatChar(quote)) { 7140 if (this._maybeEatChar(quote)) {
7127 return this.finishMultilineRawString(quote); 7141 return this.finishMultilineRawString(quote);
7128 } 7142 }
7129 else { 7143 else {
7130 return this._finishToken(58/*TokenKind.STRING*/); 7144 return this._makeStringToken(new Array(), false);
7131 } 7145 }
7132 } 7146 }
7133 while (true) { 7147 while (true) {
7134 var ch = this._nextChar(); 7148 var ch = this._nextChar();
7135 if (ch == quote) { 7149 if (ch == quote) {
7136 return this._finishToken(58/*TokenKind.STRING*/); 7150 return this._makeRawStringToken(false);
7137 } 7151 }
7138 else if (ch == 0) { 7152 else if (ch == 0) {
7139 return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/); 7153 return this._errorToken();
7140 } 7154 }
7141 } 7155 }
7142 } 7156 }
7143 TokenizerBase.prototype.finishMultilineRawString = function(quote) { 7157 TokenizerBase.prototype.finishMultilineRawString = function(quote) {
7144 while (true) { 7158 while (true) {
7145 var ch = this._nextChar(); 7159 var ch = this._nextChar();
7146 if (ch == 0) { 7160 if (ch == 0) {
7147 var kind = quote == 34 ? 68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/ : 69/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/; 7161 return this._errorToken();
7148 return this._finishToken(kind);
7149 } 7162 }
7150 else if (ch == quote && this._maybeEatChar(quote) && this._maybeEatChar(quot e)) { 7163 else if (ch == quote && this._maybeEatChar(quote) && this._maybeEatChar(quot e)) {
7151 return this._finishToken(58/*TokenKind.STRING*/); 7164 return this._makeRawStringToken(true);
7152 } 7165 }
7153 } 7166 }
7154 } 7167 }
7155 TokenizerBase.prototype.finishStringBody = function(quote) { 7168 TokenizerBase.prototype.finishStringBody = function(quote) {
7169 var buf = new Array();
7156 while (true) { 7170 while (true) {
7157 var ch = this._nextChar(); 7171 var ch = this._nextChar();
7158 if (ch == quote) { 7172 if (ch == quote) {
7159 return this._finishToken(58/*TokenKind.STRING*/); 7173 return this._makeStringToken(buf, false);
7160 } 7174 }
7161 else if (ch == 36) { 7175 else if (ch == 36) {
7162 this._interpStack = InterpStack.push(this._interpStack, quote, false); 7176 this._interpStack = InterpStack.push(this._interpStack, quote, false);
7163 return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/); 7177 return this._makeStringToken(buf, true);
7164 } 7178 }
7165 else if (ch == 0) { 7179 else if (ch == 0) {
7166 return this._finishToken(66/*TokenKind.INCOMPLETE_STRING*/); 7180 return this._errorToken();
7167 } 7181 }
7168 else if (ch == 92) { 7182 else if (ch == 92) {
7169 if (!this.eatEscapeSequence()) { 7183 var escapeVal = this.readEscapeSequence();
7184 if ($eq(escapeVal, -1)) {
7170 return this._errorToken("invalid hex escape sequence"); 7185 return this._errorToken("invalid hex escape sequence");
7171 } 7186 }
7187 else {
7188 buf.add$1(escapeVal);
7189 }
7190 }
7191 else {
7192 buf.add$1(ch);
7172 } 7193 }
7173 } 7194 }
7174 } 7195 }
7175 TokenizerBase.prototype.eatEscapeSequence = function() { 7196 TokenizerBase.prototype.readEscapeSequence = function() {
7176 var hex; 7197 var ch = this._nextChar();
7177 switch (this._nextChar()) { 7198 var hexValue;
7199 switch (ch) {
7200 case 110:
7201
7202 return 10;
7203
7204 case 114:
7205
7206 return 13;
7207
7208 case 102:
7209
7210 return 12;
7211
7212 case 98:
7213
7214 return 8;
7215
7216 case 116:
7217
7218 return 9;
7219
7220 case 118:
7221
7222 return 11;
7223
7178 case 120: 7224 case 120:
7179 7225
7180 return this.maybeEatHexDigit() && this.maybeEatHexDigit(); 7226 hexValue = this.readHex(2);
7227 break;
7181 7228
7182 case 117: 7229 case 117:
7183 7230
7184 if (this._maybeEatChar(123)) { 7231 if (this._maybeEatChar(123)) {
7185 var start = this._lang_index; 7232 hexValue = this.readHex();
7186 this.eatHexDigits(); 7233 if (!this._maybeEatChar(125)) {
7187 var chars = this._lang_index - start; 7234 return -1;
7188 if (chars > 0 && chars <= 6 && this._maybeEatChar(125)) {
7189 hex = this._text.substring(start, start + chars);
7190 break;
7191 } 7235 }
7192 else { 7236 else {
7193 return false; 7237 break;
7194 } 7238 }
7195 } 7239 }
7196 else { 7240 else {
7197 if (this.maybeEatHexDigit() && this.maybeEatHexDigit() && this.maybeEatH exDigit() && this.maybeEatHexDigit()) { 7241 hexValue = this.readHex(4);
7198 hex = this._text.substring(this._lang_index - 4, this._lang_index); 7242 break;
7199 break;
7200 }
7201 else {
7202 return false;
7203 }
7204 } 7243 }
7205 7244
7206 default: 7245 default:
7207 7246
7208 return true; 7247 return ch;
7209 7248
7210 } 7249 }
7211 var n = Parser.parseHex(hex); 7250 if (hexValue == -1) return -1;
7212 return n < 0xD800 || n > 0xDFFF && n <= 0x10FFFF; 7251 if (hexValue < 55296 || hexValue > 57343 && hexValue <= 65535) {
7252 return hexValue;
7253 }
7254 else if (hexValue <= 1114111) {
7255 $globals.world.fatal("unicode values greater than 2 bytes not implemented ye t");
7256 return -1;
7257 }
7258 else {
7259 return -1;
7260 }
7213 } 7261 }
7214 TokenizerBase.prototype.finishDot = function() { 7262 TokenizerBase.prototype.finishDot = function() {
7215 if (TokenizerHelpers.isDigit(this._peekChar())) { 7263 if (TokenizerHelpers.isDigit(this._peekChar())) {
7216 this.eatDigits(); 7264 this.eatDigits();
7217 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/); 7265 return this.finishNumberExtra(62/*TokenKind.DOUBLE*/);
7218 } 7266 }
7219 else { 7267 else {
7220 return this._finishToken(14/*TokenKind.DOT*/); 7268 return this._finishToken(14/*TokenKind.DOT*/);
7221 } 7269 }
7222 } 7270 }
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
8420 return 10; 8468 return 10;
8421 8469
8422 default: 8470 default:
8423 8471
8424 return -1; 8472 return -1;
8425 8473
8426 } 8474 }
8427 } 8475 }
8428 TokenKind.rawOperatorFromMethod = function(name) { 8476 TokenKind.rawOperatorFromMethod = function(name) {
8429 switch (name) { 8477 switch (name) {
8430 case ':bit_not': 8478 case ":bit_not":
8431 8479
8432 return '~'; 8480 return "~";
8433 8481
8434 case ':bit_or': 8482 case ":bit_or":
8435 8483
8436 return '|'; 8484 return "|";
8437 8485
8438 case ':bit_xor': 8486 case ":bit_xor":
8439 8487
8440 return '^'; 8488 return "^";
8441 8489
8442 case ':bit_and': 8490 case ":bit_and":
8443 8491
8444 return '&'; 8492 return "&";
8445 8493
8446 case ':shl': 8494 case ":shl":
8447 8495
8448 return '<<'; 8496 return "<<";
8449 8497
8450 case ':sar': 8498 case ":sar":
8451 8499
8452 return '>>'; 8500 return ">>";
8453 8501
8454 case ':shr': 8502 case ":shr":
8455 8503
8456 return '>>>'; 8504 return ">>>";
8457 8505
8458 case ':add': 8506 case ":add":
8459 8507
8460 return '+'; 8508 return "+";
8461 8509
8462 case ':sub': 8510 case ":sub":
8463 8511
8464 return '-'; 8512 return "-";
8465 8513
8466 case ':mul': 8514 case ":mul":
8467 8515
8468 return '*'; 8516 return "*";
8469 8517
8470 case ':div': 8518 case ":div":
8471 8519
8472 return '/'; 8520 return "/";
8473 8521
8474 case ':truncdiv': 8522 case ":truncdiv":
8475 8523
8476 return '~/'; 8524 return "~/";
8477 8525
8478 case ':mod': 8526 case ":mod":
8479 8527
8480 return '%'; 8528 return "%";
8481 8529
8482 case ':eq': 8530 case ":eq":
8483 8531
8484 return '=='; 8532 return "==";
8485 8533
8486 case ':lt': 8534 case ":lt":
8487 8535
8488 return '<'; 8536 return "<";
8489 8537
8490 case ':gt': 8538 case ":gt":
8491 8539
8492 return '>'; 8540 return ">";
8493 8541
8494 case ':lte': 8542 case ":lte":
8495 8543
8496 return '<='; 8544 return "<=";
8497 8545
8498 case ':gte': 8546 case ":gte":
8499 8547
8500 return '>='; 8548 return ">=";
8501 8549
8502 case ':index': 8550 case ":index":
8503 8551
8504 return '[]'; 8552 return "[]";
8505 8553
8506 case ':setindex': 8554 case ":setindex":
8507 8555
8508 return '[]='; 8556 return "[]=";
8509 8557
8510 case ':ne': 8558 case ":ne":
8511 8559
8512 return '!='; 8560 return "!=";
8513 8561
8514 } 8562 }
8515 } 8563 }
8516 TokenKind.binaryMethodName = function(kind) { 8564 TokenKind.binaryMethodName = function(kind) {
8517 switch (kind) { 8565 switch (kind) {
8518 case 18/*TokenKind.BIT_NOT*/: 8566 case 18/*TokenKind.BIT_NOT*/:
8519 8567
8520 return ':bit_not'; 8568 return ":bit_not";
8521 8569
8522 case 36/*TokenKind.BIT_OR*/: 8570 case 36/*TokenKind.BIT_OR*/:
8523 8571
8524 return ':bit_or'; 8572 return ":bit_or";
8525 8573
8526 case 37/*TokenKind.BIT_XOR*/: 8574 case 37/*TokenKind.BIT_XOR*/:
8527 8575
8528 return ':bit_xor'; 8576 return ":bit_xor";
8529 8577
8530 case 38/*TokenKind.BIT_AND*/: 8578 case 38/*TokenKind.BIT_AND*/:
8531 8579
8532 return ':bit_and'; 8580 return ":bit_and";
8533 8581
8534 case 39/*TokenKind.SHL*/: 8582 case 39/*TokenKind.SHL*/:
8535 8583
8536 return ':shl'; 8584 return ":shl";
8537 8585
8538 case 40/*TokenKind.SAR*/: 8586 case 40/*TokenKind.SAR*/:
8539 8587
8540 return ':sar'; 8588 return ":sar";
8541 8589
8542 case 41/*TokenKind.SHR*/: 8590 case 41/*TokenKind.SHR*/:
8543 8591
8544 return ':shr'; 8592 return ":shr";
8545 8593
8546 case 42/*TokenKind.ADD*/: 8594 case 42/*TokenKind.ADD*/:
8547 8595
8548 return ':add'; 8596 return ":add";
8549 8597
8550 case 43/*TokenKind.SUB*/: 8598 case 43/*TokenKind.SUB*/:
8551 8599
8552 return ':sub'; 8600 return ":sub";
8553 8601
8554 case 44/*TokenKind.MUL*/: 8602 case 44/*TokenKind.MUL*/:
8555 8603
8556 return ':mul'; 8604 return ":mul";
8557 8605
8558 case 45/*TokenKind.DIV*/: 8606 case 45/*TokenKind.DIV*/:
8559 8607
8560 return ':div'; 8608 return ":div";
8561 8609
8562 case 46/*TokenKind.TRUNCDIV*/: 8610 case 46/*TokenKind.TRUNCDIV*/:
8563 8611
8564 return ':truncdiv'; 8612 return ":truncdiv";
8565 8613
8566 case 47/*TokenKind.MOD*/: 8614 case 47/*TokenKind.MOD*/:
8567 8615
8568 return ':mod'; 8616 return ":mod";
8569 8617
8570 case 48/*TokenKind.EQ*/: 8618 case 48/*TokenKind.EQ*/:
8571 8619
8572 return ':eq'; 8620 return ":eq";
8573 8621
8574 case 52/*TokenKind.LT*/: 8622 case 52/*TokenKind.LT*/:
8575 8623
8576 return ':lt'; 8624 return ":lt";
8577 8625
8578 case 53/*TokenKind.GT*/: 8626 case 53/*TokenKind.GT*/:
8579 8627
8580 return ':gt'; 8628 return ":gt";
8581 8629
8582 case 54/*TokenKind.LTE*/: 8630 case 54/*TokenKind.LTE*/:
8583 8631
8584 return ':lte'; 8632 return ":lte";
8585 8633
8586 case 55/*TokenKind.GTE*/: 8634 case 55/*TokenKind.GTE*/:
8587 8635
8588 return ':gte'; 8636 return ":gte";
8589 8637
8590 case 56/*TokenKind.INDEX*/: 8638 case 56/*TokenKind.INDEX*/:
8591 8639
8592 return ':index'; 8640 return ":index";
8593 8641
8594 case 57/*TokenKind.SETINDEX*/: 8642 case 57/*TokenKind.SETINDEX*/:
8595 8643
8596 return ':setindex'; 8644 return ":setindex";
8597 8645
8598 } 8646 }
8599 } 8647 }
8600 TokenKind.kindFromAssign = function(kind) { 8648 TokenKind.kindFromAssign = function(kind) {
8601 if (kind == 20/*TokenKind.ASSIGN*/) return 0; 8649 if (kind == 20/*TokenKind.ASSIGN*/) return 0;
8602 if (kind > 20/*TokenKind.ASSIGN*/ && kind <= 32/*TokenKind.ASSIGN_MOD*/) { 8650 if (kind > 20/*TokenKind.ASSIGN*/ && kind <= 32/*TokenKind.ASSIGN_MOD*/) {
8603 return kind + (15)/*(ADD - ASSIGN_ADD)*/; 8651 return kind + (15);
8604 } 8652 }
8605 return -1; 8653 return -1;
8606 } 8654 }
8607 // ********** Code for Parser ************** 8655 // ********** Code for Parser **************
8608 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset ) { 8656 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset ) {
8609 this._inhibitLambda = false 8657 this._inhibitLambda = false
8610 this._afterParensIndex = 0 8658 this._afterParensIndex = 0
8611 this._recover = false 8659 this._recover = false
8612 this.source = source; 8660 this.source = source;
8613 this.diet = diet; 8661 this.diet = diet;
8614 this.throwOnIncomplete = throwOnIncomplete; 8662 this.throwOnIncomplete = throwOnIncomplete;
8615 this.optionalSemicolons = optionalSemicolons; 8663 this.optionalSemicolons = optionalSemicolons;
8616 // Initializers done 8664 // Initializers done
8617 this.tokenizer = new Tokenizer(this.source, true, startOffset); 8665 this.tokenizer = new Tokenizer(this.source, true, startOffset);
8618 this._peekToken = this.tokenizer.next(); 8666 this._peekToken = this.tokenizer.next();
8619 this._afterParens = []; 8667 this._afterParens = [];
8620 } 8668 }
8621 Parser.prototype.get$enableAwait = function() { 8669 Parser.prototype.get$enableAwait = function() {
8622 return $globals.experimentalAwaitPhase != null; 8670 return $globals.experimentalAwaitPhase != null;
8623 } 8671 }
8624 Parser.prototype.isPrematureEndOfFile = function() { 8672 Parser.prototype.isPrematureEndOfFile = function() {
8625 if (this.throwOnIncomplete && this._maybeEat(1/*TokenKind.END_OF_FILE*/) || th is._maybeEat(68/*TokenKind.INCOMPLETE_MULTILINE_STRING_DQ*/) || this._maybeEat(6 9/*TokenKind.INCOMPLETE_MULTILINE_STRING_SQ*/)) { 8673 if (this.throwOnIncomplete && this._maybeEat(1/*TokenKind.END_OF_FILE*/)) {
8626 $throw(new IncompleteSourceException(this._previousToken)); 8674 $throw(new IncompleteSourceException(this._previousToken));
8627 } 8675 }
8628 else if (this._maybeEat(1/*TokenKind.END_OF_FILE*/)) { 8676 else if (this._maybeEat(1/*TokenKind.END_OF_FILE*/)) {
8629 this._lang_error('unexpected end of file', this._peekToken.get$span()); 8677 this._lang_error("unexpected end of file", this._peekToken.get$span());
8630 return true; 8678 return true;
8631 } 8679 }
8632 else { 8680 else {
8633 return false; 8681 return false;
8634 } 8682 }
8635 } 8683 }
8636 Parser.prototype._recoverTo = function(kind1, kind2, kind3) { 8684 Parser.prototype._recoverTo = function(kind1, kind2, kind3) {
8637 while (!this.isPrematureEndOfFile()) { 8685 while (!this.isPrematureEndOfFile()) {
8638 var kind = this._peek(); 8686 var kind = this._peek();
8639 if (kind == kind1 || kind == kind2 || kind == kind3) { 8687 if (kind == kind1 || kind == kind2 || kind == kind3) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8680 if (this.optionalSemicolons && this._peekKind(1/*TokenKind.END_OF_FILE*/)) ret urn; 8728 if (this.optionalSemicolons && this._peekKind(1/*TokenKind.END_OF_FILE*/)) ret urn;
8681 this._eat(10/*TokenKind.SEMICOLON*/); 8729 this._eat(10/*TokenKind.SEMICOLON*/);
8682 } 8730 }
8683 Parser.prototype._errorExpected = function(expected) { 8731 Parser.prototype._errorExpected = function(expected) {
8684 if (this.throwOnIncomplete) this.isPrematureEndOfFile(); 8732 if (this.throwOnIncomplete) this.isPrematureEndOfFile();
8685 var tok = this._lang_next(); 8733 var tok = this._lang_next();
8686 if ((tok instanceof ErrorToken) && tok.get$message() != null) { 8734 if ((tok instanceof ErrorToken) && tok.get$message() != null) {
8687 this._lang_error(tok.get$message(), tok.get$span()); 8735 this._lang_error(tok.get$message(), tok.get$span());
8688 } 8736 }
8689 else { 8737 else {
8690 this._lang_error(('expected ' + expected + ', but found ' + tok), tok.get$sp an()); 8738 this._lang_error(("expected " + expected + ", but found " + tok), tok.get$sp an());
8691 } 8739 }
8692 } 8740 }
8693 Parser.prototype._lang_error = function(message, location) { 8741 Parser.prototype._lang_error = function(message, location) {
8694 if (this._recover) return; 8742 if (this._recover) return;
8695 if (location == null) { 8743 if (location == null) {
8696 location = this._peekToken.get$span(); 8744 location = this._peekToken.get$span();
8697 } 8745 }
8698 $globals.world.fatal(message, location); 8746 $globals.world.fatal(message, location);
8699 this._recover = true; 8747 this._recover = true;
8700 } 8748 }
8701 Parser.prototype._skipBlock = function() { 8749 Parser.prototype._skipBlock = function() {
8702 var depth = 1; 8750 var depth = 1;
8703 this._eat(6/*TokenKind.LBRACE*/); 8751 this._eat(6/*TokenKind.LBRACE*/);
8704 while (true) { 8752 while (true) {
8705 var tok = this._lang_next(); 8753 var tok = this._lang_next();
8706 if ($eq(tok.get$kind(), 6/*TokenKind.LBRACE*/)) { 8754 if ($eq(tok.get$kind(), 6/*TokenKind.LBRACE*/)) {
8707 depth += 1; 8755 depth += 1;
8708 } 8756 }
8709 else if ($eq(tok.get$kind(), 7/*TokenKind.RBRACE*/)) { 8757 else if ($eq(tok.get$kind(), 7/*TokenKind.RBRACE*/)) {
8710 depth -= 1; 8758 depth -= 1;
8711 if (depth == 0) return; 8759 if (depth == 0) return;
8712 } 8760 }
8713 else if ($eq(tok.get$kind(), 1/*TokenKind.END_OF_FILE*/)) { 8761 else if ($eq(tok.get$kind(), 1/*TokenKind.END_OF_FILE*/)) {
8714 this._lang_error('unexpected end of file during diet parse', tok.get$span( )); 8762 this._lang_error("unexpected end of file during diet parse", tok.get$span( ));
8715 return; 8763 return;
8716 } 8764 }
8717 } 8765 }
8718 } 8766 }
8719 Parser.prototype._makeSpan = function(start) { 8767 Parser.prototype._makeSpan = function(start) {
8720 return new SourceSpan(this.source, start, this._previousToken.end); 8768 return new SourceSpan(this.source, start, this._previousToken.end);
8721 } 8769 }
8722 Parser.prototype.compilationUnit = function() { 8770 Parser.prototype.compilationUnit = function() {
8723 var ret = []; 8771 var ret = [];
8724 this._maybeEat(13/*TokenKind.HASHBANG*/); 8772 this._maybeEat(13/*TokenKind.HASHBANG*/);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
8778 } 8826 }
8779 var _native = null; 8827 var _native = null;
8780 if (this._maybeEat(79/*TokenKind.NATIVE*/)) { 8828 if (this._maybeEat(79/*TokenKind.NATIVE*/)) {
8781 _native = this.maybeStringLiteral(); 8829 _native = this.maybeStringLiteral();
8782 if (_native != null) _native = new NativeType(_native); 8830 if (_native != null) _native = new NativeType(_native);
8783 } 8831 }
8784 var oldFactory = this._maybeEat(73/*TokenKind.FACTORY*/); 8832 var oldFactory = this._maybeEat(73/*TokenKind.FACTORY*/);
8785 var defaultType = null; 8833 var defaultType = null;
8786 if (oldFactory || this._maybeEat(93/*TokenKind.DEFAULT*/)) { 8834 if (oldFactory || this._maybeEat(93/*TokenKind.DEFAULT*/)) {
8787 if (oldFactory) { 8835 if (oldFactory) {
8788 $globals.world.warning('factory no longer supported, use "default" instead ', this._previousToken.get$span()); 8836 $globals.world.warning("factory no longer supported, use \"default\" inste ad", this._previousToken.get$span());
8789 } 8837 }
8790 var baseType = this.nameTypeReference(); 8838 var baseType = this.nameTypeReference();
8791 var typeParams0 = null; 8839 var typeParams0 = null;
8792 if (this._peekKind(52/*TokenKind.LT*/)) { 8840 if (this._peekKind(52/*TokenKind.LT*/)) {
8793 typeParams0 = this.typeParameters(); 8841 typeParams0 = this.typeParameters();
8794 } 8842 }
8795 defaultType = new DefaultTypeReference(oldFactory, baseType, typeParams0, th is._makeSpan(baseType.get$span().get$start())); 8843 defaultType = new DefaultTypeReference(oldFactory, baseType, typeParams0, th is._makeSpan(baseType.get$span().get$start()));
8796 } 8844 }
8797 var body = []; 8845 var body = [];
8798 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 8846 if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
8799 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) { 8847 while (!this._maybeEat(7/*TokenKind.RBRACE*/)) {
8800 body.add$1(this.declaration(true)); 8848 body.add$1(this.declaration(true));
8801 if (this._recover) { 8849 if (this._recover) {
8802 if (!this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.SEMICOLON*/)) break; 8850 if (!this._recoverTo(7/*TokenKind.RBRACE*/, 10/*TokenKind.SEMICOLON*/)) break;
8803 this._maybeEat(10/*TokenKind.SEMICOLON*/); 8851 this._maybeEat(10/*TokenKind.SEMICOLON*/);
8804 } 8852 }
8805 } 8853 }
8806 } 8854 }
8807 else { 8855 else {
8808 this._errorExpected('block starting with "{" or ";"'); 8856 this._errorExpected("block starting with \"{\" or \";\"");
8809 } 8857 }
8810 return new TypeDefinition(kind == 90/*TokenKind.CLASS*/, name, typeParams, _ex tends, _implements, _native, defaultType, body, this._makeSpan(start)); 8858 return new TypeDefinition(kind == 90/*TokenKind.CLASS*/, name, typeParams, _ex tends, _implements, _native, defaultType, body, this._makeSpan(start));
8811 } 8859 }
8812 Parser.prototype.functionTypeAlias = function() { 8860 Parser.prototype.functionTypeAlias = function() {
8813 var start = this._peekToken.start; 8861 var start = this._peekToken.start;
8814 this._eat(85/*TokenKind.TYPEDEF*/); 8862 this._eat(85/*TokenKind.TYPEDEF*/);
8815 var di = this.declaredIdentifier(false); 8863 var di = this.declaredIdentifier(false);
8816 var typeParams = null; 8864 var typeParams = null;
8817 if (this._peekKind(52/*TokenKind.LT*/)) { 8865 if (this._peekKind(52/*TokenKind.LT*/)) {
8818 typeParams = this.typeParameters(); 8866 typeParams = this.typeParameters();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8851 } 8899 }
8852 else { 8900 else {
8853 return this.block(); 8901 return this.block();
8854 } 8902 }
8855 } 8903 }
8856 else if (!inExpression) { 8904 else if (!inExpression) {
8857 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) { 8905 if (this._maybeEat(10/*TokenKind.SEMICOLON*/)) {
8858 return null; 8906 return null;
8859 } 8907 }
8860 } 8908 }
8861 this._lang_error('Expected function body (neither { nor => found)'); 8909 this._lang_error("Expected function body (neither { nor => found)");
8862 } 8910 }
8863 Parser.prototype.finishField = function(start, modifiers, type, name, value) { 8911 Parser.prototype.finishField = function(start, modifiers, type, name, value) {
8864 var names = [name]; 8912 var names = [name];
8865 var values = [value]; 8913 var values = [value];
8866 while (this._maybeEat(11/*TokenKind.COMMA*/)) { 8914 while (this._maybeEat(11/*TokenKind.COMMA*/)) {
8867 names.add$1(this.identifier()); 8915 names.add$1(this.identifier());
8868 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 8916 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
8869 values.add$1(this.expression()); 8917 values.add$1(this.expression());
8870 } 8918 }
8871 else { 8919 else {
8872 values.add$1(); 8920 values.add$1();
8873 } 8921 }
8874 } 8922 }
8875 this._eatSemicolon(); 8923 this._eatSemicolon();
8876 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s tart)); 8924 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s tart));
8877 } 8925 }
8878 Parser.prototype.finishDefinition = function(start, modifiers, di) { 8926 Parser.prototype.finishDefinition = function(start, modifiers, di) {
8879 switch (this._peek()) { 8927 switch (this._peek()) {
8880 case 2/*TokenKind.LPAREN*/: 8928 case 2/*TokenKind.LPAREN*/:
8881 8929
8882 var formals = this.formalParameterList(); 8930 var formals = this.formalParameterList();
8883 var inits = null, native_ = null; 8931 var inits = null, native_ = null;
8884 if (this._maybeEat(8/*TokenKind.COLON*/)) { 8932 if (this._maybeEat(8/*TokenKind.COLON*/)) {
8885 inits = this.initializers(); 8933 inits = this.initializers();
8886 } 8934 }
8887 if (this._maybeEat(79/*TokenKind.NATIVE*/)) { 8935 if (this._maybeEat(79/*TokenKind.NATIVE*/)) {
8888 native_ = this.maybeStringLiteral(); 8936 native_ = this.maybeStringLiteral();
8889 if (native_ == null) native_ = ''; 8937 if (native_ == null) native_ = "";
8890 } 8938 }
8891 var body = this.functionBody(false); 8939 var body = this.functionBody(false);
8892 if (di.get$name() == null) { 8940 if (di.get$name() == null) {
8893 di.set$name(di.get$type().get$name()); 8941 di.set$name(di.get$type().get$name());
8894 } 8942 }
8895 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for mals, inits, native_, body, this._makeSpan(start)); 8943 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for mals, inits, native_, body, this._makeSpan(start));
8896 8944
8897 case 20/*TokenKind.ASSIGN*/: 8945 case 20/*TokenKind.ASSIGN*/:
8898 8946
8899 this._eat(20/*TokenKind.ASSIGN*/); 8947 this._eat(20/*TokenKind.ASSIGN*/);
8900 var value = this.expression(); 8948 var value = this.expression();
8901 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va lue); 8949 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va lue);
8902 8950
8903 case 11/*TokenKind.COMMA*/: 8951 case 11/*TokenKind.COMMA*/:
8904 case 10/*TokenKind.SEMICOLON*/: 8952 case 10/*TokenKind.SEMICOLON*/:
8905 8953
8906 return this.finishField(start, modifiers, di.get$type(), di.get$name(), nu ll); 8954 return this.finishField(start, modifiers, di.get$type(), di.get$name(), nu ll);
8907 8955
8908 default: 8956 default:
8909 8957
8910 this._errorExpected('declaration'); 8958 this._errorExpected("declaration");
8911 return null; 8959 return null;
8912 8960
8913 } 8961 }
8914 } 8962 }
8915 Parser.prototype.declaration = function(includeOperators) { 8963 Parser.prototype.declaration = function(includeOperators) {
8916 var start = this._peekToken.start; 8964 var start = this._peekToken.start;
8917 if (this._peekKind(73/*TokenKind.FACTORY*/)) { 8965 if (this._peekKind(73/*TokenKind.FACTORY*/)) {
8918 return this.factoryConstructorDeclaration(); 8966 return this.factoryConstructorDeclaration();
8919 } 8967 }
8920 var modifiers = this._readModifiers(); 8968 var modifiers = this._readModifiers();
8921 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include Operators)); 8969 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include Operators));
8922 } 8970 }
8923 Parser.prototype.factoryConstructorDeclaration = function() { 8971 Parser.prototype.factoryConstructorDeclaration = function() {
8924 var start = this._peekToken.start; 8972 var start = this._peekToken.start;
8925 var factoryToken = this._lang_next(); 8973 var factoryToken = this._lang_next();
8926 var names = [this.identifier()]; 8974 var names = [this.identifier()];
8927 while (this._maybeEat(14/*TokenKind.DOT*/)) { 8975 while (this._maybeEat(14/*TokenKind.DOT*/)) {
8928 names.add$1(this.identifier()); 8976 names.add$1(this.identifier());
8929 } 8977 }
8930 if (this._peekKind(52/*TokenKind.LT*/)) { 8978 if (this._peekKind(52/*TokenKind.LT*/)) {
8931 var tp = this.typeParameters(); 8979 var tp = this.typeParameters();
8932 $globals.world.warning('type parameters on factories are no longer supported , place them on the class instead'/*'type parameters on factories are no longer supported, ' 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()));
8933 + 'place them on the class instead'*/, this._makeSpan(tp.$index(0) .get$span().get$start()));
8934 } 8981 }
8935 var name = null; 8982 var name = null;
8936 var type = null; 8983 var type = null;
8937 if (this._maybeEat(14/*TokenKind.DOT*/)) { 8984 if (this._maybeEat(14/*TokenKind.DOT*/)) {
8938 name = this.identifier(); 8985 name = this.identifier();
8939 } 8986 }
8940 else { 8987 else {
8941 if (names.get$length() > 1) { 8988 if (names.get$length() > 1) {
8942 name = names.removeLast$0(); 8989 name = names.removeLast$0();
8943 } 8990 }
8944 else { 8991 else {
8945 name = new Identifier('', names.$index(0).get$span()); 8992 name = new Identifier("", names.$index(0).get$span());
8946 } 8993 }
8947 } 8994 }
8948 if (names.get$length() > 1) { 8995 if (names.get$length() > 1) {
8949 this._lang_error('unsupported qualified name for factory', names.$index(0).g et$span()); 8996 this._lang_error("unsupported qualified name for factory", names.$index(0).g et$span());
8950 } 8997 }
8951 type = new NameTypeReference(false, names.$index(0), null, names.$index(0).get $span()); 8998 type = new NameTypeReference(false, names.$index(0), null, names.$index(0).get $span());
8952 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); 8999 var di = new DeclaredIdentifier(type, name, this._makeSpan(start));
8953 return this.finishDefinition(start, [factoryToken], di); 9000 return this.finishDefinition(start, [factoryToken], di);
8954 } 9001 }
8955 Parser.prototype.statement = function() { 9002 Parser.prototype.statement = function() {
8956 switch (this._peek()) { 9003 switch (this._peek()) {
8957 case 87/*TokenKind.BREAK*/: 9004 case 87/*TokenKind.BREAK*/:
8958 9005
8959 return this.breakStatement(); 9006 return this.breakStatement();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
9218 } 9265 }
9219 else if (this._maybeEat(93/*TokenKind.DEFAULT*/)) { 9266 else if (this._maybeEat(93/*TokenKind.DEFAULT*/)) {
9220 cases.add$1(); 9267 cases.add$1();
9221 this._eat(8/*TokenKind.COLON*/); 9268 this._eat(8/*TokenKind.COLON*/);
9222 } 9269 }
9223 else { 9270 else {
9224 break; 9271 break;
9225 } 9272 }
9226 } 9273 }
9227 if ($eq(cases.get$length(), 0)) { 9274 if ($eq(cases.get$length(), 0)) {
9228 this._lang_error('case or default'); 9275 this._lang_error("case or default");
9229 } 9276 }
9230 var stmts = []; 9277 var stmts = [];
9231 while (!this._peekCaseEnd()) { 9278 while (!this._peekCaseEnd()) {
9232 stmts.add$1(this.statement()); 9279 stmts.add$1(this.statement());
9233 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 88/*TokenKind.C ASE*/, 93/*TokenKind.DEFAULT*/)) { 9280 if (this._recover && !this._recoverTo(7/*TokenKind.RBRACE*/, 88/*TokenKind.C ASE*/, 93/*TokenKind.DEFAULT*/)) {
9234 break; 9281 break;
9235 } 9282 }
9236 } 9283 }
9237 return new CaseNode(label, cases, stmts, this._makeSpan(start)); 9284 return new CaseNode(label, cases, stmts, this._makeSpan(start));
9238 } 9285 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
9303 if (type.get$names() == null) { 9350 if (type.get$names() == null) {
9304 type.set$names([expr.get$name()]); 9351 type.set$names([expr.get$name()]);
9305 } 9352 }
9306 else { 9353 else {
9307 type.get$names().add$1(expr.get$name()); 9354 type.get$names().add$1(expr.get$name());
9308 } 9355 }
9309 type.set$span(expr.get$span()); 9356 type.set$span(expr.get$span());
9310 return type; 9357 return type;
9311 } 9358 }
9312 else { 9359 else {
9313 this._lang_error('expected type reference'); 9360 this._lang_error("expected type reference");
9314 return null; 9361 return null;
9315 } 9362 }
9316 } 9363 }
9317 Parser.prototype.infixExpression = function(precedence) { 9364 Parser.prototype.infixExpression = function(precedence) {
9318 return this.finishInfixExpression(this.unaryExpression(), precedence); 9365 return this.finishInfixExpression(this.unaryExpression(), precedence);
9319 } 9366 }
9320 Parser.prototype._finishDeclaredId = function(type) { 9367 Parser.prototype._finishDeclaredId = function(type) {
9321 var name = this.identifier(); 9368 var name = this.identifier();
9322 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().get$start()))); 9369 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().get$start())));
9323 } 9370 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
9407 var expr = this.unaryExpression(); 9454 var expr = this.unaryExpression();
9408 return new AwaitExpression(expr, this._makeSpan(start)); 9455 return new AwaitExpression(expr, this._makeSpan(start));
9409 } 9456 }
9410 return this.finishPostfixExpression(this.primary()); 9457 return this.finishPostfixExpression(this.primary());
9411 } 9458 }
9412 Parser.prototype.argument = function() { 9459 Parser.prototype.argument = function() {
9413 var start = this._peekToken.start; 9460 var start = this._peekToken.start;
9414 var expr; 9461 var expr;
9415 var label = null; 9462 var label = null;
9416 if (this._maybeEat(15/*TokenKind.ELLIPSIS*/)) { 9463 if (this._maybeEat(15/*TokenKind.ELLIPSIS*/)) {
9417 label = new Identifier('...', this._makeSpan(start)); 9464 label = new Identifier("...", this._makeSpan(start));
9418 } 9465 }
9419 expr = this.expression(); 9466 expr = this.expression();
9420 if (label == null && this._maybeEat(8/*TokenKind.COLON*/)) { 9467 if (label == null && this._maybeEat(8/*TokenKind.COLON*/)) {
9421 label = this._makeLabel(expr); 9468 label = this._makeLabel(expr);
9422 expr = this.expression(); 9469 expr = this.expression();
9423 } 9470 }
9424 return new ArgumentNode(label, expr, this._makeSpan(start)); 9471 return new ArgumentNode(label, expr, this._makeSpan(start));
9425 } 9472 }
9426 Parser.prototype.arguments = function() { 9473 Parser.prototype.arguments = function() {
9427 var args = []; 9474 var args = [];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
9484 } 9531 }
9485 } 9532 }
9486 Parser.prototype.finishCallOrLambdaExpression = function(expr) { 9533 Parser.prototype.finishCallOrLambdaExpression = function(expr) {
9487 if (this._atClosureParameters()) { 9534 if (this._atClosureParameters()) {
9488 var formals = this.formalParameterList(); 9535 var formals = this.formalParameterList();
9489 var body = this.functionBody(true); 9536 var body = this.functionBody(true);
9490 return this._makeFunction(expr, formals, body); 9537 return this._makeFunction(expr, formals, body);
9491 } 9538 }
9492 else { 9539 else {
9493 if ((expr instanceof DeclaredIdentifier)) { 9540 if ((expr instanceof DeclaredIdentifier)) {
9494 this._lang_error('illegal target for call, did you mean to declare a funct ion?', expr.get$span()); 9541 this._lang_error("illegal target for call, did you mean to declare a funct ion?", expr.get$span());
9495 } 9542 }
9496 var args = this.arguments(); 9543 var args = this.arguments();
9497 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak eSpan(expr.get$span().get$start()))); 9544 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak eSpan(expr.get$span().get$start())));
9498 } 9545 }
9499 } 9546 }
9500 Parser.prototype._isBin = function(expr, kind) { 9547 Parser.prototype._isBin = function(expr, kind) {
9501 return (expr instanceof BinaryExpression) && $eq(expr.get$op().get$kind(), kin d); 9548 return (expr instanceof BinaryExpression) && $eq(expr.get$op().get$kind(), kin d);
9502 } 9549 }
9503 Parser.prototype._boolTypeRef = function(span) { 9550 Parser.prototype._makeLiteral = function(value) {
9504 return new TypeReference(span, $globals.world.nonNullBool); 9551 return new LiteralExpression(value, value.span);
9505 }
9506 Parser.prototype._intTypeRef = function(span) {
9507 return new TypeReference(span, $globals.world.intType);
9508 }
9509 Parser.prototype._doubleTypeRef = function(span) {
9510 return new TypeReference(span, $globals.world.doubleType);
9511 }
9512 Parser.prototype._stringTypeRef = function(span) {
9513 return new TypeReference(span, $globals.world.stringType);
9514 } 9552 }
9515 Parser.prototype.primary = function() { 9553 Parser.prototype.primary = function() {
9516 var start = this._peekToken.start; 9554 var start = this._peekToken.start;
9517 switch (this._peek()) { 9555 switch (this._peek()) {
9518 case 109/*TokenKind.THIS*/: 9556 case 109/*TokenKind.THIS*/:
9519 9557
9520 this._eat(109/*TokenKind.THIS*/); 9558 this._eat(109/*TokenKind.THIS*/);
9521 return new ThisExpression(this._makeSpan(start)); 9559 return new ThisExpression(this._makeSpan(start));
9522 9560
9523 case 107/*TokenKind.SUPER*/: 9561 case 107/*TokenKind.SUPER*/:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
9555 9593
9556 return this.finishListLiteral(start, false, null); 9594 return this.finishListLiteral(start, false, null);
9557 9595
9558 case 6/*TokenKind.LBRACE*/: 9596 case 6/*TokenKind.LBRACE*/:
9559 9597
9560 return this.finishMapLiteral(start, false, null); 9598 return this.finishMapLiteral(start, false, null);
9561 9599
9562 case 105/*TokenKind.NULL*/: 9600 case 105/*TokenKind.NULL*/:
9563 9601
9564 this._eat(105/*TokenKind.NULL*/); 9602 this._eat(105/*TokenKind.NULL*/);
9565 return new NullExpression(this._makeSpan(start)); 9603 return this._makeLiteral(Value.fromNull(this._makeSpan(start)));
9566 9604
9567 case 111/*TokenKind.TRUE*/: 9605 case 111/*TokenKind.TRUE*/:
9568 9606
9569 this._eat(111/*TokenKind.TRUE*/); 9607 this._eat(111/*TokenKind.TRUE*/);
9570 return new LiteralExpression(true, this._boolTypeRef(this._makeSpan(start) ), 'true', this._makeSpan(start)); 9608 return this._makeLiteral(Value.fromBool(true, this._makeSpan(start)));
9571 9609
9572 case 97/*TokenKind.FALSE*/: 9610 case 97/*TokenKind.FALSE*/:
9573 9611
9574 this._eat(97/*TokenKind.FALSE*/); 9612 this._eat(97/*TokenKind.FALSE*/);
9575 return new LiteralExpression(false, this._boolTypeRef(this._makeSpan(start )), 'false', this._makeSpan(start)); 9613 return this._makeLiteral(Value.fromBool(false, this._makeSpan(start)));
9576 9614
9577 case 61/*TokenKind.HEX_INTEGER*/: 9615 case 61/*TokenKind.HEX_INTEGER*/:
9578 9616
9579 var t = this._lang_next(); 9617 var t = this._lang_next();
9580 return new LiteralExpression(Parser.parseHex(t.get$text().substring$1(2)), this._intTypeRef(this._makeSpan(start)), t.get$text(), this._makeSpan(start)); 9618 return this._makeLiteral(Value.fromInt(t.get$value(), t.get$span()));
9581 9619
9582 case 60/*TokenKind.INTEGER*/: 9620 case 60/*TokenKind.INTEGER*/:
9583 9621
9584 var t = this._lang_next(); 9622 var t = this._lang_next();
9585 return new LiteralExpression(Math.parseInt(t.get$text()), this._intTypeRef (this._makeSpan(start)), t.get$text(), this._makeSpan(start)); 9623 return this._makeLiteral(Value.fromInt(Math.parseInt(t.get$text()), t.get$ span()));
9586 9624
9587 case 62/*TokenKind.DOUBLE*/: 9625 case 62/*TokenKind.DOUBLE*/:
9588 9626
9589 var t = this._lang_next(); 9627 var t = this._lang_next();
9590 return new LiteralExpression(Math.parseDouble(t.get$text()), this._doubleT ypeRef(this._makeSpan(start)), t.get$text(), this._makeSpan(start)); 9628 return this._makeLiteral(Value.fromDouble(Math.parseDouble(t.get$text()), t.get$span()));
9591 9629
9592 case 58/*TokenKind.STRING*/: 9630 case 58/*TokenKind.STRING*/:
9593 9631
9594 return this.stringLiteralExpr(); 9632 var t = this._lang_next();
9633 return this._makeLiteral(Value.fromString(t.get$value(), t.get$span()));
9595 9634
9596 case 66/*TokenKind.INCOMPLETE_STRING*/: 9635 case 59/*TokenKind.STRING_PART*/:
9597 9636
9598 return this.stringInterpolation(); 9637 return this.stringInterpolation();
9599 9638
9600 case 52/*TokenKind.LT*/: 9639 case 52/*TokenKind.LT*/:
9601 9640
9602 return this.finishTypedLiteral(start, false); 9641 return this.finishTypedLiteral(start, false);
9603 9642
9604 case 114/*TokenKind.VOID*/: 9643 case 114/*TokenKind.VOID*/:
9605 case 113/*TokenKind.VAR*/: 9644 case 113/*TokenKind.VAR*/:
9606 case 98/*TokenKind.FINAL*/: 9645 case 98/*TokenKind.FINAL*/:
9607 9646
9608 return this.declaredIdentifier(false); 9647 return this.declaredIdentifier(false);
9609 9648
9610 default: 9649 default:
9611 9650
9612 if (!this._peekIdentifier()) { 9651 if (!this._peekIdentifier()) {
9613 this._errorExpected('expression'); 9652 this._errorExpected("expression");
9614 } 9653 }
9615 return new VarExpression(this.identifier(), this._makeSpan(start)); 9654 return new VarExpression(this.identifier(), this._makeSpan(start));
9616 9655
9617 } 9656 }
9618 } 9657 }
9619 Parser.prototype.stringInterpolation = function() { 9658 Parser.prototype.stringInterpolation = function() {
9620 var start = this._peekToken.start; 9659 var start = this._peekToken.start;
9621 var lits = []; 9660 var pieces = new Array();
9622 var startQuote = null, endQuote = null; 9661 var startQuote = null, endQuote = null;
9623 while (this._peekKind(66/*TokenKind.INCOMPLETE_STRING*/)) { 9662 while (this._peekKind(59/*TokenKind.STRING_PART*/)) {
9624 var token = this._lang_next(); 9663 var token = this._lang_next();
9625 var text = token.get$text(); 9664 pieces.add$1(this._makeLiteral(Value.fromString(token.get$value(), token.get $span())));
9626 if (startQuote == null) {
9627 if (isMultilineString(text)) {
9628 endQuote = text.substring$2(0, 3);
9629 startQuote = endQuote + '\n';
9630 }
9631 else {
9632 startQuote = endQuote = text.$index(0);
9633 }
9634 text = text.substring$2(0, text.get$length() - 1) + endQuote;
9635 }
9636 else {
9637 text = startQuote + text.substring$2(0, text.get$length() - 1) + endQuote;
9638 }
9639 lits.add$1(this.makeStringLiteral(text, token.get$span()));
9640 if (this._maybeEat(6/*TokenKind.LBRACE*/)) { 9665 if (this._maybeEat(6/*TokenKind.LBRACE*/)) {
9641 lits.add$1(this.expression()); 9666 pieces.add$1(this.expression());
9642 this._eat(7/*TokenKind.RBRACE*/); 9667 this._eat(7/*TokenKind.RBRACE*/);
9643 } 9668 }
9644 else if (this._maybeEat(109/*TokenKind.THIS*/)) { 9669 else if (this._maybeEat(109/*TokenKind.THIS*/)) {
9645 lits.add$1(new ThisExpression(this._previousToken.get$span())); 9670 pieces.add$1(new ThisExpression(this._previousToken.get$span()));
9646 } 9671 }
9647 else { 9672 else {
9648 var id = this.identifier(); 9673 var id = this.identifier();
9649 lits.add$1(new VarExpression(id, id.get$span())); 9674 pieces.add$1(new VarExpression(id, id.get$span()));
9650 } 9675 }
9651 } 9676 }
9652 var tok = this._lang_next(); 9677 var tok = this._lang_next();
9653 if ($ne(tok.get$kind(), 58/*TokenKind.STRING*/)) { 9678 if ($ne(tok.get$kind(), 58/*TokenKind.STRING*/)) {
9654 this._errorExpected('interpolated string'); 9679 this._errorExpected("interpolated string");
9655 } 9680 }
9656 var text = startQuote + tok.get$text(); 9681 pieces.add$1(this._makeLiteral(Value.fromString(tok.get$value(), tok.get$span( ))));
9657 lits.add$1(this.makeStringLiteral(text, tok.get$span()));
9658 var span = this._makeSpan(start); 9682 var span = this._makeSpan(start);
9659 return new LiteralExpression(lits, this._stringTypeRef(span), '\$\$\$', span); 9683 return new StringInterpExpression(pieces, span);
9660 }
9661 Parser.prototype.makeStringLiteral = function(text, span) {
9662 return new LiteralExpression(text, this._stringTypeRef(span), text, span);
9663 }
9664 Parser.prototype.stringLiteralExpr = function() {
9665 var token = this._lang_next();
9666 return this.makeStringLiteral(token.get$text(), token.get$span());
9667 } 9684 }
9668 Parser.prototype.maybeStringLiteral = function() { 9685 Parser.prototype.maybeStringLiteral = function() {
9669 var kind = this._peek(); 9686 var kind = this._peek();
9670 if ($eq(kind, 58/*TokenKind.STRING*/)) { 9687 if ($eq(kind, 58/*TokenKind.STRING*/)) {
9671 return parseStringLiteral(this._lang_next().get$text()); 9688 var t = this._lang_next();
9689 return t.get$value();
9672 } 9690 }
9673 else if ($eq(kind, 59/*TokenKind.STRING_PART*/)) { 9691 else if ($eq(kind, 59/*TokenKind.STRING_PART*/)) {
9674 this._lang_next(); 9692 this._lang_next();
9675 this._errorExpected('string literal, but found interpolated string start'); 9693 this._errorExpected("string literal, but found interpolated string start");
9676 }
9677 else if ($eq(kind, 66/*TokenKind.INCOMPLETE_STRING*/)) {
9678 this._lang_next();
9679 this._errorExpected('string literal, but found incomplete string');
9680 } 9694 }
9681 return null; 9695 return null;
9682 } 9696 }
9683 Parser.prototype._parenOrLambda = function() { 9697 Parser.prototype._parenOrLambda = function() {
9684 var start = this._peekToken.start; 9698 var start = this._peekToken.start;
9685 if (this._atClosureParameters()) { 9699 if (this._atClosureParameters()) {
9686 var formals = this.formalParameterList(); 9700 var formals = this.formalParameterList();
9687 var body = this.functionBody(true); 9701 var body = this.functionBody(true);
9688 var func = new FunctionDefinition(null, null, null, formals, null, null, bod y, this._makeSpan(start)); 9702 var func = new FunctionDefinition(null, null, null, formals, null, null, bod y, this._makeSpan(start));
9689 return new LambdaExpression(func, func.get$span()); 9703 return new LambdaExpression(func, func.get$span());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
9740 Parser.prototype._typeAsIdentifier = function(type) { 9754 Parser.prototype._typeAsIdentifier = function(type) {
9741 return type.get$name(); 9755 return type.get$name();
9742 } 9756 }
9743 Parser.prototype._specialIdentifier = function(includeOperators) { 9757 Parser.prototype._specialIdentifier = function(includeOperators) {
9744 var start = this._peekToken.start; 9758 var start = this._peekToken.start;
9745 var name; 9759 var name;
9746 switch (this._peek()) { 9760 switch (this._peek()) {
9747 case 15/*TokenKind.ELLIPSIS*/: 9761 case 15/*TokenKind.ELLIPSIS*/:
9748 9762
9749 this._eat(15/*TokenKind.ELLIPSIS*/); 9763 this._eat(15/*TokenKind.ELLIPSIS*/);
9750 this._lang_error('rest no longer supported', this._previousToken.get$span( )); 9764 this._lang_error("rest no longer supported", this._previousToken.get$span( ));
9751 name = this.identifier().get$name(); 9765 name = this.identifier().get$name();
9752 break; 9766 break;
9753 9767
9754 case 109/*TokenKind.THIS*/: 9768 case 109/*TokenKind.THIS*/:
9755 9769
9756 this._eat(109/*TokenKind.THIS*/); 9770 this._eat(109/*TokenKind.THIS*/);
9757 this._eat(14/*TokenKind.DOT*/); 9771 this._eat(14/*TokenKind.DOT*/);
9758 name = ('this.' + this.identifier().get$name()); 9772 name = ("this." + this.identifier().get$name());
9759 break; 9773 break;
9760 9774
9761 case 74/*TokenKind.GET*/: 9775 case 74/*TokenKind.GET*/:
9762 9776
9763 if (!includeOperators) return null; 9777 if (!includeOperators) return null;
9764 this._eat(74/*TokenKind.GET*/); 9778 this._eat(74/*TokenKind.GET*/);
9765 if (this._peekIdentifier()) { 9779 if (this._peekIdentifier()) {
9766 name = ('get:' + this.identifier().get$name()); 9780 name = ("get:" + this.identifier().get$name());
9767 } 9781 }
9768 else { 9782 else {
9769 name = 'get'; 9783 name = "get";
9770 } 9784 }
9771 break; 9785 break;
9772 9786
9773 case 82/*TokenKind.SET*/: 9787 case 82/*TokenKind.SET*/:
9774 9788
9775 if (!includeOperators) return null; 9789 if (!includeOperators) return null;
9776 this._eat(82/*TokenKind.SET*/); 9790 this._eat(82/*TokenKind.SET*/);
9777 if (this._peekIdentifier()) { 9791 if (this._peekIdentifier()) {
9778 name = ('set:' + this.identifier().get$name()); 9792 name = ("set:" + this.identifier().get$name());
9779 } 9793 }
9780 else { 9794 else {
9781 name = 'set'; 9795 name = "set";
9782 } 9796 }
9783 break; 9797 break;
9784 9798
9785 case 81/*TokenKind.OPERATOR*/: 9799 case 81/*TokenKind.OPERATOR*/:
9786 9800
9787 if (!includeOperators) return null; 9801 if (!includeOperators) return null;
9788 this._eat(81/*TokenKind.OPERATOR*/); 9802 this._eat(81/*TokenKind.OPERATOR*/);
9789 var kind = this._peek(); 9803 var kind = this._peek();
9790 if ($eq(kind, 80/*TokenKind.NEGATE*/)) { 9804 if ($eq(kind, 80/*TokenKind.NEGATE*/)) {
9791 name = ':negate'; 9805 name = ":negate";
9792 this._lang_next(); 9806 this._lang_next();
9793 } 9807 }
9794 else { 9808 else {
9795 name = TokenKind.binaryMethodName(kind); 9809 name = TokenKind.binaryMethodName(kind);
9796 if (name == null) { 9810 if (name == null) {
9797 name = 'operator'; 9811 name = "operator";
9798 } 9812 }
9799 else { 9813 else {
9800 this._lang_next(); 9814 this._lang_next();
9801 } 9815 }
9802 } 9816 }
9803 break; 9817 break;
9804 9818
9805 default: 9819 default:
9806 9820
9807 return null; 9821 return null;
(...skipping 15 matching lines...) Expand all
9823 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu ll) { 9837 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu ll) {
9824 name = this._typeAsIdentifier(myType); 9838 name = this._typeAsIdentifier(myType);
9825 myType = null; 9839 myType = null;
9826 } 9840 }
9827 else { 9841 else {
9828 } 9842 }
9829 } 9843 }
9830 } 9844 }
9831 return new DeclaredIdentifier(myType, name, this._makeSpan(start)); 9845 return new DeclaredIdentifier(myType, name, this._makeSpan(start));
9832 } 9846 }
9833 Parser._hexDigit = function(c) {
9834 if (c >= 48 && c <= 57) {
9835 return c - 48;
9836 }
9837 else if (c >= 97 && c <= 102) {
9838 return c - 87;
9839 }
9840 else if (c >= 65 && c <= 70) {
9841 return c - 55;
9842 }
9843 else {
9844 return -1;
9845 }
9846 }
9847 Parser.parseHex = function(hex) {
9848 var result = 0;
9849 for (var i = 0;
9850 i < hex.length; i++) {
9851 var digit = Parser._hexDigit(hex.charCodeAt(i));
9852 result = (result * 16) + digit;
9853 }
9854 return result;
9855 }
9856 Parser.prototype.finishNewExpression = function(start, isConst) { 9847 Parser.prototype.finishNewExpression = function(start, isConst) {
9857 var type = this.type(0); 9848 var type = this.type(0);
9858 var name = null; 9849 var name = null;
9859 if (this._maybeEat(14/*TokenKind.DOT*/)) { 9850 if (this._maybeEat(14/*TokenKind.DOT*/)) {
9860 name = this.identifier(); 9851 name = this.identifier();
9861 } 9852 }
9862 var args = this.arguments(); 9853 var args = this.arguments();
9863 return new NewExpression(isConst, type, name, args, this._makeSpan(start)); 9854 return new NewExpression(isConst, type, name, args, this._makeSpan(start));
9864 } 9855 }
9865 Parser.prototype.finishListLiteral = function(start, isConst, type) { 9856 Parser.prototype.finishListLiteral = function(start, isConst, type) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9903 } 9894 }
9904 else if (this._peekKind(6/*TokenKind.LBRACE*/)) { 9895 else if (this._peekKind(6/*TokenKind.LBRACE*/)) {
9905 genericType.set$baseType(new TypeReference(span, $globals.world.mapType)); 9896 genericType.set$baseType(new TypeReference(span, $globals.world.mapType));
9906 var typeArgs = genericType.get$typeArguments(); 9897 var typeArgs = genericType.get$typeArguments();
9907 if ($eq(typeArgs.get$length(), 1)) { 9898 if ($eq(typeArgs.get$length(), 1)) {
9908 genericType.set$typeArguments([new TypeReference(span, $globals.world.stri ngType), typeArgs.$index(0)]); 9899 genericType.set$typeArguments([new TypeReference(span, $globals.world.stri ngType), typeArgs.$index(0)]);
9909 } 9900 }
9910 else if ($eq(typeArgs.get$length(), 2)) { 9901 else if ($eq(typeArgs.get$length(), 2)) {
9911 var keyType = typeArgs.$index(0); 9902 var keyType = typeArgs.$index(0);
9912 if (!(keyType instanceof NameTypeReference) || $ne(keyType.get$name().get$ name(), "String")) { 9903 if (!(keyType instanceof NameTypeReference) || $ne(keyType.get$name().get$ name(), "String")) {
9913 $globals.world.error('the key type of a map literal is implicitly "Strin g"', keyType.get$span()); 9904 $globals.world.error("the key type of a map literal is implicitly \"Stri ng\"", keyType.get$span());
9914 } 9905 }
9915 else { 9906 else {
9916 $globals.world.warning('a map literal takes one type argument specifying the value type', keyType.get$span()); 9907 $globals.world.warning("a map literal takes one type argument specifying the value type", keyType.get$span());
9917 } 9908 }
9918 } 9909 }
9919 return this.finishMapLiteral(start, isConst, genericType); 9910 return this.finishMapLiteral(start, isConst, genericType);
9920 } 9911 }
9921 else { 9912 else {
9922 this._errorExpected('array or map literal'); 9913 this._errorExpected("array or map literal");
9923 } 9914 }
9924 } 9915 }
9925 Parser.prototype._readModifiers = function() { 9916 Parser.prototype._readModifiers = function() {
9926 var modifiers = null; 9917 var modifiers = null;
9927 while (true) { 9918 while (true) {
9928 switch (this._peek()) { 9919 switch (this._peek()) {
9929 case 84/*TokenKind.STATIC*/: 9920 case 84/*TokenKind.STATIC*/:
9930 case 98/*TokenKind.FINAL*/: 9921 case 98/*TokenKind.FINAL*/:
9931 case 91/*TokenKind.CONST*/: 9922 case 91/*TokenKind.CONST*/:
9932 case 71/*TokenKind.ABSTRACT*/: 9923 case 71/*TokenKind.ABSTRACT*/:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
9982 if (this._maybeEat(53/*TokenKind.GT*/)) { 9973 if (this._maybeEat(53/*TokenKind.GT*/)) {
9983 return depth; 9974 return depth;
9984 } 9975 }
9985 else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) { 9976 else if (depth > 0 && this._maybeEat(40/*TokenKind.SAR*/)) {
9986 return depth - 1; 9977 return depth - 1;
9987 } 9978 }
9988 else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) { 9979 else if (depth > 1 && this._maybeEat(41/*TokenKind.SHR*/)) {
9989 return depth - 2; 9980 return depth - 2;
9990 } 9981 }
9991 else { 9982 else {
9992 this._errorExpected('>'); 9983 this._errorExpected(">");
9993 return depth; 9984 return depth;
9994 } 9985 }
9995 } 9986 }
9996 Parser.prototype.addTypeArguments = function(baseType, depth) { 9987 Parser.prototype.addTypeArguments = function(baseType, depth) {
9997 this._eat(52/*TokenKind.LT*/); 9988 this._eat(52/*TokenKind.LT*/);
9998 return this._finishTypeArguments(baseType, depth, []); 9989 return this._finishTypeArguments(baseType, depth, []);
9999 } 9990 }
10000 Parser.prototype._finishTypeArguments = function(baseType, depth, types) { 9991 Parser.prototype._finishTypeArguments = function(baseType, depth, types) {
10001 var delta = -1; 9992 var delta = -1;
10002 do { 9993 do {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
10073 return this.type.bind(this); 10064 return this.type.bind(this);
10074 } 10065 }
10075 Parser.prototype.formalParameter = function(inOptionalBlock) { 10066 Parser.prototype.formalParameter = function(inOptionalBlock) {
10076 var start = this._peekToken.start; 10067 var start = this._peekToken.start;
10077 var isThis = false; 10068 var isThis = false;
10078 var isRest = false; 10069 var isRest = false;
10079 var di = this.declaredIdentifier(false); 10070 var di = this.declaredIdentifier(false);
10080 var type = di.get$type(); 10071 var type = di.get$type();
10081 var name = di.get$name(); 10072 var name = di.get$name();
10082 if (name == null) { 10073 if (name == null) {
10083 this._lang_error('Formal parameter invalid', this._makeSpan(start)); 10074 this._lang_error("Formal parameter invalid", this._makeSpan(start));
10084 } 10075 }
10085 var value = null; 10076 var value = null;
10086 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) { 10077 if (this._maybeEat(20/*TokenKind.ASSIGN*/)) {
10087 if (!inOptionalBlock) { 10078 if (!inOptionalBlock) {
10088 this._lang_error('default values only allowed inside [optional] section'); 10079 this._lang_error("default values only allowed inside [optional] section");
10089 } 10080 }
10090 value = this.expression(); 10081 value = this.expression();
10091 } 10082 }
10092 else if (this._peekKind(2/*TokenKind.LPAREN*/)) { 10083 else if (this._peekKind(2/*TokenKind.LPAREN*/)) {
10093 var formals = this.formalParameterList(); 10084 var formals = this.formalParameterList();
10094 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start)); 10085 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start));
10095 type = new FunctionTypeReference(false, func, func.get$span()); 10086 type = new FunctionTypeReference(false, func, func.get$span());
10096 } 10087 }
10097 if (inOptionalBlock && value == null) { 10088 if (inOptionalBlock && value == null) {
10098 value = new NullExpression(this._makeSpan(start)); 10089 value = this._makeLiteral(Value.fromNull(this._makeSpan(start)));
10099 } 10090 }
10100 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) ); 10091 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) );
10101 } 10092 }
10102 Parser.prototype.formalParameterList = function() { 10093 Parser.prototype.formalParameterList = function() {
10103 this._eatLeftParen(); 10094 this._eatLeftParen();
10104 var formals = []; 10095 var formals = [];
10105 var inOptionalBlock = false; 10096 var inOptionalBlock = false;
10106 if (!this._maybeEat(3/*TokenKind.RPAREN*/)) { 10097 if (!this._maybeEat(3/*TokenKind.RPAREN*/)) {
10107 if (this._maybeEat(4/*TokenKind.LBRACK*/)) { 10098 if (this._maybeEat(4/*TokenKind.LBRACK*/)) {
10108 inOptionalBlock = true; 10099 inOptionalBlock = true;
10109 } 10100 }
10110 formals.add$1(this.formalParameter(inOptionalBlock)); 10101 formals.add$1(this.formalParameter(inOptionalBlock));
10111 while (this._maybeEat(11/*TokenKind.COMMA*/)) { 10102 while (this._maybeEat(11/*TokenKind.COMMA*/)) {
10112 if (this._maybeEat(4/*TokenKind.LBRACK*/)) { 10103 if (this._maybeEat(4/*TokenKind.LBRACK*/)) {
10113 if (inOptionalBlock) { 10104 if (inOptionalBlock) {
10114 this._lang_error('already inside an optional block', this._previousTok en.get$span()); 10105 this._lang_error("already inside an optional block", this._previousTok en.get$span());
10115 } 10106 }
10116 inOptionalBlock = true; 10107 inOptionalBlock = true;
10117 } 10108 }
10118 formals.add$1(this.formalParameter(inOptionalBlock)); 10109 formals.add$1(this.formalParameter(inOptionalBlock));
10119 } 10110 }
10120 if (inOptionalBlock) { 10111 if (inOptionalBlock) {
10121 this._eat(5/*TokenKind.RBRACK*/); 10112 this._eat(5/*TokenKind.RBRACK*/);
10122 } 10113 }
10123 this._eat(3/*TokenKind.RPAREN*/); 10114 this._eat(3/*TokenKind.RPAREN*/);
10124 } 10115 }
10125 return formals; 10116 return formals;
10126 } 10117 }
10127 Parser.prototype.identifier = function() { 10118 Parser.prototype.identifier = function() {
10128 var tok = this._lang_next(); 10119 var tok = this._lang_next();
10129 if (!this._isIdentifier(tok.get$kind())) { 10120 if (!this._isIdentifier(tok.get$kind())) {
10130 this._lang_error(('expected identifier, but found ' + tok), tok.get$span()); 10121 this._lang_error(("expected identifier, but found " + tok), tok.get$span());
10131 } 10122 }
10132 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); 10123 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start()));
10133 } 10124 }
10134 Parser.prototype._makeFunction = function(expr, formals, body) { 10125 Parser.prototype._makeFunction = function(expr, formals, body) {
10135 var name, type; 10126 var name, type;
10136 if ((expr instanceof VarExpression)) { 10127 if ((expr instanceof VarExpression)) {
10137 name = expr.get$name(); 10128 name = expr.get$name();
10138 type = null; 10129 type = null;
10139 } 10130 }
10140 else if ((expr instanceof DeclaredIdentifier)) { 10131 else if ((expr instanceof DeclaredIdentifier)) {
10141 name = expr.get$name(); 10132 name = expr.get$name();
10142 type = expr.get$type(); 10133 type = expr.get$type();
10143 } 10134 }
10144 else { 10135 else {
10145 this._lang_error('bad function body', expr.get$span()); 10136 this._lang_error("bad function body", expr.get$span());
10146 } 10137 }
10147 var span = new SourceSpan(expr.get$span().get$file(), expr.get$span().get$star t(), body.get$span().get$end()); 10138 var span = new SourceSpan(expr.get$span().get$file(), expr.get$span().get$star t(), body.get$span().get$end());
10148 var func = new FunctionDefinition(null, type, name, formals, null, null, body, span); 10139 var func = new FunctionDefinition(null, type, name, formals, null, null, body, span);
10149 return new LambdaExpression(func, func.get$span()); 10140 return new LambdaExpression(func, func.get$span());
10150 } 10141 }
10151 Parser.prototype._makeDeclaredIdentifier = function(e) { 10142 Parser.prototype._makeDeclaredIdentifier = function(e) {
10152 if ((e instanceof VarExpression)) { 10143 if ((e instanceof VarExpression)) {
10153 return new DeclaredIdentifier(null, e.get$name(), e.get$span()); 10144 return new DeclaredIdentifier(null, e.get$name(), e.get$span());
10154 } 10145 }
10155 else if ((e instanceof DeclaredIdentifier)) { 10146 else if ((e instanceof DeclaredIdentifier)) {
10156 return e; 10147 return e;
10157 } 10148 }
10158 else { 10149 else {
10159 this._lang_error('expected declared identifier'); 10150 this._lang_error("expected declared identifier");
10160 return new DeclaredIdentifier(null, null, e.get$span()); 10151 return new DeclaredIdentifier(null, null, e.get$span());
10161 } 10152 }
10162 } 10153 }
10163 Parser.prototype._makeLabel = function(expr) { 10154 Parser.prototype._makeLabel = function(expr) {
10164 if ((expr instanceof VarExpression)) { 10155 if ((expr instanceof VarExpression)) {
10165 return expr.get$name(); 10156 return expr.get$name();
10166 } 10157 }
10167 else { 10158 else {
10168 this._errorExpected('label'); 10159 this._errorExpected("label");
10169 return null; 10160 return null;
10170 } 10161 }
10171 } 10162 }
10172 Parser.prototype.block$0 = Parser.prototype.block; 10163 Parser.prototype.block$0 = Parser.prototype.block;
10173 // ********** Code for IncompleteSourceException ************** 10164 // ********** Code for IncompleteSourceException **************
10174 function IncompleteSourceException(token) { 10165 function IncompleteSourceException(token) {
10175 this.token = token; 10166 this.token = token;
10176 // Initializers done 10167 // Initializers done
10177 } 10168 }
10178 IncompleteSourceException.prototype.toString = function() { 10169 IncompleteSourceException.prototype.toString = function() {
10179 if (this.token.get$span() == null) return ('Unexpected ' + this.token); 10170 if (this.token.get$span() == null) return ("Unexpected " + this.token);
10180 return this.token.get$span().toMessageString(('Unexpected ' + this.token)); 10171 return this.token.get$span().toMessageString(("Unexpected " + this.token));
10181 } 10172 }
10182 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto type.toString; 10173 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto type.toString;
10183 // ********** Code for DivertedTokenSource ************** 10174 // ********** Code for DivertedTokenSource **************
10184 function DivertedTokenSource(tokens, parser, previousTokenizer) { 10175 function DivertedTokenSource(tokens, parser, previousTokenizer) {
10185 this._lang_pos = 0 10176 this._lang_pos = 0
10186 this.tokens = tokens; 10177 this.tokens = tokens;
10187 this.parser = parser; 10178 this.parser = parser;
10188 this.previousTokenizer = previousTokenizer; 10179 this.previousTokenizer = previousTokenizer;
10189 // Initializers done 10180 // Initializers done
10190 } 10181 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
10828 // ********** Code for SuperExpression ************** 10819 // ********** Code for SuperExpression **************
10829 $inherits(SuperExpression, Expression); 10820 $inherits(SuperExpression, Expression);
10830 function SuperExpression(span) { 10821 function SuperExpression(span) {
10831 // Initializers done 10822 // Initializers done
10832 Expression.call(this, span); 10823 Expression.call(this, span);
10833 } 10824 }
10834 SuperExpression.prototype.visit = function(visitor) { 10825 SuperExpression.prototype.visit = function(visitor) {
10835 return visitor.visitSuperExpression(this); 10826 return visitor.visitSuperExpression(this);
10836 } 10827 }
10837 SuperExpression.prototype.visit$1 = SuperExpression.prototype.visit; 10828 SuperExpression.prototype.visit$1 = SuperExpression.prototype.visit;
10838 // ********** Code for NullExpression **************
10839 $inherits(NullExpression, Expression);
10840 function NullExpression(span) {
10841 // Initializers done
10842 Expression.call(this, span);
10843 }
10844 NullExpression.prototype.visit = function(visitor) {
10845 return visitor.visitNullExpression(this);
10846 }
10847 NullExpression.prototype.visit$1 = NullExpression.prototype.visit;
10848 // ********** Code for LiteralExpression ************** 10829 // ********** Code for LiteralExpression **************
10849 $inherits(LiteralExpression, Expression); 10830 $inherits(LiteralExpression, Expression);
10850 function LiteralExpression(value, type, text, span) { 10831 function LiteralExpression(value, span) {
10851 this.value = value; 10832 this.value = value;
10852 this.type = type;
10853 this.text = text;
10854 // Initializers done 10833 // Initializers done
10855 Expression.call(this, span); 10834 Expression.call(this, span);
10856 } 10835 }
10857 LiteralExpression.prototype.get$value = function() { return this.value; }; 10836 LiteralExpression.prototype.get$value = function() { return this.value; };
10858 LiteralExpression.prototype.set$value = function(value) { return this.value = va lue; }; 10837 LiteralExpression.prototype.set$value = function(value) { return this.value = va lue; };
10859 LiteralExpression.prototype.get$type = function() { return this.type; };
10860 LiteralExpression.prototype.set$type = function(value) { return this.type = valu e; };
10861 LiteralExpression.prototype.get$text = function() { return this.text; };
10862 LiteralExpression.prototype.set$text = function(value) { return this.text = valu e; };
10863 LiteralExpression.prototype.visit = function(visitor) { 10838 LiteralExpression.prototype.visit = function(visitor) {
10864 return visitor.visitLiteralExpression(this); 10839 return visitor.visitLiteralExpression(this);
10865 } 10840 }
10866 LiteralExpression.prototype.visit$1 = LiteralExpression.prototype.visit; 10841 LiteralExpression.prototype.visit$1 = LiteralExpression.prototype.visit;
10842 // ********** Code for StringInterpExpression **************
10843 $inherits(StringInterpExpression, Expression);
10844 function StringInterpExpression(pieces, span) {
10845 this.pieces = pieces;
10846 // Initializers done
10847 Expression.call(this, span);
10848 }
10849 StringInterpExpression.prototype.visit = function(visitor) {
10850 return visitor.visitStringInterpExpression(this);
10851 }
10852 StringInterpExpression.prototype.visit$1 = StringInterpExpression.prototype.visi t;
10867 // ********** Code for NameTypeReference ************** 10853 // ********** Code for NameTypeReference **************
10868 $inherits(NameTypeReference, TypeReference); 10854 $inherits(NameTypeReference, TypeReference);
10869 function NameTypeReference(isFinal, name, names, span) { 10855 function NameTypeReference(isFinal, name, names, span) {
10870 this.isFinal = isFinal; 10856 this.isFinal = isFinal;
10871 this.name = name; 10857 this.name = name;
10872 this.names = names; 10858 this.names = names;
10873 // Initializers done 10859 // Initializers done
10874 TypeReference.call(this, span); 10860 TypeReference.call(this, span);
10875 } 10861 }
10876 NameTypeReference.prototype.get$isFinal = function() { return this.isFinal; }; 10862 NameTypeReference.prototype.get$isFinal = function() { return this.isFinal; };
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
11213 } 11199 }
11214 Type.prototype._checkOverride = function(member) { 11200 Type.prototype._checkOverride = function(member) {
11215 var parentMember = this._getMemberInParents(member.name); 11201 var parentMember = this._getMemberInParents(member.name);
11216 if (parentMember != null) { 11202 if (parentMember != null) {
11217 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li brary())) { 11203 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li brary())) {
11218 member.override(parentMember); 11204 member.override(parentMember);
11219 } 11205 }
11220 } 11206 }
11221 } 11207 }
11222 Type.prototype._createNotEqualMember = function() { 11208 Type.prototype._createNotEqualMember = function() {
11223 var eq = this.get$members().$index(':eq'); 11209 var eq = this.get$members().$index(":eq");
11224 if (eq == null) { 11210 if (eq == null) {
11225 return; 11211 return;
11226 } 11212 }
11227 var ne = new MethodMember(':ne', this, eq.definition); 11213 var ne = new MethodMember(":ne", this, eq.definition);
11228 ne.isGenerated = true; 11214 ne.isGenerated = true;
11229 ne.returnType = eq.returnType; 11215 ne.returnType = eq.returnType;
11230 ne.parameters = eq.parameters; 11216 ne.parameters = eq.parameters;
11231 ne.isStatic = eq.isStatic; 11217 ne.isStatic = eq.isStatic;
11232 ne.isAbstract = eq.isAbstract; 11218 ne.isAbstract = eq.isAbstract;
11233 this.get$members().$setindex(':ne', ne); 11219 this.get$members().$setindex(":ne", ne);
11234 } 11220 }
11235 Type.prototype._getMemberInParents = function(memberName) { 11221 Type.prototype._getMemberInParents = function(memberName) {
11236 if (this.get$isClass()) { 11222 if (this.get$isClass()) {
11237 if (this.get$parent() != null) { 11223 if (this.get$parent() != null) {
11238 return this.get$parent().getMember(memberName); 11224 return this.get$parent().getMember(memberName);
11239 } 11225 }
11240 else { 11226 else {
11241 return null; 11227 return null;
11242 } 11228 }
11243 } 11229 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
11280 else { 11266 else {
11281 var m = t.get$members().$index(memberName); 11267 var m = t.get$members().$index(memberName);
11282 if (m != null) ret.add(m); 11268 if (m != null) ret.add(m);
11283 } 11269 }
11284 } 11270 }
11285 return ret; 11271 return ret;
11286 } 11272 }
11287 } 11273 }
11288 Type.prototype.ensureSubtypeOf = function(other, span, typeErrors) { 11274 Type.prototype.ensureSubtypeOf = function(other, span, typeErrors) {
11289 if (!this.isSubtypeOf(other)) { 11275 if (!this.isSubtypeOf(other)) {
11290 var msg = ('type ' + this.name + ' is not a subtype of ' + other.name); 11276 var msg = ("type " + this.name + " is not a subtype of " + other.name);
11291 if (typeErrors) { 11277 if (typeErrors) {
11292 $globals.world.error(msg, span); 11278 $globals.world.error(msg, span);
11293 } 11279 }
11294 else { 11280 else {
11295 $globals.world.warning(msg, span); 11281 $globals.world.warning(msg, span);
11296 } 11282 }
11297 } 11283 }
11298 } 11284 }
11299 Type.prototype.needsVarCall = function(args) { 11285 Type.prototype.needsVarCall = function(args) {
11300 if (this.get$isVarOrFunction()) { 11286 if (this.get$isVarOrFunction()) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
11416 ParameterType.prototype.get$isClass = function() { 11402 ParameterType.prototype.get$isClass = function() {
11417 return false; 11403 return false;
11418 } 11404 }
11419 ParameterType.prototype.get$library = function() { 11405 ParameterType.prototype.get$library = function() {
11420 return null; 11406 return null;
11421 } 11407 }
11422 ParameterType.prototype.get$span = function() { 11408 ParameterType.prototype.get$span = function() {
11423 return this.typeParameter.span; 11409 return this.typeParameter.span;
11424 } 11410 }
11425 ParameterType.prototype.get$constructors = function() { 11411 ParameterType.prototype.get$constructors = function() {
11426 $globals.world.internalError('no constructors on type parameters yet'); 11412 $globals.world.internalError("no constructors on type parameters yet");
11427 } 11413 }
11428 ParameterType.prototype.getCallMethod = function() { 11414 ParameterType.prototype.getCallMethod = function() {
11429 return this.extendsType.getCallMethod(); 11415 return this.extendsType.getCallMethod();
11430 } 11416 }
11431 ParameterType.prototype.genMethod = function(method) { 11417 ParameterType.prototype.genMethod = function(method) {
11432 this.extendsType.genMethod(method); 11418 this.extendsType.genMethod(method);
11433 } 11419 }
11434 ParameterType.prototype.isSubtypeOf = function(other) { 11420 ParameterType.prototype.isSubtypeOf = function(other) {
11435 return true; 11421 return true;
11436 } 11422 }
11437 ParameterType.prototype.resolveMember = function(memberName) { 11423 ParameterType.prototype.resolveMember = function(memberName) {
11438 return this.extendsType.resolveMember(memberName); 11424 return this.extendsType.resolveMember(memberName);
11439 } 11425 }
11440 ParameterType.prototype.getConstructor = function(constructorName) { 11426 ParameterType.prototype.getConstructor = function(constructorName) {
11441 $globals.world.internalError('no constructors on type parameters yet'); 11427 $globals.world.internalError("no constructors on type parameters yet");
11442 } 11428 }
11443 ParameterType.prototype.getOrMakeConcreteType = function(typeArgs) { 11429 ParameterType.prototype.getOrMakeConcreteType = function(typeArgs) {
11444 $globals.world.internalError('no concrete types of type parameters yet', this. get$span()); 11430 $globals.world.internalError("no concrete types of type parameters yet", this. get$span());
11445 } 11431 }
11446 ParameterType.prototype.resolveTypeParams = function(inType) { 11432 ParameterType.prototype.resolveTypeParams = function(inType) {
11447 return inType.typeArguments.$index(this.name); 11433 return inType.typeArguments.$index(this.name);
11448 } 11434 }
11449 ParameterType.prototype.addDirectSubtype = function(type) { 11435 ParameterType.prototype.addDirectSubtype = function(type) {
11450 $globals.world.internalError('no subtypes of type parameters yet', this.get$sp an()); 11436 $globals.world.internalError("no subtypes of type parameters yet", this.get$sp an());
11451 } 11437 }
11452 ParameterType.prototype.resolve = function() { 11438 ParameterType.prototype.resolve = function() {
11453 if (this.typeParameter.extendsType != null) { 11439 if (this.typeParameter.extendsType != null) {
11454 this.extendsType = this.get$enclosingElement().resolveType(this.typeParamete r.extendsType, true); 11440 this.extendsType = this.get$enclosingElement().resolveType(this.typeParamete r.extendsType, true);
11455 } 11441 }
11456 else { 11442 else {
11457 this.extendsType = $globals.world.objectType; 11443 this.extendsType = $globals.world.objectType;
11458 } 11444 }
11459 } 11445 }
11460 ParameterType.prototype.addDirectSubtype$1 = ParameterType.prototype.addDirectSu btype; 11446 ParameterType.prototype.addDirectSubtype$1 = ParameterType.prototype.addDirectSu btype;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
11812 DefinedType.prototype.get$isVar = function() { 11798 DefinedType.prototype.get$isVar = function() {
11813 return $eq(this, $globals.world.varType); 11799 return $eq(this, $globals.world.varType);
11814 } 11800 }
11815 DefinedType.prototype.get$isVoid = function() { 11801 DefinedType.prototype.get$isVoid = function() {
11816 return $eq(this, $globals.world.voidType); 11802 return $eq(this, $globals.world.voidType);
11817 } 11803 }
11818 DefinedType.prototype.get$isTop = function() { 11804 DefinedType.prototype.get$isTop = function() {
11819 return this.name == null; 11805 return this.name == null;
11820 } 11806 }
11821 DefinedType.prototype.get$isObject = function() { 11807 DefinedType.prototype.get$isObject = function() {
11822 return this.library.get$isCore() && this.name == 'Object'; 11808 return this.library.get$isCore() && this.name == "Object";
11823 } 11809 }
11824 DefinedType.prototype.get$isString = function() { 11810 DefinedType.prototype.get$isString = function() {
11825 return this.library.get$isCore() && this.name == 'String' || this.library.get$ isCoreImpl() && this.name == 'StringImplementation'; 11811 return this.library.get$isCore() && this.name == "String" || this.library.get$ isCoreImpl() && this.name == "StringImplementation";
11826 } 11812 }
11827 DefinedType.prototype.get$isBool = function() { 11813 DefinedType.prototype.get$isBool = function() {
11828 return this.library.get$isCore() && this.name == 'bool'; 11814 return this.library.get$isCore() && this.name == "bool";
11829 } 11815 }
11830 DefinedType.prototype.get$isFunction = function() { 11816 DefinedType.prototype.get$isFunction = function() {
11831 return this.library.get$isCore() && this.name == 'Function'; 11817 return this.library.get$isCore() && this.name == "Function";
11832 } 11818 }
11833 DefinedType.prototype.get$isList = function() { 11819 DefinedType.prototype.get$isList = function() {
11834 return this.library.get$isCore() && this.name == 'List'; 11820 return this.library.get$isCore() && this.name == "List";
11835 } 11821 }
11836 DefinedType.prototype.get$isGeneric = function() { 11822 DefinedType.prototype.get$isGeneric = function() {
11837 return this.typeParameters != null; 11823 return this.typeParameters != null;
11838 } 11824 }
11839 DefinedType.prototype.get$span = function() { 11825 DefinedType.prototype.get$span = function() {
11840 return this.definition == null ? null : this.definition.span; 11826 return this.definition == null ? null : this.definition.span;
11841 } 11827 }
11842 DefinedType.prototype.get$typeofName = function() { 11828 DefinedType.prototype.get$typeofName = function() {
11843 if (!this.library.get$isCore()) return null; 11829 if (!this.library.get$isCore()) return null;
11844 if (this.get$isBool()) return 'boolean'; 11830 if (this.get$isBool()) return "boolean";
11845 else if (this.get$isNum()) return 'number'; 11831 else if (this.get$isNum()) return "number";
11846 else if (this.get$isString()) return 'string'; 11832 else if (this.get$isString()) return "string";
11847 else if (this.get$isFunction()) return 'function'; 11833 else if (this.get$isFunction()) return "function";
11848 else return null; 11834 else return null;
11849 } 11835 }
11850 DefinedType.prototype.get$isNum = function() { 11836 DefinedType.prototype.get$isNum = function() {
11851 return this.library != null && this.library.get$isCore() && (this.name == 'num ' || this.name == 'int' || this.name == 'double'); 11837 return this.library != null && this.library.get$isCore() && (this.name == "num " || this.name == "int" || this.name == "double");
11852 } 11838 }
11853 DefinedType.prototype.getCallMethod = function() { 11839 DefinedType.prototype.getCallMethod = function() {
11854 return this.members.$index(':call'); 11840 return this.members.$index(":call");
11855 } 11841 }
11856 DefinedType.prototype.getAllMembers = function() { 11842 DefinedType.prototype.getAllMembers = function() {
11857 return HashMapImplementation.HashMapImplementation$from$factory(this.members); 11843 return HashMapImplementation.HashMapImplementation$from$factory(this.members);
11858 } 11844 }
11859 DefinedType.prototype.markUsed = function() { 11845 DefinedType.prototype.markUsed = function() {
11860 if (this.isUsed) return; 11846 if (this.isUsed) return;
11861 this.isUsed = true; 11847 this.isUsed = true;
11862 this._checkExtends(); 11848 this._checkExtends();
11863 if (this._lazyGenMethods != null) { 11849 if (this._lazyGenMethods != null) {
11864 var $$list = orderValuesByKeys(this._lazyGenMethods); 11850 var $$list = orderValuesByKeys(this._lazyGenMethods);
(...skipping 14 matching lines...) Expand all
11879 this._lazyGenMethods.$setindex(method.name, method); 11865 this._lazyGenMethods.$setindex(method.name, method);
11880 } 11866 }
11881 } 11867 }
11882 DefinedType.prototype._resolveInterfaces = function(types) { 11868 DefinedType.prototype._resolveInterfaces = function(types) {
11883 if (types == null) return []; 11869 if (types == null) return [];
11884 var interfaces = []; 11870 var interfaces = [];
11885 for (var $$i = 0;$$i < types.get$length(); $$i++) { 11871 for (var $$i = 0;$$i < types.get$length(); $$i++) {
11886 var type = types.$index($$i); 11872 var type = types.$index($$i);
11887 var resolvedInterface = this.resolveType(type, true); 11873 var resolvedInterface = this.resolveType(type, true);
11888 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this. library.get$isCoreImpl())) { 11874 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this. library.get$isCoreImpl())) {
11889 $globals.world.error(('can not implement "' + resolvedInterface.get$name() + '": ') + 'only native implementation allowed', type.get$span()); 11875 $globals.world.error(("can not implement \"" + resolvedInterface.get$name( ) + "\": ") + "only native implementation allowed", type.get$span());
11890 } 11876 }
11891 resolvedInterface.addDirectSubtype$1(this); 11877 resolvedInterface.addDirectSubtype$1(this);
11892 interfaces.add$1(resolvedInterface); 11878 interfaces.add$1(resolvedInterface);
11893 } 11879 }
11894 return interfaces; 11880 return interfaces;
11895 } 11881 }
11896 DefinedType.prototype.addDirectSubtype = function(type) { 11882 DefinedType.prototype.addDirectSubtype = function(type) {
11897 this.directSubtypes.add(type); 11883 this.directSubtypes.add(type);
11898 } 11884 }
11899 DefinedType.prototype.get$subtypes = function() { 11885 DefinedType.prototype.get$subtypes = function() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
11949 if (_helper(this.interfaces.$index(i))) return i; 11935 if (_helper(this.interfaces.$index(i))) return i;
11950 } 11936 }
11951 return -1; 11937 return -1;
11952 } 11938 }
11953 DefinedType.prototype.resolve = function() { 11939 DefinedType.prototype.resolve = function() {
11954 if ((this.definition instanceof TypeDefinition)) { 11940 if ((this.definition instanceof TypeDefinition)) {
11955 var typeDef = this.definition; 11941 var typeDef = this.definition;
11956 if (this.isClass) { 11942 if (this.isClass) {
11957 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > 0) { 11943 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > 0) {
11958 if (typeDef.extendsTypes.get$length() > 1) { 11944 if (typeDef.extendsTypes.get$length() > 1) {
11959 $globals.world.error('more than one base class', typeDef.extendsTypes. $index(1).get$span()); 11945 $globals.world.error("more than one base class", typeDef.extendsTypes. $index(1).get$span());
11960 } 11946 }
11961 var extendsTypeRef = typeDef.extendsTypes.$index(0); 11947 var extendsTypeRef = typeDef.extendsTypes.$index(0);
11962 if ((extendsTypeRef instanceof GenericTypeReference)) { 11948 if ((extendsTypeRef instanceof GenericTypeReference)) {
11963 var g = extendsTypeRef; 11949 var g = extendsTypeRef;
11964 this.set$parent(this.resolveType(g.baseType, true)); 11950 this.set$parent(this.resolveType(g.baseType, true));
11965 } 11951 }
11966 this.set$parent(this.resolveType(extendsTypeRef, true)); 11952 this.set$parent(this.resolveType(extendsTypeRef, true));
11967 if (!this.get$parent().get$isClass()) { 11953 if (!this.get$parent().get$isClass()) {
11968 $globals.world.error('class may not extend an interface - use implemen ts', typeDef.extendsTypes.$index(0).get$span()); 11954 $globals.world.error("class may not extend an interface - use implemen ts", typeDef.extendsTypes.$index(0).get$span());
11969 } 11955 }
11970 this.get$parent().addDirectSubtype(this); 11956 this.get$parent().addDirectSubtype(this);
11971 if (this._cycleInClassExtends()) { 11957 if (this._cycleInClassExtends()) {
11972 $globals.world.error(('class "' + this.name + '" has a cycle in its in heritance chain'), extendsTypeRef.get$span()); 11958 $globals.world.error(("class \"" + this.name + "\" has a cycle in its inheritance chain"), extendsTypeRef.get$span());
11973 } 11959 }
11974 } 11960 }
11975 else { 11961 else {
11976 if (!this.get$isObject()) { 11962 if (!this.get$isObject()) {
11977 this.set$parent($globals.world.objectType); 11963 this.set$parent($globals.world.objectType);
11978 this.get$parent().addDirectSubtype(this); 11964 this.get$parent().addDirectSubtype(this);
11979 } 11965 }
11980 } 11966 }
11981 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes); 11967 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes);
11982 if (typeDef.defaultType != null) { 11968 if (typeDef.defaultType != null) {
11983 $globals.world.error('default not allowed on classes', typeDef.defaultTy pe.span); 11969 $globals.world.error("default not allowed on classes", typeDef.defaultTy pe.span);
11984 } 11970 }
11985 } 11971 }
11986 else { 11972 else {
11987 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length( ) > 0) { 11973 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length( ) > 0) {
11988 $globals.world.error('implements not allowed on interfaces (use extends) ', typeDef.implementsTypes.$index(0).get$span()); 11974 $globals.world.error("implements not allowed on interfaces (use extends) ", typeDef.implementsTypes.$index(0).get$span());
11989 } 11975 }
11990 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes); 11976 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes);
11991 var res = this._cycleInInterfaceExtends(); 11977 var res = this._cycleInInterfaceExtends();
11992 if (res >= 0) { 11978 if (res >= 0) {
11993 $globals.world.error(('interface "' + this.name + '" has a cycle in its inheritance chain'), typeDef.extendsTypes.$index(res).get$span()); 11979 $globals.world.error(("interface \"" + this.name + "\" has a cycle in it s inheritance chain"), typeDef.extendsTypes.$index(res).get$span());
11994 } 11980 }
11995 if (typeDef.defaultType != null) { 11981 if (typeDef.defaultType != null) {
11996 this.defaultType = this.resolveType(typeDef.defaultType.baseType, true); 11982 this.defaultType = this.resolveType(typeDef.defaultType.baseType, true);
11997 if (this.defaultType == null) { 11983 if (this.defaultType == null) {
11998 $globals.world.warning('unresolved default class', typeDef.defaultType .span); 11984 $globals.world.warning("unresolved default class", typeDef.defaultType .span);
11999 } 11985 }
12000 else { 11986 else {
12001 this.defaultType._resolveTypeParams(typeDef.defaultType.typeParameters ); 11987 this.defaultType._resolveTypeParams(typeDef.defaultType.typeParameters );
12002 } 11988 }
12003 } 11989 }
12004 } 11990 }
12005 } 11991 }
12006 else if ((this.definition instanceof FunctionTypeDefinition)) { 11992 else if ((this.definition instanceof FunctionTypeDefinition)) {
12007 this.interfaces = [$globals.world.functionType]; 11993 this.interfaces = [$globals.world.functionType];
12008 } 11994 }
(...skipping 28 matching lines...) Expand all
12037 var tp = params.$index($$i); 12023 var tp = params.$index($$i);
12038 tp.set$enclosingElement(this); 12024 tp.set$enclosingElement(this);
12039 tp.resolve$0(); 12025 tp.resolve$0();
12040 } 12026 }
12041 } 12027 }
12042 DefinedType.prototype.addMethod = function(methodName, definition) { 12028 DefinedType.prototype.addMethod = function(methodName, definition) {
12043 if (methodName == null) methodName = definition.name.name; 12029 if (methodName == null) methodName = definition.name.name;
12044 var method = new MethodMember(methodName, this, definition); 12030 var method = new MethodMember(methodName, this, definition);
12045 if (method.get$isConstructor()) { 12031 if (method.get$isConstructor()) {
12046 if (this.constructors.containsKey(method.get$constructorName())) { 12032 if (this.constructors.containsKey(method.get$constructorName())) {
12047 $globals.world.error(('duplicate constructor definition of ' + method.get$ name()), definition.span); 12033 $globals.world.error(("duplicate constructor definition of " + method.get$ name()), definition.span);
12048 return; 12034 return;
12049 } 12035 }
12050 this.constructors.$setindex(method.get$constructorName(), method); 12036 this.constructors.$setindex(method.get$constructorName(), method);
12051 return; 12037 return;
12052 } 12038 }
12053 if (definition.modifiers != null && definition.modifiers.get$length() == 1 && $eq(definition.modifiers.$index(0).get$kind(), 73/*TokenKind.FACTORY*/)) { 12039 if (definition.modifiers != null && definition.modifiers.get$length() == 1 && $eq(definition.modifiers.$index(0).get$kind(), 73/*TokenKind.FACTORY*/)) {
12054 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) { 12040 if (this.factories.getFactory(method.get$constructorName(), method.get$name( )) != null) {
12055 $globals.world.error(('duplicate factory definition of "' + method.get$nam e() + '"'), definition.span); 12041 $globals.world.error(("duplicate factory definition of \"" + method.get$na me() + "\""), definition.span);
12056 return; 12042 return;
12057 } 12043 }
12058 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod); 12044 this.factories.addFactory(method.get$constructorName(), method.get$name(), m ethod);
12059 return; 12045 return;
12060 } 12046 }
12061 if (methodName.startsWith('get:') || methodName.startsWith('set:')) { 12047 if (methodName.startsWith("get:") || methodName.startsWith("set:")) {
12062 var propName = methodName.substring(4); 12048 var propName = methodName.substring(4);
12063 var prop = this.members.$index(propName); 12049 var prop = this.members.$index(propName);
12064 if (prop == null) { 12050 if (prop == null) {
12065 prop = new PropertyMember(propName, this); 12051 prop = new PropertyMember(propName, this);
12066 this.members.$setindex(propName, prop); 12052 this.members.$setindex(propName, prop);
12067 } 12053 }
12068 if (!(prop instanceof PropertyMember)) { 12054 if (!(prop instanceof PropertyMember)) {
12069 $globals.world.error(('property conflicts with field "' + propName + '"'), definition.span); 12055 $globals.world.error(("property conflicts with field \"" + propName + "\"" ), definition.span);
12070 return; 12056 return;
12071 } 12057 }
12072 if (methodName[0] == 'g') { 12058 if (methodName[0] == "g") {
12073 if (prop.get$getter() != null) { 12059 if (prop.get$getter() != null) {
12074 $globals.world.error(('duplicate getter definition for "' + propName + ' "'), definition.span); 12060 $globals.world.error(("duplicate getter definition for \"" + propName + "\""), definition.span);
12075 } 12061 }
12076 prop.set$getter(method); 12062 prop.set$getter(method);
12077 } 12063 }
12078 else { 12064 else {
12079 if (prop.get$setter() != null) { 12065 if (prop.get$setter() != null) {
12080 $globals.world.error(('duplicate setter definition for "' + propName + ' "'), definition.span); 12066 $globals.world.error(("duplicate setter definition for \"" + propName + "\""), definition.span);
12081 } 12067 }
12082 prop.set$setter(method); 12068 prop.set$setter(method);
12083 } 12069 }
12084 return; 12070 return;
12085 } 12071 }
12086 if (this.members.containsKey(methodName)) { 12072 if (this.members.containsKey(methodName)) {
12087 $globals.world.error(('duplicate method definition of "' + method.get$name() + '"'), definition.span); 12073 $globals.world.error(("duplicate method definition of \"" + method.get$name( ) + "\""), definition.span);
12088 return; 12074 return;
12089 } 12075 }
12090 this.members.$setindex(methodName, method); 12076 this.members.$setindex(methodName, method);
12091 } 12077 }
12092 DefinedType.prototype.addField = function(definition) { 12078 DefinedType.prototype.addField = function(definition) {
12093 for (var i = 0; 12079 for (var i = 0;
12094 i < definition.names.get$length(); i++) { 12080 i < definition.names.get$length(); i++) {
12095 var name = definition.names.$index(i).get$name(); 12081 var name = definition.names.$index(i).get$name();
12096 if (this.members.containsKey(name)) { 12082 if (this.members.containsKey(name)) {
12097 $globals.world.error(('duplicate field definition of "' + name + '"'), def inition.span); 12083 $globals.world.error(("duplicate field definition of \"" + name + "\""), d efinition.span);
12098 return; 12084 return;
12099 } 12085 }
12100 var value = null; 12086 var value = null;
12101 if (definition.values != null) { 12087 if (definition.values != null) {
12102 value = definition.values.$index(i); 12088 value = definition.values.$index(i);
12103 } 12089 }
12104 var field = new FieldMember(name, this, definition, value); 12090 var field = new FieldMember(name, this, definition, value);
12105 this.members.$setindex(name, field); 12091 this.members.$setindex(name, field);
12106 if (this.isNative) { 12092 if (this.isNative) {
12107 field.set$isNative(true); 12093 field.set$isNative(true);
(...skipping 27 matching lines...) Expand all
12135 return (list != null ? list : const$127/*const []*/); 12121 return (list != null ? list : const$127/*const []*/);
12136 } 12122 }
12137 var typeDef = this.definition; 12123 var typeDef = this.definition;
12138 if (typeDef.defaultType.oldFactory) { 12124 if (typeDef.defaultType.oldFactory) {
12139 return; 12125 return;
12140 } 12126 }
12141 var interfaceParams = toList(this.typeParameters); 12127 var interfaceParams = toList(this.typeParameters);
12142 var defaultParams = toList(typeDef.defaultType.typeParameters); 12128 var defaultParams = toList(typeDef.defaultType.typeParameters);
12143 var classParams = toList(this.defaultType.typeParameters); 12129 var classParams = toList(this.defaultType.typeParameters);
12144 if ($ne(interfaceParams.get$length(), defaultParams.get$length()) || $ne(defau ltParams.get$length(), classParams.get$length())) { 12130 if ($ne(interfaceParams.get$length(), defaultParams.get$length()) || $ne(defau ltParams.get$length(), classParams.get$length())) {
12145 $globals.world.error('"default" must have the same number of type parameters as the class and interface do'/*'"default" must have the same number of type pa rameters as ' 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());
12146 + 'the class and interface do'*/, this.get$span(), typeDef.default Type.span, this.defaultType.get$span());
12147 return; 12132 return;
12148 } 12133 }
12149 for (var i = 0; 12134 for (var i = 0;
12150 i < interfaceParams.get$length(); i++) { 12135 i < interfaceParams.get$length(); i++) {
12151 var ip = interfaceParams.$index(i); 12136 var ip = interfaceParams.$index(i);
12152 var dp = defaultParams.$index(i); 12137 var dp = defaultParams.$index(i);
12153 var cp = classParams.$index(i); 12138 var cp = classParams.$index(i);
12154 dp.resolve$0(); 12139 dp.resolve$0();
12155 if ($ne(ip.get$name(), dp.get$name()) || $ne(dp.get$name(), cp.get$name())) { 12140 if ($ne(ip.get$name(), dp.get$name()) || $ne(dp.get$name(), cp.get$name())) {
12156 $globals.world.error('default class must have the same type parameter name s as the class and interface'/*'default class must have the same type parameter names as ' 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());
12157 + 'the class and interface'*/, ip.get$span(), dp.get$span(), c p.get$span());
12158 } 12142 }
12159 else if ($ne(dp.get$extendsType(), cp.get$extendsType())) { 12143 else if ($ne(dp.get$extendsType(), cp.get$extendsType())) {
12160 $globals.world.error('default class type parameters must have the same ext ends as the class does'/*'default class type parameters must have the same exten ds ' 12144 $globals.world.error("default class type parameters must have the same ext ends as the class does", dp.get$span(), cp.get$span());
12161 + 'as the class does'*/, dp.get$span(), cp.get$span());
12162 } 12145 }
12163 else if (!dp.get$extendsType().isSubtypeOf$1(ip.get$extendsType())) { 12146 else if (!dp.get$extendsType().isSubtypeOf$1(ip.get$extendsType())) {
12164 $globals.world.warning('"default" can only have tighter type parameter "ex tends" than the interface'/*'"default" can only have tighter type parameter "ext ends"' 12147 $globals.world.warning("\"default\" can only have tighter type parameter \ "extends\" than the interface", dp.get$span(), ip.get$span());
12165 + ' than the interface'*/, dp.get$span(), ip.get$span());
12166 } 12148 }
12167 } 12149 }
12168 } 12150 }
12169 DefinedType.prototype._tryCreateDefaultConstructor = function(name) { 12151 DefinedType.prototype._tryCreateDefaultConstructor = function(name) {
12170 if (name == '' && this.definition != null && this.isClass && this.constructors .get$length() == 0) { 12152 if (name == "" && this.definition != null && this.isClass && this.constructors .get$length() == 0) {
12171 var span = this.definition.span; 12153 var span = this.definition.span;
12172 var inits = null, native_ = null, body = null; 12154 var inits = null, native_ = null, body = null;
12173 if (this.isNative) { 12155 if (this.isNative) {
12174 native_ = ''; 12156 native_ = "";
12175 inits = null; 12157 inits = null;
12176 } 12158 }
12177 else { 12159 else {
12178 body = null; 12160 body = null;
12179 inits = [new CallExpression(new SuperExpression(span), [], span)]; 12161 inits = [new CallExpression(new SuperExpression(span), [], span)];
12180 } 12162 }
12181 var typeDef = this.definition; 12163 var typeDef = this.definition;
12182 var c = new FunctionDefinition(null, null, typeDef.name, [], inits, native_, body, span); 12164 var c = new FunctionDefinition(null, null, typeDef.name, [], inits, native_, body, span);
12183 this.addMethod(null, c); 12165 this.addMethod(null, c);
12184 this.constructors.$index('').resolve$0(); 12166 this.constructors.$index("").resolve$0();
12185 return this.constructors.$index(''); 12167 return this.constructors.$index("");
12186 } 12168 }
12187 return null; 12169 return null;
12188 } 12170 }
12189 DefinedType.prototype.getMember = function(memberName) { 12171 DefinedType.prototype.getMember = function(memberName) {
12190 var member = this.members.$index(memberName); 12172 var member = this.members.$index(memberName);
12191 if (member != null) { 12173 if (member != null) {
12192 this._checkOverride(member); 12174 this._checkOverride(member);
12193 return member; 12175 return member;
12194 } 12176 }
12195 if (this.get$isTop()) { 12177 if (this.get$isTop()) {
(...skipping 11 matching lines...) Expand all
12207 var jsnames = []; 12189 var jsnames = [];
12208 var names = []; 12190 var names = [];
12209 var typeMap = new HashMapImplementation(); 12191 var typeMap = new HashMapImplementation();
12210 for (var i = 0; 12192 for (var i = 0;
12211 i < typeArgs.get$length(); i++) { 12193 i < typeArgs.get$length(); i++) {
12212 var paramName = this.typeParameters.$index(i).get$name(); 12194 var paramName = this.typeParameters.$index(i).get$name();
12213 typeMap.$setindex(paramName, typeArgs.$index(i)); 12195 typeMap.$setindex(paramName, typeArgs.$index(i));
12214 names.add$1(typeArgs.$index(i).get$name()); 12196 names.add$1(typeArgs.$index(i).get$name());
12215 jsnames.add$1(typeArgs.$index(i).get$jsname()); 12197 jsnames.add$1(typeArgs.$index(i).get$jsname());
12216 } 12198 }
12217 var jsname = ('' + this.get$jsname() + '_' + Strings.join(jsnames, '\$')); 12199 var jsname = ("" + this.get$jsname() + "_" + Strings.join(jsnames, "$"));
12218 var simpleName = ('' + this.name + '<' + Strings.join(names, ', ') + '>'); 12200 var simpleName = ("" + this.name + "<" + Strings.join(names, ", ") + ">");
12219 var key = Strings.join(names, '\$'); 12201 var key = Strings.join(names, "$");
12220 var ret = this._concreteTypes.$index(key); 12202 var ret = this._concreteTypes.$index(key);
12221 if (ret == null) { 12203 if (ret == null) {
12222 ret = new ConcreteType(simpleName, this, typeMap, typeArgs); 12204 ret = new ConcreteType(simpleName, this, typeMap, typeArgs);
12223 ret.set$_jsname(jsname); 12205 ret.set$_jsname(jsname);
12224 this._concreteTypes.$setindex(key, ret); 12206 this._concreteTypes.$setindex(key, ret);
12225 } 12207 }
12226 return ret; 12208 return ret;
12227 } 12209 }
12228 DefinedType.prototype.getCallStub = function(args) { 12210 DefinedType.prototype.getCallStub = function(args) {
12229 var name = _getCallStubName('call', args); 12211 var name = _getCallStubName("call", args);
12230 var stub = this.varStubs.$index(name); 12212 var stub = this.varStubs.$index(name);
12231 if (stub == null) { 12213 if (stub == null) {
12232 stub = new VarFunctionStub(name, args); 12214 stub = new VarFunctionStub(name, args);
12233 this.varStubs.$setindex(name, stub); 12215 this.varStubs.$setindex(name, stub);
12234 } 12216 }
12235 return stub; 12217 return stub;
12236 } 12218 }
12237 DefinedType.prototype.addDirectSubtype$1 = DefinedType.prototype.addDirectSubtyp e; 12219 DefinedType.prototype.addDirectSubtype$1 = DefinedType.prototype.addDirectSubtyp e;
12238 DefinedType.prototype.addMethod$2 = DefinedType.prototype.addMethod; 12220 DefinedType.prototype.addMethod$2 = DefinedType.prototype.addMethod;
12239 DefinedType.prototype.getConstructor$1 = DefinedType.prototype.getConstructor; 12221 DefinedType.prototype.getConstructor$1 = DefinedType.prototype.getConstructor;
12240 DefinedType.prototype.getFactory$2 = DefinedType.prototype.getFactory; 12222 DefinedType.prototype.getFactory$2 = DefinedType.prototype.getFactory;
12241 DefinedType.prototype.getMember$1 = DefinedType.prototype.getMember; 12223 DefinedType.prototype.getMember$1 = DefinedType.prototype.getMember;
12242 DefinedType.prototype.getOrMakeConcreteType$1 = DefinedType.prototype.getOrMakeC oncreteType; 12224 DefinedType.prototype.getOrMakeConcreteType$1 = DefinedType.prototype.getOrMakeC oncreteType;
12243 DefinedType.prototype.markUsed$0 = DefinedType.prototype.markUsed; 12225 DefinedType.prototype.markUsed$0 = DefinedType.prototype.markUsed;
12244 DefinedType.prototype.resolve$0 = DefinedType.prototype.resolve; 12226 DefinedType.prototype.resolve$0 = DefinedType.prototype.resolve;
12245 DefinedType.prototype.resolveTypeParams$1 = DefinedType.prototype.resolveTypePar ams; 12227 DefinedType.prototype.resolveTypeParams$1 = DefinedType.prototype.resolveTypePar ams;
12246 DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition; 12228 DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition;
12247 // ********** Code for NativeType ************** 12229 // ********** Code for NativeType **************
12248 function NativeType(name) { 12230 function NativeType(name) {
12249 this.isConstructorHidden = false 12231 this.isConstructorHidden = false
12250 this.isJsGlobalObject = false 12232 this.isJsGlobalObject = false
12251 this.isSingleton = false 12233 this.isSingleton = false
12252 this.name = name; 12234 this.name = name;
12253 // Initializers done 12235 // Initializers done
12254 while (true) { 12236 while (true) {
12255 if (this.name.startsWith('@')) { 12237 if (this.name.startsWith("@")) {
12256 this.name = this.name.substring(1); 12238 this.name = this.name.substring(1);
12257 this.isJsGlobalObject = true; 12239 this.isJsGlobalObject = true;
12258 } 12240 }
12259 else if (this.name.startsWith('*')) { 12241 else if (this.name.startsWith("*")) {
12260 this.name = this.name.substring(1); 12242 this.name = this.name.substring(1);
12261 this.isConstructorHidden = true; 12243 this.isConstructorHidden = true;
12262 } 12244 }
12263 else { 12245 else {
12264 break; 12246 break;
12265 } 12247 }
12266 } 12248 }
12267 if (this.name.startsWith('=')) { 12249 if (this.name.startsWith("=")) {
12268 this.name = this.name.substring(1); 12250 this.name = this.name.substring(1);
12269 this.isSingleton = true; 12251 this.isSingleton = true;
12270 } 12252 }
12271 } 12253 }
12272 NativeType.prototype.get$name = function() { return this.name; }; 12254 NativeType.prototype.get$name = function() { return this.name; };
12273 NativeType.prototype.set$name = function(value) { return this.name = value; }; 12255 NativeType.prototype.set$name = function(value) { return this.name = value; };
12274 // ********** Code for FixedCollection ************** 12256 // ********** Code for FixedCollection **************
12275 function FixedCollection(value, length) { 12257 function FixedCollection(value, length) {
12276 this.value = value; 12258 this.value = value;
12277 this.length = length; 12259 this.length = length;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
12348 function Value(_type, code, span, needsTemp) { 12330 function Value(_type, code, span, needsTemp) {
12349 this.isSuper = false 12331 this.isSuper = false
12350 this.isType = false 12332 this.isType = false
12351 this.isFinal = false 12333 this.isFinal = false
12352 this.allowDynamic = true 12334 this.allowDynamic = true
12353 this._type = _type; 12335 this._type = _type;
12354 this.code = code; 12336 this.code = code;
12355 this.span = span; 12337 this.span = span;
12356 this.needsTemp = needsTemp; 12338 this.needsTemp = needsTemp;
12357 // Initializers done 12339 // Initializers done
12358 if (this._type == null) $globals.world.internalError('type passed as null', th is.span); 12340 if (this._type == null) $globals.world.internalError("type passed as null", th is.span);
12359 } 12341 }
12360 Value.type$ctor = function(_type, span) { 12342 Value.type$ctor = function(_type, span) {
12361 this.isSuper = false 12343 this.isSuper = false
12362 this.isType = false 12344 this.isType = false
12363 this.isFinal = false 12345 this.isFinal = false
12364 this.allowDynamic = true 12346 this.allowDynamic = true
12365 this._type = _type; 12347 this._type = _type;
12366 this.span = span; 12348 this.span = span;
12367 this.code = null; 12349 this.code = null;
12368 this.needsTemp = false; 12350 this.needsTemp = false;
12369 this.isType = true; 12351 this.isType = true;
12370 // Initializers done 12352 // Initializers done
12371 if (this._type == null) $globals.world.internalError('type passed as null', th is.span); 12353 if (this._type == null) $globals.world.internalError("type passed as null", th is.span);
12372 } 12354 }
12373 Value.type$ctor.prototype = Value.prototype; 12355 Value.type$ctor.prototype = Value.prototype;
12374 Value.prototype.get$code = function() { return this.code; }; 12356 Value.prototype.get$code = function() { return this.code; };
12375 Value.prototype.set$code = function(value) { return this.code = value; }; 12357 Value.prototype.set$code = function(value) { return this.code = value; };
12376 Value.prototype.get$span = function() { return this.span; }; 12358 Value.prototype.get$span = function() { return this.span; };
12377 Value.prototype.set$span = function(value) { return this.span = value; }; 12359 Value.prototype.set$span = function(value) { return this.span = value; };
12378 Value.prototype.get$isSuper = function() { return this.isSuper; }; 12360 Value.prototype.get$isSuper = function() { return this.isSuper; };
12379 Value.prototype.set$isSuper = function(value) { return this.isSuper = value; }; 12361 Value.prototype.set$isSuper = function(value) { return this.isSuper = value; };
12380 Value.prototype.get$isType = function() { return this.isType; }; 12362 Value.prototype.get$isType = function() { return this.isType; };
12381 Value.prototype.set$isType = function(value) { return this.isType = value; }; 12363 Value.prototype.set$isType = function(value) { return this.isType = value; };
(...skipping 22 matching lines...) Expand all
12404 } 12386 }
12405 Value.prototype.get$constValue = function() { 12387 Value.prototype.get$constValue = function() {
12406 return null; 12388 return null;
12407 } 12389 }
12408 Value.prototype.get_ = function(context, name, node) { 12390 Value.prototype.get_ = function(context, name, node) {
12409 var member = this._resolveMember(context, name, node, false); 12391 var member = this._resolveMember(context, name, node, false);
12410 if (member != null) { 12392 if (member != null) {
12411 return member._get$3(context, node, this); 12393 return member._get$3(context, node, this);
12412 } 12394 }
12413 else { 12395 else {
12414 return this.invokeNoSuchMethod(context, ('get:' + name), node); 12396 return this.invokeNoSuchMethod(context, ("get:" + name), node);
12415 } 12397 }
12416 } 12398 }
12417 Value.prototype.set_ = function(context, name, node, value, isDynamic) { 12399 Value.prototype.set_ = function(context, name, node, value, isDynamic) {
12418 var member = this._resolveMember(context, name, node, isDynamic); 12400 var member = this._resolveMember(context, name, node, isDynamic);
12419 if (member != null) { 12401 if (member != null) {
12420 return member._set$5(context, node, this, value, isDynamic); 12402 return member._set$5(context, node, this, value, isDynamic);
12421 } 12403 }
12422 else { 12404 else {
12423 return this.invokeNoSuchMethod(context, ('set:' + name), node, new Arguments (null, [value])); 12405 return this.invokeNoSuchMethod(context, ("set:" + name), node, new Arguments (null, [value]));
12424 } 12406 }
12425 } 12407 }
12426 Value.prototype.invoke = function(context, name, node, args, isDynamic) { 12408 Value.prototype.invoke = function(context, name, node, args, isDynamic) {
12427 if (name == ':call') { 12409 if (name == ":call") {
12428 if (this.isType) { 12410 if (this.isType) {
12429 $globals.world.error('must use "new" or "const" to construct a new instanc e', node.span); 12411 $globals.world.error("must use \"new\" or \"const\" to construct a new ins tance", node.span);
12430 } 12412 }
12431 if (this.get$type().needsVarCall(args)) { 12413 if (this.get$type().needsVarCall(args)) {
12432 return this._varCall(context, node, args); 12414 return this._varCall(context, node, args);
12433 } 12415 }
12434 } 12416 }
12435 var member = this._resolveMember(context, name, node, isDynamic); 12417 var member = this._resolveMember(context, name, node, isDynamic);
12436 if (member == null) { 12418 if (member == null) {
12437 return this.invokeNoSuchMethod(context, name, node, args); 12419 return this.invokeNoSuchMethod(context, name, node, args);
12438 } 12420 }
12439 else { 12421 else {
12440 return member.invoke$5(context, node, this, args, isDynamic); 12422 return member.invoke$5(context, node, this, args, isDynamic);
12441 } 12423 }
12442 } 12424 }
12443 Value.prototype.canInvoke = function(context, name, args) { 12425 Value.prototype.canInvoke = function(context, name, args) {
12444 if (this.get$type().get$isVarOrFunction() && name == ':call') { 12426 if (this.get$type().get$isVarOrFunction() && name == ":call") {
12445 return true; 12427 return true;
12446 } 12428 }
12447 var member = this._resolveMember(context, name, null, true); 12429 var member = this._resolveMember(context, name, null, true);
12448 return member != null && member.canInvoke$2(context, args); 12430 return member != null && member.canInvoke$2(context, args);
12449 } 12431 }
12450 Value.prototype._hasOverriddenNoSuchMethod = function() { 12432 Value.prototype._hasOverriddenNoSuchMethod = function() {
12451 if (this.isSuper) { 12433 if (this.isSuper) {
12452 var m = this.get$type().getMember('noSuchMethod'); 12434 var m = this.get$type().getMember("noSuchMethod");
12453 return m != null && !m.get$declaringType().get$isObject(); 12435 return m != null && !m.get$declaringType().get$isObject();
12454 } 12436 }
12455 else { 12437 else {
12456 var m = this.get$type().resolveMember('noSuchMethod'); 12438 var m = this.get$type().resolveMember("noSuchMethod");
12457 return m != null && m.get$members().get$length() > 1; 12439 return m != null && m.get$members().get$length() > 1;
12458 } 12440 }
12459 } 12441 }
12460 Value.prototype._tryResolveMember = function(context, name) { 12442 Value.prototype._tryResolveMember = function(context, name) {
12461 if (this.isSuper) { 12443 if (this.isSuper) {
12462 return this.get$type().getMember(name); 12444 return this.get$type().getMember(name);
12463 } 12445 }
12464 else { 12446 else {
12465 return this.get$type().resolveMember(name); 12447 return this.get$type().resolveMember(name);
12466 } 12448 }
12467 } 12449 }
12468 Value.prototype._resolveMember = function(context, name, node, isDynamic) { 12450 Value.prototype._resolveMember = function(context, name, node, isDynamic) {
12469 var member; 12451 var member;
12470 if (!this.get$_typeIsVarOrParameterType()) { 12452 if (!this.get$_typeIsVarOrParameterType()) {
12471 member = this._tryResolveMember(context, name); 12453 member = this._tryResolveMember(context, name);
12472 if (member != null && this.isType && !member.get$isStatic()) { 12454 if (member != null && this.isType && !member.get$isStatic()) {
12473 if (!isDynamic) { 12455 if (!isDynamic) {
12474 $globals.world.error('can not refer to instance member as static', node. span); 12456 $globals.world.error("can not refer to instance member as static", node. span);
12475 } 12457 }
12476 return null; 12458 return null;
12477 } 12459 }
12478 if (member == null && !isDynamic && !this._hasOverriddenNoSuchMethod()) { 12460 if (member == null && !isDynamic && !this._hasOverriddenNoSuchMethod()) {
12479 var typeName = this.get$type().name == null ? this.get$type().get$library( ).name : this.get$type().name; 12461 var typeName = this.get$type().name == null ? this.get$type().get$library( ).name : this.get$type().name;
12480 var message = ('can not resolve "' + name + '" on "' + typeName + '"'); 12462 var message = ("can not resolve \"" + name + "\" on \"" + typeName + "\"") ;
12481 if (this.isType) { 12463 if (this.isType) {
12482 $globals.world.error(message, node.span); 12464 $globals.world.error(message, node.span);
12483 } 12465 }
12484 else { 12466 else {
12485 $globals.world.warning(message, node.span); 12467 $globals.world.warning(message, node.span);
12486 } 12468 }
12487 } 12469 }
12488 } 12470 }
12489 if (member == null && !this.isSuper && !this.isType) { 12471 if (member == null && !this.isSuper && !this.isType) {
12490 member = context.findMembers(name); 12472 member = context.findMembers(name);
12491 if (member == null && !isDynamic) { 12473 if (member == null && !isDynamic) {
12492 var where = 'the world'; 12474 var where = "the world";
12493 if (name.startsWith('_')) { 12475 if (name.startsWith("_")) {
12494 where = ('library "' + context.get$library().name + '"'); 12476 where = ("library \"" + context.get$library().name + "\"");
12495 } 12477 }
12496 $globals.world.warning(('' + name + ' is not defined anywhere in ' + where + '.'), node.span); 12478 $globals.world.warning(("" + name + " is not defined anywhere in " + where + "."), node.span);
12497 } 12479 }
12498 } 12480 }
12499 return member; 12481 return member;
12500 } 12482 }
12501 Value.prototype.checkFirstClass = function(span) { 12483 Value.prototype.checkFirstClass = function(span) {
12502 if (this.isType) { 12484 if (this.isType) {
12503 $globals.world.error('Types are not first class', span); 12485 $globals.world.error("Types are not first class", span);
12504 } 12486 }
12505 } 12487 }
12506 Value.prototype._varCall = function(context, node, args) { 12488 Value.prototype._varCall = function(context, node, args) {
12507 var stub = $globals.world.functionType.getCallStub(args); 12489 var stub = $globals.world.functionType.getCallStub(args);
12508 return stub.invoke$4(context, node, this, args); 12490 return stub.invoke$4(context, node, this, args);
12509 } 12491 }
12510 Value.prototype.needsConversion = function(toType) { 12492 Value.prototype.needsConversion = function(toType) {
12511 return $ne(this, this.convertTo(null, toType, true)); 12493 return $ne(this, this.convertTo(null, toType, true));
12512 } 12494 }
12513 Value.prototype.convertTo = function(context, toType, isDynamic) { 12495 Value.prototype.convertTo = function(context, toType, isDynamic) {
12514 var checked = !isDynamic; 12496 var checked = !isDynamic;
12515 var callMethod = toType.getCallMethod(); 12497 var callMethod = toType.getCallMethod();
12516 if (callMethod != null) { 12498 if (callMethod != null) {
12517 if (checked && !toType.isAssignable(this.get$type())) { 12499 if (checked && !toType.isAssignable(this.get$type())) {
12518 this.convertWarning(toType); 12500 this.convertWarning(toType);
12519 } 12501 }
12520 return this._maybeWrapFunction(toType, callMethod); 12502 return this._maybeWrapFunction(toType, callMethod);
12521 } 12503 }
12522 var fromType = this.get$type(); 12504 var fromType = this.get$type();
12523 if (this.get$type().get$isVar() && (this.code != 'null' || !toType.get$isNulla ble())) { 12505 if (this.get$type().get$isVar() && (this.code != "null" || !toType.get$isNulla ble())) {
12524 fromType = $globals.world.objectType; 12506 fromType = $globals.world.objectType;
12525 } 12507 }
12526 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); 12508 var bothNum = this.get$type().get$isNum() && toType.get$isNum();
12527 if (fromType.isSubtypeOf(toType) || bothNum) { 12509 if (fromType.isSubtypeOf(toType) || bothNum) {
12528 return this; 12510 return this;
12529 } 12511 }
12530 if (checked && !toType.isSubtypeOf(this.get$type())) { 12512 if (checked && !toType.isSubtypeOf(this.get$type())) {
12531 this.convertWarning(toType); 12513 this.convertWarning(toType);
12532 } 12514 }
12533 if ($globals.options.enableTypeChecks) { 12515 if ($globals.options.enableTypeChecks) {
12534 if (context == null && isDynamic) { 12516 if (context == null && isDynamic) {
12535 return null; 12517 return null;
12536 } 12518 }
12537 return this._typeAssert(context, toType, isDynamic); 12519 return this._typeAssert(context, toType, isDynamic);
12538 } 12520 }
12539 else { 12521 else {
12540 return this; 12522 return this;
12541 } 12523 }
12542 } 12524 }
12543 Value.prototype._maybeWrapFunction = function(toType, callMethod) { 12525 Value.prototype._maybeWrapFunction = function(toType, callMethod) {
12544 var arity = callMethod.parameters.get$length(); 12526 var arity = callMethod.parameters.get$length();
12545 var myCall = this.get$type().getCallMethod(); 12527 var myCall = this.get$type().getCallMethod();
12546 var result = this; 12528 var result = this;
12547 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { 12529 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) {
12548 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$ factory(arity)); 12530 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$ factory(arity));
12549 result = new Value(toType, ('to\$' + stub.name + '(' + this.code + ')'), thi s.span, true); 12531 result = new Value(toType, ("to$" + stub.name + "(" + this.code + ")"), this .span, true);
12550 } 12532 }
12551 if (toType.get$library().get$isDom() && !this.get$type().get$library().get$isD om()) { 12533 if (toType.get$library().get$isDom() && !this.get$type().get$library().get$isD om()) {
12552 if (arity == 0) { 12534 if (arity == 0) {
12553 $globals.world.gen.corejs.useWrap0 = true; 12535 $globals.world.gen.corejs.useWrap0 = true;
12554 } 12536 }
12555 else { 12537 else {
12556 $globals.world.gen.corejs.useWrap1 = true; 12538 $globals.world.gen.corejs.useWrap1 = true;
12557 } 12539 }
12558 result = new Value(toType, ('\$wrap_call\$' + arity + '(' + result.code + ') '), this.span, true); 12540 result = new Value(toType, ("$wrap_call$" + arity + "(" + result.code + ")") , this.span, true);
12559 } 12541 }
12560 return result; 12542 return result;
12561 } 12543 }
12562 Value.prototype._typeAssert = function(context, toType, isDynamic) { 12544 Value.prototype._typeAssert = function(context, toType, isDynamic) {
12563 if ((toType instanceof ParameterType)) { 12545 if ((toType instanceof ParameterType)) {
12564 var p = toType; 12546 var p = toType;
12565 toType = p.extendsType; 12547 toType = p.extendsType;
12566 } 12548 }
12567 if (toType.get$isObject() || toType.get$isVar()) { 12549 if (toType.get$isObject() || toType.get$isVar()) {
12568 $globals.world.internalError(('We thought ' + this.get$type().name + ' is no t a subtype of ' + toType.name + '?')); 12550 $globals.world.internalError(("We thought " + this.get$type().name + " is no t a subtype of " + toType.name + "?"));
12569 } 12551 }
12570 function throwTypeError(paramName) { 12552 function throwTypeError(paramName) {
12571 return $globals.world.withoutForceDynamic((function () { 12553 return $globals.world.withoutForceDynamic((function () {
12572 var typeErrorCtor = $globals.world.typeErrorType.getConstructor('_internal '); 12554 var typeErrorCtor = $globals.world.typeErrorType.getConstructor("_internal ");
12573 $globals.world.gen.corejs.ensureTypeNameOf(); 12555 $globals.world.gen.corejs.ensureTypeNameOf();
12574 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); 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);
12575 $globals.world.gen.corejs.useThrow = true; 12557 $globals.world.gen.corejs.useThrow = true;
12576 return ('\$throw(' + result.get$code() + ')'); 12558 return ("$throw(" + result.get$code() + ")");
12577 }) 12559 })
12578 ); 12560 );
12579 } 12561 }
12580 if (toType.get$isNum()) toType = $globals.world.numType; 12562 if (toType.get$isNum()) toType = $globals.world.numType;
12581 var check; 12563 var check;
12582 if (toType.get$isVoid()) { 12564 if (toType.get$isVoid()) {
12583 check = ('\$assert_void(' + this.code + ')'); 12565 check = ("$assert_void(" + this.code + ")");
12584 if (toType.typeCheckCode == null) { 12566 if (toType.typeCheckCode == null) {
12585 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu rn null;\n " + throwTypeError("x") + "\n}"); 12567 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu rn null;\n " + throwTypeError("x") + "\n}");
12586 } 12568 }
12587 } 12569 }
12588 else if ($eq(toType, $globals.world.nonNullBool)) { 12570 else if ($eq(toType, $globals.world.nonNullBool)) {
12589 $globals.world.gen.corejs.useNotNullBool = true; 12571 $globals.world.gen.corejs.useNotNullBool = true;
12590 check = ('\$notnull_bool(' + this.code + ')'); 12572 check = ("$notnull_bool(" + this.code + ")");
12591 } 12573 }
12592 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null) { 12574 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null) {
12593 check = ('\$assert_' + toType.name + '(' + this.code + ')'); 12575 check = ("$assert_" + toType.name + "(" + this.code + ")");
12594 if (toType.typeCheckCode == null) { 12576 if (toType.typeCheckCode == null) {
12595 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if ( x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " + throwTypeError("x") + "\n}"); 12577 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if ( x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " + throwTypeError("x") + "\n}");
12596 } 12578 }
12597 } 12579 }
12598 else { 12580 else {
12599 toType.isChecked = true; 12581 toType.isChecked = true;
12600 var checkName = 'assert\$' + toType.get$jsname(); 12582 var checkName = "assert$" + toType.get$jsname();
12601 var temp = context.getTemp(this); 12583 var temp = context.getTemp(this);
12602 check = ('(' + context.assignTemp(temp, this).code + ' == null ? null :'); 12584 check = ("(" + context.assignTemp(temp, this).code + " == null ? null :");
12603 check = check + (' ' + temp.get$code() + '.' + checkName + '())'); 12585 check = check + (" " + temp.get$code() + "." + checkName + "())");
12604 if ($ne(this, temp)) context.freeTemp(temp); 12586 if ($ne(this, temp)) context.freeTemp(temp);
12605 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () { 12587 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () {
12606 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType Error('this')); 12588 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType Error("this"));
12607 }) 12589 })
12608 ); 12590 );
12609 } 12591 }
12610 return new Value(toType, check, this.span, true); 12592 return new Value(toType, check, this.span, true);
12611 } 12593 }
12612 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck) { 12594 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck) {
12613 if (toType.get$isVar()) { 12595 if (toType.get$isVar()) {
12614 $globals.world.error('can not resolve type', span); 12596 $globals.world.error("can not resolve type", span);
12615 } 12597 }
12616 var testCode = null; 12598 var testCode = null;
12617 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete rType)) { 12599 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete rType)) {
12618 if (this.needsTemp) { 12600 if (this.needsTemp) {
12619 return new Value($globals.world.nonNullBool, ('(' + this.code + ', true)') , span, true); 12601 return new Value($globals.world.nonNullBool, ("(" + this.code + ", true)") , span, true);
12620 } 12602 }
12621 else { 12603 else {
12622 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, t rue, 'true', null); 12604 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, t rue, "true", null);
12623 } 12605 }
12624 } 12606 }
12625 if (toType.get$library().get$isCore()) { 12607 if (toType.get$library().get$isCore()) {
12626 var typeofName = toType.get$typeofName(); 12608 var typeofName = toType.get$typeofName();
12627 if (typeofName != null) { 12609 if (typeofName != null) {
12628 testCode = ("(typeof(" + this.code + ") " + (isTrue ? '==' : '!=') + " '" + typeofName + "')"); 12610 testCode = ("(typeof(" + this.code + ") " + (isTrue ? "==" : "!=") + " '" + typeofName + "')");
12629 } 12611 }
12630 } 12612 }
12631 if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$i sHiddenNativeType()) { 12613 if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$i sHiddenNativeType()) {
12632 toType.markUsed(); 12614 toType.markUsed();
12633 testCode = ('(' + this.code + ' instanceof ' + toType.get$jsname() + ')'); 12615 testCode = ("(" + this.code + " instanceof " + toType.get$jsname() + ")");
12634 if (!isTrue) { 12616 if (!isTrue) {
12635 testCode = '!' + testCode; 12617 testCode = "!" + testCode;
12636 } 12618 }
12637 } 12619 }
12638 if (testCode == null) { 12620 if (testCode == null) {
12639 toType.isTested = true; 12621 toType.isTested = true;
12640 var temp = context.getTemp(this); 12622 var temp = context.getTemp(this);
12641 var checkName = ('is\$' + toType.get$jsname()); 12623 var checkName = ("is$" + toType.get$jsname());
12642 testCode = ('(' + context.assignTemp(temp, this).code + ' &&'); 12624 testCode = ("(" + context.assignTemp(temp, this).code + " &&");
12643 testCode = testCode + (' ' + temp.get$code() + '.' + checkName + '())'); 12625 testCode = testCode + (" " + temp.get$code() + "." + checkName + "())");
12644 if (isTrue) { 12626 if (isTrue) {
12645 testCode = '!!' + testCode; 12627 testCode = "!!" + testCode;
12646 } 12628 }
12647 else { 12629 else {
12648 testCode = '!' + testCode; 12630 testCode = "!" + testCode;
12649 } 12631 }
12650 if ($ne(this, temp)) context.freeTemp(temp); 12632 if ($ne(this, temp)) context.freeTemp(temp);
12651 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { 12633 if (!$globals.world.objectType.varStubs.containsKey(checkName)) {
12652 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub( checkName, null, Arguments.get$EMPTY(), 'return false')); 12634 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub( checkName, null, Arguments.get$EMPTY(), "return false"));
12653 } 12635 }
12654 } 12636 }
12655 return new Value($globals.world.nonNullBool, testCode, span, true); 12637 return new Value($globals.world.nonNullBool, testCode, span, true);
12656 } 12638 }
12657 Value.prototype.convertWarning = function(toType) { 12639 Value.prototype.convertWarning = function(toType) {
12658 $globals.world.warning(('type "' + this.get$type().name + '" is not assignable to "' + toType.name + '"'), this.span); 12640 $globals.world.warning(("type \"" + this.get$type().name + "\" is not assignab le to \"" + toType.name + "\""), this.span);
12659 } 12641 }
12660 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { 12642 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) {
12661 var pos = ''; 12643 var pos = "";
12662 if (args != null) { 12644 if (args != null) {
12663 var argsCode = []; 12645 var argsCode = [];
12664 for (var i = 0; 12646 for (var i = 0;
12665 i < args.get$length(); i++) { 12647 i < args.get$length(); i++) {
12666 argsCode.add$1(args.values.$index(i).get$code()); 12648 argsCode.add$1(args.values.$index(i).get$code());
12667 } 12649 }
12668 pos = Strings.join(argsCode, ", "); 12650 pos = Strings.join(argsCode, ", ");
12669 } 12651 }
12670 var noSuchArgs = [new Value($globals.world.stringType, ('"' + name + '"'), nod e.span, true), new Value($globals.world.listType, ('[' + pos + ']'), node.span, true)]; 12652 var noSuchArgs = [new Value($globals.world.stringType, ("\"" + name + "\""), n ode.span, true), new Value($globals.world.listType, ("[" + pos + "]"), node.span , true)];
12671 return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(cont ext, node, this, new Arguments(null, noSuchArgs)); 12653 return this._resolveMember(context, "noSuchMethod", node, false).invoke$4(cont ext, node, this, new Arguments(null, noSuchArgs));
12654 }
12655 Value.fromBool = function(value, span) {
12656 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, value , value.toString(), span);
12657 }
12658 Value.fromInt = function(value, span) {
12659 var strValue = value.toString();
12660 return EvaluatedValue.EvaluatedValue$factory($globals.world.numType, value, st rValue, span);
12661 }
12662 Value.fromDouble = function(value, span) {
12663 var strValue = value.toString();
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 }
12669 Value.fromString = function(value, span) {
12670 var buf = new StringBufferImpl("");
12671 buf.add("\"");
12672 for (var i = 0;
12673 i < value.length; i++) {
12674 var ch = value.charCodeAt(i);
12675 switch (ch) {
12676 case 9:
12677
12678 buf.add("\\t");
12679 break;
12680
12681 case 10:
12682
12683 buf.add("\\n");
12684 break;
12685
12686 case 13:
12687
12688 buf.add("\\r");
12689 break;
12690
12691 case 34:
12692
12693 buf.add("\\\"");
12694 break;
12695
12696 case 92:
12697
12698 buf.add("\\\\");
12699 break;
12700
12701 default:
12702
12703 if (ch >= 32 && ch <= 126) {
12704 buf.add(value[i]);
12705 }
12706 else {
12707 var hex = ch.toRadixString$1(16);
12708 switch (hex.get$length()) {
12709 case 1:
12710
12711 buf.add("\\x0");
12712 buf.add(hex);
12713 break;
12714
12715 case 2:
12716
12717 buf.add("\\x");
12718 buf.add(hex);
12719 break;
12720
12721 case 3:
12722
12723 buf.add("\\u0");
12724 buf.add(hex);
12725 break;
12726
12727 case 4:
12728
12729 buf.add("\\u");
12730 buf.add(hex);
12731 break;
12732
12733 default:
12734
12735 $globals.world.internalError("unicode values greater than 2 bytes not implemented");
12736 break;
12737
12738 }
12739 }
12740 break;
12741
12742 }
12743 }
12744 buf.add("\"");
12745 return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType, value, buf.toString(), span);
12746 }
12747 Value.fromNull = function(span) {
12748 return EvaluatedValue.EvaluatedValue$factory($globals.world.varType, null, "nu ll", span);
12672 } 12749 }
12673 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass; 12750 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass;
12674 Value.prototype.convertTo$2 = function($0, $1) { 12751 Value.prototype.convertTo$2 = function($0, $1) {
12675 return this.convertTo($0, $1, false); 12752 return this.convertTo($0, $1, false);
12676 }; 12753 };
12677 Value.prototype.convertTo$3 = Value.prototype.convertTo; 12754 Value.prototype.convertTo$3 = Value.prototype.convertTo;
12678 Value.prototype.get_$3 = Value.prototype.get_; 12755 Value.prototype.get_$3 = Value.prototype.get_;
12679 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf; 12756 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf;
12680 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) { 12757 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) {
12681 return this.instanceOf($0, $1, $2, $3, false); 12758 return this.instanceOf($0, $1, $2, $3, false);
(...skipping 24 matching lines...) Expand all
12706 EvaluatedValue.prototype.set$actualValue = function(value) { return this.actualV alue = value; }; 12783 EvaluatedValue.prototype.set$actualValue = function(value) { return this.actualV alue = value; };
12707 EvaluatedValue.prototype.get$isConst = function() { 12784 EvaluatedValue.prototype.get$isConst = function() {
12708 return true; 12785 return true;
12709 } 12786 }
12710 EvaluatedValue.prototype.get$constValue = function() { 12787 EvaluatedValue.prototype.get$constValue = function() {
12711 return this; 12788 return this;
12712 } 12789 }
12713 EvaluatedValue.prototype.get$canonicalCode = function() { return this.canonicalC ode; }; 12790 EvaluatedValue.prototype.get$canonicalCode = function() { return this.canonicalC ode; };
12714 EvaluatedValue.prototype.set$canonicalCode = function(value) { return this.canon icalCode = value; }; 12791 EvaluatedValue.prototype.set$canonicalCode = function(value) { return this.canon icalCode = value; };
12715 EvaluatedValue.codeWithComments = function(canonicalCode, span) { 12792 EvaluatedValue.codeWithComments = function(canonicalCode, span) {
12716 return (span != null && span.get$text() != canonicalCode) ? ('' + canonicalCod e + '/*' + _escapeForComment(span.get$text()) + '*/') : canonicalCode; 12793 return canonicalCode;
12717 } 12794 }
12718 // ********** Code for ConstListValue ************** 12795 // ********** Code for ConstListValue **************
12719 $inherits(ConstListValue, EvaluatedValue); 12796 $inherits(ConstListValue, EvaluatedValue);
12720 function ConstListValue() {} 12797 function ConstListValue() {}
12721 ConstListValue._internal$ctor = function(type, values, actualValue, canonicalCod e, span, code) { 12798 ConstListValue._internal$ctor = function(type, values, actualValue, canonicalCod e, span, code) {
12722 this.values = values; 12799 this.values = values;
12723 // Initializers done 12800 // Initializers done
12724 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12801 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code);
12725 } 12802 }
12726 ConstListValue._internal$ctor.prototype = ConstListValue.prototype; 12803 ConstListValue._internal$ctor.prototype = ConstListValue.prototype;
(...skipping 28 matching lines...) Expand all
12755 this.fields = fields; 12832 this.fields = fields;
12756 // Initializers done 12833 // Initializers done
12757 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code); 12834 EvaluatedValue._internal$ctor.call(this, type, actualValue, canonicalCode, spa n, code);
12758 } 12835 }
12759 ConstObjectValue._internal$ctor.prototype = ConstObjectValue.prototype; 12836 ConstObjectValue._internal$ctor.prototype = ConstObjectValue.prototype;
12760 ConstObjectValue.ConstObjectValue$factory = function(type, fields, canonicalCode , span) { 12837 ConstObjectValue.ConstObjectValue$factory = function(type, fields, canonicalCode , span) {
12761 var fieldValues = []; 12838 var fieldValues = [];
12762 var $$list = fields.getKeys(); 12839 var $$list = fields.getKeys();
12763 for (var $$i = fields.getKeys().iterator$0(); $$i.hasNext$0(); ) { 12840 for (var $$i = fields.getKeys().iterator$0(); $$i.hasNext$0(); ) {
12764 var f = $$i.next$0(); 12841 var f = $$i.next$0();
12765 fieldValues.add(('' + f + ' = ' + fields.$index(f).get$actualValue())); 12842 fieldValues.add(("" + f + " = " + fields.$index(f).get$actualValue()));
12766 } 12843 }
12767 fieldValues.sort((function (a, b) { 12844 fieldValues.sort((function (a, b) {
12768 return a.compareTo$1(b); 12845 return a.compareTo$1(b);
12769 }) 12846 })
12770 ); 12847 );
12771 var actualValue = ('const ' + type.get$jsname() + ' [') + Strings.join(fieldVa lues, ',') + ']'; 12848 var actualValue = ("const " + type.get$jsname() + " [") + Strings.join(fieldVa lues, ",") + "]";
12772 return new ConstObjectValue._internal$ctor(type, fields, actualValue, canonica lCode, span, EvaluatedValue.codeWithComments(canonicalCode, span)); 12849 return new ConstObjectValue._internal$ctor(type, fields, actualValue, canonica lCode, span, EvaluatedValue.codeWithComments(canonicalCode, span));
12773 } 12850 }
12774 ConstObjectValue.prototype.get$fields = function() { return this.fields; }; 12851 ConstObjectValue.prototype.get$fields = function() { return this.fields; };
12775 ConstObjectValue.prototype.set$fields = function(value) { return this.fields = v alue; }; 12852 ConstObjectValue.prototype.set$fields = function(value) { return this.fields = v alue; };
12776 // ********** Code for GlobalValue ************** 12853 // ********** Code for GlobalValue **************
12777 $inherits(GlobalValue, Value); 12854 $inherits(GlobalValue, Value);
12778 function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) { 12855 function GlobalValue(type, code, isConst, field, name, exp, canonicalCode, span, _dependencies) {
12779 this.field = field; 12856 this.field = field;
12780 this.name = name; 12857 this.name = name;
12781 this.exp = exp; 12858 this.exp = exp;
12782 this.canonicalCode = canonicalCode; 12859 this.canonicalCode = canonicalCode;
12783 this.dependencies = []; 12860 this.dependencies = [];
12784 // Initializers done 12861 // Initializers done
12785 Value.call(this, type, code, span, !isConst); 12862 Value.call(this, type, code, span, !isConst);
12786 for (var $$i = 0;$$i < _dependencies.get$length(); $$i++) { 12863 for (var $$i = 0;$$i < _dependencies.get$length(); $$i++) {
12787 var dep = _dependencies.$index($$i); 12864 var dep = _dependencies.$index($$i);
12788 this.dependencies.add(dep); 12865 this.dependencies.add(dep);
12789 this.dependencies.addAll(dep.get$dependencies()); 12866 this.dependencies.addAll(dep.get$dependencies());
12790 } 12867 }
12791 } 12868 }
12792 GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) { 12869 GlobalValue.GlobalValue$fromStatic$factory = function(field, exp, dependencies) {
12793 var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code); 12870 var code = (exp.get$isConst() ? exp.get$canonicalCode() : exp.code);
12794 var codeWithComment = ('' + code + '/*' + field.get$declaringType().get$name() + '.' + field.get$name() + '*/'); 12871 var codeWithComment = ("" + code + "/*" + field.get$declaringType().get$name() + "." + field.get$name() + "*/");
12795 return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), f ield, null, exp, code, exp.span, dependencies.filter$1((function (d) { 12872 return new GlobalValue(exp.get$type(), codeWithComment, field.get$isFinal(), f ield, null, exp, code, exp.span, dependencies.filter$1((function (d) {
12796 return (d instanceof GlobalValue); 12873 return (d instanceof GlobalValue);
12797 }) 12874 })
12798 )); 12875 ));
12799 } 12876 }
12800 GlobalValue.GlobalValue$fromConst$factory = function(uniqueId, exp, dependencies ) { 12877 GlobalValue.GlobalValue$fromConst$factory = function(uniqueId, exp, dependencies ) {
12801 var name = ("const\$" + uniqueId); 12878 var name = ("const$" + uniqueId);
12802 var codeWithComment = ("" + name + "/*" + _escapeForComment(exp.span.get$text( )) + "*/"); 12879 var codeWithComment = ("" + name + "/*" + _escapeForComment(exp.span.get$text( )) + "*/");
12803 return new GlobalValue(exp.get$type(), codeWithComment, true, null, name, exp, name, exp.span, dependencies.filter$1((function (d) { 12880 return new GlobalValue(exp.get$type(), codeWithComment, true, null, name, exp, name, exp.span, dependencies.filter$1((function (d) {
12804 return (d instanceof GlobalValue); 12881 return (d instanceof GlobalValue);
12805 }) 12882 })
12806 )); 12883 ));
12807 } 12884 }
12808 GlobalValue.prototype.get$field = function() { return this.field; }; 12885 GlobalValue.prototype.get$field = function() { return this.field; };
12809 GlobalValue.prototype.set$field = function(value) { return this.field = value; } ; 12886 GlobalValue.prototype.set$field = function(value) { return this.field = value; } ;
12810 GlobalValue.prototype.get$name = function() { return this.name; }; 12887 GlobalValue.prototype.get$name = function() { return this.name; };
12811 GlobalValue.prototype.set$name = function(value) { return this.name = value; }; 12888 GlobalValue.prototype.set$name = function(value) { return this.name = value; };
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
12891 return null; 12968 return null;
12892 } 12969 }
12893 // ********** Code for CompilerException ************** 12970 // ********** Code for CompilerException **************
12894 function CompilerException(_message, _location) { 12971 function CompilerException(_message, _location) {
12895 this._lang_message = _message; 12972 this._lang_message = _message;
12896 this._location = _location; 12973 this._location = _location;
12897 // Initializers done 12974 // Initializers done
12898 } 12975 }
12899 CompilerException.prototype.toString = function() { 12976 CompilerException.prototype.toString = function() {
12900 if (this._location != null) { 12977 if (this._location != null) {
12901 return ('CompilerException: ' + this._location.toMessageString(this._lang_me ssage)); 12978 return ("CompilerException: " + this._location.toMessageString(this._lang_me ssage));
12902 } 12979 }
12903 else { 12980 else {
12904 return ('CompilerException: ' + this._lang_message); 12981 return ("CompilerException: " + this._lang_message);
12905 } 12982 }
12906 } 12983 }
12907 CompilerException.prototype.toString$0 = CompilerException.prototype.toString; 12984 CompilerException.prototype.toString$0 = CompilerException.prototype.toString;
12908 // ********** Code for World ************** 12985 // ********** Code for World **************
12909 function World(files) { 12986 function World(files) {
12910 this.errors = 0 12987 this.errors = 0
12911 this.warnings = 0 12988 this.warnings = 0
12912 this.dartBytesRead = 0 12989 this.dartBytesRead = 0
12913 this.jsBytesWritten = 0 12990 this.jsBytesWritten = 0
12914 this.seenFatal = false 12991 this.seenFatal = false
12915 this.files = files; 12992 this.files = files;
12916 this.libraries = new HashMapImplementation(); 12993 this.libraries = new HashMapImplementation();
12917 this._todo = []; 12994 this._todo = [];
12918 this._members = new HashMapImplementation(); 12995 this._members = new HashMapImplementation();
12919 this._topNames = new HashMapImplementation(); 12996 this._topNames = new HashMapImplementation();
12920 this.reader = new LibraryReader(); 12997 this.reader = new LibraryReader();
12921 // Initializers done 12998 // Initializers done
12922 } 12999 }
12923 World.prototype.get$functionType = function() { return this.functionType; }; 13000 World.prototype.get$functionType = function() { return this.functionType; };
12924 World.prototype.set$functionType = function(value) { return this.functionType = value; }; 13001 World.prototype.set$functionType = function(value) { return this.functionType = value; };
12925 World.prototype.init = function() { 13002 World.prototype.init = function() {
12926 this.corelib = new Library(this.readFile('dart:core')); 13003 this.corelib = new Library(this.readFile("dart:core"));
12927 this.libraries.$setindex('dart:core', this.corelib); 13004 this.libraries.$setindex("dart:core", this.corelib);
12928 this._todo.add(this.corelib); 13005 this._todo.add(this.corelib);
12929 this.coreimpl = this.getOrAddLibrary('dart:coreimpl'); 13006 this.coreimpl = this.getOrAddLibrary("dart:coreimpl");
12930 this.voidType = this.corelib.addType('void', null, false); 13007 this.voidType = this.corelib.addType("void", null, false);
12931 this.dynamicType = this.corelib.addType('Dynamic', null, false); 13008 this.dynamicType = this.corelib.addType("Dynamic", null, false);
12932 this.varType = this.dynamicType; 13009 this.varType = this.dynamicType;
12933 this.objectType = this.corelib.addType('Object', null, true); 13010 this.objectType = this.corelib.addType("Object", null, true);
12934 this.numType = this.corelib.addType('num', null, false); 13011 this.numType = this.corelib.addType("num", null, false);
12935 this.intType = this.corelib.addType('int', null, false); 13012 this.intType = this.corelib.addType("int", null, false);
12936 this.doubleType = this.corelib.addType('double', null, false); 13013 this.doubleType = this.corelib.addType("double", null, false);
12937 this.boolType = this.corelib.addType('bool', null, false); 13014 this.boolType = this.corelib.addType("bool", null, false);
12938 this.stringType = this.corelib.addType('String', null, false); 13015 this.stringType = this.corelib.addType("String", null, false);
12939 this.listType = this.corelib.addType('List', null, false); 13016 this.listType = this.corelib.addType("List", null, false);
12940 this.mapType = this.corelib.addType('Map', null, false); 13017 this.mapType = this.corelib.addType("Map", null, false);
12941 this.functionType = this.corelib.addType('Function', null, false); 13018 this.functionType = this.corelib.addType("Function", null, false);
12942 this.typeErrorType = this.corelib.addType('TypeError', null, false); 13019 this.typeErrorType = this.corelib.addType("TypeError", null, false);
12943 this.numImplType = this.coreimpl.addType('NumImplementation', null, true); 13020 this.numImplType = this.coreimpl.addType("NumImplementation", null, true);
12944 this.stringImplType = this.coreimpl.addType('StringImplementation', null, true ); 13021 this.stringImplType = this.coreimpl.addType("StringImplementation", null, true );
12945 this.immutableListType = this.coreimpl.addType('ImmutableList', null, true); 13022 this.immutableListType = this.coreimpl.addType("ImmutableList", null, true);
12946 this.listFactoryType = this.coreimpl.addType('ListFactory', null, true); 13023 this.listFactoryType = this.coreimpl.addType("ListFactory", null, true);
12947 this.functionImplType = this.coreimpl.addType('_FunctionImplementation', null, true); 13024 this.functionImplType = this.coreimpl.addType("_FunctionImplementation", null, true);
12948 this.nonNullBool = new NonNullableType(this.boolType); 13025 this.nonNullBool = new NonNullableType(this.boolType);
12949 } 13026 }
12950 World.prototype._addMember = function(member) { 13027 World.prototype._addMember = function(member) {
12951 if (member.get$isStatic()) { 13028 if (member.get$isStatic()) {
12952 if (member.declaringType.get$isTop()) { 13029 if (member.declaringType.get$isTop()) {
12953 this._addTopName(member); 13030 this._addTopName(member);
12954 } 13031 }
12955 return; 13032 return;
12956 } 13033 }
12957 var mset = this._members.$index(member.name); 13034 var mset = this._members.$index(member.name);
(...skipping 12 matching lines...) Expand all
12970 this._addJavascriptTopName(named, named.get$jsname()); 13047 this._addJavascriptTopName(named, named.get$jsname());
12971 } 13048 }
12972 World.prototype._addJavascriptTopName = function(named, name) { 13049 World.prototype._addJavascriptTopName = function(named, name) {
12973 var existing = this._topNames.$index(name); 13050 var existing = this._topNames.$index(name);
12974 if (existing === named) { 13051 if (existing === named) {
12975 if (named.get$avoidNativeName()) { 13052 if (named.get$avoidNativeName()) {
12976 this._renameJavascriptTopName(named); 13053 this._renameJavascriptTopName(named);
12977 } 13054 }
12978 } 13055 }
12979 else if (existing != null) { 13056 else if (existing != null) {
12980 this.info(('mangling matching top level name "' + named.get$jsname() + '" in ') + ('both "' + named.get$library().get$jsname() + '" and "' + existing.get$li brary().get$jsname() + '"')); 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() + "\""));
12981 var existingPri = existing.get$jsnamePriority(); 13058 var existingPri = existing.get$jsnamePriority();
12982 var namedPri = named.get$jsnamePriority(); 13059 var namedPri = named.get$jsnamePriority();
12983 if (existingPri > namedPri || namedPri == 0) { 13060 if (existingPri > namedPri || namedPri == 0) {
12984 this._renameJavascriptTopName(named); 13061 this._renameJavascriptTopName(named);
12985 } 13062 }
12986 else if (namedPri > existingPri) { 13063 else if (namedPri > existingPri) {
12987 this._renameJavascriptTopName(existing); 13064 this._renameJavascriptTopName(existing);
12988 } 13065 }
12989 else { 13066 else {
12990 var msg = ('conflicting JS name "' + name + '" of same ') + ('priority ' + existingPri + ': (already defined in) ') + ('' + existing.get$span().get$locati onText() + ' with priority ' + namedPri + ')'); 13067 var msg = ("conflicting JS name \"" + name + "\" of same ") + ("priority " + existingPri + ": (already defined in) ") + ("" + existing.get$span().get$loca tionText() + " with priority " + namedPri + ")");
12991 if (named.get$isNative()) { 13068 if (named.get$isNative()) {
12992 $globals.world.info(msg, named.get$span(), existing.get$span()); 13069 $globals.world.info(msg, named.get$span(), existing.get$span());
12993 } 13070 }
12994 else { 13071 else {
12995 $globals.world.internalError(msg, named.get$span(), existing.get$span()) ; 13072 $globals.world.internalError(msg, named.get$span(), existing.get$span()) ;
12996 } 13073 }
12997 } 13074 }
12998 } 13075 }
12999 else { 13076 else {
13000 this._topNames.$setindex(name, named); 13077 this._topNames.$setindex(name, named);
13001 } 13078 }
13002 } 13079 }
13003 World.prototype._renameJavascriptTopName = function(named) { 13080 World.prototype._renameJavascriptTopName = function(named) {
13004 named._jsname = ('' + named.get$library().get$jsname() + '_' + named.get$jsnam e()); 13081 named._jsname = ("" + named.get$library().get$jsname() + "_" + named.get$jsnam e());
13005 var existing = this._topNames.$index(named.get$jsname()); 13082 var existing = this._topNames.$index(named.get$jsname());
13006 if (existing != null && $ne(existing, named)) { 13083 if (existing != null && $ne(existing, named)) {
13007 $globals.world.internalError(('name mangling failed for "' + named.get$jsnam e() + '" ') + ('("' + named.get$jsname() + '" defined also in ' + existing.get$s pan().get$locationText() + ')'), named.get$span()); 13084 $globals.world.internalError(("name mangling failed for \"" + named.get$jsna me() + "\" ") + ("(\"" + named.get$jsname() + "\" defined also in " + existing.g et$span().get$locationText() + ")"), named.get$span());
13008 } 13085 }
13009 this._topNames.$setindex(named.get$jsname(), named); 13086 this._topNames.$setindex(named.get$jsname(), named);
13010 } 13087 }
13011 World.prototype._addType = function(type) { 13088 World.prototype._addType = function(type) {
13012 if (!type.get$isTop()) this._addTopName(type); 13089 if (!type.get$isTop()) this._addTopName(type);
13013 } 13090 }
13014 World.prototype.toJsIdentifier = function(name) { 13091 World.prototype.toJsIdentifier = function(name) {
13015 if (name == null) return null; 13092 if (name == null) return null;
13016 if (this._jsKeywords == null) { 13093 if (this._jsKeywords == null) {
13017 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory( ['break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'e lse', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', ' switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'clas s', 'enum', 'export', 'extends', 'import', 'super', 'implements', 'interface', ' let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'native']) ; 13094 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory( ["break", "case", "catch", "continue", "debugger", "default", "delete", "do", "e lse", "finally", "for", "function", "if", "in", "instanceof", "new", "return", " switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "clas s", "enum", "export", "extends", "import", "super", "implements", "interface", " let", "package", "private", "protected", "public", "static", "yield", "native"]) ;
13018 } 13095 }
13019 if (this._jsKeywords.contains(name)) { 13096 if (this._jsKeywords.contains(name)) {
13020 return name + '_'; 13097 return name + "_";
13021 } 13098 }
13022 else { 13099 else {
13023 return name.replaceAll("$", "$$").replaceAll(':', "$"); 13100 return name.replaceAll("$", "$$").replaceAll(":", "$");
13024 } 13101 }
13025 } 13102 }
13026 World.prototype.compileAndSave = function() { 13103 World.prototype.compileAndSave = function() {
13027 var success = this.compile(); 13104 var success = this.compile();
13028 if ($globals.options.outfile != null) { 13105 if ($globals.options.outfile != null) {
13029 if (success) { 13106 if (success) {
13030 var code = $globals.world.getGeneratedCode(); 13107 var code = $globals.world.getGeneratedCode();
13031 if (!$globals.options.outfile.endsWith('.js')) { 13108 if (!$globals.options.outfile.endsWith(".js")) {
13032 code = '#!/usr/bin/env node\n' + code; 13109 code = "#!/usr/bin/env node\n" + code;
13033 } 13110 }
13034 $globals.world.files.writeString($globals.options.outfile, code); 13111 $globals.world.files.writeString($globals.options.outfile, code);
13035 } 13112 }
13036 else { 13113 else {
13037 $globals.world.files.writeString($globals.options.outfile, "throw 'Sorry, but I could not generate reasonable code to run.\\n';"/*"throw " + 13114 $globals.world.files.writeString($globals.options.outfile, "throw 'Sorry, but I could not generate reasonable code to run.\\n';");
13038 "'Sorry, but I could not generate reasonable code to run.\\n';"* /);
13039 } 13115 }
13040 } 13116 }
13041 return success; 13117 return success;
13042 } 13118 }
13043 World.prototype.compile = function() { 13119 World.prototype.compile = function() {
13044 if ($globals.options.dartScript == null) { 13120 if ($globals.options.dartScript == null) {
13045 this.fatal('no script provided to compile'); 13121 this.fatal("no script provided to compile");
13046 return false; 13122 return false;
13047 } 13123 }
13048 try { 13124 try {
13049 this.info(('compiling ' + $globals.options.dartScript + ' with corelib ' + t his.corelib)); 13125 this.info(("compiling " + $globals.options.dartScript + " with corelib " + t his.corelib));
13050 if (!this.runLeg()) this.runCompilationPhases(); 13126 if (!this.runLeg()) this.runCompilationPhases();
13051 } catch (exc) { 13127 } catch (exc) {
13052 exc = _toDartException(exc); 13128 exc = _toDartException(exc);
13053 if (this.get$hasErrors() && !$globals.options.throwOnErrors) { 13129 if (this.get$hasErrors() && !$globals.options.throwOnErrors) {
13054 } 13130 }
13055 else { 13131 else {
13056 throw exc; 13132 throw exc;
13057 } 13133 }
13058 } 13134 }
13059 this.printStatus(); 13135 this.printStatus();
13060 return !this.get$hasErrors(); 13136 return !this.get$hasErrors();
13061 } 13137 }
13062 World.prototype.runLeg = function() { 13138 World.prototype.runLeg = function() {
13063 var $this = this; // closure support 13139 var $this = this; // closure support
13064 if (!$globals.options.enableLeg) return false; 13140 if (!$globals.options.enableLeg) return false;
13065 if ($globals.legCompile == null) { 13141 if ($globals.legCompile == null) {
13066 this.fatal('requested leg enabled, but no leg compiler available'); 13142 this.fatal("requested leg enabled, but no leg compiler available");
13067 } 13143 }
13068 var res = this.withTiming('try leg compile', (function () { 13144 var res = this.withTiming("try leg compile", (function () {
13069 return $globals.legCompile($this); 13145 return $globals.legCompile($this);
13070 }) 13146 })
13071 ); 13147 );
13072 if (!res && $globals.options.legOnly) { 13148 if (!res && $globals.options.legOnly) {
13073 this.fatal(("Leg could not compile " + $globals.options.dartScript)); 13149 this.fatal(("Leg could not compile " + $globals.options.dartScript));
13074 return true; 13150 return true;
13075 } 13151 }
13076 return res; 13152 return res;
13077 } 13153 }
13078 World.prototype.runCompilationPhases = function() { 13154 World.prototype.runCompilationPhases = function() {
13079 var $this = this; // closure support 13155 var $this = this; // closure support
13080 var lib = this.withTiming('first pass', (function () { 13156 var lib = this.withTiming("first pass", (function () {
13081 return $this.processDartScript(); 13157 return $this.processDartScript();
13082 }) 13158 })
13083 ); 13159 );
13084 this.withTiming('resolve top level', this.get$resolveAll()); 13160 this.withTiming("resolve top level", this.get$resolveAll());
13085 if ($globals.experimentalAwaitPhase != null) { 13161 if ($globals.experimentalAwaitPhase != null) {
13086 this.withTiming('await translation', to$call$0($globals.experimentalAwaitPha se)); 13162 this.withTiming("await translation", to$call$0($globals.experimentalAwaitPha se));
13087 } 13163 }
13088 this.withTiming('generate code', (function () { 13164 this.withTiming("generate code", (function () {
13089 $this.generateCode(lib); 13165 $this.generateCode(lib);
13090 }) 13166 })
13091 ); 13167 );
13092 } 13168 }
13093 World.prototype.getGeneratedCode = function() { 13169 World.prototype.getGeneratedCode = function() {
13094 if (this.legCode != null) { 13170 if (this.legCode != null) {
13095 return this.legCode; 13171 return this.legCode;
13096 } 13172 }
13097 else { 13173 else {
13098 return this.gen.writer.get$text(); 13174 return this.gen.writer.get$text();
13099 } 13175 }
13100 } 13176 }
13101 World.prototype.readFile = function(filename) { 13177 World.prototype.readFile = function(filename) {
13102 try { 13178 try {
13103 var sourceFile = this.reader.readFile(filename); 13179 var sourceFile = this.reader.readFile(filename);
13104 this.dartBytesRead += sourceFile.get$text().length; 13180 this.dartBytesRead += sourceFile.get$text().length;
13105 return sourceFile; 13181 return sourceFile;
13106 } catch (e) { 13182 } catch (e) {
13107 e = _toDartException(e); 13183 e = _toDartException(e);
13108 this.warning(('Error reading file: ' + filename)); 13184 this.warning(("Error reading file: " + filename));
13109 return new SourceFile(filename, ''); 13185 return new SourceFile(filename, "");
13110 } 13186 }
13111 } 13187 }
13112 World.prototype.getOrAddLibrary = function(filename) { 13188 World.prototype.getOrAddLibrary = function(filename) {
13113 var library = this.libraries.$index(filename); 13189 var library = this.libraries.$index(filename);
13114 if (library == null) { 13190 if (library == null) {
13115 library = new Library(this.readFile(filename)); 13191 library = new Library(this.readFile(filename));
13116 this.info(('read library ' + filename)); 13192 this.info(("read library " + filename));
13117 if (!library.get$isCore() && !library.imports.some((function (li) { 13193 if (!library.get$isCore() && !library.imports.some((function (li) {
13118 return li.get$library().get$isCore(); 13194 return li.get$library().get$isCore();
13119 }) 13195 })
13120 )) { 13196 )) {
13121 library.imports.add(new LibraryImport(this.corelib)); 13197 library.imports.add(new LibraryImport(this.corelib));
13122 } 13198 }
13123 this.libraries.$setindex(filename, library); 13199 this.libraries.$setindex(filename, library);
13124 this._todo.add(library); 13200 this._todo.add(library);
13125 if (filename == 'dart:dom') { 13201 if (filename == "dart:dom") {
13126 this.dom = library; 13202 this.dom = library;
13127 } 13203 }
13128 } 13204 }
13129 return library; 13205 return library;
13130 } 13206 }
13131 World.prototype.process = function() { 13207 World.prototype.process = function() {
13132 while (this._todo.get$length() > 0) { 13208 while (this._todo.get$length() > 0) {
13133 var todo = this._todo; 13209 var todo = this._todo;
13134 this._todo = []; 13210 this._todo = [];
13135 for (var $$i = 0;$$i < todo.get$length(); $$i++) { 13211 for (var $$i = 0;$$i < todo.get$length(); $$i++) {
(...skipping 12 matching lines...) Expand all
13148 var $$list = this.libraries.getValues(); 13224 var $$list = this.libraries.getValues();
13149 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) { 13225 for (var $$i = this.libraries.getValues().iterator$0(); $$i.hasNext$0(); ) {
13150 var lib = $$i.next$0(); 13226 var lib = $$i.next$0();
13151 lib.resolve$0(); 13227 lib.resolve$0();
13152 } 13228 }
13153 } 13229 }
13154 World.prototype.get$resolveAll = function() { 13230 World.prototype.get$resolveAll = function() {
13155 return this.resolveAll.bind(this); 13231 return this.resolveAll.bind(this);
13156 } 13232 }
13157 World.prototype.findMainMethod = function(lib) { 13233 World.prototype.findMainMethod = function(lib) {
13158 var mainMembers = lib.topType.resolveMember('main'); 13234 var mainMembers = lib.topType.resolveMember("main");
13159 var main = null; 13235 var main = null;
13160 if (mainMembers == null || $eq(mainMembers.get$members().get$length(), 0)) { 13236 if (mainMembers == null || $eq(mainMembers.get$members().get$length(), 0)) {
13161 this.fatal('no main method specified'); 13237 this.fatal("no main method specified");
13162 } 13238 }
13163 else if (mainMembers.get$members().get$length() > 1) { 13239 else if (mainMembers.get$members().get$length() > 1) {
13164 var $$list = mainMembers.get$members(); 13240 var $$list = mainMembers.get$members();
13165 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) { 13241 for (var $$i = mainMembers.get$members().iterator$0(); $$i.hasNext$0(); ) {
13166 var m = $$i.next$0(); 13242 var m = $$i.next$0();
13167 main = m; 13243 main = m;
13168 this.error('more than one main member (using last?)', main.get$span()); 13244 this.error("more than one main member (using last?)", main.get$span());
13169 } 13245 }
13170 } 13246 }
13171 else { 13247 else {
13172 main = mainMembers.get$members().$index(0); 13248 main = mainMembers.get$members().$index(0);
13173 } 13249 }
13174 return main; 13250 return main;
13175 } 13251 }
13176 World.prototype.generateCode = function(lib) { 13252 World.prototype.generateCode = function(lib) {
13177 var codeWriter = new CodeWriter(); 13253 var codeWriter = new CodeWriter();
13178 this.gen = new WorldGenerator(this.findMainMethod(lib), codeWriter); 13254 this.gen = new WorldGenerator(this.findMainMethod(lib), codeWriter);
(...skipping 23 matching lines...) Expand all
13202 if (span2 != null) { 13278 if (span2 != null) {
13203 print(span2.toMessageString(messageWithPrefix)); 13279 print(span2.toMessageString(messageWithPrefix));
13204 } 13280 }
13205 } 13281 }
13206 if (throwing) { 13282 if (throwing) {
13207 $throw(new CompilerException(prefix + message, span)); 13283 $throw(new CompilerException(prefix + message, span));
13208 } 13284 }
13209 } 13285 }
13210 World.prototype.error = function(message, span, span1, span2) { 13286 World.prototype.error = function(message, span, span1, span2) {
13211 this.errors++; 13287 this.errors++;
13212 this._message($globals._RED_COLOR, 'error: ', message, span, span1, span2, $gl obals.options.throwOnErrors); 13288 this._message($globals._RED_COLOR, "error: ", message, span, span1, span2, $gl obals.options.throwOnErrors);
13213 } 13289 }
13214 World.prototype.warning = function(message, span, span1, span2) { 13290 World.prototype.warning = function(message, span, span1, span2) {
13215 if ($globals.options.warningsAsErrors) { 13291 if ($globals.options.warningsAsErrors) {
13216 this.error(message, span, span1, span2); 13292 this.error(message, span, span1, span2);
13217 return; 13293 return;
13218 } 13294 }
13219 this.warnings++; 13295 this.warnings++;
13220 if ($globals.options.showWarnings) { 13296 if ($globals.options.showWarnings) {
13221 this._message($globals._MAGENTA_COLOR, 'warning: ', message, span, span1, sp an2, $globals.options.throwOnWarnings); 13297 this._message($globals._MAGENTA_COLOR, "warning: ", message, span, span1, sp an2, $globals.options.throwOnWarnings);
13222 } 13298 }
13223 } 13299 }
13224 World.prototype.fatal = function(message, span, span1, span2) { 13300 World.prototype.fatal = function(message, span, span1, span2) {
13225 this.errors++; 13301 this.errors++;
13226 this.seenFatal = true; 13302 this.seenFatal = true;
13227 this._message($globals._RED_COLOR, 'fatal: ', message, span, span1, span2, $gl obals.options.throwOnFatal || $globals.options.throwOnErrors); 13303 this._message($globals._RED_COLOR, "fatal: ", message, span, span1, span2, $gl obals.options.throwOnFatal || $globals.options.throwOnErrors);
13228 } 13304 }
13229 World.prototype.internalError = function(message, span, span1, span2) { 13305 World.prototype.internalError = function(message, span, span1, span2) {
13230 this._message($globals._NO_COLOR, 'We are sorry, but...', message, span, span1 , span2, true); 13306 this._message($globals._NO_COLOR, "We are sorry, but...", message, span, span1 , span2, true);
13231 } 13307 }
13232 World.prototype.info = function(message, span, span1, span2) { 13308 World.prototype.info = function(message, span, span1, span2) {
13233 if ($globals.options.showInfo) { 13309 if ($globals.options.showInfo) {
13234 this._message($globals._GREEN_COLOR, 'info: ', message, span, span1, span2, false); 13310 this._message($globals._GREEN_COLOR, "info: ", message, span, span1, span2, false);
13235 } 13311 }
13236 } 13312 }
13237 World.prototype.withoutForceDynamic = function(fn) { 13313 World.prototype.withoutForceDynamic = function(fn) {
13238 var oldForceDynamic = $globals.options.forceDynamic; 13314 var oldForceDynamic = $globals.options.forceDynamic;
13239 $globals.options.forceDynamic = false; 13315 $globals.options.forceDynamic = false;
13240 try { 13316 try {
13241 return fn(); 13317 return fn();
13242 } finally { 13318 } finally {
13243 $globals.options.forceDynamic = oldForceDynamic; 13319 $globals.options.forceDynamic = oldForceDynamic;
13244 } 13320 }
13245 } 13321 }
13246 World.prototype.get$hasErrors = function() { 13322 World.prototype.get$hasErrors = function() {
13247 return this.errors > 0; 13323 return this.errors > 0;
13248 } 13324 }
13249 World.prototype.printStatus = function() { 13325 World.prototype.printStatus = function() {
13250 this.info(('compiled ' + this.dartBytesRead + ' bytes Dart -> ' + this.jsBytes Written + ' bytes JS')); 13326 this.info(("compiled " + this.dartBytesRead + " bytes Dart -> " + this.jsBytes Written + " bytes JS"));
13251 if (this.get$hasErrors()) { 13327 if (this.get$hasErrors()) {
13252 print(('compilation failed with ' + this.errors + ' errors')); 13328 print(("compilation failed with " + this.errors + " errors"));
13253 } 13329 }
13254 else { 13330 else {
13255 if (this.warnings > 0) { 13331 if (this.warnings > 0) {
13256 this.info(('compilation completed successfully with ' + this.warnings + ' warnings')); 13332 this.info(("compilation completed successfully with " + this.warnings + " warnings"));
13257 } 13333 }
13258 else { 13334 else {
13259 this.info('compilation completed sucessfully'); 13335 this.info("compilation completed sucessfully");
13260 } 13336 }
13261 } 13337 }
13262 } 13338 }
13263 World.prototype.withTiming = function(name, f) { 13339 World.prototype.withTiming = function(name, f) {
13264 var sw = new StopwatchImplementation(); 13340 var sw = new StopwatchImplementation();
13265 sw.start(); 13341 sw.start();
13266 var result = f(); 13342 var result = f();
13267 sw.stop(); 13343 sw.stop();
13268 this.info(('' + name + ' in ' + sw.elapsedInMs() + 'msec')); 13344 this.info(("" + name + " in " + sw.elapsedInMs() + "msec"));
13269 return result; 13345 return result;
13270 } 13346 }
13271 // ********** Code for FrogOptions ************** 13347 // ********** Code for FrogOptions **************
13272 function FrogOptions(homedir, args, files) { 13348 function FrogOptions(homedir, args, files) {
13273 this.config = 'dev' 13349 this.config = "dev"
13274 this.enableLeg = false 13350 this.enableLeg = false
13275 this.legOnly = false 13351 this.legOnly = false
13276 this.enableAsserts = false 13352 this.enableAsserts = false
13277 this.enableTypeChecks = false 13353 this.enableTypeChecks = false
13278 this.warningsAsErrors = false 13354 this.warningsAsErrors = false
13279 this.verifyImplements = false 13355 this.verifyImplements = false
13280 this.compileAll = false 13356 this.compileAll = false
13281 this.forceDynamic = false 13357 this.forceDynamic = false
13282 this.dietParse = false 13358 this.dietParse = false
13283 this.compileOnly = false 13359 this.compileOnly = false
13284 this.throwOnErrors = false 13360 this.throwOnErrors = false
13285 this.throwOnWarnings = false 13361 this.throwOnWarnings = false
13286 this.throwOnFatal = false 13362 this.throwOnFatal = false
13287 this.showInfo = false 13363 this.showInfo = false
13288 this.showWarnings = true 13364 this.showWarnings = true
13289 this.useColors = true 13365 this.useColors = true
13290 // Initializers done 13366 // Initializers done
13291 if ($eq(this.config, 'dev')) { 13367 if ($eq(this.config, "dev")) {
13292 this.libDir = joinPaths(homedir, '/lib'); 13368 this.libDir = joinPaths(homedir, "/lib");
13293 } 13369 }
13294 else if ($eq(this.config, 'sdk')) { 13370 else if ($eq(this.config, "sdk")) {
13295 this.libDir = joinPaths(homedir, '/../lib'); 13371 this.libDir = joinPaths(homedir, "/../lib");
13296 } 13372 }
13297 else { 13373 else {
13298 $globals.world.error(('Invalid configuration ' + this.config)); 13374 $globals.world.error(("Invalid configuration " + this.config));
13299 $throw(('Invalid configuration')); 13375 $throw(("Invalid configuration"));
13300 } 13376 }
13301 var ignoreUnrecognizedFlags = false; 13377 var ignoreUnrecognizedFlags = false;
13302 var passedLibDir = false; 13378 var passedLibDir = false;
13303 this.childArgs = []; 13379 this.childArgs = [];
13304 loop: 13380 loop:
13305 for (var i = 2; 13381 for (var i = 2;
13306 i < args.get$length(); i++) { 13382 i < args.get$length(); i++) {
13307 var arg = args.$index(i); 13383 var arg = args.$index(i);
13308 switch (arg) { 13384 switch (arg) {
13309 case '--enable_leg': 13385 case "--enable_leg":
13310 13386
13311 this.enableLeg = true; 13387 this.enableLeg = true;
13312 break; 13388 break;
13313 13389
13314 case '--leg_only': 13390 case "--leg_only":
13315 13391
13316 this.enableLeg = true; 13392 this.enableLeg = true;
13317 this.legOnly = true; 13393 this.legOnly = true;
13318 break; 13394 break;
13319 13395
13320 case '--enable_asserts': 13396 case "--enable_asserts":
13321 13397
13322 this.enableAsserts = true; 13398 this.enableAsserts = true;
13323 break; 13399 break;
13324 13400
13325 case '--enable_type_checks': 13401 case "--enable_type_checks":
13326 13402
13327 this.enableTypeChecks = true; 13403 this.enableTypeChecks = true;
13328 this.enableAsserts = true; 13404 this.enableAsserts = true;
13329 break; 13405 break;
13330 13406
13331 case '--verify_implements': 13407 case "--verify_implements":
13332 13408
13333 this.verifyImplements = true; 13409 this.verifyImplements = true;
13334 break; 13410 break;
13335 13411
13336 case '--compile_all': 13412 case "--compile_all":
13337 13413
13338 this.compileAll = true; 13414 this.compileAll = true;
13339 break; 13415 break;
13340 13416
13341 case '--diet-parse': 13417 case "--diet-parse":
13342 13418
13343 this.dietParse = true; 13419 this.dietParse = true;
13344 break; 13420 break;
13345 13421
13346 case '--ignore-unrecognized-flags': 13422 case "--ignore-unrecognized-flags":
13347 13423
13348 ignoreUnrecognizedFlags = true; 13424 ignoreUnrecognizedFlags = true;
13349 break; 13425 break;
13350 13426
13351 case '--verbose': 13427 case "--verbose":
13352 13428
13353 this.showInfo = true; 13429 this.showInfo = true;
13354 break; 13430 break;
13355 13431
13356 case '--suppress_warnings': 13432 case "--suppress_warnings":
13357 13433
13358 this.showWarnings = false; 13434 this.showWarnings = false;
13359 break; 13435 break;
13360 13436
13361 case '--warnings_as_errors': 13437 case "--warnings_as_errors":
13362 13438
13363 this.warningsAsErrors = true; 13439 this.warningsAsErrors = true;
13364 break; 13440 break;
13365 13441
13366 case '--throw_on_errors': 13442 case "--throw_on_errors":
13367 13443
13368 this.throwOnErrors = true; 13444 this.throwOnErrors = true;
13369 break; 13445 break;
13370 13446
13371 case '--throw_on_warnings': 13447 case "--throw_on_warnings":
13372 13448
13373 this.throwOnWarnings = true; 13449 this.throwOnWarnings = true;
13374 break; 13450 break;
13375 13451
13376 case '--compile-only': 13452 case "--compile-only":
13377 13453
13378 this.compileOnly = true; 13454 this.compileOnly = true;
13379 break; 13455 break;
13380 13456
13381 case '--force_dynamic': 13457 case "--force_dynamic":
13382 13458
13383 this.forceDynamic = true; 13459 this.forceDynamic = true;
13384 break; 13460 break;
13385 13461
13386 case '--no_colors': 13462 case "--no_colors":
13387 13463
13388 this.useColors = false; 13464 this.useColors = false;
13389 break; 13465 break;
13390 13466
13391 default: 13467 default:
13392 13468
13393 if (arg.endsWith$1('.dart')) { 13469 if (arg.endsWith$1(".dart")) {
13394 this.dartScript = arg; 13470 this.dartScript = arg;
13395 this.childArgs = args.getRange(i + 1, args.get$length() - i - 1); 13471 this.childArgs = args.getRange(i + 1, args.get$length() - i - 1);
13396 break loop; 13472 break loop;
13397 } 13473 }
13398 else if (arg.startsWith$1('--out=')) { 13474 else if (arg.startsWith$1("--out=")) {
13399 this.outfile = arg.substring$1('--out='.length); 13475 this.outfile = arg.substring$1("--out=".length);
13400 } 13476 }
13401 else if (arg.startsWith$1('--libdir=')) { 13477 else if (arg.startsWith$1("--libdir=")) {
13402 this.libDir = arg.substring$1('--libdir='.length); 13478 this.libDir = arg.substring$1("--libdir=".length);
13403 passedLibDir = true; 13479 passedLibDir = true;
13404 } 13480 }
13405 else { 13481 else {
13406 if (!ignoreUnrecognizedFlags) { 13482 if (!ignoreUnrecognizedFlags) {
13407 print(('unrecognized flag: "' + arg + '"')); 13483 print(("unrecognized flag: \"" + arg + "\""));
13408 } 13484 }
13409 } 13485 }
13410 13486
13411 } 13487 }
13412 } 13488 }
13413 if (!passedLibDir && $eq(this.config, 'dev') && !files.fileExists(this.libDir) ) { 13489 if (!passedLibDir && $eq(this.config, "dev") && !files.fileExists(this.libDir) ) {
13414 var temp = 'frog/lib'; 13490 var temp = "frog/lib";
13415 if (files.fileExists(temp)) { 13491 if (files.fileExists(temp)) {
13416 this.libDir = temp; 13492 this.libDir = temp;
13417 } 13493 }
13418 else { 13494 else {
13419 this.libDir = 'lib'; 13495 this.libDir = "lib";
13420 } 13496 }
13421 } 13497 }
13422 } 13498 }
13423 // ********** Code for LibraryReader ************** 13499 // ********** Code for LibraryReader **************
13424 function LibraryReader() { 13500 function LibraryReader() {
13425 // Initializers done 13501 // Initializers done
13426 if ($eq($globals.options.config, 'dev')) { 13502 if ($eq($globals.options.config, "dev")) {
13427 this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'c orelib.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corelib_impl .dart'), 'dart:html', joinPaths($globals.options.libDir, '../../client/html/rele ase/html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, '../../clie nt/html/release/htmlimpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, '../../client/dom/frog/dom_frog.dart'), 'dart:json', joinPaths($globals.options. libDir, 'json_frog.dart')]); 13503 this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "c orelib.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "corelib_impl .dart"), "dart:html", joinPaths($globals.options.libDir, "../../client/html/rele ase/html.dart"), "dart:htmlimpl", joinPaths($globals.options.libDir, "../../clie nt/html/release/htmlimpl.dart"), "dart:dom", joinPaths($globals.options.libDir, "../../client/dom/frog/dom_frog.dart"), "dart:json", joinPaths($globals.options. libDir, "json_frog.dart")]);
13428 } 13504 }
13429 else if ($eq($globals.options.config, 'sdk')) { 13505 else if ($eq($globals.options.config, "sdk")) {
13430 this._specialLibs = _map(['dart:core', joinPaths($globals.options.libDir, 'c ore/core_frog.dart'), 'dart:coreimpl', joinPaths($globals.options.libDir, 'corei mpl/coreimpl_frog.dart'), 'dart:html', joinPaths($globals.options.libDir, 'html/ html.dart'), 'dart:htmlimpl', joinPaths($globals.options.libDir, 'htmlimpl/htmli mpl.dart'), 'dart:dom', joinPaths($globals.options.libDir, 'dom/frog/dom_frog.da rt'), 'dart:json', joinPaths($globals.options.libDir, 'json/json_frog.dart')]); 13506 this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "c ore/core_frog.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "corei mpl/coreimpl_frog.dart"), "dart:html", joinPaths($globals.options.libDir, "html/ html.dart"), "dart:htmlimpl", joinPaths($globals.options.libDir, "htmlimpl/htmli mpl.dart"), "dart:dom", joinPaths($globals.options.libDir, "dom/frog/dom_frog.da rt"), "dart:json", joinPaths($globals.options.libDir, "json/json_frog.dart")]);
13431 } 13507 }
13432 else { 13508 else {
13433 $globals.world.error(('Invalid configuration ' + $globals.options.config)); 13509 $globals.world.error(("Invalid configuration " + $globals.options.config));
13434 } 13510 }
13435 } 13511 }
13436 LibraryReader.prototype.readFile = function(fullname) { 13512 LibraryReader.prototype.readFile = function(fullname) {
13437 var filename = this._specialLibs.$index(fullname); 13513 var filename = this._specialLibs.$index(fullname);
13438 if (filename == null) { 13514 if (filename == null) {
13439 filename = fullname; 13515 filename = fullname;
13440 } 13516 }
13441 if ($globals.world.files.fileExists(filename)) { 13517 if ($globals.world.files.fileExists(filename)) {
13442 return new SourceFile(filename, $globals.world.files.readAll(filename)); 13518 return new SourceFile(filename, $globals.world.files.readAll(filename));
13443 } 13519 }
13444 else { 13520 else {
13445 $globals.world.error(('File not found: ' + filename)); 13521 $globals.world.error(("File not found: " + filename));
13446 return new SourceFile(filename, ''); 13522 return new SourceFile(filename, "");
13447 } 13523 }
13448 } 13524 }
13449 // ********** Code for VarMember ************** 13525 // ********** Code for VarMember **************
13450 function VarMember(name) { 13526 function VarMember(name) {
13451 this.isGenerated = false 13527 this.isGenerated = false
13452 this.name = name; 13528 this.name = name;
13453 // Initializers done 13529 // Initializers done
13454 } 13530 }
13455 VarMember.prototype.get$name = function() { return this.name; }; 13531 VarMember.prototype.get$name = function() { return this.name; };
13456 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; }; 13532 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; };
13457 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated = value; }; 13533 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated = value; };
13458 VarMember.prototype.get$returnType = function() { 13534 VarMember.prototype.get$returnType = function() {
13459 return $globals.world.varType; 13535 return $globals.world.varType;
13460 } 13536 }
13461 VarMember.prototype.invoke = function(context, node, target, args) { 13537 VarMember.prototype.invoke = function(context, node, target, args) {
13462 return new Value(this.get$returnType(), ('' + target.code + '.' + this.name + '(' + args.getCode() + ')'), node.span, true); 13538 return new Value(this.get$returnType(), ("" + target.code + "." + this.name + "(" + args.getCode() + ")"), node.span, true);
13463 } 13539 }
13464 VarMember.prototype.generate$1 = VarMember.prototype.generate; 13540 VarMember.prototype.generate$1 = VarMember.prototype.generate;
13465 VarMember.prototype.invoke$4 = VarMember.prototype.invoke; 13541 VarMember.prototype.invoke$4 = VarMember.prototype.invoke;
13466 // ********** Code for VarFunctionStub ************** 13542 // ********** Code for VarFunctionStub **************
13467 $inherits(VarFunctionStub, VarMember); 13543 $inherits(VarFunctionStub, VarMember);
13468 function VarFunctionStub(name, callArgs) { 13544 function VarFunctionStub(name, callArgs) {
13469 this.args = callArgs.toCallStubArgs(); 13545 this.args = callArgs.toCallStubArgs();
13470 // Initializers done 13546 // Initializers done
13471 VarMember.call(this, name); 13547 VarMember.call(this, name);
13472 $globals.world.functionImplType.markUsed(); 13548 $globals.world.functionImplType.markUsed();
13473 $globals.world.gen.genMethod($globals.world.functionImplType.getMember('_genSt ub')); 13549 $globals.world.gen.genMethod($globals.world.functionImplType.getMember("_genSt ub"));
13474 } 13550 }
13475 VarFunctionStub.prototype.invoke = function(context, node, target, args) { 13551 VarFunctionStub.prototype.invoke = function(context, node, target, args) {
13476 return VarMember.prototype.invoke.call(this, context, node, target, args); 13552 return VarMember.prototype.invoke.call(this, context, node, target, args);
13477 } 13553 }
13478 VarFunctionStub.prototype.generate = function(code) { 13554 VarFunctionStub.prototype.generate = function(code) {
13479 this.isGenerated = true; 13555 this.isGenerated = true;
13480 if (this.args.get$hasNames()) { 13556 if (this.args.get$hasNames()) {
13481 this.generateNamed(code); 13557 this.generateNamed(code);
13482 } 13558 }
13483 else { 13559 else {
13484 this.generatePositional(code); 13560 this.generatePositional(code);
13485 } 13561 }
13486 } 13562 }
13487 VarFunctionStub.prototype.generatePositional = function(w) { 13563 VarFunctionStub.prototype.generatePositional = function(w) {
13488 var arity = this.args.get$length(); 13564 var arity = this.args.get$length();
13489 w.enterBlock(('Function.prototype.to\$' + this.name + ' = function() {')); 13565 w.enterBlock(("Function.prototype.to$" + this.name + " = function() {"));
13490 w.writeln(('this.' + this.name + ' = this._genStub(' + arity + ');')); 13566 w.writeln(("this." + this.name + " = this._genStub(" + arity + ");"));
13491 w.writeln(('this.to\$' + this.name + ' = function() { return this.' + this.nam e + '; };')); 13567 w.writeln(("this.to$" + this.name + " = function() { return this." + this.name + "; };"));
13492 w.writeln(('return this.' + this.name + ';')); 13568 w.writeln(("return this." + this.name + ";"));
13493 w.exitBlock('};'); 13569 w.exitBlock("};");
13494 var argsCode = this.args.getCode(); 13570 var argsCode = this.args.getCode();
13495 w.enterBlock(('Function.prototype.' + this.name + ' = function(' + argsCode + ') {')); 13571 w.enterBlock(("Function.prototype." + this.name + " = function(" + argsCode + ") {"));
13496 w.writeln(('return this.to\$' + this.name + '()(' + argsCode + ');')); 13572 w.writeln(("return this.to$" + this.name + "()(" + argsCode + ");"));
13497 w.exitBlock('};'); 13573 w.exitBlock("};");
13498 w.writeln(('function to\$' + this.name + '(f) { return f && f.to\$' + this.nam e + '(); }')); 13574 w.writeln(("function to$" + this.name + "(f) { return f && f.to$" + this.name + "(); }"));
13499 } 13575 }
13500 VarFunctionStub.prototype.generateNamed = function(w) { 13576 VarFunctionStub.prototype.generateNamed = function(w) {
13501 var named = Strings.join(this.args.getNames(), '", "'); 13577 var named = Strings.join(this.args.getNames(), "\", \"");
13502 var argsCode = this.args.getCode(); 13578 var argsCode = this.args.getCode();
13503 w.enterBlock(('Function.prototype.' + this.name + ' = function(' + argsCode + ') {')); 13579 w.enterBlock(("Function.prototype." + this.name + " = function(" + argsCode + ") {"));
13504 w.writeln(('this.' + this.name + ' = this._genStub(' + this.args.get$length() + ', ["' + named + '"]);')); 13580 w.writeln(("this." + this.name + " = this._genStub(" + this.args.get$length() + ", [\"" + named + "\"]);"));
13505 w.writeln(('return this.' + this.name + '(' + argsCode + ');')); 13581 w.writeln(("return this." + this.name + "(" + argsCode + ");"));
13506 w.exitBlock('}'); 13582 w.exitBlock("}");
13507 } 13583 }
13508 VarFunctionStub.prototype.generate$1 = VarFunctionStub.prototype.generate; 13584 VarFunctionStub.prototype.generate$1 = VarFunctionStub.prototype.generate;
13509 VarFunctionStub.prototype.invoke$4 = VarFunctionStub.prototype.invoke; 13585 VarFunctionStub.prototype.invoke$4 = VarFunctionStub.prototype.invoke;
13510 // ********** Code for VarMethodStub ************** 13586 // ********** Code for VarMethodStub **************
13511 $inherits(VarMethodStub, VarMember); 13587 $inherits(VarMethodStub, VarMember);
13512 function VarMethodStub(name, member, args, body) { 13588 function VarMethodStub(name, member, args, body) {
13513 this.member = member; 13589 this.member = member;
13514 this.args = args; 13590 this.args = args;
13515 this.body = body; 13591 this.body = body;
13516 // Initializers done 13592 // Initializers done
13517 VarMember.call(this, name); 13593 VarMember.call(this, name);
13518 } 13594 }
13519 VarMethodStub.prototype.get$body = function() { return this.body; }; 13595 VarMethodStub.prototype.get$body = function() { return this.body; };
13520 VarMethodStub.prototype.get$isHidden = function() { 13596 VarMethodStub.prototype.get$isHidden = function() {
13521 return this.member != null ? this.member.declaringType.get$isHiddenNativeType( ) : false; 13597 return this.member != null ? this.member.declaringType.get$isHiddenNativeType( ) : false;
13522 } 13598 }
13523 VarMethodStub.prototype.get$returnType = function() { 13599 VarMethodStub.prototype.get$returnType = function() {
13524 return this.member != null ? this.member.get$returnType() : $globals.world.var Type; 13600 return this.member != null ? this.member.get$returnType() : $globals.world.var Type;
13525 } 13601 }
13526 VarMethodStub.prototype.get$declaringType = function() { 13602 VarMethodStub.prototype.get$declaringType = function() {
13527 return this.member != null ? this.member.declaringType : $globals.world.object Type; 13603 return this.member != null ? this.member.declaringType : $globals.world.object Type;
13528 } 13604 }
13529 VarMethodStub.prototype.generate = function(code) { 13605 VarMethodStub.prototype.generate = function(code) {
13530 this.isGenerated = true; 13606 this.isGenerated = true;
13531 code.write($globals.world.gen._prototypeOf(this.get$declaringType(), this.name ) + ' = '); 13607 code.write($globals.world.gen._prototypeOf(this.get$declaringType(), this.name ) + " = ");
13532 if (!this.get$isHidden() && this._useDirectCall(this.args)) { 13608 if (!this.get$isHidden() && this._useDirectCall(this.args)) {
13533 code.writeln($globals.world.gen._prototypeOf(this.get$declaringType(), this. member.get$jsname()) + ';'); 13609 code.writeln($globals.world.gen._prototypeOf(this.get$declaringType(), this. member.get$jsname()) + ";");
13534 } 13610 }
13535 else if (this._needsExactTypeCheck()) { 13611 else if (this._needsExactTypeCheck()) {
13536 code.enterBlock(('function(' + this.args.getCode() + ') {')); 13612 code.enterBlock(("function(" + this.args.getCode() + ") {"));
13537 code.enterBlock(('if (Object.getPrototypeOf(this).hasOwnProperty("' + this.n ame + '")) {')); 13613 code.enterBlock(("if (Object.getPrototypeOf(this).hasOwnProperty(\"" + this. name + "\")) {"));
13538 code.writeln(('' + this.body + ';')); 13614 code.writeln(("" + this.body + ";"));
13539 code.exitBlock('}'); 13615 code.exitBlock("}");
13540 var argsCode = this.args.getCode(); 13616 var argsCode = this.args.getCode();
13541 if (argsCode != '') argsCode = ', ' + argsCode; 13617 if (argsCode != "") argsCode = ", " + argsCode;
13542 code.writeln(('return Object.prototype.' + this.name + '.call(this' + argsCo de + ');')); 13618 code.writeln(("return Object.prototype." + this.name + ".call(this" + argsCo de + ");"));
13543 code.exitBlock('};'); 13619 code.exitBlock("};");
13544 } 13620 }
13545 else { 13621 else {
13546 code.enterBlock(('function(' + this.args.getCode() + ') {')); 13622 code.enterBlock(("function(" + this.args.getCode() + ") {"));
13547 code.writeln(('' + this.body + ';')); 13623 code.writeln(("" + this.body + ";"));
13548 code.exitBlock('};'); 13624 code.exitBlock("};");
13549 } 13625 }
13550 } 13626 }
13551 VarMethodStub.prototype._needsExactTypeCheck = function() { 13627 VarMethodStub.prototype._needsExactTypeCheck = function() {
13552 var $this = this; // closure support 13628 var $this = this; // closure support
13553 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse; 13629 if (this.member == null || this.member.declaringType.get$isObject()) return fa lse;
13554 var members = this.member.declaringType.resolveMember(this.member.name).member s; 13630 var members = this.member.declaringType.resolveMember(this.member.name).member s;
13555 return members.filter$1((function (m) { 13631 return members.filter$1((function (m) {
13556 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( ); 13632 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType( );
13557 }) 13633 })
13558 ).get$length() >= 1; 13634 ).get$length() >= 1;
13559 } 13635 }
13560 VarMethodStub.prototype._useDirectCall = function(args) { 13636 VarMethodStub.prototype._useDirectCall = function(args) {
13561 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) { 13637 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha sNativeSubtypes()) {
13562 var method = this.member; 13638 var method = this.member;
13563 if (method.needsArgumentConversion(args)) { 13639 if (method.needsArgumentConversion(args)) {
13564 return false; 13640 return false;
13565 } 13641 }
13566 for (var i = args.get$length(); 13642 for (var i = args.get$length();
13567 i < method.parameters.get$length(); i++) { 13643 i < method.parameters.get$length(); i++) {
13568 if ($ne(method.parameters.$index(i).get$value().get$code(), 'null')) { 13644 if ($ne(method.parameters.$index(i).get$value().get$code(), "null")) {
13569 return false; 13645 return false;
13570 } 13646 }
13571 } 13647 }
13572 return method.namesInHomePositions(args); 13648 return method.namesInHomePositions(args);
13573 } 13649 }
13574 else { 13650 else {
13575 return false; 13651 return false;
13576 } 13652 }
13577 } 13653 }
13578 VarMethodStub.prototype.generate$1 = VarMethodStub.prototype.generate; 13654 VarMethodStub.prototype.generate$1 = VarMethodStub.prototype.generate;
(...skipping 15 matching lines...) Expand all
13594 return VarMember.prototype.invoke.call(this, context, node, target, args); 13670 return VarMember.prototype.invoke.call(this, context, node, target, args);
13595 } 13671 }
13596 VarMethodSet.prototype._invokeMembers = function(context, node) { 13672 VarMethodSet.prototype._invokeMembers = function(context, node) {
13597 if (this.invoked) return; 13673 if (this.invoked) return;
13598 this.invoked = true; 13674 this.invoked = true;
13599 var hasObjectType = false; 13675 var hasObjectType = false;
13600 var $$list = this.members; 13676 var $$list = this.members;
13601 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { 13677 for (var $$i = 0;$$i < $$list.get$length(); $$i++) {
13602 var member = $$list.$index($$i); 13678 var member = $$list.$index($$i);
13603 var type = member.get$declaringType(); 13679 var type = member.get$declaringType();
13604 var target = new Value(type, 'this', node.span, true); 13680 var target = new Value(type, "this", node.span, true);
13605 var result = member.invoke$4$isDynamic(context, node, target, this.args, tru e); 13681 var result = member.invoke$4$isDynamic(context, node, target, this.args, tru e);
13606 var stub = new VarMethodStub(this.name, member, this.args, 'return ' + resul t.get$code()); 13682 var stub = new VarMethodStub(this.name, member, this.args, "return " + resul t.get$code());
13607 type.get$varStubs().$setindex(stub.get$name(), stub); 13683 type.get$varStubs().$setindex(stub.get$name(), stub);
13608 if (type.get$isObject()) hasObjectType = true; 13684 if (type.get$isObject()) hasObjectType = true;
13609 } 13685 }
13610 if (!hasObjectType) { 13686 if (!hasObjectType) {
13611 var target = new Value($globals.world.objectType, 'this', node.span, true); 13687 var target = new Value($globals.world.objectType, "this", node.span, true);
13612 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs); 13688 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs);
13613 var stub = new VarMethodStub(this.name, null, this.args, 'return ' + result. get$code()); 13689 var stub = new VarMethodStub(this.name, null, this.args, "return " + result. get$code());
13614 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub); 13690 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub);
13615 } 13691 }
13616 } 13692 }
13617 VarMethodSet.prototype.generate = function(code) { 13693 VarMethodSet.prototype.generate = function(code) {
13618 13694
13619 } 13695 }
13620 VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate; 13696 VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate;
13621 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke; 13697 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke;
13622 // ********** Code for top level ************** 13698 // ********** Code for top level **************
13623 function _otherOperator(jsname, op) { 13699 function _otherOperator(jsname, op) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
13658 return x.compareTo$1(y); 13734 return x.compareTo$1(y);
13659 }) 13735 })
13660 ); 13736 );
13661 var values = []; 13737 var values = [];
13662 for (var $$i = 0;$$i < keys.get$length(); $$i++) { 13738 for (var $$i = 0;$$i < keys.get$length(); $$i++) {
13663 var k = keys.$index($$i); 13739 var k = keys.$index($$i);
13664 values.add(map.$index(k)); 13740 values.add(map.$index(k));
13665 } 13741 }
13666 return values; 13742 return values;
13667 } 13743 }
13668 function isMultilineString(text) {
13669 return text.startsWith('"""') || text.startsWith("'''");
13670 }
13671 function isRawMultilineString(text) {
13672 return text.startsWith('@"""') || text.startsWith("@'''");
13673 }
13674 function toDoubleQuote(s) {
13675 return s.replaceAll('"', '\\"').replaceAll("\\'", "'");
13676 }
13677 function parseStringLiteral(lit) {
13678 if (lit.startsWith('@')) {
13679 if (isRawMultilineString(lit)) {
13680 return stripLeadingNewline(lit.substring(4, lit.length - 3));
13681 }
13682 else {
13683 return lit.substring(2, lit.length - 1);
13684 }
13685 }
13686 else if (isMultilineString(lit)) {
13687 lit = lit.substring(3, lit.length - 3).replaceAll('\\\$', '\$');
13688 return stripLeadingNewline(lit);
13689 }
13690 else {
13691 return lit.substring(1, lit.length - 1).replaceAll('\\\$', '\$');
13692 }
13693 }
13694 function stripLeadingNewline(text) {
13695 if (text.startsWith('\n')) {
13696 return text.substring(1);
13697 }
13698 else if (text.startsWith('\r')) {
13699 if (text.startsWith('\r\n')) {
13700 return text.substring(2);
13701 }
13702 else {
13703 return text.substring(1);
13704 }
13705 }
13706 else {
13707 return text;
13708 }
13709 }
13710 function _escapeForComment(text) { 13744 function _escapeForComment(text) {
13711 return text.replaceAll('/*', '/ *').replaceAll('*/', '* /'); 13745 return text.replaceAll("/*", "/ *").replaceAll("*/", "* /");
13712 } 13746 }
13713 var world; 13747 var world;
13714 var experimentalAwaitPhase; 13748 var experimentalAwaitPhase;
13715 var legCompile; 13749 var legCompile;
13716 function initializeWorld(files) { 13750 function initializeWorld(files) {
13717 $globals.world = new World(files); 13751 $globals.world = new World(files);
13718 $globals.world.init(); 13752 $globals.world.init();
13719 } 13753 }
13720 function compile(homedir, args, files) { 13754 function compile(homedir, args, files) {
13721 parseOptions(homedir, args, files); 13755 parseOptions(homedir, args, files);
13722 initializeWorld(files); 13756 initializeWorld(files);
13723 return $globals.world.compileAndSave(); 13757 return $globals.world.compileAndSave();
13724 } 13758 }
13725 var options; 13759 var options;
13726 function parseOptions(homedir, args, files) { 13760 function parseOptions(homedir, args, files) {
13727 $globals.options = new FrogOptions(homedir, args, files); 13761 $globals.options = new FrogOptions(homedir, args, files);
13728 } 13762 }
13729 function _getCallStubName(name, args) { 13763 function _getCallStubName(name, args) {
13730 var nameBuilder = new StringBufferImpl(('' + name + '\$' + args.get$bareCount( ))); 13764 var nameBuilder = new StringBufferImpl(("" + name + "$" + args.get$bareCount() ));
13731 for (var i = args.get$bareCount(); 13765 for (var i = args.get$bareCount();
13732 i < args.get$length(); i++) { 13766 i < args.get$length(); i++) {
13733 var name0 = args.getName(i); 13767 var name0 = args.getName(i);
13734 nameBuilder.add('\$'); 13768 nameBuilder.add("$");
13735 if (name0.contains$1('\$')) { 13769 if (name0.contains$1("$")) {
13736 nameBuilder.add(('' + name0.get$length())); 13770 nameBuilder.add(("" + name0.get$length()));
13737 } 13771 }
13738 nameBuilder.add(name0); 13772 nameBuilder.add(name0);
13739 } 13773 }
13740 return nameBuilder.toString(); 13774 return nameBuilder.toString();
13741 } 13775 }
13742 // ********** Library minfrog ************** 13776 // ********** Library minfrog **************
13743 // ********** Code for top level ************** 13777 // ********** Code for top level **************
13744 function main() { 13778 function main() {
13745 var homedir = path.dirname(fs.realpathSync(get$process().get$argv().$index(1)) ); 13779 var homedir = path.dirname(fs.realpathSync(get$process().get$argv().$index(1)) );
13746 var argv = []; 13780 var argv = [];
13747 for (var i = 0; 13781 for (var i = 0;
13748 i < get$process().get$argv().get$length(); i++) { 13782 i < get$process().get$argv().get$length(); i++) {
13749 argv.add$1(get$process().get$argv().$index(i)); 13783 argv.add$1(get$process().get$argv().$index(i));
13750 if (i == 1) { 13784 if (i == 1) {
13751 var terminal = get$process().get$env().$index('TERM'); 13785 var terminal = get$process().get$env().$index("TERM");
13752 if (terminal == null || !terminal.startsWith$1('xterm')) { 13786 if (terminal == null || !terminal.startsWith$1("xterm")) {
13753 argv.add$1('--no_colors'); 13787 argv.add$1("--no_colors");
13754 } 13788 }
13755 } 13789 }
13756 } 13790 }
13757 if (compile(homedir, argv, new NodeFileSystem())) { 13791 if (compile(homedir, argv, new NodeFileSystem())) {
13758 var code = $globals.world.getGeneratedCode(); 13792 var code = $globals.world.getGeneratedCode();
13759 if ($globals.options.compileOnly) { 13793 if ($globals.options.compileOnly) {
13760 if ($globals.options.outfile != null) { 13794 if ($globals.options.outfile != null) {
13761 print(('Compilation succeded. Code generated in: ' + $globals.options.ou tfile)); 13795 print(("Compilation succeded. Code generated in: " + $globals.options.ou tfile));
13762 } 13796 }
13763 else { 13797 else {
13764 print('Compilation succeded.'); 13798 print("Compilation succeded.");
13765 } 13799 }
13766 } 13800 }
13767 else { 13801 else {
13768 get$process().set$argv([argv.$index(0), argv.$index(1)]); 13802 get$process().set$argv([argv.$index(0), argv.$index(1)]);
13769 get$process().get$argv().addAll($globals.options.childArgs); 13803 get$process().get$argv().addAll($globals.options.childArgs);
13770 vm.runInNewContext(code, createSandbox()); 13804 vm.runInNewContext(code, createSandbox());
13771 } 13805 }
13772 } 13806 }
13773 else { 13807 else {
13774 get$process().exit(1); 13808 get$process().exit(1);
13775 } 13809 }
13776 } 13810 }
13777 // ********** Generic Type Inheritance ************** 13811 // ********** Generic Type Inheritance **************
13778 /** Implements extends for generic types. */ 13812 /** Implements extends for generic types. */
13779 function $inheritsMembers(child, parent) { 13813 function $inheritsMembers(child, parent) {
13780 child = child.prototype; 13814 child = child.prototype;
13781 parent = parent.prototype; 13815 parent = parent.prototype;
13782 Object.getOwnPropertyNames(parent).forEach(function(name) { 13816 Object.getOwnPropertyNames(parent).forEach(function(name) {
13783 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; 13817 if (typeof(child[name]) == 'undefined') child[name] = parent[name];
13784 }); 13818 });
13785 } 13819 }
13786 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); 13820 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E);
13787 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V); 13821 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V);
13788 // 1 dynamic types. 13822 // 1 dynamic types.
13789 // 1 types 13823 // 1 types
13790 // 0 !leaf 13824 // 0 !leaf
13791 // ********** Globals ************** 13825 // ********** Globals **************
13792 function $static_init(){ 13826 function $static_init(){
13793 $globals._GREEN_COLOR = '\u001b[32m'; 13827 $globals._GREEN_COLOR = "\x1b[32m";
13794 $globals._MAGENTA_COLOR = '\u001b[35m'; 13828 $globals._MAGENTA_COLOR = "\x1b[35m";
13795 $globals._NO_COLOR = '\u001b[0m'; 13829 $globals._NO_COLOR = "\x1b[0m";
13796 $globals._RED_COLOR = '\u001b[31m'; 13830 $globals._RED_COLOR = "\x1b[31m";
13797 } 13831 }
13798 var const$1 = new EmptyQueueException()/*const EmptyQueueException()*/; 13832 var const$1 = new EmptyQueueException();
13799 var const$126 = new IllegalAccessException()/*const IllegalAccessException()*/; 13833 var const$126 = new IllegalAccessException();
13800 var const$127 = ImmutableList.ImmutableList$from$factory([])/*const []*/; 13834 var const$127 = ImmutableList.ImmutableList$from$factory([]);
13801 var const$2 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 13835 var const$2 = new _DeletedKeySentinel();
13802 var const$7 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 13836 var const$7 = new NoMoreElementsException();
13803 var $globals = {}; 13837 var $globals = {};
13804 $static_init(); 13838 $static_init();
13805 main(); 13839 main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698