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

Side by Side Diff: frog/minfrog

Issue 9422019: isolates refactor: this change introduces 'dart:isolate' as a library. This is a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 8 years, 10 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 $defProp(obj, prop, value) { 4 function $defProp(obj, prop, value) {
5 Object.defineProperty(obj, prop, 5 Object.defineProperty(obj, prop,
6 {value: value, enumerable: false, writable: true, configurable: true}); 6 {value: value, enumerable: false, writable: true, configurable: true});
7 } 7 }
8 Function.prototype.bind = Function.prototype.bind || 8 Function.prototype.bind = Function.prototype.bind ||
9 function(thisObj, args) { 9 function(thisObj, args) {
10 var func = this; 10 var func = this;
(...skipping 14 matching lines...) Expand all
25 function $throw(e) { 25 function $throw(e) {
26 // If e is not a value, we can use V8's captureStackTrace utility method. 26 // If e is not a value, we can use V8's captureStackTrace utility method.
27 // TODO(jmesserly): capture the stack trace on other JS engines. 27 // TODO(jmesserly): capture the stack trace on other JS engines.
28 if (e && (typeof e == 'object') && Error.captureStackTrace) { 28 if (e && (typeof e == 'object') && Error.captureStackTrace) {
29 // TODO(jmesserly): this will clobber the e.stack property 29 // TODO(jmesserly): this will clobber the e.stack property
30 Error.captureStackTrace(e, $throw); 30 Error.captureStackTrace(e, $throw);
31 } 31 }
32 throw e; 32 throw e;
33 } 33 }
34 $defProp(Object.prototype, '$index', function(i) { 34 $defProp(Object.prototype, '$index', function(i) {
35 var proto = Object.getPrototypeOf(this); 35 $throw(new NoSuchMethodException(this, "operator []", [i]));
36 if (proto !== Object) {
37 proto.$index = function(i) { return this[i]; }
38 }
39 return this[i];
40 }); 36 });
41 $defProp(Array.prototype, '$index', function(index) { 37 $defProp(Array.prototype, '$index', function(index) {
42 var i = index | 0; 38 var i = index | 0;
43 if (i !== index) { 39 if (i !== index) {
44 throw new IllegalArgumentException('index is not int'); 40 throw new IllegalArgumentException('index is not int');
45 } else if (i < 0 || i >= this.length) { 41 } else if (i < 0 || i >= this.length) {
46 throw new IndexOutOfRangeException(index); 42 throw new IndexOutOfRangeException(index);
47 } 43 }
48 return this[i]; 44 return this[i];
49 }); 45 });
50 $defProp(String.prototype, '$index', function(i) { 46 $defProp(String.prototype, '$index', function(i) {
51 return this[i]; 47 return this[i];
52 }); 48 });
53 $defProp(Object.prototype, '$setindex', function(i, value) { 49 $defProp(Object.prototype, '$setindex', function(i, value) {
54 var proto = Object.getPrototypeOf(this); 50 $throw(new NoSuchMethodException(this, "operator []=", [i, value]));
55 if (proto !== Object) {
56 proto.$setindex = function(i, value) { return this[i] = value; }
57 }
58 return this[i] = value;
59 }); 51 });
60 $defProp(Array.prototype, '$setindex', function(index, value) { 52 $defProp(Array.prototype, '$setindex', function(index, value) {
61 var i = index | 0; 53 var i = index | 0;
62 if (i !== index) { 54 if (i !== index) {
63 throw new IllegalArgumentException('index is not int'); 55 throw new IllegalArgumentException('index is not int');
64 } else if (i < 0 || i >= this.length) { 56 } else if (i < 0 || i >= this.length) {
65 throw new IndexOutOfRangeException(index); 57 throw new IndexOutOfRangeException(index);
66 } 58 }
67 return this[i] = value; 59 return this[i] = value;
68 }); 60 });
61 function $add$complex(x, y) {
62 if (typeof(x) == 'number') {
63 $throw(new IllegalArgumentException(y));
64 } else if (typeof(x) == 'string') {
65 var str = (y == null) ? 'null' : y.toString();
66 if (typeof(str) != 'string') {
67 throw new Error("calling toString() on right hand operand of operator " +
68 "+ did not return a String");
69 }
70 return x + str;
71 } else if (typeof(x) == 'object') {
72 return x.$add(y);
73 } else {
74 $throw(new NoSuchMethodException(x, "operator +", [y]));
75 }
76 }
77
69 function $add(x, y) { 78 function $add(x, y) {
70 return ((typeof(x) == 'number' && typeof(y) == 'number') || 79 if (typeof(x) == 'number' && typeof(y) == 'number') return x + y;
71 (typeof(x) == 'string')) 80 return $add$complex(x, y);
72 ? x + y : x.$add(y); 81 }
82 function $bit_xor$complex(x, y) {
83 if (typeof(x) == 'number') {
84 $throw(new IllegalArgumentException(y));
85 } else if (typeof(x) == 'object') {
86 return x.$bit_xor(y);
87 } else {
88 $throw(new NoSuchMethodException(x, "operator ^", [y]));
89 }
73 } 90 }
74 function $bit_xor(x, y) { 91 function $bit_xor(x, y) {
75 return (typeof(x) == 'number' && typeof(y) == 'number') 92 if (typeof(x) == 'number' && typeof(y) == 'number') return x ^ y;
76 ? x ^ y : x.$bit_xor(y); 93 return $bit_xor$complex(x, y);
77 } 94 }
78 function $eq(x, y) { 95 function $eq(x, y) {
79 if (x == null) return y == null; 96 if (x == null) return y == null;
80 return (typeof(x) == 'number' && typeof(y) == 'number') || 97 return (typeof(x) != 'object') ? x === y : x.$eq(y);
81 (typeof(x) == 'boolean' && typeof(y) == 'boolean') ||
82 (typeof(x) == 'string' && typeof(y) == 'string')
83 ? x == y : x.$eq(y);
84 } 98 }
85 // TODO(jimhug): Should this or should it not match equals? 99 // TODO(jimhug): Should this or should it not match equals?
86 $defProp(Object.prototype, '$eq', function(other) { 100 $defProp(Object.prototype, '$eq', function(other) {
87 return this === other; 101 return this === other;
88 }); 102 });
103 function $gt$complex(x, y) {
104 if (typeof(x) == 'number') {
105 $throw(new IllegalArgumentException(y));
106 } else if (typeof(x) == 'object') {
107 return x.$gt(y);
108 } else {
109 $throw(new NoSuchMethodException(x, "operator >", [y]));
110 }
111 }
89 function $gt(x, y) { 112 function $gt(x, y) {
90 return (typeof(x) == 'number' && typeof(y) == 'number') 113 if (typeof(x) == 'number' && typeof(y) == 'number') return x > y;
91 ? x > y : x.$gt(y); 114 return $gt$complex(x, y);
115 }
116 function $gte$complex(x, y) {
117 if (typeof(x) == 'number') {
118 $throw(new IllegalArgumentException(y));
119 } else if (typeof(x) == 'object') {
120 return x.$gte(y);
121 } else {
122 $throw(new NoSuchMethodException(x, "operator >=", [y]));
123 }
92 } 124 }
93 function $gte(x, y) { 125 function $gte(x, y) {
94 return (typeof(x) == 'number' && typeof(y) == 'number') 126 if (typeof(x) == 'number' && typeof(y) == 'number') return x >= y;
95 ? x >= y : x.$gte(y); 127 return $gte$complex(x, y);
128 }
129 function $lt$complex(x, y) {
130 if (typeof(x) == 'number') {
131 $throw(new IllegalArgumentException(y));
132 } else if (typeof(x) == 'object') {
133 return x.$lt(y);
134 } else {
135 $throw(new NoSuchMethodException(x, "operator <", [y]));
136 }
96 } 137 }
97 function $lt(x, y) { 138 function $lt(x, y) {
98 return (typeof(x) == 'number' && typeof(y) == 'number') 139 if (typeof(x) == 'number' && typeof(y) == 'number') return x < y;
99 ? x < y : x.$lt(y); 140 return $lt$complex(x, y);
141 }
142 function $lte$complex(x, y) {
143 if (typeof(x) == 'number') {
144 $throw(new IllegalArgumentException(y));
145 } else if (typeof(x) == 'object') {
146 return x.$lte(y);
147 } else {
148 $throw(new NoSuchMethodException(x, "operator <=", [y]));
149 }
100 } 150 }
101 function $lte(x, y) { 151 function $lte(x, y) {
102 return (typeof(x) == 'number' && typeof(y) == 'number') 152 if (typeof(x) == 'number' && typeof(y) == 'number') return x <= y;
103 ? x <= y : x.$lte(y); 153 return $lte$complex(x, y);
104 } 154 }
105 function $mod(x, y) { 155 function $mod(x, y) {
106 if (typeof(x) == 'number' && typeof(y) == 'number') { 156 if (typeof(x) == 'number') {
107 var result = x % y; 157 if (typeof(y) == 'number') {
108 if (result == 0) { 158 var result = x % y;
109 return 0; // Make sure we don't return -0.0. 159 if (result == 0) {
110 } else if (result < 0) { 160 return 0; // Make sure we don't return -0.0.
111 if (y < 0) { 161 } else if (result < 0) {
112 return result - y; 162 if (y < 0) {
113 } else { 163 return result - y;
114 return result + y; 164 } else {
165 return result + y;
166 }
115 } 167 }
168 return result;
169 } else {
170 $throw(new IllegalArgumentException(y));
116 } 171 }
117 return result; 172 } else if (typeof(x) == 'object') {
173 return x.$mod(y);
118 } else { 174 } else {
119 return x.$mod(y); 175 $throw(new NoSuchMethodException(x, "operator %", [y]));
176 }
177 }
178 function $mul$complex(x, y) {
179 if (typeof(x) == 'number') {
180 $throw(new IllegalArgumentException(y));
181 } else if (typeof(x) == 'object') {
182 return x.$mul(y);
183 } else {
184 $throw(new NoSuchMethodException(x, "operator *", [y]));
120 } 185 }
121 } 186 }
122 function $mul(x, y) { 187 function $mul(x, y) {
123 return (typeof(x) == 'number' && typeof(y) == 'number') 188 if (typeof(x) == 'number' && typeof(y) == 'number') return x * y;
124 ? x * y : x.$mul(y); 189 return $mul$complex(x, y);
125 } 190 }
126 function $ne(x, y) { 191 function $ne(x, y) {
127 if (x == null) return y != null; 192 if (x == null) return y != null;
128 return (typeof(x) == 'number' && typeof(y) == 'number') || 193 return (typeof(x) != 'object') ? x !== y : !x.$eq(y);
129 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || 194 }
130 (typeof(x) == 'string' && typeof(y) == 'string') 195 function $shl$complex(x, y) {
131 ? x != y : !x.$eq(y); 196 if (typeof(x) == 'number') {
197 $throw(new IllegalArgumentException(y));
198 } else if (typeof(x) == 'object') {
199 return x.$shl(y);
200 } else {
201 $throw(new NoSuchMethodException(x, "operator <<", [y]));
202 }
132 } 203 }
133 function $shl(x, y) { 204 function $shl(x, y) {
134 return (typeof(x) == 'number' && typeof(y) == 'number') 205 if (typeof(x) == 'number' && typeof(y) == 'number') return x << y;
135 ? x << y : x.$shl(y); 206 return $shl$complex(x, y);
207 }
208 function $sub$complex(x, y) {
209 if (typeof(x) == 'number') {
210 $throw(new IllegalArgumentException(y));
211 } else if (typeof(x) == 'object') {
212 return x.$sub(y);
213 } else {
214 $throw(new NoSuchMethodException(x, "operator -", [y]));
215 }
136 } 216 }
137 function $sub(x, y) { 217 function $sub(x, y) {
138 return (typeof(x) == 'number' && typeof(y) == 'number') 218 if (typeof(x) == 'number' && typeof(y) == 'number') return x - y;
139 ? x - y : x.$sub(y); 219 return $sub$complex(x, y);
140 } 220 }
141 function $truncdiv(x, y) { 221 function $truncdiv(x, y) {
142 if (typeof(x) == 'number' && typeof(y) == 'number') { 222 if (typeof(x) == 'number') {
143 if (y == 0) $throw(new IntegerDivisionByZeroException()); 223 if (typeof(y) == 'number') {
144 var tmp = x / y; 224 if (y == 0) $throw(new IntegerDivisionByZeroException());
145 return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp); 225 var tmp = x / y;
226 return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp);
227 } else {
228 $throw(new IllegalArgumentException(y));
229 }
230 } else if (typeof(x) == 'object') {
231 return x.$truncdiv(y);
146 } else { 232 } else {
147 return x.$truncdiv(y); 233 $throw(new NoSuchMethodException(x, "operator ~/", [y]));
148 } 234 }
149 } 235 }
150 // ********** Code for Object ************** 236 // ********** Code for Object **************
151 $defProp(Object.prototype, "get$dynamic", function() { 237 $defProp(Object.prototype, "get$dynamic", function() {
152 "use strict"; return this; 238 "use strict"; return this;
153 }); 239 });
154 $defProp(Object.prototype, "noSuchMethod", function(name, args) { 240 $defProp(Object.prototype, "noSuchMethod", function(name, args) {
155 $throw(new NoSuchMethodException(this, name, args)); 241 $throw(new NoSuchMethodException(this, name, args));
156 }); 242 });
157 $defProp(Object.prototype, "_pushBlock$1", function($0) { 243 $defProp(Object.prototype, "_pushBlock$1", function($0) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return "Attempt to modify an immutable object"; 334 return "Attempt to modify an immutable object";
249 } 335 }
250 IllegalAccessException.prototype.toString$0 = IllegalAccessException.prototype.t oString; 336 IllegalAccessException.prototype.toString$0 = IllegalAccessException.prototype.t oString;
251 // ********** Code for NoSuchMethodException ************** 337 // ********** Code for NoSuchMethodException **************
252 function NoSuchMethodException(_receiver, _functionName, _arguments, _existingAr gumentNames) { 338 function NoSuchMethodException(_receiver, _functionName, _arguments, _existingAr gumentNames) {
253 this._existingArgumentNames = _existingArgumentNames; 339 this._existingArgumentNames = _existingArgumentNames;
254 this._receiver = _receiver; 340 this._receiver = _receiver;
255 this._functionName = _functionName; 341 this._functionName = _functionName;
256 this._arguments = _arguments; 342 this._arguments = _arguments;
257 } 343 }
344 NoSuchMethodException.prototype.is$NoSuchMethodException = function(){return tru e};
258 NoSuchMethodException.prototype.toString = function() { 345 NoSuchMethodException.prototype.toString = function() {
259 var sb = new StringBufferImpl(""); 346 var sb = new StringBufferImpl("");
260 for (var i = (0); 347 for (var i = (0);
261 i < this._arguments.get$length(); i++) { 348 i < this._arguments.get$length(); i++) {
262 if (i > (0)) { 349 if (i > (0)) {
263 sb.add(", "); 350 sb.add(", ");
264 } 351 }
265 sb.add(this._arguments.$index(i)); 352 sb.add(this._arguments.$index(i));
266 } 353 }
267 if (null == this._existingArgumentNames) { 354 if (null == this._existingArgumentNames) {
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); 1597 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
1511 hash ^= hash >> 11; 1598 hash ^= hash >> 11;
1512 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); 1599 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
1513 } 1600 }
1514 StringImplementation.prototype.compareTo = function(other) { 1601 StringImplementation.prototype.compareTo = function(other) {
1515 'use strict'; return this == other ? 0 : this < other ? -1 : 1; 1602 'use strict'; return this == other ? 0 : this < other ? -1 : 1;
1516 } 1603 }
1517 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta ins; 1604 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta ins;
1518 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO f; 1605 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO f;
1519 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs tring; 1606 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs tring;
1520 // ********** Code for _Worker **************
1521 // ********** Code for _ArgumentMismatchException ************** 1607 // ********** Code for _ArgumentMismatchException **************
1522 $inherits(_ArgumentMismatchException, ClosureArgumentMismatchException); 1608 $inherits(_ArgumentMismatchException, ClosureArgumentMismatchException);
1523 function _ArgumentMismatchException(_message) { 1609 function _ArgumentMismatchException(_message) {
1524 this._dart_coreimpl_message = _message; 1610 this._dart_coreimpl_message = _message;
1525 ClosureArgumentMismatchException.call(this); 1611 ClosureArgumentMismatchException.call(this);
1526 } 1612 }
1527 _ArgumentMismatchException.prototype.toString = function() { 1613 _ArgumentMismatchException.prototype.toString = function() {
1528 return ("Closure argument mismatch: " + this._dart_coreimpl_message); 1614 return ("Closure argument mismatch: " + this._dart_coreimpl_message);
1529 } 1615 }
1530 _ArgumentMismatchException.prototype.toString$0 = _ArgumentMismatchException.pro totype.toString; 1616 _ArgumentMismatchException.prototype.toString$0 = _ArgumentMismatchException.pro totype.toString;
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 this.useThrow = false; 2870 this.useThrow = false;
2785 this._generatedDynamicProto = false; 2871 this._generatedDynamicProto = false;
2786 this._generatedBind = false; 2872 this._generatedBind = false;
2787 this.useWrap1 = false; 2873 this.useWrap1 = false;
2788 this.useSetIndex = false; 2874 this.useSetIndex = false;
2789 this.useIndex = false; 2875 this.useIndex = false;
2790 this._generatedDefProp = false; 2876 this._generatedDefProp = false;
2791 } 2877 }
2792 CoreJs.prototype.get$writer = function() { return this.writer; }; 2878 CoreJs.prototype.get$writer = function() { return this.writer; };
2793 CoreJs.prototype.set$writer = function(value) { return this.writer = value; }; 2879 CoreJs.prototype.set$writer = function(value) { return this.writer = value; };
2880 CoreJs.prototype.markCorelibTypeUsed = function(typeName) {
2881 $globals.world.gen.markTypeUsed($globals.world.corelib.types.$index(typeName)) ;
2882 }
2794 CoreJs.prototype.useOperator = function(name) { 2883 CoreJs.prototype.useOperator = function(name) {
2795 if ($ne(this._usedOperators.$index(name))) return; 2884 if ($ne(this._usedOperators.$index(name))) return;
2885 if (name != ":ne" && name != ":eq") {
2886 this.markCorelibTypeUsed("NoSuchMethodException");
2887 }
2888 if (name != ":bit_not" && name != ":negate") {
2889 this.markCorelibTypeUsed("IllegalArgumentException");
2890 }
2796 var code; 2891 var code;
2797 switch (name) { 2892 switch (name) {
2798 case ":ne": 2893 case ":ne":
2799 2894
2800 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}"; 2895 code = "function $ne(x, y) {\n if (x == null) return y != null;\n return (typeof(x) != 'object') ? x !== y : !x.$eq(y);\n}";
2801 break; 2896 break;
2802 2897
2803 case ":eq": 2898 case ":eq":
2804 2899
2805 this.ensureDefProp(); 2900 this.ensureDefProp();
2806 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?\n$defProp(Object.prototype, '$eq', function(other) {\n return this === other;\n});"; 2901 code = "function $eq(x, y) {\n if (x == null) return y == null;\n return (typeof(x) != 'object') ? x === y : x.$eq(y);\n}\n// TODO(jimhug): Should this or should it not match equals?\n$defProp(Object.prototype, '$eq', function(other ) {\n return this === other;\n});";
2807 break; 2902 break;
2808 2903
2809 case ":bit_not": 2904 case ":bit_not":
2810 2905
2811 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x. $bit_not();\n}"; 2906 code = "function $bit_not(x) {\n if (typeof(x) == 'number') return ~x;\n if (typeof(x) == 'object') return x.$bit_not();\n $throw(new NoSuchMethodExce ption(x, \"operator ~\", []));\n}";
2812 break; 2907 break;
2813 2908
2814 case ":negate": 2909 case ":negate":
2815 2910
2816 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$ negate();\n}"; 2911 code = "function $negate(x) {\n if (typeof(x) == 'number') return -x;\n if (typeof(x) == 'object') return x.$negate();\n $throw(new NoSuchMethodExcepti on(x, \"operator negate\", []));\n}";
2817 break; 2912 break;
2818 2913
2819 case ":add": 2914 case ":add":
2820 2915
2821 code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof( y) == 'number') ||\n (typeof(x) == 'string'))\n ? x + y : x.$add(y); \n}"; 2916 code = "function $add$complex(x, y) {\n if (typeof(x) == 'number') {\n $throw(new IllegalArgumentException(y));\n } else if (typeof(x) == 'string') { \n var str = (y == null) ? 'null' : y.toString();\n if (typeof(str) != 'st ring') {\n throw new Error(\"calling toString() on right hand operand of op erator \" +\n \"+ did not return a String\");\n }\n return x + str;\n } else if (typeof(x) == 'object') {\n return x.$add(y);\n } else {\n $t hrow(new NoSuchMethodException(x, \"operator +\", [y]));\n }\n}\n\nfunction $ad d(x, y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') return x + y;\n return $add$complex(x, y);\n}";
2822 break; 2917 break;
2823 2918
2824 case ":truncdiv": 2919 case ":truncdiv":
2825 2920
2826 this.useThrow = true; 2921 this.useThrow = true;
2827 $globals.world.gen.markTypeUsed($globals.world.corelib.types.$index("Integ erDivisionByZeroException")); 2922 this.markCorelibTypeUsed("IntegerDivisionByZeroException");
2828 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}"; 2923 code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number') {\n if (typeof(y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroEx ception());\n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : M ath.floor(tmp);\n } else {\n $throw(new IllegalArgumentException(y));\n }\n } else if (typeof(x) == 'object') {\n return x.$truncdiv(y);\n } els e {\n $throw(new NoSuchMethodException(x, \"operator ~/\", [y]));\n }\n}";
2829 break; 2924 break;
2830 2925
2831 case ":mod": 2926 case ":mod":
2832 2927
2833 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}"; 2928 code = "function $mod(x, y) {\n if (typeof(x) == 'number') {\n if (typ eof(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 $throw(new IllegalArgumentException(y));\n }\n } else if (typeof(x) == 'object') {\n return x.$mod(y);\n } else {\n $throw(new NoSuchMethodExcep tion(x, \"operator %\", [y]));\n }\n}";
2834 break; 2929 break;
2835 2930
2836 default: 2931 default:
2837 2932
2838 var op = TokenKind.rawOperatorFromMethod(name); 2933 var op = TokenKind.rawOperatorFromMethod(name);
2839 var jsname = $globals.world.toJsIdentifier(name); 2934 var jsname = $globals.world.toJsIdentifier(name);
2840 code = _otherOperator(jsname, op); 2935 code = _otherOperator(jsname, op);
2841 break; 2936 break;
2842 2937
2843 } 2938 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 w.write(this.writer.get$text()); 2975 w.write(this.writer.get$text());
2881 this.writer = w; 2976 this.writer = w;
2882 if (this.useNotNullBool) { 2977 if (this.useNotNullBool) {
2883 this.useThrow = true; 2978 this.useThrow = true;
2884 w.writeln("function $notnull_bool(test) {\n if (test === true || test === f alse) return test;\n $throw(new TypeError(test, 'bool'));\n}"); 2979 w.writeln("function $notnull_bool(test) {\n if (test === true || test === f alse) return test;\n $throw(new TypeError(test, 'bool'));\n}");
2885 } 2980 }
2886 if (this.useThrow) { 2981 if (this.useThrow) {
2887 w.writeln("function $throw(e) {\n // If e is not a value, we can use V8's c aptureStackTrace utility method.\n // TODO(jmesserly): capture the stack trace on other JS engines.\n if (e && (typeof e == 'object') && Error.captureStackTra ce) {\n // TODO(jmesserly): this will clobber the e.stack property\n Error .captureStackTrace(e, $throw);\n }\n throw e;\n}"); 2982 w.writeln("function $throw(e) {\n // If e is not a value, we can use V8's c aptureStackTrace utility method.\n // TODO(jmesserly): capture the stack trace on other JS engines.\n if (e && (typeof e == 'object') && Error.captureStackTra ce) {\n // TODO(jmesserly): this will clobber the e.stack property\n Error .captureStackTrace(e, $throw);\n }\n throw e;\n}");
2888 } 2983 }
2889 if (this.useIndex) { 2984 if (this.useIndex) {
2985 this.markCorelibTypeUsed("NoSuchMethodException");
2890 this.ensureDefProp(); 2986 this.ensureDefProp();
2891 w.writeln($globals.options.disableBoundsChecks ? "$defProp(Object.prototype, '$index', function(i) {\n var proto = Object.getPrototypeOf(this);\n if (prot o !== Object) {\n proto.$index = function(i) { return this[i]; }\n }\n retu rn this[i];\n});\n$defProp(Array.prototype, '$index', function(i) {\n return th is[i];\n});\n$defProp(String.prototype, '$index', function(i) {\n return this[i ];\n});" : "$defProp(Object.prototype, '$index', function(i) {\n var proto = Ob ject.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$index = functi on(i) { return this[i]; }\n }\n return this[i];\n});\n$defProp(Array.prototype , '$index', function(index) {\n var i = index | 0;\n if (i !== index) {\n t hrow new IllegalArgumentException('index is not int');\n } else if (i < 0 || i >= this.length) {\n throw new IndexOutOfRangeException(index);\n }\n return this[i];\n});\n$defProp(String.prototype, '$index', function(i) {\n return thi s[i];\n});"); 2987 w.writeln($globals.options.disableBoundsChecks ? "$defProp(Object.prototype, '$index', function(i) {\n $throw(new NoSuchMethodException(this, \"operator [] \", [i]));\n});\n$defProp(Array.prototype, '$index', function(i) {\n return thi s[i];\n});\n$defProp(String.prototype, '$index', function(i) {\n return this[i] ;\n});" : "$defProp(Object.prototype, '$index', function(i) {\n $throw(new NoSu chMethodException(this, \"operator []\", [i]));\n});\n$defProp(Array.prototype, '$index', function(index) {\n var i = index | 0;\n if (i !== index) {\n thr ow new IllegalArgumentException('index is not int');\n } else if (i < 0 || i >= this.length) {\n throw new IndexOutOfRangeException(index);\n }\n return t his[i];\n});\n$defProp(String.prototype, '$index', function(i) {\n return this[ i];\n});");
2892 } 2988 }
2893 if (this.useSetIndex) { 2989 if (this.useSetIndex) {
2990 this.markCorelibTypeUsed("NoSuchMethodException");
2894 this.ensureDefProp(); 2991 this.ensureDefProp();
2895 w.writeln($globals.options.disableBoundsChecks ? "$defProp(Object.prototype, '$setindex', function(i, value) {\n var proto = Object.getPrototypeOf(this);\n if (proto !== Object) {\n proto.$setindex = function(i, value) { return thi s[i] = value; }\n }\n return this[i] = value;\n});\n$defProp(Array.prototype, '$setindex',\n function(i, value) { return this[i] = value; });" : "$defProp( Object.prototype, '$setindex', function(i, value) {\n var proto = Object.getPro totypeOf(this);\n if (proto !== Object) {\n proto.$setindex = function(i, va lue) { return this[i] = value; }\n }\n return this[i] = value;\n});\n$defProp( Array.prototype, '$setindex', function(index, value) {\n var i = index | 0;\n if (i !== index) {\n throw new IllegalArgumentException('index is not int');\ n } else if (i < 0 || i >= this.length) {\n throw new IndexOutOfRangeExcepti on(index);\n }\n return this[i] = value;\n});"); 2992 w.writeln($globals.options.disableBoundsChecks ? "$defProp(Object.prototype, '$setindex', function(i, value) {\n $throw(new NoSuchMethodException(this, \"o perator []=\", [i, value]));\n});\n$defProp(Array.prototype, '$setindex',\n f unction(i, value) { return this[i] = value; });" : "$defProp(Object.prototype, ' $setindex', function(i, value) {\n $throw(new NoSuchMethodException(this, \"ope rator []=\", [i, value]));\n});\n$defProp(Array.prototype, '$setindex', function (index, value) {\n var i = index | 0;\n if (i !== index) {\n throw new Ille galArgumentException('index is not int');\n } else if (i < 0 || i >= this.lengt h) {\n throw new IndexOutOfRangeException(index);\n }\n return this[i] = va lue;\n});");
2896 } 2993 }
2897 if (this.useIsolates) { 2994 if (!this.useIsolates) {
2898 if (this.useWrap0) {
2899 w.writeln("// Wrap a 0-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$0(fn) { return fn && fn.wrap$call$0(); }\nFunction.proto type.wrap$call$0 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$0 = function() {\n isolateContext.eval( self);\n $globalState.topEventLoop.run();\n };\n this.wrap$call$0 = functio n() { return this.wrap$0; };\n return this.wrap$0;\n}");
2900 }
2901 if (this.useWrap1) {
2902 w.writeln("// Wrap a 1-arg dom-callback to bind it with the current isolat e:\nfunction $wrap_call$1(fn) { return fn && fn.wrap$call$1(); }\nFunction.proto type.wrap$call$1 = function() {\n var isolateContext = $globalState.currentCont ext;\n var self = this;\n this.wrap$1 = function(arg) {\n isolateContext.ev al(function() { self(arg); });\n $globalState.topEventLoop.run();\n };\n th is.wrap$call$1 = function() { return this.wrap$1; };\n return this.wrap$1;\n}") ;
2903 }
2904 w.writeln("var $globalThis = this;\nvar $globals = null;\nvar $globalState = null;");
2905 }
2906 else {
2907 if (this.useWrap0) { 2995 if (this.useWrap0) {
2908 w.writeln("function $wrap_call$0(fn) { return fn; }"); 2996 w.writeln("function $wrap_call$0(fn) { return fn; }");
2909 } 2997 }
2910 if (this.useWrap1) { 2998 if (this.useWrap1) {
2911 w.writeln("function $wrap_call$1(fn) { return fn; }"); 2999 w.writeln("function $wrap_call$1(fn) { return fn; }");
2912 } 3000 }
2913 } 3001 }
2914 var $$list = orderValuesByKeys(this._usedOperators); 3002 var $$list = orderValuesByKeys(this._usedOperators);
2915 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { 3003 for (var $$i = $$list.iterator(); $$i.hasNext(); ) {
2916 var opImpl = $$i.next(); 3004 var opImpl = $$i.next();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]); 3190 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi s.main.declaringType.get$library()]);
3103 } 3191 }
3104 $globals.world.numImplType.markUsed(); 3192 $globals.world.numImplType.markUsed();
3105 $globals.world.stringImplType.markUsed(); 3193 $globals.world.stringImplType.markUsed();
3106 if (this.corejs.useIndex || this.corejs.useSetIndex) { 3194 if (this.corejs.useIndex || this.corejs.useSetIndex) {
3107 if (!$globals.options.disableBoundsChecks) { 3195 if (!$globals.options.disableBoundsChecks) {
3108 this.markTypeUsed($globals.world.corelib.types.$index("IndexOutOfRangeExce ption")); 3196 this.markTypeUsed($globals.world.corelib.types.$index("IndexOutOfRangeExce ption"));
3109 this.markTypeUsed($globals.world.corelib.types.$index("IllegalArgumentExce ption")); 3197 this.markTypeUsed($globals.world.corelib.types.$index("IllegalArgumentExce ption"));
3110 } 3198 }
3111 } 3199 }
3112 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) { 3200 if ($globals.world.isolatelib != null) {
3113 if (this.corejs.useWrap0 || this.corejs.useWrap1) {
3114 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM ember("eval"));
3115 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember ("run"));
3116 }
3117 this.corejs.useIsolates = true; 3201 this.corejs.useIsolates = true;
3118 var isolateMain = $globals.world.coreimpl.lookup("startRootIsolate", this.ma in.get$span()); 3202 var isolateMain = $globals.world.isolatelib.lookup("startRootIsolate", this. main.get$span());
3119 var isolateMainTarget = new TypeValue($globals.world.coreimpl.topType, this. main.get$span()); 3203 mainCall = isolateMain.invoke(this.mainContext, null, new TypeValue($globals .world.isolatelib.topType, this.main.get$span()), new Arguments(null, [this.main ._get(this.mainContext, this.main.definition, null)]));
3120 mainCall = isolateMain.invoke(this.mainContext, null, isolateMainTarget, new Arguments(null, [this.main._get(this.mainContext, this.main.definition, null)]) );
3121 } 3204 }
3122 this.writeTypes($globals.world.coreimpl); 3205 this.writeTypes($globals.world.coreimpl);
3123 this.writeTypes($globals.world.corelib); 3206 this.writeTypes($globals.world.corelib);
3124 this.writeTypes(this.main.declaringType.get$library()); 3207 this.writeTypes(this.main.declaringType.get$library());
3125 if (this._mixins != null) this.writer.write(this._mixins.get$text()); 3208 if (this._mixins != null) this.writer.write(this._mixins.get$text());
3126 this.writeDynamicDispatchMetadata(); 3209 this.writeDynamicDispatchMetadata();
3127 this.writeGlobals(); 3210 this.writeGlobals();
3128 this.writer.writeln(("" + mainCall.get$code() + ";")); 3211 this.writer.writeln(("" + mainCall.get$code() + ";"));
3129 } 3212 }
3130 WorldGenerator.prototype.markLibrariesUsed = function(libs) { 3213 WorldGenerator.prototype.markLibrariesUsed = function(libs) {
(...skipping 5830 matching lines...) Expand 10 before | Expand all | Expand 10 after
8961 this._afterParens = []; 9044 this._afterParens = [];
8962 } 9045 }
8963 Parser.prototype.get$enableAwait = function() { 9046 Parser.prototype.get$enableAwait = function() {
8964 return $globals.experimentalAwaitPhase != null; 9047 return $globals.experimentalAwaitPhase != null;
8965 } 9048 }
8966 Parser.prototype.isPrematureEndOfFile = function() { 9049 Parser.prototype.isPrematureEndOfFile = function() {
8967 if (this.throwOnIncomplete && this._maybeEat((1))) { 9050 if (this.throwOnIncomplete && this._maybeEat((1))) {
8968 $throw(new IncompleteSourceException(this._previousToken)); 9051 $throw(new IncompleteSourceException(this._previousToken));
8969 } 9052 }
8970 else if (this._maybeEat((1))) { 9053 else if (this._maybeEat((1))) {
8971 this._lang_error("unexpected end of file", this._peekToken.get$span()); 9054 this._error("unexpected end of file", this._peekToken.get$span());
8972 return true; 9055 return true;
8973 } 9056 }
8974 else { 9057 else {
8975 return false; 9058 return false;
8976 } 9059 }
8977 } 9060 }
8978 Parser.prototype._recoverTo = function(kind1, kind2, kind3) { 9061 Parser.prototype._recoverTo = function(kind1, kind2, kind3) {
8979 while (!this.isPrematureEndOfFile()) { 9062 while (!this.isPrematureEndOfFile()) {
8980 var kind = this._peek(); 9063 var kind = this._peek();
8981 if (kind == kind1 || kind == kind2 || kind == kind3) { 9064 if (kind == kind1 || kind == kind2 || kind == kind3) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9019 } 9102 }
9020 } 9103 }
9021 Parser.prototype._eatSemicolon = function() { 9104 Parser.prototype._eatSemicolon = function() {
9022 if (this.optionalSemicolons && this._peekKind((1))) return; 9105 if (this.optionalSemicolons && this._peekKind((1))) return;
9023 this._eat((10)); 9106 this._eat((10));
9024 } 9107 }
9025 Parser.prototype._errorExpected = function(expected) { 9108 Parser.prototype._errorExpected = function(expected) {
9026 if (this.throwOnIncomplete) this.isPrematureEndOfFile(); 9109 if (this.throwOnIncomplete) this.isPrematureEndOfFile();
9027 var tok = this._lang_next(); 9110 var tok = this._lang_next();
9028 if ((tok instanceof ErrorToken) && tok.get$message() != null) { 9111 if ((tok instanceof ErrorToken) && tok.get$message() != null) {
9029 this._lang_error(tok.get$message(), tok.get$span()); 9112 this._error(tok.get$message(), tok.get$span());
9030 } 9113 }
9031 else { 9114 else {
9032 this._lang_error(("expected " + expected + ", but found " + tok), tok.get$sp an()); 9115 this._error(("expected " + expected + ", but found " + tok), tok.get$span()) ;
9033 } 9116 }
9034 } 9117 }
9035 Parser.prototype._lang_error = function(message, location) { 9118 Parser.prototype._error = function(message, location) {
9036 if (this._recover) return; 9119 if (this._recover) return;
9037 if (location == null) { 9120 if (location == null) {
9038 location = this._peekToken.get$span(); 9121 location = this._peekToken.get$span();
9039 } 9122 }
9040 $globals.world.fatal(message, location); 9123 $globals.world.fatal(message, location);
9041 this._recover = true; 9124 this._recover = true;
9042 } 9125 }
9043 Parser.prototype._skipBlock = function() { 9126 Parser.prototype._skipBlock = function() {
9044 var depth = (1); 9127 var depth = (1);
9045 this._eat((6)); 9128 this._eat((6));
9046 while (true) { 9129 while (true) {
9047 var tok = this._lang_next(); 9130 var tok = this._lang_next();
9048 if (tok.get$kind() == (6)) { 9131 if (tok.get$kind() == (6)) {
9049 depth += (1); 9132 depth += (1);
9050 } 9133 }
9051 else if (tok.get$kind() == (7)) { 9134 else if (tok.get$kind() == (7)) {
9052 depth -= (1); 9135 depth -= (1);
9053 if (depth == (0)) return; 9136 if (depth == (0)) return;
9054 } 9137 }
9055 else if (tok.get$kind() == (1)) { 9138 else if (tok.get$kind() == (1)) {
9056 this._lang_error("unexpected end of file during diet parse", tok.get$span( )); 9139 this._error("unexpected end of file during diet parse", tok.get$span());
9057 return; 9140 return;
9058 } 9141 }
9059 } 9142 }
9060 } 9143 }
9061 Parser.prototype._makeSpan = function(start) { 9144 Parser.prototype._makeSpan = function(start) {
9062 return new SourceSpan(this.source, start, this._previousToken.end); 9145 return new SourceSpan(this.source, start, this._previousToken.end);
9063 } 9146 }
9064 Parser.prototype.compilationUnit = function() { 9147 Parser.prototype.compilationUnit = function() {
9065 var ret = []; 9148 var ret = [];
9066 this._maybeEat((13)); 9149 this._maybeEat((13));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
9193 } 9276 }
9194 else { 9277 else {
9195 return this.block(); 9278 return this.block();
9196 } 9279 }
9197 } 9280 }
9198 else if (!inExpression) { 9281 else if (!inExpression) {
9199 if (this._maybeEat((10))) { 9282 if (this._maybeEat((10))) {
9200 return null; 9283 return null;
9201 } 9284 }
9202 } 9285 }
9203 this._lang_error("Expected function body (neither { nor => found)"); 9286 this._error("Expected function body (neither { nor => found)");
9204 } 9287 }
9205 Parser.prototype.finishField = function(start, modifiers, type, name, value) { 9288 Parser.prototype.finishField = function(start, modifiers, type, name, value) {
9206 var names = [name]; 9289 var names = [name];
9207 var values = [value]; 9290 var values = [value];
9208 while (this._maybeEat((11))) { 9291 while (this._maybeEat((11))) {
9209 names.add(this.identifier()); 9292 names.add(this.identifier());
9210 if (this._maybeEat((20))) { 9293 if (this._maybeEat((20))) {
9211 values.add(this.expression()); 9294 values.add(this.expression());
9212 } 9295 }
9213 else { 9296 else {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
9280 } 9363 }
9281 else { 9364 else {
9282 if (names.get$length() > (1)) { 9365 if (names.get$length() > (1)) {
9283 name = names.removeLast(); 9366 name = names.removeLast();
9284 } 9367 }
9285 else { 9368 else {
9286 name = new Identifier("", names.$index((0)).get$span()); 9369 name = new Identifier("", names.$index((0)).get$span());
9287 } 9370 }
9288 } 9371 }
9289 if (names.get$length() > (1)) { 9372 if (names.get$length() > (1)) {
9290 this._lang_error("unsupported qualified name for factory", names.$index((0)) .get$span()); 9373 this._error("unsupported qualified name for factory", names.$index((0)).get$ span());
9291 } 9374 }
9292 type = new NameTypeReference(false, names.$index((0)), null, names.$index((0)) .get$span()); 9375 type = new NameTypeReference(false, names.$index((0)), null, names.$index((0)) .get$span());
9293 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); 9376 var di = new DeclaredIdentifier(type, name, this._makeSpan(start));
9294 return this.finishDefinition(start, [factoryToken], di); 9377 return this.finishDefinition(start, [factoryToken], di);
9295 } 9378 }
9296 Parser.prototype.statement = function() { 9379 Parser.prototype.statement = function() {
9297 switch (this._peek()) { 9380 switch (this._peek()) {
9298 case (88): 9381 case (88):
9299 9382
9300 return this.breakStatement(); 9383 return this.breakStatement();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
9559 } 9642 }
9560 else if (this._maybeEat((94))) { 9643 else if (this._maybeEat((94))) {
9561 cases.add(); 9644 cases.add();
9562 this._eat((8)); 9645 this._eat((8));
9563 } 9646 }
9564 else { 9647 else {
9565 break; 9648 break;
9566 } 9649 }
9567 } 9650 }
9568 if (cases.get$length() == (0)) { 9651 if (cases.get$length() == (0)) {
9569 this._lang_error("case or default"); 9652 this._error("case or default");
9570 } 9653 }
9571 var stmts = []; 9654 var stmts = [];
9572 while (!this._peekCaseEnd()) { 9655 while (!this._peekCaseEnd()) {
9573 stmts.add(this.statement()); 9656 stmts.add(this.statement());
9574 if (this._recover && !this._recoverTo((7), (89), (94))) { 9657 if (this._recover && !this._recoverTo((7), (89), (94))) {
9575 break; 9658 break;
9576 } 9659 }
9577 } 9660 }
9578 return new CaseNode(label, cases, stmts, this._makeSpan(start)); 9661 return new CaseNode(label, cases, stmts, this._makeSpan(start));
9579 } 9662 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
9644 if (type.get$names() == null) { 9727 if (type.get$names() == null) {
9645 type.set$names([expr.get$name()]); 9728 type.set$names([expr.get$name()]);
9646 } 9729 }
9647 else { 9730 else {
9648 type.get$names().add(expr.get$name()); 9731 type.get$names().add(expr.get$name());
9649 } 9732 }
9650 type.set$span(expr.get$span()); 9733 type.set$span(expr.get$span());
9651 return type; 9734 return type;
9652 } 9735 }
9653 else { 9736 else {
9654 this._lang_error("expected type reference"); 9737 this._error("expected type reference");
9655 return null; 9738 return null;
9656 } 9739 }
9657 } 9740 }
9658 Parser.prototype.infixExpression = function(precedence) { 9741 Parser.prototype.infixExpression = function(precedence) {
9659 return this.finishInfixExpression(this.unaryExpression(), precedence); 9742 return this.finishInfixExpression(this.unaryExpression(), precedence);
9660 } 9743 }
9661 Parser.prototype._finishDeclaredId = function(type) { 9744 Parser.prototype._finishDeclaredId = function(type) {
9662 var name = this.identifier(); 9745 var name = this.identifier();
9663 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().start))); 9746 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m akeSpan(type.get$span().start)));
9664 } 9747 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
9822 } 9905 }
9823 } 9906 }
9824 Parser.prototype.finishCallOrLambdaExpression = function(expr) { 9907 Parser.prototype.finishCallOrLambdaExpression = function(expr) {
9825 if (this._atClosureParameters()) { 9908 if (this._atClosureParameters()) {
9826 var formals = this.formalParameterList(); 9909 var formals = this.formalParameterList();
9827 var body = this.functionBody(true); 9910 var body = this.functionBody(true);
9828 return this._makeFunction(expr, formals, body); 9911 return this._makeFunction(expr, formals, body);
9829 } 9912 }
9830 else { 9913 else {
9831 if ((expr instanceof DeclaredIdentifier)) { 9914 if ((expr instanceof DeclaredIdentifier)) {
9832 this._lang_error("illegal target for call, did you mean to declare a funct ion?", expr.get$span()); 9915 this._error("illegal target for call, did you mean to declare a function?" , expr.get$span());
9833 } 9916 }
9834 var args = this.arguments(); 9917 var args = this.arguments();
9835 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak eSpan(expr.get$span().start))); 9918 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak eSpan(expr.get$span().start)));
9836 } 9919 }
9837 } 9920 }
9838 Parser.prototype._isBin = function(expr, kind) { 9921 Parser.prototype._isBin = function(expr, kind) {
9839 return (expr instanceof BinaryExpression) && expr.get$op().kind == kind; 9922 return (expr instanceof BinaryExpression) && expr.get$op().kind == kind;
9840 } 9923 }
9841 Parser.prototype._makeLiteral = function(value) { 9924 Parser.prototype._makeLiteral = function(value) {
9842 return new LiteralExpression(value, value.span); 9925 return new LiteralExpression(value, value.span);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
10048 } 10131 }
10049 return type.get$name(); 10132 return type.get$name();
10050 } 10133 }
10051 Parser.prototype._specialIdentifier = function(includeOperators) { 10134 Parser.prototype._specialIdentifier = function(includeOperators) {
10052 var start = this._peekToken.start; 10135 var start = this._peekToken.start;
10053 var name; 10136 var name;
10054 switch (this._peek()) { 10137 switch (this._peek()) {
10055 case (15): 10138 case (15):
10056 10139
10057 this._eat((15)); 10140 this._eat((15));
10058 this._lang_error("rest no longer supported", this._previousToken.get$span( )); 10141 this._error("rest no longer supported", this._previousToken.get$span());
10059 name = this.identifier().get$name(); 10142 name = this.identifier().get$name();
10060 break; 10143 break;
10061 10144
10062 case (110): 10145 case (110):
10063 10146
10064 this._eat((110)); 10147 this._eat((110));
10065 this._eat((14)); 10148 this._eat((14));
10066 name = ("this." + this.identifier().get$name()); 10149 name = ("this." + this.identifier().get$name());
10067 break; 10150 break;
10068 10151
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
10357 return this.type.bind(this); 10440 return this.type.bind(this);
10358 } 10441 }
10359 Parser.prototype.formalParameter = function(inOptionalBlock) { 10442 Parser.prototype.formalParameter = function(inOptionalBlock) {
10360 var start = this._peekToken.start; 10443 var start = this._peekToken.start;
10361 var isThis = false; 10444 var isThis = false;
10362 var isRest = false; 10445 var isRest = false;
10363 var di = this.declaredIdentifier(false); 10446 var di = this.declaredIdentifier(false);
10364 var type = di.get$type(); 10447 var type = di.get$type();
10365 var name = di.get$name(); 10448 var name = di.get$name();
10366 if ($eq(name)) { 10449 if ($eq(name)) {
10367 this._lang_error("Formal parameter invalid", this._makeSpan(start)); 10450 this._error("Formal parameter invalid", this._makeSpan(start));
10368 } 10451 }
10369 var value = null; 10452 var value = null;
10370 if (this._maybeEat((20))) { 10453 if (this._maybeEat((20))) {
10371 if (!inOptionalBlock) { 10454 if (!inOptionalBlock) {
10372 this._lang_error("default values only allowed inside [optional] section"); 10455 this._error("default values only allowed inside [optional] section");
10373 } 10456 }
10374 value = this.expression(); 10457 value = this.expression();
10375 } 10458 }
10376 else if (this._peekKind((2))) { 10459 else if (this._peekKind((2))) {
10377 var formals = this.formalParameterList(); 10460 var formals = this.formalParameterList();
10378 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start)); 10461 var func = new FunctionDefinition(null, type, name, formals, null, null, nul l, this._makeSpan(start));
10379 type = new FunctionTypeReference(false, func, func.get$span()); 10462 type = new FunctionTypeReference(false, func, func.get$span());
10380 } 10463 }
10381 if (inOptionalBlock && $eq(value)) { 10464 if (inOptionalBlock && $eq(value)) {
10382 value = this._makeLiteral(Value.fromNull(this._makeSpan(start))); 10465 value = this._makeLiteral(Value.fromNull(this._makeSpan(start)));
10383 } 10466 }
10384 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) ); 10467 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start) );
10385 } 10468 }
10386 Parser.prototype.formalParameterList = function() { 10469 Parser.prototype.formalParameterList = function() {
10387 this._eatLeftParen(); 10470 this._eatLeftParen();
10388 var formals = []; 10471 var formals = [];
10389 var inOptionalBlock = false; 10472 var inOptionalBlock = false;
10390 if (!this._maybeEat((3))) { 10473 if (!this._maybeEat((3))) {
10391 if (this._maybeEat((4))) { 10474 if (this._maybeEat((4))) {
10392 inOptionalBlock = true; 10475 inOptionalBlock = true;
10393 } 10476 }
10394 formals.add(this.formalParameter(inOptionalBlock)); 10477 formals.add(this.formalParameter(inOptionalBlock));
10395 while (this._maybeEat((11))) { 10478 while (this._maybeEat((11))) {
10396 if (this._maybeEat((4))) { 10479 if (this._maybeEat((4))) {
10397 if (inOptionalBlock) { 10480 if (inOptionalBlock) {
10398 this._lang_error("already inside an optional block", this._previousTok en.get$span()); 10481 this._error("already inside an optional block", this._previousToken.ge t$span());
10399 } 10482 }
10400 inOptionalBlock = true; 10483 inOptionalBlock = true;
10401 } 10484 }
10402 formals.add(this.formalParameter(inOptionalBlock)); 10485 formals.add(this.formalParameter(inOptionalBlock));
10403 } 10486 }
10404 if (inOptionalBlock) { 10487 if (inOptionalBlock) {
10405 this._eat((5)); 10488 this._eat((5));
10406 } 10489 }
10407 this._eat((3)); 10490 this._eat((3));
10408 } 10491 }
10409 return formals; 10492 return formals;
10410 } 10493 }
10411 Parser.prototype.identifierForType = function() { 10494 Parser.prototype.identifierForType = function() {
10412 var $0; 10495 var $0;
10413 var tok = this._lang_next(); 10496 var tok = this._lang_next();
10414 if (!this._isIdentifier(tok.get$kind())) { 10497 if (!this._isIdentifier(tok.get$kind())) {
10415 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); 10498 this._error(("expected identifier, but found " + tok), tok.get$span());
10416 } 10499 }
10417 if ((($0 = tok.get$kind()) == null ? null != ((70)) : $0 !== (70)) && tok.get$ kind() != (80)) { 10500 if ((($0 = tok.get$kind()) == null ? null != ((70)) : $0 !== (70)) && tok.get$ kind() != (80)) {
10418 this._lang_error(("" + tok + " may not be used as a type name"), tok.get$spa n()); 10501 this._error(("" + tok + " may not be used as a type name"), tok.get$span());
10419 } 10502 }
10420 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); 10503 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start()));
10421 } 10504 }
10422 Parser.prototype.identifier = function() { 10505 Parser.prototype.identifier = function() {
10423 var tok = this._lang_next(); 10506 var tok = this._lang_next();
10424 if (!this._isIdentifier(tok.get$kind())) { 10507 if (!this._isIdentifier(tok.get$kind())) {
10425 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); 10508 this._error(("expected identifier, but found " + tok), tok.get$span());
10426 } 10509 }
10427 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); 10510 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start()));
10428 } 10511 }
10429 Parser.prototype._makeFunction = function(expr, formals, body) { 10512 Parser.prototype._makeFunction = function(expr, formals, body) {
10430 var name, type; 10513 var name, type;
10431 if ((expr instanceof VarExpression)) { 10514 if ((expr instanceof VarExpression)) {
10432 name = expr.get$name(); 10515 name = expr.get$name();
10433 type = null; 10516 type = null;
10434 } 10517 }
10435 else if ((expr instanceof DeclaredIdentifier)) { 10518 else if ((expr instanceof DeclaredIdentifier)) {
10436 name = expr.get$name(); 10519 name = expr.get$name();
10437 type = expr.get$type(); 10520 type = expr.get$type();
10438 if ($eq(name)) { 10521 if ($eq(name)) {
10439 this._lang_error("expected name and type", expr.get$span()); 10522 this._error("expected name and type", expr.get$span());
10440 } 10523 }
10441 } 10524 }
10442 else { 10525 else {
10443 this._lang_error("bad function body", expr.get$span()); 10526 this._error("bad function body", expr.get$span());
10444 } 10527 }
10445 var span = new SourceSpan(expr.get$span().file, expr.get$span().start, body.ge t$span().end); 10528 var span = new SourceSpan(expr.get$span().file, expr.get$span().start, body.ge t$span().end);
10446 var func = new FunctionDefinition(null, type, name, formals, null, null, body, span); 10529 var func = new FunctionDefinition(null, type, name, formals, null, null, body, span);
10447 return new LambdaExpression(func, func.get$span()); 10530 return new LambdaExpression(func, func.get$span());
10448 } 10531 }
10449 Parser.prototype._makeDeclaredIdentifier = function(e) { 10532 Parser.prototype._makeDeclaredIdentifier = function(e) {
10450 if ((e instanceof VarExpression)) { 10533 if ((e instanceof VarExpression)) {
10451 return new DeclaredIdentifier(null, e.get$name(), e.get$span()); 10534 return new DeclaredIdentifier(null, e.get$name(), e.get$span());
10452 } 10535 }
10453 else if ((e instanceof DeclaredIdentifier)) { 10536 else if ((e instanceof DeclaredIdentifier)) {
10454 return e; 10537 return e;
10455 } 10538 }
10456 else { 10539 else {
10457 this._lang_error("expected declared identifier"); 10540 this._error("expected declared identifier");
10458 return new DeclaredIdentifier(null, null, e.get$span()); 10541 return new DeclaredIdentifier(null, null, e.get$span());
10459 } 10542 }
10460 } 10543 }
10461 Parser.prototype._makeLabel = function(expr) { 10544 Parser.prototype._makeLabel = function(expr) {
10462 if ((expr instanceof VarExpression)) { 10545 if ((expr instanceof VarExpression)) {
10463 return expr.get$name(); 10546 return expr.get$name();
10464 } 10547 }
10465 else { 10548 else {
10466 this._errorExpected("label"); 10549 this._errorExpected("label");
10467 return null; 10550 return null;
(...skipping 3484 matching lines...) Expand 10 before | Expand all | Expand 10 after
13952 return li.get$library().get$isCore(); 14035 return li.get$library().get$isCore();
13953 }) 14036 })
13954 )) { 14037 )) {
13955 library.imports.add(new LibraryImport(this.corelib)); 14038 library.imports.add(new LibraryImport(this.corelib));
13956 } 14039 }
13957 this.libraries.$setindex(filename, library); 14040 this.libraries.$setindex(filename, library);
13958 this._todo.add(library); 14041 this._todo.add(library);
13959 if (filename == "dart:dom") { 14042 if (filename == "dart:dom") {
13960 this.dom = library; 14043 this.dom = library;
13961 } 14044 }
14045 else if (filename == "dart:isolate") {
14046 this.isolatelib = library;
14047 }
13962 } 14048 }
13963 return library; 14049 return library;
13964 } 14050 }
13965 World.prototype.process = function() { 14051 World.prototype.process = function() {
13966 while (this._todo.get$length() > (0)) { 14052 while (this._todo.get$length() > (0)) {
13967 var todo = this._todo; 14053 var todo = this._todo;
13968 this._todo = []; 14054 this._todo = [];
13969 for (var $$i = todo.iterator(); $$i.hasNext(); ) { 14055 for (var $$i = todo.iterator(); $$i.hasNext(); ) {
13970 var lib = $$i.next(); 14056 var lib = $$i.next();
13971 lib.visitSources(); 14057 lib.visitSources();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
14267 this.libDir = temp; 14353 this.libDir = temp;
14268 } 14354 }
14269 else { 14355 else {
14270 this.libDir = "lib"; 14356 this.libDir = "lib";
14271 } 14357 }
14272 } 14358 }
14273 } 14359 }
14274 // ********** Code for LibraryReader ************** 14360 // ********** Code for LibraryReader **************
14275 function LibraryReader() { 14361 function LibraryReader() {
14276 if ($eq($globals.options.config, "dev")) { 14362 if ($eq($globals.options.config, "dev")) {
14277 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, "../../lib/json/json_frog.dart")]); 14363 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, "../../lib/json/json_frog.dart"), "dart:isolate", joinPaths($globals.opt ions.libDir, "../../lib/isolate/isolate_frog.dart")]);
14278 } 14364 }
14279 else if ($eq($globals.options.config, "sdk")) { 14365 else if ($eq($globals.options.config, "sdk")) {
14280 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")]); 14366 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"), "d art:isolate", joinPaths($globals.options.libDir, "isolate/isolate_frog.dart")]);
14281 } 14367 }
14282 else { 14368 else {
14283 $globals.world.error(("Invalid configuration " + $globals.options.config)); 14369 $globals.world.error(("Invalid configuration " + $globals.options.config));
14284 } 14370 }
14285 } 14371 }
14286 LibraryReader.prototype.readFile = function(fullname) { 14372 LibraryReader.prototype.readFile = function(fullname) {
14287 var filename = this._specialLibs.$index(fullname); 14373 var filename = this._specialLibs.$index(fullname);
14288 if ($eq(filename)) { 14374 if ($eq(filename)) {
14289 filename = fullname; 14375 filename = fullname;
14290 } 14376 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
14458 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs); 14544 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar gs);
14459 var stub = new VarMethodStub(this.name, null, this.args, $add("return ", res ult.get$code())); 14545 var stub = new VarMethodStub(this.name, null, this.args, $add("return ", res ult.get$code()));
14460 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub); 14546 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub);
14461 } 14547 }
14462 } 14548 }
14463 VarMethodSet.prototype.generate = function(code) { 14549 VarMethodSet.prototype.generate = function(code) {
14464 14550
14465 } 14551 }
14466 // ********** Code for top level ************** 14552 // ********** Code for top level **************
14467 function _otherOperator(jsname, op) { 14553 function _otherOperator(jsname, op) {
14468 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}"); 14554 return ("function " + jsname + "$complex(x, y) {\n if (typeof(x) == 'number') {\n $throw(new IllegalArgumentException(y));\n } else if (typeof(x) == 'obj ect') {\n return x." + jsname + "(y);\n } else {\n $throw(new NoSuchMetho dException(x, \"operator " + op + "\", [y]));\n }\n}\nfunction " + jsname + "(x , y) {\n if (typeof(x) == 'number' && typeof(y) == 'number') return x " + op + " y;\n return " + jsname + "$complex(x, y);\n}");
14469 } 14555 }
14470 function map(source, mapper) { 14556 function map(source, mapper) {
14471 var result = new Array(); 14557 var result = new Array();
14472 if (!!(source && source.is$List())) { 14558 if (!!(source && source.is$List())) {
14473 var list = source; 14559 var list = source;
14474 result.set$length(list.get$length()); 14560 result.set$length(list.get$length());
14475 for (var i = (0); 14561 for (var i = (0);
14476 i < list.get$length(); i++) { 14562 i < list.get$length(); i++) {
14477 result.$setindex(i, mapper(list.$index(i))); 14563 result.$setindex(i, mapper(list.$index(i)));
14478 } 14564 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
14585 } 14671 }
14586 var const$0000 = Object.create(_DeletedKeySentinel.prototype, {}); 14672 var const$0000 = Object.create(_DeletedKeySentinel.prototype, {});
14587 var const$0001 = Object.create(NoMoreElementsException.prototype, {}); 14673 var const$0001 = Object.create(NoMoreElementsException.prototype, {});
14588 var const$0002 = Object.create(EmptyQueueException.prototype, {}); 14674 var const$0002 = Object.create(EmptyQueueException.prototype, {});
14589 var const$0006 = Object.create(IllegalAccessException.prototype, {}); 14675 var const$0006 = Object.create(IllegalAccessException.prototype, {});
14590 var const$0007 = ImmutableList.ImmutableList$from$factory([]); 14676 var const$0007 = ImmutableList.ImmutableList$from$factory([]);
14591 var const$0009 = new JSSyntaxRegExp("^[a-zA-Z]:/"); 14677 var const$0009 = new JSSyntaxRegExp("^[a-zA-Z]:/");
14592 var $globals = {}; 14678 var $globals = {};
14593 $static_init(); 14679 $static_init();
14594 main(); 14680 main();
OLDNEW
« no previous file with comments | « frog/lib/newisolate.dart ('k') | frog/reader.dart » ('j') | lib/isolate/isolate_api.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698