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

Side by Side Diff: test/codegen/expect/_js_helper/_js_helper.js

Issue 962083002: support the JS builtin (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 var _js_helper; 1 var _js_helper;
2 (function(_js_helper) { 2 (function(_js_helper) {
3 'use strict'; 3 'use strict';
4 class _Patch extends dart.Object { 4 class _Patch extends dart.Object {
5 _Patch() { 5 _Patch() {
6 } 6 }
7 } 7 }
8 let patch = new _Patch(); 8 let patch = new _Patch();
9 class InternalMap extends dart.Object { 9 class InternalMap extends dart.Object {
10 } 10 }
11 // Function requiresPreamble: () → dynamic 11 // Function requiresPreamble: () → dynamic
12 function requiresPreamble() { 12 function requiresPreamble() {
13 } 13 }
14 // Function isJsIndexable: (dynamic, dynamic) → bool 14 // Function isJsIndexable: (dynamic, dynamic) → bool
15 function isJsIndexable(object, record) { 15 function isJsIndexable(object, record) {
16 if (record !== null) { 16 if (record !== null) {
17 let result = _interceptors.dispatchRecordIndexability(record); 17 let result = _interceptors.dispatchRecordIndexability(record);
18 if (result !== null) 18 if (result !== null)
19 return dart.as(result, core.bool); 19 return dart.as(result, core.bool);
20 } 20 }
21 return dart.is(object, JavaScriptIndexingBehavior); 21 return dart.is(object, JavaScriptIndexingBehavior);
22 } 22 }
23 // Function S: (dynamic) → String 23 // Function S: (dynamic) → String
24 function S(value) { 24 function S(value) {
25 if (typeof value == string) 25 if (typeof value == string)
26 return dart.as(value, core.String); 26 return dart.as(value, core.String);
27 if (dart.is(value, core.num)) { 27 if (dart.is(value, core.num)) {
28 if (!dart.equals(value, 0)) { 28 if (!dart.equals(value, 0)) {
29 return dart.as(_foreign_helper.JS('String', '"" + (#)', value), core.Str ing); 29 return "" + value;
30 } 30 }
31 } else if (true === value) { 31 } else if (true === value) {
32 return 'true'; 32 return 'true';
33 } else if (false === value) { 33 } else if (false === value) {
34 return 'false'; 34 return 'false';
35 } else if (value === null) { 35 } else if (value === null) {
36 return 'null'; 36 return 'null';
37 } 37 }
38 let res = dart.dinvoke(value, 'toString'); 38 let res = dart.dinvoke(value, 'toString');
39 if (!(typeof res == string)) 39 if (!(typeof res == string))
40 throw new core.ArgumentError(value); 40 throw new core.ArgumentError(value);
41 return dart.as(res, core.String); 41 return dart.as(res, core.String);
42 } 42 }
43 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic 43 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic
44 function createInvocationMirror(name, internalName, kind, arguments, argumentN ames) { 44 function createInvocationMirror(name, internalName, kind, arguments, argumentN ames) {
45 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, core. List)); 45 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, core. List));
46 } 46 }
47 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic 47 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic
48 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments , argumentNames) { 48 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments , argumentNames) {
49 return new JSInvocationMirror(symbol, dart.as(internalName, core.String), da rt.as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, cor e.List)); 49 return new JSInvocationMirror(symbol, dart.as(internalName, core.String), da rt.as(kind, core.int), dart.as(arguments, core.List), dart.as(argumentNames, cor e.List));
50 } 50 }
51 // Function throwInvalidReflectionError: (String) → void 51 // Function throwInvalidReflectionError: (String) → void
52 function throwInvalidReflectionError(memberName) { 52 function throwInvalidReflectionError(memberName) {
53 throw new core.UnsupportedError(`Can't use '${memberName}' in reflection ` + "because it is not included in a @MirrorsUsed annotation."); 53 throw new core.UnsupportedError(`Can't use '${memberName}' in reflection ` + "because it is not included in a @MirrorsUsed annotation.");
54 } 54 }
55 // Function traceHelper: (String) → void 55 // Function traceHelper: (String) → void
56 function traceHelper(method) { 56 function traceHelper(method) {
57 if (_foreign_helper.JS('bool', '!this.cache')) { 57 if (!this.cache) {
58 _foreign_helper.JS('', 'this.cache = Object.create(null)'); 58 this.cache = Object.create(null);
59 } 59 }
60 if (_foreign_helper.JS('bool', '!this.cache[#]', method)) { 60 if (!this.cache[method]) {
61 _foreign_helper.JS('', 'console.log(#)', method); 61 console.log(method);
62 _foreign_helper.JS('', 'this.cache[#] = true', method); 62 this.cache[method] = true;
63 } 63 }
64 } 64 }
65 class JSInvocationMirror extends dart.Object { 65 class JSInvocationMirror extends dart.Object {
66 JSInvocationMirror(_memberName, _internalName, _kind, _arguments, _namedArgu mentNames) { 66 JSInvocationMirror(_memberName, _internalName, _kind, _arguments, _namedArgu mentNames) {
67 this._memberName = _memberName; 67 this._memberName = _memberName;
68 this._internalName = _internalName; 68 this._internalName = _internalName;
69 this._kind = _kind; 69 this._kind = _kind;
70 this._arguments = _arguments; 70 this._arguments = _arguments;
71 this._namedArgumentNames = _namedArgumentNames; 71 this._namedArgumentNames = _namedArgumentNames;
72 this._namedIndices = null; 72 this._namedIndices = null;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 map.set(new _internal.Symbol.unvalidated(dart.as(this._namedArgumentName s.get(i), core.String)), this._arguments.get(namedArgumentsStartIndex + i)); 122 map.set(new _internal.Symbol.unvalidated(dart.as(this._namedArgumentName s.get(i), core.String)), this._arguments.get(namedArgumentsStartIndex + i));
123 } 123 }
124 return map; 124 return map;
125 } 125 }
126 _getCachedInvocation(object) { 126 _getCachedInvocation(object) {
127 let interceptor = _interceptors.getInterceptor(object); 127 let interceptor = _interceptors.getInterceptor(object);
128 let receiver = object; 128 let receiver = object;
129 let name = this._internalName; 129 let name = this._internalName;
130 let arguments = this._arguments; 130 let arguments = this._arguments;
131 let interceptedNames = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_ embedded_names.INTERCEPTED_NAMES, core.String)); 131 let interceptedNames = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_ embedded_names.INTERCEPTED_NAMES, core.String));
132 let isIntercepted = dart.as(_foreign_helper.JS("bool", 'Object.prototype.h asOwnProperty.call(#, #)', interceptedNames, name), core.bool); 132 let isIntercepted = Object.prototype.hasOwnProperty.call(interceptedNames, name);
133 if (isIntercepted) { 133 if (isIntercepted) {
134 receiver = interceptor; 134 receiver = interceptor;
135 if (_foreign_helper.JS('bool', '# === #', object, interceptor)) { 135 if (object === interceptor) {
136 interceptor = null; 136 interceptor = null;
137 } 137 }
138 } else { 138 } else {
139 interceptor = null; 139 interceptor = null;
140 } 140 }
141 let isCatchAll = false; 141 let isCatchAll = false;
142 let method = _foreign_helper.JS('var', '#[#]', receiver, name); 142 let method = receiver[name];
143 if (_foreign_helper.JS('bool', 'typeof # != "function"', method)) { 143 if (typeof method != "function") {
144 let baseName = _internal.Symbol.getName(dart.as(this.memberName, _intern al.Symbol)); 144 let baseName = _internal.Symbol.getName(dart.as(this.memberName, _intern al.Symbol));
145 method = _foreign_helper.JS('', '#[# + "*"]', receiver, baseName); 145 method = receiver[baseName + "*"];
146 if (method === null) { 146 if (method === null) {
147 interceptor = _interceptors.getInterceptor(object); 147 interceptor = _interceptors.getInterceptor(object);
148 method = _foreign_helper.JS('', '#[# + "*"]', interceptor, baseName); 148 method = interceptor[baseName + "*"];
149 if (method !== null) { 149 if (method !== null) {
150 isIntercepted = true; 150 isIntercepted = true;
151 receiver = interceptor; 151 receiver = interceptor;
152 } else { 152 } else {
153 interceptor = null; 153 interceptor = null;
154 } 154 }
155 } 155 }
156 isCatchAll = true; 156 isCatchAll = true;
157 } 157 }
158 if (_foreign_helper.JS('bool', 'typeof # == "function"', method)) { 158 if (typeof method == "function") {
159 if (isCatchAll) { 159 if (isCatchAll) {
160 return new CachedCatchAllInvocation(name, method, isIntercepted, dart. as(interceptor, _interceptors.Interceptor)); 160 return new CachedCatchAllInvocation(name, method, isIntercepted, dart. as(interceptor, _interceptors.Interceptor));
161 } else { 161 } else {
162 return new CachedInvocation(name, method, isIntercepted, dart.as(inter ceptor, _interceptors.Interceptor)); 162 return new CachedInvocation(name, method, isIntercepted, dart.as(inter ceptor, _interceptors.Interceptor));
163 } 163 }
164 } else { 164 } else {
165 return new CachedNoSuchMethodInvocation(interceptor); 165 return new CachedNoSuchMethodInvocation(interceptor);
166 } 166 }
167 } 167 }
168 static invokeFromMirror(invocation, victim) { 168 static invokeFromMirror(invocation, victim) {
(...skipping 15 matching lines...) Expand all
184 CachedInvocation(mangledName, jsFunction, isIntercepted, cachedInterceptor) { 184 CachedInvocation(mangledName, jsFunction, isIntercepted, cachedInterceptor) {
185 this.mangledName = mangledName; 185 this.mangledName = mangledName;
186 this.jsFunction = jsFunction; 186 this.jsFunction = jsFunction;
187 this.isIntercepted = isIntercepted; 187 this.isIntercepted = isIntercepted;
188 this.cachedInterceptor = cachedInterceptor; 188 this.cachedInterceptor = cachedInterceptor;
189 } 189 }
190 get isNoSuchMethod() { 190 get isNoSuchMethod() {
191 return false; 191 return false;
192 } 192 }
193 get isGetterStub() { 193 get isGetterStub() {
194 return dart.as(_foreign_helper.JS("bool", "!!#.$getterStub", this.jsFuncti on), core.bool); 194 return !!this.jsFunction.$getterStub;
195 } 195 }
196 invokeOn(victim, arguments) { 196 invokeOn(victim, arguments) {
197 let receiver = victim; 197 let receiver = victim;
198 if (!dart.notNull(this.isIntercepted)) { 198 if (!dart.notNull(this.isIntercepted)) {
199 if (!dart.is(arguments, _interceptors.JSArray)) 199 if (!dart.is(arguments, _interceptors.JSArray))
200 arguments = new core.List.from(arguments); 200 arguments = new core.List.from(arguments);
201 } else { 201 } else {
202 arguments = new List.from([victim]); 202 arguments = new List.from([victim]);
203 arguments.addAll(arguments); 203 arguments.addAll(arguments);
204 if (this.cachedInterceptor !== null) 204 if (this.cachedInterceptor !== null)
205 receiver = this.cachedInterceptor; 205 receiver = this.cachedInterceptor;
206 } 206 }
207 return _foreign_helper.JS("var", "#.apply(#, #)", this.jsFunction, receive r, arguments); 207 return this.jsFunction.apply(receiver, arguments);
208 } 208 }
209 } 209 }
210 class CachedCatchAllInvocation extends CachedInvocation { 210 class CachedCatchAllInvocation extends CachedInvocation {
211 CachedCatchAllInvocation(name, jsFunction, isIntercepted, cachedInterceptor) { 211 CachedCatchAllInvocation(name, jsFunction, isIntercepted, cachedInterceptor) {
212 this.info = new ReflectionInfo(jsFunction); 212 this.info = new ReflectionInfo(jsFunction);
213 super.CachedInvocation(name, jsFunction, isIntercepted, cachedInterceptor) ; 213 super.CachedInvocation(name, jsFunction, isIntercepted, cachedInterceptor) ;
214 } 214 }
215 get isGetterStub() { 215 get isGetterStub() {
216 return false; 216 return false;
217 } 217 }
(...skipping 21 matching lines...) Expand all
239 if (dart.notNull(this.info.areOptionalParametersNamed) && dart.notNull(pro videdArgumentCount > this.info.requiredParameterCount)) { 239 if (dart.notNull(this.info.areOptionalParametersNamed) && dart.notNull(pro videdArgumentCount > this.info.requiredParameterCount)) {
240 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${arguments.length} arguments.`); 240 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${arguments.length} arguments.`);
241 } else if (providedArgumentCount < this.info.requiredParameterCount) { 241 } else if (providedArgumentCount < this.info.requiredParameterCount) {
242 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too few).`); 242 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too few).`);
243 } else if (providedArgumentCount > fullParameterCount) { 243 } else if (providedArgumentCount > fullParameterCount) {
244 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too many).`); 244 throw new UnimplementedNoSuchMethodError(`Invocation of unstubbed method '${this.info.reflectionName}'` + ` with ${providedArgumentCount} arguments (too many).`);
245 } 245 }
246 for (let i = providedArgumentCount; i < fullParameterCount; i++) { 246 for (let i = providedArgumentCount; i < fullParameterCount; i++) {
247 arguments.add(getMetadata(this.info.defaultValue(i))); 247 arguments.add(getMetadata(this.info.defaultValue(i)));
248 } 248 }
249 return _foreign_helper.JS("var", "#.apply(#, #)", this.jsFunction, receive r, arguments); 249 return this.jsFunction.apply(receiver, arguments);
250 } 250 }
251 } 251 }
252 class CachedNoSuchMethodInvocation extends dart.Object { 252 class CachedNoSuchMethodInvocation extends dart.Object {
253 CachedNoSuchMethodInvocation(interceptor) { 253 CachedNoSuchMethodInvocation(interceptor) {
254 this.interceptor = interceptor; 254 this.interceptor = interceptor;
255 } 255 }
256 get isNoSuchMethod() { 256 get isNoSuchMethod() {
257 return true; 257 return true;
258 } 258 }
259 get isGetterStub() { 259 get isGetterStub() {
260 return false; 260 return false;
261 } 261 }
262 invokeOn(victim, invocation) { 262 invokeOn(victim, invocation) {
263 let receiver = this.interceptor === null ? victim : this.interceptor; 263 let receiver = this.interceptor === null ? victim : this.interceptor;
264 return dart.dinvoke(receiver, 'noSuchMethod', invocation); 264 return dart.dinvoke(receiver, 'noSuchMethod', invocation);
265 } 265 }
266 } 266 }
267 class ReflectionInfo extends dart.Object { 267 class ReflectionInfo extends dart.Object {
268 ReflectionInfo$internal(jsFunction, data, isAccessor, requiredParameterCount , optionalParameterCount, areOptionalParametersNamed, functionType) { 268 ReflectionInfo$internal(jsFunction, data, isAccessor, requiredParameterCount , optionalParameterCount, areOptionalParametersNamed, functionType) {
269 this.jsFunction = jsFunction; 269 this.jsFunction = jsFunction;
270 this.data = data; 270 this.data = data;
271 this.isAccessor = isAccessor; 271 this.isAccessor = isAccessor;
272 this.requiredParameterCount = requiredParameterCount; 272 this.requiredParameterCount = requiredParameterCount;
273 this.optionalParameterCount = optionalParameterCount; 273 this.optionalParameterCount = optionalParameterCount;
274 this.areOptionalParametersNamed = areOptionalParametersNamed; 274 this.areOptionalParametersNamed = areOptionalParametersNamed;
275 this.functionType = functionType; 275 this.functionType = functionType;
276 this.cachedSortedIndices = null; 276 this.cachedSortedIndices = null;
277 } 277 }
278 ReflectionInfo(jsFunction) { 278 ReflectionInfo(jsFunction) {
279 let data = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#.$reflec tionInfo', jsFunction), core.List); 279 let data = dart.as(jsFunction.$reflectionInfo, core.List);
280 if (data === null) 280 if (data === null)
281 return null; 281 return null;
282 data = _interceptors.JSArray.markFixedList(data); 282 data = _interceptors.JSArray.markFixedList(data);
283 let requiredParametersInfo = dart.as(_foreign_helper.JS('int', '#[#]', dat a, REQUIRED_PARAMETERS_INFO), core.int); 283 let requiredParametersInfo = data[REQUIRED_PARAMETERS_INFO];
284 let requiredParameterCount = dart.as(_foreign_helper.JS('int', '# >> 1', r equiredParametersInfo), core.int); 284 let requiredParameterCount = requiredParametersInfo >> 1;
285 let isAccessor = (requiredParametersInfo & 1) === 1; 285 let isAccessor = (requiredParametersInfo & 1) === 1;
286 let optionalParametersInfo = dart.as(_foreign_helper.JS('int', '#[#]', dat a, OPTIONAL_PARAMETERS_INFO), core.int); 286 let optionalParametersInfo = data[OPTIONAL_PARAMETERS_INFO];
287 let optionalParameterCount = dart.as(_foreign_helper.JS('int', '# >> 1', o ptionalParametersInfo), core.int); 287 let optionalParameterCount = optionalParametersInfo >> 1;
288 let areOptionalParametersNamed = (optionalParametersInfo & 1) === 1; 288 let areOptionalParametersNamed = (optionalParametersInfo & 1) === 1;
289 let functionType = _foreign_helper.JS('', '#[#]', data, FUNCTION_TYPE_INDE X); 289 let functionType = data[FUNCTION_TYPE_INDEX];
290 return new ReflectionInfo.internal(jsFunction, data, isAccessor, requiredP arameterCount, optionalParameterCount, areOptionalParametersNamed, functionType) ; 290 return new ReflectionInfo.internal(jsFunction, data, isAccessor, requiredP arameterCount, optionalParameterCount, areOptionalParametersNamed, functionType) ;
291 } 291 }
292 parameterName(parameter) { 292 parameterName(parameter) {
293 let metadataIndex = null; 293 let metadataIndex = null;
294 if (_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA')) { 294 if (_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA')) {
295 metadataIndex = dart.as(_foreign_helper.JS('int', '#[2 * # + # + #]', th is.data, parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.i nt); 295 metadataIndex = this.data[2 * parameter + this.optionalParameterCount + FIRST_DEFAULT_ARGUMENT];
296 } else { 296 } else {
297 metadataIndex = dart.as(_foreign_helper.JS('int', '#[# + # + #]', this.d ata, parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.int); 297 metadataIndex = this.data[parameter + this.optionalParameterCount + FIRS T_DEFAULT_ARGUMENT];
298 } 298 }
299 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded _names.METADATA, core.String)); 299 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded _names.METADATA, core.String));
300 return dart.as(_foreign_helper.JS('String', '#[#]', metadata, metadataInde x), core.String); 300 return metadata[metadataIndex];
301 } 301 }
302 parameterMetadataAnnotations(parameter) { 302 parameterMetadataAnnotations(parameter) {
303 if (!dart.notNull(_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA'))) { 303 if (!dart.notNull(_foreign_helper.JS_GET_FLAG('MUST_RETAIN_METADATA'))) {
304 throw new core.StateError('metadata has not been preserved'); 304 throw new core.StateError('metadata has not been preserved');
305 } else { 305 } else {
306 return dart.as(_foreign_helper.JS('', '#[2 * # + # + # + 1]', this.data, parameter, this.optionalParameterCount, FIRST_DEFAULT_ARGUMENT), core.List$(cor e.int)); 306 return dart.as(this.data[2 * parameter + this.optionalParameterCount + F IRST_DEFAULT_ARGUMENT + 1], core.List$(core.int));
307 } 307 }
308 } 308 }
309 defaultValue(parameter) { 309 defaultValue(parameter) {
310 if (parameter < this.requiredParameterCount) 310 if (parameter < this.requiredParameterCount)
311 return dart.as(null, core.int); 311 return dart.as(null, core.int);
312 return dart.as(_foreign_helper.JS('int', '#[# + # - #]', this.data, FIRST_ DEFAULT_ARGUMENT, parameter, this.requiredParameterCount), core.int); 312 return this.data[FIRST_DEFAULT_ARGUMENT + parameter - this.requiredParamet erCount];
313 } 313 }
314 defaultValueInOrder(parameter) { 314 defaultValueInOrder(parameter) {
315 if (parameter < this.requiredParameterCount) 315 if (parameter < this.requiredParameterCount)
316 return dart.as(null, core.int); 316 return dart.as(null, core.int);
317 if (dart.notNull(!dart.notNull(this.areOptionalParametersNamed)) || dart.n otNull(this.optionalParameterCount === 1)) { 317 if (dart.notNull(!dart.notNull(this.areOptionalParametersNamed)) || dart.n otNull(this.optionalParameterCount === 1)) {
318 return this.defaultValue(parameter); 318 return this.defaultValue(parameter);
319 } 319 }
320 let index = this.sortedIndex(parameter - this.requiredParameterCount); 320 let index = this.sortedIndex(parameter - this.requiredParameterCount);
321 return this.defaultValue(index); 321 return this.defaultValue(index);
322 } 322 }
(...skipping 18 matching lines...) Expand all
341 ((_) => { 341 ((_) => {
342 _.sort(); 342 _.sort();
343 return _; 343 return _;
344 }).bind(this)(positions.keys.toList()).forEach(((name) => { 344 }).bind(this)(positions.keys.toList()).forEach(((name) => {
345 this.cachedSortedIndices.set(index++, positions.get(name)); 345 this.cachedSortedIndices.set(index++, positions.get(name));
346 }).bind(this)); 346 }).bind(this));
347 } 347 }
348 return dart.as(this.cachedSortedIndices.get(unsortedIndex), core.int); 348 return dart.as(this.cachedSortedIndices.get(unsortedIndex), core.int);
349 } 349 }
350 computeFunctionRti(jsConstructor) { 350 computeFunctionRti(jsConstructor) {
351 if (_foreign_helper.JS('bool', 'typeof # == "number"', this.functionType)) { 351 if (typeof this.functionType == "number") {
352 return getMetadata(dart.as(this.functionType, core.int)); 352 return getMetadata(dart.as(this.functionType, core.int));
353 } else if (_foreign_helper.JS('bool', 'typeof # == "function"', this.funct ionType)) { 353 } else if (typeof this.functionType == "function") {
354 let fakeInstance = _foreign_helper.JS('', 'new #()', jsConstructor); 354 let fakeInstance = new jsConstructor();
355 setRuntimeTypeInfo(fakeInstance, _foreign_helper.JS('JSExtendableArray', '#["<>"]', fakeInstance)); 355 setRuntimeTypeInfo(fakeInstance, fakeInstance["<>"]);
356 return _foreign_helper.JS('=Object|Null', '#.apply({$receiver:#})', this .functionType, fakeInstance); 356 return this.functionType.apply({$receiver: fakeInstance});
357 } else { 357 } else {
358 throw new RuntimeError('Unexpected function type'); 358 throw new RuntimeError('Unexpected function type');
359 } 359 }
360 } 360 }
361 get reflectionName() { 361 get reflectionName() {
362 return dart.as(_foreign_helper.JS('String', '#.$reflectionName', this.jsFu nction), core.String); 362 return this.jsFunction.$reflectionName;
363 } 363 }
364 } 364 }
365 dart.defineNamedConstructor(ReflectionInfo, 'internal'); 365 dart.defineNamedConstructor(ReflectionInfo, 'internal');
366 ReflectionInfo.REQUIRED_PARAMETERS_INFO = 0; 366 ReflectionInfo.REQUIRED_PARAMETERS_INFO = 0;
367 ReflectionInfo.OPTIONAL_PARAMETERS_INFO = 1; 367 ReflectionInfo.OPTIONAL_PARAMETERS_INFO = 1;
368 ReflectionInfo.FUNCTION_TYPE_INDEX = 2; 368 ReflectionInfo.FUNCTION_TYPE_INDEX = 2;
369 ReflectionInfo.FIRST_DEFAULT_ARGUMENT = 3; 369 ReflectionInfo.FIRST_DEFAULT_ARGUMENT = 3;
370 // Function getMetadata: (int) → dynamic 370 // Function getMetadata: (int) → dynamic
371 function getMetadata(index) { 371 function getMetadata(index) {
372 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_n ames.METADATA, core.String)); 372 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_n ames.METADATA, core.String));
373 return _foreign_helper.JS('', '#[#]', metadata, index); 373 return metadata[index];
374 } 374 }
375 class Primitives extends dart.Object { 375 class Primitives extends dart.Object {
376 static initializeStatics(id) { 376 static initializeStatics(id) {
377 mirrorFunctionCacheName = `_${id}`; 377 mirrorFunctionCacheName = `_${id}`;
378 mirrorInvokeCacheName = `_${id}`; 378 mirrorInvokeCacheName = `_${id}`;
379 } 379 }
380 static objectHashCode(object) { 380 static objectHashCode(object) {
381 let hash = dart.as(_foreign_helper.JS('int|Null', '#.$identityHash', objec t), core.int); 381 let hash = dart.as(object.$identityHash, core.int);
382 if (hash === null) { 382 if (hash === null) {
383 hash = dart.as(_foreign_helper.JS('int', '(Math.random() * 0x3fffffff) | 0'), core.int); 383 hash = Math.random() * 0x3fffffff | 0;
384 _foreign_helper.JS('void', '#.$identityHash = #', object, hash); 384 object.$identityHash = hash;
385 } 385 }
386 return dart.as(_foreign_helper.JS('int', '#', hash), core.int); 386 return hash;
387 } 387 }
388 static _throwFormatException(string) { 388 static _throwFormatException(string) {
389 throw new core.FormatException(string); 389 throw new core.FormatException(string);
390 } 390 }
391 static parseInt(source, radix, handleError) { 391 static parseInt(source, radix, handleError) {
392 if (handleError === null) 392 if (handleError === null)
393 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented type (String) → int")); 393 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented type (String) → int"));
394 checkString(source); 394 checkString(source);
395 let match = _foreign_helper.JS('JSExtendableArray|Null', '/^\\s*[+-]?((0x[ a-f0-9]+)|(\\d+)|([a-z0-9]+))\\s*$/i.exec(#)', source); 395 let match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source) ;
396 let digitsIndex = 1; 396 let digitsIndex = 1;
397 let hexIndex = 2; 397 let hexIndex = 2;
398 let decimalIndex = 3; 398 let decimalIndex = 3;
399 let nonDecimalHexIndex = 4; 399 let nonDecimalHexIndex = 4;
400 if (radix === null) { 400 if (radix === null) {
401 radix = 10; 401 radix = 10;
402 if (match !== null) { 402 if (match !== null) {
403 if (dart.dindex(match, hexIndex) !== null) { 403 if (dart.dindex(match, hexIndex) !== null) {
404 return dart.as(_foreign_helper.JS('num', 'parseInt(#, 16)', source), core.int); 404 return dart.notNull(parseInt(source, 16));
405 } 405 }
406 if (dart.dindex(match, decimalIndex) !== null) { 406 if (dart.dindex(match, decimalIndex) !== null) {
407 return dart.as(_foreign_helper.JS('num', 'parseInt(#, 10)', source), core.int); 407 return dart.notNull(parseInt(source, 10));
408 } 408 }
409 return handleError(source); 409 return handleError(source);
410 } 410 }
411 } else { 411 } else {
412 if (!(typeof radix == number)) 412 if (!(typeof radix == number))
413 throw new core.ArgumentError("Radix is not an integer"); 413 throw new core.ArgumentError("Radix is not an integer");
414 if (dart.notNull(radix < 2) || dart.notNull(radix > 36)) { 414 if (dart.notNull(radix < 2) || dart.notNull(radix > 36)) {
415 throw new core.RangeError(`Radix ${radix} not in range 2..36`); 415 throw new core.RangeError(`Radix ${radix} not in range 2..36`);
416 } 416 }
417 if (match !== null) { 417 if (match !== null) {
418 if (dart.notNull(radix === 10) && dart.notNull(dart.dindex(match, deci malIndex) !== null)) { 418 if (dart.notNull(radix === 10) && dart.notNull(dart.dindex(match, deci malIndex) !== null)) {
419 return dart.as(_foreign_helper.JS('num', 'parseInt(#, 10)', source), core.int); 419 return dart.notNull(parseInt(source, 10));
420 } 420 }
421 if (dart.notNull(radix < 10) || dart.notNull(dart.dindex(match, decima lIndex) === null)) { 421 if (dart.notNull(radix < 10) || dart.notNull(dart.dindex(match, decima lIndex) === null)) {
422 let maxCharCode = null; 422 let maxCharCode = null;
423 if (radix <= 10) { 423 if (radix <= 10) {
424 maxCharCode = 48 + radix - 1; 424 maxCharCode = 48 + radix - 1;
425 } else { 425 } else {
426 maxCharCode = 97 + radix - 10 - 1; 426 maxCharCode = 97 + radix - 10 - 1;
427 } 427 }
428 let digitsPart = dart.as(dart.dindex(match, digitsIndex), core.Strin g); 428 let digitsPart = dart.as(dart.dindex(match, digitsIndex), core.Strin g);
429 for (let i = 0; i < digitsPart.length; i++) { 429 for (let i = 0; i < digitsPart.length; i++) {
430 let characterCode = digitsPart.codeUnitAt(0) | 32; 430 let characterCode = digitsPart.codeUnitAt(0) | 32;
431 if (digitsPart.codeUnitAt(i) > maxCharCode) { 431 if (digitsPart.codeUnitAt(i) > maxCharCode) {
432 return handleError(source); 432 return handleError(source);
433 } 433 }
434 } 434 }
435 } 435 }
436 } 436 }
437 } 437 }
438 if (match === null) 438 if (match === null)
439 return handleError(source); 439 return handleError(source);
440 return dart.as(_foreign_helper.JS('num', 'parseInt(#, #)', source, radix), core.int); 440 return dart.notNull(parseInt(source, radix));
441 } 441 }
442 static parseDouble(source, handleError) { 442 static parseDouble(source, handleError) {
443 checkString(source); 443 checkString(source);
444 if (handleError === null) 444 if (handleError === null)
445 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented type (String) → double")); 445 handleError = dart.as(_throwFormatException, dart.throw_("Unimplemented type (String) → double"));
446 if (dart.throw_("Unimplemented PrefixExpression: !JS('bool', r'/^\\s*[+-]? (?:Infinity|NaN|' r'(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:[eE][+-]?\\d+)?)\\s*$/.test(# )', source)")) { 446 if (!dart.notNull(/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE] [+-]?\d+)?)\s*$/.test(source))) {
447 return handleError(source); 447 return handleError(source);
448 } 448 }
449 let result = _foreign_helper.JS('num', 'parseFloat(#)', source); 449 let result = parseFloat(source);
450 if (dart.dload(result, 'isNaN')) { 450 if (result.isNaN) {
451 let trimmed = source.trim(); 451 let trimmed = source.trim();
452 if (dart.notNull(dart.notNull(dart.equals(trimmed, 'NaN')) || dart.notNu ll(dart.equals(trimmed, '+NaN'))) || dart.notNull(dart.equals(trimmed, '-NaN'))) { 452 if (dart.notNull(dart.notNull(dart.equals(trimmed, 'NaN')) || dart.notNu ll(dart.equals(trimmed, '+NaN'))) || dart.notNull(dart.equals(trimmed, '-NaN'))) {
453 return dart.as(result, core.double); 453 return dart.notNull(result);
454 } 454 }
455 return handleError(source); 455 return handleError(source);
456 } 456 }
457 return dart.as(result, core.double); 457 return dart.notNull(result);
458 } 458 }
459 static formatType(className, typeArguments) { 459 static formatType(className, typeArguments) {
460 return _js_names.unmangleAllIdentifiersIfPreservedAnyways(`${className}${j oinArguments(typeArguments, 0)}`); 460 return _js_names.unmangleAllIdentifiersIfPreservedAnyways(`${className}${j oinArguments(typeArguments, 0)}`);
461 } 461 }
462 static objectTypeName(object) { 462 static objectTypeName(object) {
463 let name = constructorNameFallback(_interceptors.getInterceptor(object)); 463 let name = constructorNameFallback(_interceptors.getInterceptor(object));
464 if (dart.equals(name, 'Object')) { 464 if (dart.equals(name, 'Object')) {
465 let decompiled = _foreign_helper.JS('var', '#.match(/^\\s*function\\s*(\ \S*)\\s*\\(/)[1]', _foreign_helper.JS('var', 'String(#.constructor)', object)); 465 let decompiled = String(object.constructor).match(/^\s*function\s*(\S*)\ s*\(/)[1];
466 if (typeof decompiled == string) 466 if (typeof decompiled == string)
467 if (_foreign_helper.JS('bool', '/^\\w+$/.test(#)', decompiled)) 467 if (/^\w+$/.test(decompiled))
468 name = dart.as(decompiled, core.String); 468 name = dart.as(decompiled, core.String);
469 } 469 }
470 if (dart.notNull(name.length > 1) && dart.notNull(core.identical(name.code UnitAt(0), DOLLAR_CHAR_VALUE))) { 470 if (dart.notNull(name.length > 1) && dart.notNull(core.identical(name.code UnitAt(0), DOLLAR_CHAR_VALUE))) {
471 name = name.substring(1); 471 name = name.substring(1);
472 } 472 }
473 return formatType(name, dart.as(getRuntimeTypeInfo(object), core.List)); 473 return formatType(name, dart.as(getRuntimeTypeInfo(object), core.List));
474 } 474 }
475 static objectToString(object) { 475 static objectToString(object) {
476 let name = objectTypeName(object); 476 let name = objectTypeName(object);
477 return `Instance of '${name}'`; 477 return `Instance of '${name}'`;
478 } 478 }
479 static dateNow() { 479 static dateNow() {
480 return dart.as(_foreign_helper.JS('int', 'Date.now()'), core.num); 480 return Date.now();
481 } 481 }
482 static initTicker() { 482 static initTicker() {
483 if (timerFrequency !== null) 483 if (timerFrequency !== null)
484 return; 484 return;
485 timerFrequency = 1000; 485 timerFrequency = 1000;
486 timerTicks = dateNow; 486 timerTicks = dateNow;
487 if (_foreign_helper.JS('bool', 'typeof window == "undefined"')) 487 if (typeof window == "undefined")
488 return; 488 return;
489 let window = _foreign_helper.JS('var', 'window'); 489 let window = window;
490 if (window === null) 490 if (window === null)
491 return; 491 return;
492 let performance = _foreign_helper.JS('var', '#.performance', window); 492 let performance = window.performance;
493 if (performance === null) 493 if (performance === null)
494 return; 494 return;
495 if (_foreign_helper.JS('bool', 'typeof #.now != "function"', performance)) 495 if (typeof performance.now != "function")
496 return; 496 return;
497 timerFrequency = 1000000; 497 timerFrequency = 1000000;
498 timerTicks = (() => 1000['*'](_foreign_helper.JS('num', '#.now()', perform ance)).floor()).bind(this); 498 timerTicks = (() => (1000 * dart.notNull(performance.now())).floor()).bind (this);
499 } 499 }
500 static get isD8() { 500 static get isD8() {
501 return dart.as(_foreign_helper.JS('bool', 'typeof version == "function"' + ' && typeof os == "object" && "system" in os'), core.bool); 501 return typeof version == "function" && typeof os == "object" && "system" i n os;
502 } 502 }
503 static get isJsshell() { 503 static get isJsshell() {
504 return dart.as(_foreign_helper.JS('bool', 'typeof version == "function" && typeof system == "function"'), core.bool); 504 return typeof version == "function" && typeof system == "function";
505 } 505 }
506 static currentUri() { 506 static currentUri() {
507 requiresPreamble(); 507 requiresPreamble();
508 if (_foreign_helper.JS('bool', '!!self.location')) { 508 if (!!self.location) {
509 return dart.as(_foreign_helper.JS('String', 'self.location.href'), core. String); 509 return self.location.href;
510 } 510 }
511 return null; 511 return null;
512 } 512 }
513 static _fromCharCodeApply(array) { 513 static _fromCharCodeApply(array) {
514 let result = ""; 514 let result = "";
515 let kMaxApply = 500; 515 let kMaxApply = 500;
516 let end = array.length; 516 let end = array.length;
517 for (let i = 0; i < end; i = kMaxApply) { 517 for (let i = 0; i < end; i = kMaxApply) {
518 let subarray = null; 518 let subarray = null;
519 if (end <= kMaxApply) { 519 if (end <= kMaxApply) {
520 subarray = array; 520 subarray = array;
521 } else { 521 } else {
522 subarray = _foreign_helper.JS('JSExtendableArray', '#.slice(#, #)', ar ray, i, i + kMaxApply < end ? i + kMaxApply : end); 522 subarray = array.slice(i, i + kMaxApply < end ? i + kMaxApply : end);
523 } 523 }
524 result = dart.as(_foreign_helper.JS('String', '# + String.fromCharCode.a pply(#, #)', result, null, subarray), core.String); 524 result = result + String.fromCharCode.apply(null, subarray);
525 } 525 }
526 return result; 526 return result;
527 } 527 }
528 static stringFromCodePoints(codePoints) { 528 static stringFromCodePoints(codePoints) {
529 let a = new List.from([]); 529 let a = new List.from([]);
530 for (let i of codePoints) { 530 for (let i of codePoints) {
531 if (!(typeof i == number)) 531 if (!(typeof i == number))
532 throw new core.ArgumentError(i); 532 throw new core.ArgumentError(i);
533 if (dart.dbinary(i, '<=', 65535)) { 533 if (dart.dbinary(i, '<=', 65535)) {
534 a.add(dart.as(i, core.int)); 534 a.add(dart.as(i, core.int));
(...skipping 13 matching lines...) Expand all
548 if (dart.dbinary(i, '<', 0)) 548 if (dart.dbinary(i, '<', 0))
549 throw new core.ArgumentError(i); 549 throw new core.ArgumentError(i);
550 if (dart.dbinary(i, '>', 65535)) 550 if (dart.dbinary(i, '>', 65535))
551 return stringFromCodePoints(charCodes); 551 return stringFromCodePoints(charCodes);
552 } 552 }
553 return _fromCharCodeApply(dart.as(charCodes, core.List$(core.int))); 553 return _fromCharCodeApply(dart.as(charCodes, core.List$(core.int)));
554 } 554 }
555 static stringFromCharCode(charCode) { 555 static stringFromCharCode(charCode) {
556 if (0['<='](charCode)) { 556 if (0['<='](charCode)) {
557 if (dart.dbinary(charCode, '<=', 65535)) { 557 if (dart.dbinary(charCode, '<=', 65535)) {
558 return dart.as(_foreign_helper.JS('String', 'String.fromCharCode(#)', charCode), core.String); 558 return String.fromCharCode(charCode);
559 } 559 }
560 if (dart.dbinary(charCode, '<=', 1114111)) { 560 if (dart.dbinary(charCode, '<=', 1114111)) {
561 let bits = dart.dbinary(charCode, '-', 65536); 561 let bits = dart.dbinary(charCode, '-', 65536);
562 let low = 56320['|'](dart.dbinary(bits, '&', 1023)); 562 let low = 56320['|'](dart.dbinary(bits, '&', 1023));
563 let high = 55296['|'](dart.dbinary(bits, '>>', 10)); 563 let high = 55296['|'](dart.dbinary(bits, '>>', 10));
564 return dart.as(_foreign_helper.JS('String', 'String.fromCharCode(#, #) ', high, low), core.String); 564 return String.fromCharCode(high, low);
565 } 565 }
566 } 566 }
567 throw new core.RangeError.range(dart.as(charCode, core.num), 0, 1114111); 567 throw new core.RangeError.range(dart.as(charCode, core.num), 0, 1114111);
568 } 568 }
569 static stringConcatUnchecked(string1, string2) { 569 static stringConcatUnchecked(string1, string2) {
570 return _foreign_helper.JS_STRING_CONCAT(string1, string2); 570 return _foreign_helper.JS_STRING_CONCAT(string1, string2);
571 } 571 }
572 static flattenString(str) { 572 static flattenString(str) {
573 return dart.as(_foreign_helper.JS('String', "#.charCodeAt(0) == 0 ? # : #" , str, str, str), core.String); 573 return str.charCodeAt(0) == 0 ? str : str;
574 } 574 }
575 static getTimeZoneName(receiver) { 575 static getTimeZoneName(receiver) {
576 let d = lazyAsJsDate(receiver); 576 let d = lazyAsJsDate(receiver);
577 let match = dart.as(_foreign_helper.JS('JSArray|Null', '/\\((.*)\\)/.exec( #.toString())', d), core.List); 577 let match = dart.as(/\((.*)\)/.exec(d.toString()), core.List);
578 if (match !== null) 578 if (match !== null)
579 return dart.as(match.get(1), core.String); 579 return dart.as(match.get(1), core.String);
580 match = dart.as(_foreign_helper.JS('JSArray|Null', '/^[A-Z,a-z]{3}\\s' + ' [A-Z,a-z]{3}\\s\\d+\\s' + '\\d{2}:\\d{2}:\\d{2}\\s' + '([A-Z]{3,5})\\s' + '\\d{4 }$/' + '.exec(#.toString())', d), core.List); 580 match = dart.as(/^[A-Z,a-z]{3}\s[A-Z,a-z]{3}\s\d+\s\d{2}:\d{2}:\d{2}\s([A- Z]{3,5})\s\d{4}$/.exec(d.toString()), core.List);
581 if (match !== null) 581 if (match !== null)
582 return dart.as(match.get(1), core.String); 582 return dart.as(match.get(1), core.String);
583 match = dart.as(_foreign_helper.JS('JSArray|Null', '/(?:GMT|UTC)[+-]\\d{4} /.exec(#.toString())', d), core.List); 583 match = dart.as(/(?:GMT|UTC)[+-]\d{4}/.exec(d.toString()), core.List);
584 if (match !== null) 584 if (match !== null)
585 return dart.as(match.get(0), core.String); 585 return dart.as(match.get(0), core.String);
586 return ""; 586 return "";
587 } 587 }
588 static getTimeZoneOffsetInMinutes(receiver) { 588 static getTimeZoneOffsetInMinutes(receiver) {
589 return dart.as(dart.throw_("Unimplemented PrefixExpression: -JS('int', r'# .getTimezoneOffset()', lazyAsJsDate(receiver))"), core.int); 589 return -lazyAsJsDate(receiver).getTimezoneOffset();
590 } 590 }
591 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, m illiseconds, isUtc) { 591 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, m illiseconds, isUtc) {
592 let MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; 592 let MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
593 checkInt(years); 593 checkInt(years);
594 checkInt(month); 594 checkInt(month);
595 checkInt(day); 595 checkInt(day);
596 checkInt(hours); 596 checkInt(hours);
597 checkInt(minutes); 597 checkInt(minutes);
598 checkInt(seconds); 598 checkInt(seconds);
599 checkInt(milliseconds); 599 checkInt(milliseconds);
600 checkBool(isUtc); 600 checkBool(isUtc);
601 let jsMonth = dart.dbinary(month, '-', 1); 601 let jsMonth = dart.dbinary(month, '-', 1);
602 let value = null; 602 let value = null;
603 if (isUtc) { 603 if (isUtc) {
604 value = _foreign_helper.JS('num', 'Date.UTC(#, #, #, #, #, #, #)', years , jsMonth, day, hours, minutes, seconds, milliseconds); 604 value = Date.UTC(years, jsMonth, day, hours, minutes, seconds, milliseco nds);
605 } else { 605 } else {
606 value = _foreign_helper.JS('num', 'new Date(#, #, #, #, #, #, #).valueOf ()', years, jsMonth, day, hours, minutes, seconds, milliseconds); 606 value = new Date(years, jsMonth, day, hours, minutes, seconds, milliseco nds).valueOf();
607 } 607 }
608 if (core.bool['||'](dart.dbinary(dart.dload(value, 'isNaN'), '||', dart.db inary(value, '<', -MAX_MILLISECONDS_SINCE_EPOCH)), dart.dbinary(value, '>', MAX_ MILLISECONDS_SINCE_EPOCH))) { 608 if (core.bool['||'](dart.dbinary(dart.dload(value, 'isNaN'), '||', dart.db inary(value, '<', -MAX_MILLISECONDS_SINCE_EPOCH)), dart.dbinary(value, '>', MAX_ MILLISECONDS_SINCE_EPOCH))) {
609 return null; 609 return null;
610 } 610 }
611 if (dart.dbinary(dart.dbinary(years, '<=', 0), '||', dart.dbinary(years, ' <', 100))) 611 if (dart.dbinary(dart.dbinary(years, '<=', 0), '||', dart.dbinary(years, ' <', 100)))
612 return patchUpY2K(value, years, isUtc); 612 return patchUpY2K(value, years, isUtc);
613 return value; 613 return value;
614 } 614 }
615 static patchUpY2K(value, years, isUtc) { 615 static patchUpY2K(value, years, isUtc) {
616 let date = _foreign_helper.JS('', 'new Date(#)', value); 616 let date = new Date(value);
617 if (isUtc) { 617 if (isUtc) {
618 _foreign_helper.JS('num', '#.setUTCFullYear(#)', date, years); 618 date.setUTCFullYear(years);
619 } else { 619 } else {
620 _foreign_helper.JS('num', '#.setFullYear(#)', date, years); 620 date.setFullYear(years);
621 } 621 }
622 return _foreign_helper.JS('num', '#.valueOf()', date); 622 return date.valueOf();
623 } 623 }
624 static lazyAsJsDate(receiver) { 624 static lazyAsJsDate(receiver) {
625 if (_foreign_helper.JS('bool', '#.date === (void 0)', receiver)) { 625 if (receiver.date === void 0) {
626 _foreign_helper.JS('void', '#.date = new Date(#)', receiver, dart.dload( receiver, 'millisecondsSinceEpoch')); 626 receiver.date = new Date(dart.dload(receiver, 'millisecondsSinceEpoch')) ;
627 } 627 }
628 return _foreign_helper.JS('var', '#.date', receiver); 628 return receiver.date;
629 } 629 }
630 static getYear(receiver) { 630 static getYear(receiver) {
631 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CFullYear() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getFu llYear() + 0)', lazyAsJsDate(receiver)); 631 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCFullYe ar() + 0 : lazyAsJsDate(receiver).getFullYear() + 0;
632 } 632 }
633 static getMonth(receiver) { 633 static getMonth(receiver) {
634 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '#.getUTC Month() + 1', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '#.getMonth() + 1', lazyAsJsDate(receiver)); 634 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMonth( ) + 1 : lazyAsJsDate(receiver).getMonth() + 1;
635 } 635 }
636 static getDay(receiver) { 636 static getDay(receiver) {
637 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CDate() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getDate() + 0)', lazyAsJsDate(receiver)); 637 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCDate() + 0 : lazyAsJsDate(receiver).getDate() + 0;
638 } 638 }
639 static getHours(receiver) { 639 static getHours(receiver) {
640 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CHours() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getHours () + 0)', lazyAsJsDate(receiver)); 640 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCHours( ) + 0 : lazyAsJsDate(receiver).getHours() + 0;
641 } 641 }
642 static getMinutes(receiver) { 642 static getMinutes(receiver) {
643 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CMinutes() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getMin utes() + 0)', lazyAsJsDate(receiver)); 643 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMinute s() + 0 : lazyAsJsDate(receiver).getMinutes() + 0;
644 } 644 }
645 static getSeconds(receiver) { 645 static getSeconds(receiver) {
646 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CSeconds() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.getSec onds() + 0)', lazyAsJsDate(receiver)); 646 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCSecond s() + 0 : lazyAsJsDate(receiver).getSeconds() + 0;
647 } 647 }
648 static getMilliseconds(receiver) { 648 static getMilliseconds(receiver) {
649 return dart.dload(receiver, 'isUtc') ? _foreign_helper.JS('int', '(#.getUT CMilliseconds() + 0)', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', '(#.g etMilliseconds() + 0)', lazyAsJsDate(receiver)); 649 return dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUTCMillis econds() + 0 : lazyAsJsDate(receiver).getMilliseconds() + 0;
650 } 650 }
651 static getWeekday(receiver) { 651 static getWeekday(receiver) {
652 let weekday = dart.as(dart.dload(receiver, 'isUtc') ? _foreign_helper.JS(' int', '#.getUTCDay() + 0', lazyAsJsDate(receiver)) : _foreign_helper.JS('int', ' #.getDay() + 0', lazyAsJsDate(receiver)), core.int); 652 let weekday = dart.dload(receiver, 'isUtc') ? lazyAsJsDate(receiver).getUT CDay() + 0 : lazyAsJsDate(receiver).getDay() + 0;
653 return (weekday + 6) % 7 + 1; 653 return (weekday + 6) % 7 + 1;
654 } 654 }
655 static valueFromDateString(str) { 655 static valueFromDateString(str) {
656 if (!(typeof str == string)) 656 if (!(typeof str == string))
657 throw new core.ArgumentError(str); 657 throw new core.ArgumentError(str);
658 let value = _foreign_helper.JS('num', 'Date.parse(#)', str); 658 let value = Date.parse(str);
659 if (dart.dload(value, 'isNaN')) 659 if (value.isNaN)
660 throw new core.ArgumentError(str); 660 throw new core.ArgumentError(str);
661 return value; 661 return value;
662 } 662 }
663 static getProperty(object, key) { 663 static getProperty(object, key) {
664 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart .notNull(typeof object == string)) { 664 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart .notNull(typeof object == string)) {
665 throw new core.ArgumentError(object); 665 throw new core.ArgumentError(object);
666 } 666 }
667 return _foreign_helper.JS('var', '#[#]', object, key); 667 return object[key];
668 } 668 }
669 static setProperty(object, key, value) { 669 static setProperty(object, key, value) {
670 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart .notNull(typeof object == string)) { 670 if (dart.notNull(dart.notNull(dart.notNull(object === null) || dart.notNul l(typeof object == boolean)) || dart.notNull(dart.is(object, core.num))) || dart .notNull(typeof object == string)) {
671 throw new core.ArgumentError(object); 671 throw new core.ArgumentError(object);
672 } 672 }
673 _foreign_helper.JS('void', '#[#] = #', object, key, value); 673 object[key] = value;
674 } 674 }
675 static functionNoSuchMethod(function, positionalArguments, namedArguments) { 675 static functionNoSuchMethod(function, positionalArguments, namedArguments) {
676 let argumentCount = 0; 676 let argumentCount = 0;
677 let arguments = new List.from([]); 677 let arguments = new List.from([]);
678 let namedArgumentList = new List.from([]); 678 let namedArgumentList = new List.from([]);
679 if (positionalArguments !== null) { 679 if (positionalArguments !== null) {
680 argumentCount = positionalArguments.length; 680 argumentCount = positionalArguments.length;
681 arguments.addAll(positionalArguments); 681 arguments.addAll(positionalArguments);
682 } 682 }
683 let names = ''; 683 let names = '';
684 if (dart.notNull(namedArguments !== null) && dart.notNull(!dart.notNull(na medArguments.isEmpty))) { 684 if (dart.notNull(namedArguments !== null) && dart.notNull(!dart.notNull(na medArguments.isEmpty))) {
685 namedArguments.forEach(((name, argument) => { 685 namedArguments.forEach(((name, argument) => {
686 names = `${names}$${name}`; 686 names = `${names}$${name}`;
687 namedArgumentList.add(name); 687 namedArgumentList.add(name);
688 arguments.add(argument); 688 arguments.add(argument);
689 argumentCount++; 689 argumentCount++;
690 }).bind(this)); 690 }).bind(this));
691 } 691 }
692 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}${names}`; 692 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}${names}`;
693 return dart.dinvoke(function, 'noSuchMethod', createUnmangledInvocationMir ror(dart.throw_("Unimplemented SymbolLiteral: #call"), selectorName, JSInvocatio nMirror.METHOD, arguments, namedArgumentList)); 693 return dart.dinvoke(function, 'noSuchMethod', createUnmangledInvocationMir ror(dart.throw_("Unimplemented SymbolLiteral: #call"), selectorName, JSInvocatio nMirror.METHOD, arguments, namedArgumentList));
694 } 694 }
695 static applyFunction(function, positionalArguments, namedArguments) { 695 static applyFunction(function, positionalArguments, namedArguments) {
696 return namedArguments === null ? applyFunctionWithPositionalArguments(func tion, positionalArguments) : applyFunctionWithNamedArguments(function, positiona lArguments, namedArguments); 696 return namedArguments === null ? applyFunctionWithPositionalArguments(func tion, positionalArguments) : applyFunctionWithNamedArguments(function, positiona lArguments, namedArguments);
697 } 697 }
698 static applyFunctionWithPositionalArguments(function, positionalArguments) { 698 static applyFunctionWithPositionalArguments(function, positionalArguments) {
699 let argumentCount = 0; 699 let argumentCount = 0;
700 let arguments = null; 700 let arguments = null;
701 if (positionalArguments !== null) { 701 if (positionalArguments !== null) {
702 if (_foreign_helper.JS('bool', '# instanceof Array', positionalArguments )) { 702 if (positionalArguments instanceof Array) {
703 arguments = positionalArguments; 703 arguments = positionalArguments;
704 } else { 704 } else {
705 arguments = new core.List.from(positionalArguments); 705 arguments = new core.List.from(positionalArguments);
706 } 706 }
707 argumentCount = dart.as(_foreign_helper.JS('int', '#.length', arguments) , core.int); 707 argumentCount = arguments.length;
708 } else { 708 } else {
709 arguments = new List.from([]); 709 arguments = new List.from([]);
710 } 710 }
711 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}`; 711 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}`;
712 let jsFunction = _foreign_helper.JS('var', '#[#]', function, selectorName) ; 712 let jsFunction = function[selectorName];
713 if (jsFunction === null) { 713 if (jsFunction === null) {
714 return functionNoSuchMethod(function, positionalArguments, null); 714 return functionNoSuchMethod(function, positionalArguments, null);
715 } 715 }
716 return _foreign_helper.JS('var', '#.apply(#, #)', jsFunction, function, ar guments); 716 return jsFunction.apply(function, arguments);
717 } 717 }
718 static applyFunctionWithNamedArguments(function, positionalArguments, namedA rguments) { 718 static applyFunctionWithNamedArguments(function, positionalArguments, namedA rguments) {
719 if (namedArguments.isEmpty) { 719 if (namedArguments.isEmpty) {
720 return applyFunctionWithPositionalArguments(function, positionalArgument s); 720 return applyFunctionWithPositionalArguments(function, positionalArgument s);
721 } 721 }
722 let interceptor = _interceptors.getInterceptor(function); 722 let interceptor = _interceptors.getInterceptor(function);
723 let jsFunction = _foreign_helper.JS('', '#["call*"]', interceptor); 723 let jsFunction = interceptor["call*"];
724 if (jsFunction === null) { 724 if (jsFunction === null) {
725 return functionNoSuchMethod(function, positionalArguments, namedArgument s); 725 return functionNoSuchMethod(function, positionalArguments, namedArgument s);
726 } 726 }
727 let info = new ReflectionInfo(jsFunction); 727 let info = new ReflectionInfo(jsFunction);
728 if (dart.notNull(info === null) || dart.notNull(!dart.notNull(info.areOpti onalParametersNamed))) { 728 if (dart.notNull(info === null) || dart.notNull(!dart.notNull(info.areOpti onalParametersNamed))) {
729 return functionNoSuchMethod(function, positionalArguments, namedArgument s); 729 return functionNoSuchMethod(function, positionalArguments, namedArgument s);
730 } 730 }
731 if (positionalArguments !== null) { 731 if (positionalArguments !== null) {
732 positionalArguments = new core.List.from(positionalArguments); 732 positionalArguments = new core.List.from(positionalArguments);
733 } else { 733 } else {
(...skipping 15 matching lines...) Expand all
749 if (defaultArguments.containsKey(parameter)) { 749 if (defaultArguments.containsKey(parameter)) {
750 defaultArguments.set(parameter, value); 750 defaultArguments.set(parameter, value);
751 } else { 751 } else {
752 bad = true; 752 bad = true;
753 } 753 }
754 }).bind(this)); 754 }).bind(this));
755 if (bad) { 755 if (bad) {
756 return functionNoSuchMethod(function, positionalArguments, namedArgument s); 756 return functionNoSuchMethod(function, positionalArguments, namedArgument s);
757 } 757 }
758 positionalArguments.addAll(defaultArguments.values); 758 positionalArguments.addAll(defaultArguments.values);
759 return _foreign_helper.JS('', '#.apply(#, #)', jsFunction, function, posit ionalArguments); 759 return jsFunction.apply(function, positionalArguments);
760 } 760 }
761 static _mangledNameMatchesType(mangledName, type) { 761 static _mangledNameMatchesType(mangledName, type) {
762 return _foreign_helper.JS('bool', '# == #', mangledName, type._typeName); 762 return mangledName == type._typeName;
763 } 763 }
764 static identicalImplementation(a, b) { 764 static identicalImplementation(a, b) {
765 return dart.as(_foreign_helper.JS('bool', '# == null', a) ? _foreign_helpe r.JS('bool', '# == null', b) : _foreign_helper.JS('bool', '# === #', a, b), core .bool); 765 return a == null ? b == null : a === b;
766 } 766 }
767 static extractStackTrace(error) { 767 static extractStackTrace(error) {
768 return getTraceFromException(_foreign_helper.JS('', '#.$thrownJsError', er ror)); 768 return getTraceFromException(error.$thrownJsError);
769 } 769 }
770 } 770 }
771 Primitives.mirrorFunctionCacheName = '$cachedFunction'; 771 Primitives.mirrorFunctionCacheName = '$cachedFunction';
772 Primitives.mirrorInvokeCacheName = '$cachedInvocation'; 772 Primitives.mirrorInvokeCacheName = '$cachedInvocation';
773 Primitives.DOLLAR_CHAR_VALUE = 36; 773 Primitives.DOLLAR_CHAR_VALUE = 36;
774 Primitives.timerFrequency = null; 774 Primitives.timerFrequency = null;
775 Primitives.timerTicks = null; 775 Primitives.timerTicks = null;
776 class JsCache extends dart.Object { 776 class JsCache extends dart.Object {
777 static allocate() { 777 static allocate() {
778 let result = _foreign_helper.JS('=Object', 'Object.create(null)'); 778 let result = Object.create(null);
779 _foreign_helper.JS('void', '#.x=0', result); 779 result.x = 0;
780 _foreign_helper.JS('void', 'delete #.x', result); 780 delete result.x;
781 return result; 781 return result;
782 } 782 }
783 static fetch(cache, key) { 783 static fetch(cache, key) {
784 return _foreign_helper.JS('', '#[#]', cache, key); 784 return cache[key];
785 } 785 }
786 static update(cache, key, value) { 786 static update(cache, key, value) {
787 _foreign_helper.JS('void', '#[#] = #', cache, key, value); 787 cache[key] = value;
788 } 788 }
789 } 789 }
790 // Function iae: (dynamic) → dynamic 790 // Function iae: (dynamic) → dynamic
791 function iae(argument) { 791 function iae(argument) {
792 throw new core.ArgumentError(argument); 792 throw new core.ArgumentError(argument);
793 } 793 }
794 // Function ioore: (dynamic, dynamic) → dynamic 794 // Function ioore: (dynamic, dynamic) → dynamic
795 function ioore(receiver, index) { 795 function ioore(receiver, index) {
796 if (receiver === null) 796 if (receiver === null)
797 dart.dload(receiver, 'length'); 797 dart.dload(receiver, 'length');
798 if (!(typeof index == number)) 798 if (!(typeof index == number))
799 iae(index); 799 iae(index);
800 throw new core.RangeError.value(dart.as(index, core.num)); 800 throw new core.RangeError.value(dart.as(index, core.num));
801 } 801 }
802 // Function stringLastIndexOfUnchecked: (dynamic, dynamic, dynamic) → dynamic 802 // Function stringLastIndexOfUnchecked: (dynamic, dynamic, dynamic) → dynamic
803 function stringLastIndexOfUnchecked(receiver, element, start) { 803 function stringLastIndexOfUnchecked(receiver, element, start) {
804 return _foreign_helper.JS('int', '#.lastIndexOf(#, #)', receiver, element, s tart); 804 return receiver.lastIndexOf(element, start);
805 } 805 }
806 // Function checkNull: (dynamic) → dynamic 806 // Function checkNull: (dynamic) → dynamic
807 function checkNull(object) { 807 function checkNull(object) {
808 if (object === null) 808 if (object === null)
809 throw new core.ArgumentError(null); 809 throw new core.ArgumentError(null);
810 return object; 810 return object;
811 } 811 }
812 // Function checkNum: (dynamic) → dynamic 812 // Function checkNum: (dynamic) → dynamic
813 function checkNum(value) { 813 function checkNum(value) {
814 if (!dart.is(value, core.num)) { 814 if (!dart.is(value, core.num)) {
(...skipping 19 matching lines...) Expand all
834 function checkString(value) { 834 function checkString(value) {
835 if (!(typeof value == string)) { 835 if (!(typeof value == string)) {
836 throw new core.ArgumentError(value); 836 throw new core.ArgumentError(value);
837 } 837 }
838 return value; 838 return value;
839 } 839 }
840 // Function wrapException: (dynamic) → dynamic 840 // Function wrapException: (dynamic) → dynamic
841 function wrapException(ex) { 841 function wrapException(ex) {
842 if (ex === null) 842 if (ex === null)
843 ex = new core.NullThrownError(); 843 ex = new core.NullThrownError();
844 let wrapper = _foreign_helper.JS('', 'new Error()'); 844 let wrapper = new Error();
845 _foreign_helper.JS('void', '#.dartException = #', wrapper, ex); 845 wrapper.dartException = ex;
846 if (_foreign_helper.JS('bool', '"defineProperty" in Object')) { 846 if ("defineProperty" in Object) {
847 _foreign_helper.JS('void', 'Object.defineProperty(#, "message", { get: # } )', wrapper, _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper)); 847 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU RE_TO_JS(toStringWrapper)});
848 _foreign_helper.JS('void', '#.name = ""', wrapper); 848 wrapper.name = "";
849 } else { 849 } else {
850 _foreign_helper.JS('void', '#.toString = #', wrapper, _foreign_helper.DART _CLOSURE_TO_JS(toStringWrapper)); 850 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper);
851 } 851 }
852 return wrapper; 852 return wrapper;
853 } 853 }
854 // Function toStringWrapper: () → dynamic 854 // Function toStringWrapper: () → dynamic
855 function toStringWrapper() { 855 function toStringWrapper() {
856 return dart.dinvoke(_foreign_helper.JS('', 'this.dartException'), 'toString' ); 856 return dart.dinvoke(this.dartException, 'toString');
857 } 857 }
858 // Function throwExpression: (dynamic) → dynamic 858 // Function throwExpression: (dynamic) → dynamic
859 function throwExpression(ex) { 859 function throwExpression(ex) {
860 _foreign_helper.JS('void', 'throw #', wrapException(ex)); 860 throw wrapException(ex);
861 } 861 }
862 // Function makeLiteralListConst: (dynamic) → dynamic 862 // Function makeLiteralListConst: (dynamic) → dynamic
863 function makeLiteralListConst(list) { 863 function makeLiteralListConst(list) {
864 _foreign_helper.JS('bool', '#.immutable$list = #', list, true); 864 list.immutable$list = true;
865 _foreign_helper.JS('bool', '#.fixed$length = #', list, true); 865 list.fixed$length = true;
866 return list; 866 return list;
867 } 867 }
868 // Function throwRuntimeError: (dynamic) → dynamic 868 // Function throwRuntimeError: (dynamic) → dynamic
869 function throwRuntimeError(message) { 869 function throwRuntimeError(message) {
870 throw new RuntimeError(message); 870 throw new RuntimeError(message);
871 } 871 }
872 // Function throwAbstractClassInstantiationError: (dynamic) → dynamic 872 // Function throwAbstractClassInstantiationError: (dynamic) → dynamic
873 function throwAbstractClassInstantiationError(className) { 873 function throwAbstractClassInstantiationError(className) {
874 throw new core.AbstractClassInstantiationError(dart.as(className, core.Strin g)); 874 throw new core.AbstractClassInstantiationError(dart.as(className, core.Strin g));
875 } 875 }
876 class TypeErrorDecoder extends dart.Object { 876 class TypeErrorDecoder extends dart.Object {
877 TypeErrorDecoder(_arguments, _argumentsExpr, _expr, _method, _receiver, _pat tern) { 877 TypeErrorDecoder(_arguments, _argumentsExpr, _expr, _method, _receiver, _pat tern) {
878 this._arguments = _arguments; 878 this._arguments = _arguments;
879 this._argumentsExpr = _argumentsExpr; 879 this._argumentsExpr = _argumentsExpr;
880 this._expr = _expr; 880 this._expr = _expr;
881 this._method = _method; 881 this._method = _method;
882 this._receiver = _receiver; 882 this._receiver = _receiver;
883 this._pattern = _pattern; 883 this._pattern = _pattern;
884 } 884 }
885 matchTypeError(message) { 885 matchTypeError(message) {
886 let match = _foreign_helper.JS('JSExtendableArray|Null', 'new RegExp(#).ex ec(#)', this._pattern, message); 886 let match = new RegExp(this._pattern).exec(message);
887 if (match === null) 887 if (match === null)
888 return null; 888 return null;
889 let result = _foreign_helper.JS('', 'Object.create(null)'); 889 let result = Object.create(null);
890 if (this._arguments !== -1) { 890 if (this._arguments !== -1) {
891 _foreign_helper.JS('', '#.arguments = #[# + 1]', result, match, this._ar guments); 891 result.arguments = match[this._arguments + 1];
892 } 892 }
893 if (this._argumentsExpr !== -1) { 893 if (this._argumentsExpr !== -1) {
894 _foreign_helper.JS('', '#.argumentsExpr = #[# + 1]', result, match, this ._argumentsExpr); 894 result.argumentsExpr = match[this._argumentsExpr + 1];
895 } 895 }
896 if (this._expr !== -1) { 896 if (this._expr !== -1) {
897 _foreign_helper.JS('', '#.expr = #[# + 1]', result, match, this._expr); 897 result.expr = match[this._expr + 1];
898 } 898 }
899 if (this._method !== -1) { 899 if (this._method !== -1) {
900 _foreign_helper.JS('', '#.method = #[# + 1]', result, match, this._metho d); 900 result.method = match[this._method + 1];
901 } 901 }
902 if (this._receiver !== -1) { 902 if (this._receiver !== -1) {
903 _foreign_helper.JS('', '#.receiver = #[# + 1]', result, match, this._rec eiver); 903 result.receiver = match[this._receiver + 1];
904 } 904 }
905 return result; 905 return result;
906 } 906 }
907 static buildJavaScriptObject() { 907 static buildJavaScriptObject() {
908 return _foreign_helper.JS('', '{ toString: function() { return "$receiver$ "; } }'); 908 return {
909 toString: function() {
910 return "$receiver$";
911 }
912 };
909 } 913 }
910 static buildJavaScriptObjectWithNonClosure() { 914 static buildJavaScriptObjectWithNonClosure() {
911 return _foreign_helper.JS('', '{ $method$: null, ' + 'toString: function() { return "$receiver$"; } }'); 915 return {
916 $method$: null,
917 toString: function() {
918 return "$receiver$";
919 }
920 };
912 } 921 }
913 static extractPattern(message) { 922 static extractPattern(message) {
914 message = dart.as(_foreign_helper.JS('String', "#.replace(String({}), '$re ceiver$')", message), core.String); 923 message = message.replace(String({}), '$receiver$');
915 message = dart.as(_foreign_helper.JS('String', "#.replace(new RegExp(#, 'g '), '\\\\$&')", message, ESCAPE_REGEXP), core.String); 924 message = message.replace(new RegExp(ESCAPE_REGEXP, 'g'), '\\$&');
916 let match = dart.as(_foreign_helper.JS('JSExtendableArray|Null', "#.match( /\\\\\\$[a-zA-Z]+\\\\\\$/g)", message), core.List$(core.String)); 925 let match = dart.as(message.match(/\\\$[a-zA-Z]+\\\$/g), core.List$(core.S tring));
917 if (match === null) 926 if (match === null)
918 match = dart.as(new List.from([]), core.List$(core.String)); 927 match = dart.as(new List.from([]), core.List$(core.String));
919 let arguments = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, ' \\$arguments\\$'), core.int); 928 let arguments = match.indexOf('\\$arguments\\$');
920 let argumentsExpr = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', matc h, '\\$argumentsExpr\\$'), core.int); 929 let argumentsExpr = match.indexOf('\\$argumentsExpr\\$');
921 let expr = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\\$ex pr\\$'), core.int); 930 let expr = match.indexOf('\\$expr\\$');
922 let method = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\\$ method\\$'), core.int); 931 let method = match.indexOf('\\$method\\$');
923 let receiver = dart.as(_foreign_helper.JS('int', '#.indexOf(#)', match, '\ \$receiver\\$'), core.int); 932 let receiver = match.indexOf('\\$receiver\\$');
924 let pattern = dart.as(_foreign_helper.JS('String', "#.replace('\\\\$argume nts\\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$argumentsExpr\\\\$', '((?:x|[^x] )*)')" + ".replace('\\\\$expr\\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$method \\\\$', '((?:x|[^x])*)')" + ".replace('\\\\$receiver\\\\$', '((?:x|[^x])*)')", message), core.String); 933 let pattern = message.replace('\\$arguments\\$', '((?:x|[^x])*)').replace( '\\$argumentsExpr\\$', '((?:x|[^x])*)').replace('\\$expr\\$', '((?:x|[^x])*)').r eplace('\\$method\\$', '((?:x|[^x])*)').replace('\\$receiver\\$', '((?:x|[^x])*) ');
925 return new TypeErrorDecoder(arguments, argumentsExpr, expr, method, receiv er, pattern); 934 return new TypeErrorDecoder(arguments, argumentsExpr, expr, method, receiv er, pattern);
926 } 935 }
927 static provokeCallErrorOn(expression) { 936 static provokeCallErrorOn(expression) {
928 let function = _foreign_helper.JS('', "function($expr$) {\n var $argument sExpr$ = '$arguments$';\n try {\n $expr$.$method$($argumentsExpr$);\n } cat ch (e) {\n return e.message;\n }\n}"); 937 let function = function($expr$) {
929 return dart.as(_foreign_helper.JS('String', '(#)(#)', function, expression ), core.String); 938 var $argumentsExpr$ = '$arguments$';
939 try {
940 $expr$.$method$($argumentsExpr$);
941 } catch (e) {
942 return e.message;
943 }
944
945 };
946 return function(expression);
930 } 947 }
931 static provokeCallErrorOnNull() { 948 static provokeCallErrorOnNull() {
932 let function = _foreign_helper.JS('', "function() {\n var $argumentsExpr$ = '$arguments$';\n try {\n null.$method$($argumentsExpr$);\n } catch (e) { \n return e.message;\n }\n}"); 949 let function = function() {
933 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin g); 950 var $argumentsExpr$ = '$arguments$';
951 try {
952 null.$method$($argumentsExpr$);
953 } catch (e) {
954 return e.message;
955 }
956
957 };
958 return function();
934 } 959 }
935 static provokeCallErrorOnUndefined() { 960 static provokeCallErrorOnUndefined() {
936 let function = _foreign_helper.JS('', "function() {\n var $argumentsExpr$ = '$arguments$';\n try {\n (void 0).$method$($argumentsExpr$);\n } catch ( e) {\n return e.message;\n }\n}"); 961 let function = function() {
937 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin g); 962 var $argumentsExpr$ = '$arguments$';
963 try {
964 (void 0).$method$($argumentsExpr$);
965 } catch (e) {
966 return e.message;
967 }
968
969 };
970 return function();
938 } 971 }
939 static provokePropertyErrorOn(expression) { 972 static provokePropertyErrorOn(expression) {
940 let function = _foreign_helper.JS('', "function($expr$) {\n try {\n $e xpr$.$method$;\n } catch (e) {\n return e.message;\n }\n}"); 973 let function = function($expr$) {
941 return dart.as(_foreign_helper.JS('String', '(#)(#)', function, expression ), core.String); 974 try {
975 $expr$.$method$;
976 } catch (e) {
977 return e.message;
978 }
979
980 };
981 return function(expression);
942 } 982 }
943 static provokePropertyErrorOnNull() { 983 static provokePropertyErrorOnNull() {
944 let function = _foreign_helper.JS('', "function() {\n try {\n null.$me thod$;\n } catch (e) {\n return e.message;\n }\n}"); 984 let function = function() {
945 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin g); 985 try {
986 null.$method$;
987 } catch (e) {
988 return e.message;
989 }
990
991 };
992 return function();
946 } 993 }
947 static provokePropertyErrorOnUndefined() { 994 static provokePropertyErrorOnUndefined() {
948 let function = _foreign_helper.JS('', "function() {\n try {\n (void 0) .$method$;\n } catch (e) {\n return e.message;\n }\n}"); 995 let function = function() {
949 return dart.as(_foreign_helper.JS('String', '(#)()', function), core.Strin g); 996 try {
997 (void 0).$method$;
998 } catch (e) {
999 return e.message;
1000 }
1001
1002 };
1003 return function();
950 } 1004 }
951 } 1005 }
952 dart.defineLazyProperties(TypeErrorDecoder, { 1006 dart.defineLazyProperties(TypeErrorDecoder, {
953 get noSuchMethodPattern() { 1007 get noSuchMethodPattern() {
954 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObject())) , TypeErrorDecoder); 1008 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObject())) , TypeErrorDecoder);
955 }, 1009 },
956 get notClosurePattern() { 1010 get notClosurePattern() {
957 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObjectWith NonClosure())), TypeErrorDecoder); 1011 return dart.as(extractPattern(provokeCallErrorOn(buildJavaScriptObjectWith NonClosure())), TypeErrorDecoder);
958 }, 1012 },
959 get nullCallPattern() { 1013 get nullCallPattern() {
960 return dart.as(extractPattern(provokeCallErrorOn(_foreign_helper.JS('', 'n ull'))), TypeErrorDecoder); 1014 return dart.as(extractPattern(provokeCallErrorOn(null)), TypeErrorDecoder) ;
961 }, 1015 },
962 get nullLiteralCallPattern() { 1016 get nullLiteralCallPattern() {
963 return dart.as(extractPattern(provokeCallErrorOnNull()), TypeErrorDecoder) ; 1017 return dart.as(extractPattern(provokeCallErrorOnNull()), TypeErrorDecoder) ;
964 }, 1018 },
965 get undefinedCallPattern() { 1019 get undefinedCallPattern() {
966 return dart.as(extractPattern(provokeCallErrorOn(_foreign_helper.JS('', 'v oid 0'))), TypeErrorDecoder); 1020 return dart.as(extractPattern(provokeCallErrorOn(void 0)), TypeErrorDecode r);
967 }, 1021 },
968 get undefinedLiteralCallPattern() { 1022 get undefinedLiteralCallPattern() {
969 return dart.as(extractPattern(provokeCallErrorOnUndefined()), TypeErrorDec oder); 1023 return dart.as(extractPattern(provokeCallErrorOnUndefined()), TypeErrorDec oder);
970 }, 1024 },
971 get nullPropertyPattern() { 1025 get nullPropertyPattern() {
972 return dart.as(extractPattern(provokePropertyErrorOn(_foreign_helper.JS('' , 'null'))), TypeErrorDecoder); 1026 return dart.as(extractPattern(provokePropertyErrorOn(null)), TypeErrorDeco der);
973 }, 1027 },
974 get nullLiteralPropertyPattern() { 1028 get nullLiteralPropertyPattern() {
975 return dart.as(extractPattern(provokePropertyErrorOnNull()), TypeErrorDeco der); 1029 return dart.as(extractPattern(provokePropertyErrorOnNull()), TypeErrorDeco der);
976 }, 1030 },
977 get undefinedPropertyPattern() { 1031 get undefinedPropertyPattern() {
978 return dart.as(extractPattern(provokePropertyErrorOn(_foreign_helper.JS('' , 'void 0'))), TypeErrorDecoder); 1032 return dart.as(extractPattern(provokePropertyErrorOn(void 0)), TypeErrorDe coder);
979 }, 1033 },
980 get undefinedLiteralPropertyPattern() { 1034 get undefinedLiteralPropertyPattern() {
981 return dart.as(extractPattern(provokePropertyErrorOnUndefined()), TypeErro rDecoder); 1035 return dart.as(extractPattern(provokePropertyErrorOnUndefined()), TypeErro rDecoder);
982 } 1036 }
983 }); 1037 });
984 class NullError extends core.Error { 1038 class NullError extends core.Error {
985 NullError(_message, match) { 1039 NullError(_message, match) {
986 this._message = _message; 1040 this._message = _message;
987 this._method = dart.as(match === null ? null : _foreign_helper.JS('', '#.m ethod', match), core.String); 1041 this._method = dart.as(match === null ? null : match.method, core.String);
988 super.Error(); 1042 super.Error();
989 } 1043 }
990 toString() { 1044 toString() {
991 if (this._method === null) 1045 if (this._method === null)
992 return `NullError: ${this._message}`; 1046 return `NullError: ${this._message}`;
993 return `NullError: Cannot call "${this._method}" on null`; 1047 return `NullError: Cannot call "${this._method}" on null`;
994 } 1048 }
995 } 1049 }
996 class JsNoSuchMethodError extends core.Error { 1050 class JsNoSuchMethodError extends core.Error {
997 JsNoSuchMethodError(_message, match) { 1051 JsNoSuchMethodError(_message, match) {
998 this._message = _message; 1052 this._message = _message;
999 this._method = dart.as(match === null ? null : _foreign_helper.JS('String| Null', '#.method', match), core.String); 1053 this._method = dart.as(match === null ? null : match.method, core.String);
1000 this._receiver = dart.as(match === null ? null : _foreign_helper.JS('Strin g|Null', '#.receiver', match), core.String); 1054 this._receiver = dart.as(match === null ? null : match.receiver, core.Stri ng);
1001 super.Error(); 1055 super.Error();
1002 } 1056 }
1003 toString() { 1057 toString() {
1004 if (this._method === null) 1058 if (this._method === null)
1005 return `NoSuchMethodError: ${this._message}`; 1059 return `NoSuchMethodError: ${this._message}`;
1006 if (this._receiver === null) { 1060 if (this._receiver === null) {
1007 return `NoSuchMethodError: Cannot call "${this._method}" (${this._messag e})`; 1061 return `NoSuchMethodError: Cannot call "${this._method}" (${this._messag e})`;
1008 } 1062 }
1009 return `NoSuchMethodError: Cannot call "${this._method}" on "${this._recei ver}" ` + `(${this._message})`; 1063 return `NoSuchMethodError: Cannot call "${this._method}" on "${this._recei ver}" ` + `(${this._message})`;
1010 } 1064 }
1011 } 1065 }
1012 class UnknownJsTypeError extends core.Error { 1066 class UnknownJsTypeError extends core.Error {
1013 UnknownJsTypeError(_message) { 1067 UnknownJsTypeError(_message) {
1014 this._message = _message; 1068 this._message = _message;
1015 super.Error(); 1069 super.Error();
1016 } 1070 }
1017 toString() { 1071 toString() {
1018 return this._message.isEmpty ? 'Error' : `Error: ${this._message}`; 1072 return this._message.isEmpty ? 'Error' : `Error: ${this._message}`;
1019 } 1073 }
1020 } 1074 }
1021 // Function unwrapException: (dynamic) → dynamic 1075 // Function unwrapException: (dynamic) → dynamic
1022 function unwrapException(ex) { 1076 function unwrapException(ex) {
1023 // Function saveStackTrace: (dynamic) → dynamic 1077 // Function saveStackTrace: (dynamic) → dynamic
1024 function saveStackTrace(error) { 1078 function saveStackTrace(error) {
1025 if (dart.is(error, core.Error)) { 1079 if (dart.is(error, core.Error)) {
1026 let thrownStackTrace = _foreign_helper.JS('', '#.$thrownJsError', error) ; 1080 let thrownStackTrace = error.$thrownJsError;
1027 if (thrownStackTrace === null) { 1081 if (thrownStackTrace === null) {
1028 _foreign_helper.JS('void', '#.$thrownJsError = #', error, ex); 1082 error.$thrownJsError = ex;
1029 } 1083 }
1030 } 1084 }
1031 return error; 1085 return error;
1032 } 1086 }
1033 if (ex === null) 1087 if (ex === null)
1034 return null; 1088 return null;
1035 if (_foreign_helper.JS('bool', 'typeof # !== "object"', ex)) 1089 if (typeof ex !== "object")
1036 return ex; 1090 return ex;
1037 if (_foreign_helper.JS('bool', '"dartException" in #', ex)) { 1091 if ("dartException" in ex) {
1038 return saveStackTrace(_foreign_helper.JS('', '#.dartException', ex)); 1092 return saveStackTrace(ex.dartException);
1039 } else if (dart.throw_("Unimplemented PrefixExpression: !JS('bool', r'\"mess age\" in #', ex)")) { 1093 } else if (!dart.notNull("message" in ex)) {
1040 return ex; 1094 return ex;
1041 } 1095 }
1042 let message = _foreign_helper.JS('var', '#.message', ex); 1096 let message = ex.message;
1043 if (dart.dbinary(_foreign_helper.JS('bool', '"number" in #', ex), '&&', _for eign_helper.JS('bool', 'typeof #.number == "number"', ex))) { 1097 if (dart.notNull("number" in ex) && dart.notNull(typeof ex.number == "number ")) {
1044 let number = dart.as(_foreign_helper.JS('int', '#.number', ex), core.int); 1098 let number = ex.number;
1045 let ieErrorCode = number & 65535; 1099 let ieErrorCode = number & 65535;
1046 let ieFacilityNumber = number >> 16 & 8191; 1100 let ieFacilityNumber = number >> 16 & 8191;
1047 if (ieFacilityNumber === 10) { 1101 if (ieFacilityNumber === 10) {
1048 switch (ieErrorCode) { 1102 switch (ieErrorCode) {
1049 case 438: 1103 case 438:
1050 return saveStackTrace(new JsNoSuchMethodError(`${message} (Error ${i eErrorCode})`, null)); 1104 return saveStackTrace(new JsNoSuchMethodError(`${message} (Error ${i eErrorCode})`, null));
1051 case 445: 1105 case 445:
1052 case 5007: 1106 case 5007:
1053 return saveStackTrace(new NullError(`${message} (Error ${ieErrorCode })`, null)); 1107 return saveStackTrace(new NullError(`${message} (Error ${ieErrorCode })`, null));
1054 } 1108 }
1055 } 1109 }
1056 } 1110 }
1057 if (_foreign_helper.JS('bool', '# instanceof TypeError', ex)) { 1111 if (ex instanceof TypeError) {
1058 let match = null; 1112 let match = null;
1059 let nsme = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecoder.no SuchMethodPattern); 1113 let nsme = TypeErrorDecoder.noSuchMethodPattern;
1060 let notClosure = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDeco der.notClosurePattern); 1114 let notClosure = TypeErrorDecoder.notClosurePattern;
1061 let nullCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecode r.nullCallPattern); 1115 let nullCall = TypeErrorDecoder.nullCallPattern;
1062 let nullLiteralCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErro rDecoder.nullLiteralCallPattern); 1116 let nullLiteralCall = TypeErrorDecoder.nullLiteralCallPattern;
1063 let undefCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDecod er.undefinedCallPattern); 1117 let undefCall = TypeErrorDecoder.undefinedCallPattern;
1064 let undefLiteralCall = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErr orDecoder.undefinedLiteralCallPattern); 1118 let undefLiteralCall = TypeErrorDecoder.undefinedLiteralCallPattern;
1065 let nullProperty = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorDe coder.nullPropertyPattern); 1119 let nullProperty = TypeErrorDecoder.nullPropertyPattern;
1066 let nullLiteralProperty = _foreign_helper.JS('TypeErrorDecoder', '#', Type ErrorDecoder.nullLiteralPropertyPattern); 1120 let nullLiteralProperty = TypeErrorDecoder.nullLiteralPropertyPattern;
1067 let undefProperty = _foreign_helper.JS('TypeErrorDecoder', '#', TypeErrorD ecoder.undefinedPropertyPattern); 1121 let undefProperty = TypeErrorDecoder.undefinedPropertyPattern;
1068 let undefLiteralProperty = _foreign_helper.JS('TypeErrorDecoder', '#', Typ eErrorDecoder.undefinedLiteralPropertyPattern); 1122 let undefLiteralProperty = TypeErrorDecoder.undefinedLiteralPropertyPatter n;
1069 if ((match = dart.dinvoke(nsme, 'matchTypeError', message)) !== null) { 1123 if ((match = dart.dinvoke(nsme, 'matchTypeError', message)) !== null) {
1070 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri ng), match)); 1124 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri ng), match));
1071 } else if ((match = dart.dinvoke(notClosure, 'matchTypeError', message)) ! == null) { 1125 } else if ((match = dart.dinvoke(notClosure, 'matchTypeError', message)) ! == null) {
1072 _foreign_helper.JS('', '#.method = "call"', match); 1126 match.method = "call";
1073 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri ng), match)); 1127 return saveStackTrace(new JsNoSuchMethodError(dart.as(message, core.Stri ng), match));
1074 } else if (dart.notNull(dart.notNull(dart.notNull(dart.notNull(dart.notNul l(dart.notNull(dart.notNull((match = dart.dinvoke(nullCall, 'matchTypeError', me ssage)) !== null) || dart.notNull((match = dart.dinvoke(nullLiteralCall, 'matchT ypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(un defLiteralCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(nullProperty, 'matchTypeError', message)) !== null)) || dart.notNul l((match = dart.dinvoke(nullLiteralCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefProperty, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefLiteralProperty, 'matchTy peError', message)) !== null)) { 1128 } else if (dart.notNull(dart.notNull(dart.notNull(dart.notNull(dart.notNul l(dart.notNull(dart.notNull((match = dart.dinvoke(nullCall, 'matchTypeError', me ssage)) !== null) || dart.notNull((match = dart.dinvoke(nullLiteralCall, 'matchT ypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(un defLiteralCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(nullProperty, 'matchTypeError', message)) !== null)) || dart.notNul l((match = dart.dinvoke(nullLiteralCall, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefProperty, 'matchTypeError', message)) !== null)) || dart.notNull((match = dart.dinvoke(undefLiteralProperty, 'matchTy peError', message)) !== null)) {
1075 return saveStackTrace(new NullError(dart.as(message, core.String), match )); 1129 return saveStackTrace(new NullError(dart.as(message, core.String), match ));
1076 } 1130 }
1077 return saveStackTrace(new UnknownJsTypeError(dart.as(typeof message == str ing ? message : '', core.String))); 1131 return saveStackTrace(new UnknownJsTypeError(dart.as(typeof message == str ing ? message : '', core.String)));
1078 } 1132 }
1079 if (_foreign_helper.JS('bool', '# instanceof RangeError', ex)) { 1133 if (ex instanceof RangeError) {
1080 if (dart.notNull(typeof message == string) && dart.notNull(contains(dart.a s(message, core.String), 'call stack'))) { 1134 if (dart.notNull(typeof message == string) && dart.notNull(contains(dart.a s(message, core.String), 'call stack'))) {
1081 return new core.StackOverflowError(); 1135 return new core.StackOverflowError();
1082 } 1136 }
1083 return saveStackTrace(new core.ArgumentError()); 1137 return saveStackTrace(new core.ArgumentError());
1084 } 1138 }
1085 if (_foreign_helper.JS('bool', 'typeof InternalError == "function" && # inst anceof InternalError', ex)) { 1139 if (typeof InternalError == "function" && ex instanceof InternalError) {
1086 if (dart.notNull(typeof message == string) && dart.notNull(dart.equals(mes sage, 'too much recursion'))) { 1140 if (dart.notNull(typeof message == string) && dart.notNull(dart.equals(mes sage, 'too much recursion'))) {
1087 return new core.StackOverflowError(); 1141 return new core.StackOverflowError();
1088 } 1142 }
1089 } 1143 }
1090 return ex; 1144 return ex;
1091 } 1145 }
1092 // Function getTraceFromException: (dynamic) → StackTrace 1146 // Function getTraceFromException: (dynamic) → StackTrace
1093 function getTraceFromException(exception) { 1147 function getTraceFromException(exception) {
1094 return new _StackTrace(exception); 1148 return new _StackTrace(exception);
1095 } 1149 }
1096 class _StackTrace extends dart.Object { 1150 class _StackTrace extends dart.Object {
1097 _StackTrace(_exception) { 1151 _StackTrace(_exception) {
1098 this._exception = _exception; 1152 this._exception = _exception;
1099 this._trace = null; 1153 this._trace = null;
1100 } 1154 }
1101 toString() { 1155 toString() {
1102 if (this._trace !== null) 1156 if (this._trace !== null)
1103 return this._trace; 1157 return this._trace;
1104 let trace = null; 1158 let trace = null;
1105 if (_foreign_helper.JS('bool', 'typeof # === "object"', this._exception)) { 1159 if (typeof this._exception === "object") {
1106 trace = dart.as(_foreign_helper.JS("String|Null", "#.stack", this._excep tion), core.String); 1160 trace = dart.as(this._exception.stack, core.String);
1107 } 1161 }
1108 return this._trace = trace === null ? '' : trace; 1162 return this._trace = trace === null ? '' : trace;
1109 } 1163 }
1110 } 1164 }
1111 // Function objectHashCode: (dynamic) → int 1165 // Function objectHashCode: (dynamic) → int
1112 function objectHashCode(object) { 1166 function objectHashCode(object) {
1113 if (core.bool['||'](object === null, _foreign_helper.JS('bool', "typeof # != 'object'", object))) { 1167 if (dart.notNull(object === null) || dart.notNull(typeof object != 'object') ) {
1114 return dart.as(dart.dload(object, 'hashCode'), core.int); 1168 return dart.as(dart.dload(object, 'hashCode'), core.int);
1115 } else { 1169 } else {
1116 return Primitives.objectHashCode(object); 1170 return Primitives.objectHashCode(object);
1117 } 1171 }
1118 } 1172 }
1119 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic 1173 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic
1120 function fillLiteralMap(keyValuePairs, result) { 1174 function fillLiteralMap(keyValuePairs, result) {
1121 let index = 0; 1175 let index = 0;
1122 let length = getLength(keyValuePairs); 1176 let length = getLength(keyValuePairs);
1123 while (index < length) { 1177 while (index < length) {
(...skipping 16 matching lines...) Expand all
1140 } else if (numberOfArguments === 4) { 1194 } else if (numberOfArguments === 4) {
1141 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo sure, arg1, arg2, arg3, arg4)); 1195 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, () => dart.dinvokef(clo sure, arg1, arg2, arg3, arg4));
1142 } else { 1196 } else {
1143 throw new core.Exception('Unsupported number of arguments for wrapped clos ure'); 1197 throw new core.Exception('Unsupported number of arguments for wrapped clos ure');
1144 } 1198 }
1145 } 1199 }
1146 // Function convertDartClosureToJS: (dynamic, int) → dynamic 1200 // Function convertDartClosureToJS: (dynamic, int) → dynamic
1147 function convertDartClosureToJS(closure, arity) { 1201 function convertDartClosureToJS(closure, arity) {
1148 if (closure === null) 1202 if (closure === null)
1149 return null; 1203 return null;
1150 let function = _foreign_helper.JS('var', '#.$identity', closure); 1204 let function = closure.$identity;
1151 if (_foreign_helper.JS('bool', '!!#', function)) 1205 if (!!function)
1152 return function; 1206 return function;
1153 function = _foreign_helper.JS('var', '(function(closure, arity, context, inv oke) {' + ' return function(a1, a2, a3, a4) {' + ' return invoke(closure, c ontext, arity, a1, a2, a3, a4);' + ' };' + '})(#,#,#,#)', closure, arity, _fore ign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _foreign_helper.DART_CLOSURE_TO_JS(invo keClosure)); 1207 function = function(closure, arity, context, invoke) {
1154 _foreign_helper.JS('void', '#.$identity = #', closure, function); 1208 return function(a1, a2, a3, a4) {
1209 return invoke(closure, context, arity, a1, a2, a3, a4);
1210 };
1211 }(closure, arity, _foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _foreign_hel per.DART_CLOSURE_TO_JS(invokeClosure));
1212 closure.$identity = function;
1155 return function; 1213 return function;
1156 } 1214 }
1157 class Closure extends dart.Object { 1215 class Closure extends dart.Object {
1158 Closure() { 1216 Closure() {
1159 } 1217 }
1160 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument s, propertyName) { 1218 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument s, propertyName) {
1161 _foreign_helper.JS_EFFECT(() => { 1219 _foreign_helper.JS_EFFECT(() => {
1162 BoundClosure.receiverOf(dart.as(_foreign_helper.JS('BoundClosure', 'void 0'), BoundClosure)); 1220 BoundClosure.receiverOf(dart.as(void 0, BoundClosure));
1163 BoundClosure.selfOf(dart.as(_foreign_helper.JS('BoundClosure', 'void 0') , BoundClosure)); 1221 BoundClosure.selfOf(dart.as(void 0, BoundClosure));
1164 }); 1222 });
1165 let function = _foreign_helper.JS('', '#[#]', functions, 0); 1223 let function = functions[0];
1166 let name = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', functi on), core.String); 1224 let name = dart.as(function.$stubName, core.String);
1167 let callName = dart.as(_foreign_helper.JS('String|Null', '#.$callName', fu nction), core.String); 1225 let callName = dart.as(function.$callName, core.String);
1168 _foreign_helper.JS('', '#.$reflectionInfo = #', function, reflectionInfo); 1226 function.$reflectionInfo = reflectionInfo;
1169 let info = new ReflectionInfo(function); 1227 let info = new ReflectionInfo(function);
1170 let functionType = info.functionType; 1228 let functionType = info.functionType;
1171 let prototype = isStatic ? _foreign_helper.JS('TearOffClosure', 'Object.cr eate(#.constructor.prototype)', new TearOffClosure()) : _foreign_helper.JS('Boun dClosure', 'Object.create(#.constructor.prototype)', new BoundClosure(null, null , null, null)); 1229 let prototype = isStatic ? Object.create(new TearOffClosure().constructor. prototype) : Object.create(new BoundClosure(null, null, null, null).constructor. prototype);
1172 _foreign_helper.JS('', '#.$initialize = #', prototype, _foreign_helper.JS( '', '#.constructor', prototype)); 1230 prototype.$initialize = prototype.constructor;
1173 let constructor = isStatic ? _foreign_helper.JS('', 'function(){this.$init ialize()}') : isCsp ? _foreign_helper.JS('', 'function(a,b,c,d) {this.$initializ e(a,b,c,d)}') : _foreign_helper.JS('', 'new Function("a","b","c","d",' + '"this. $initialize(a,b,c,d);"+#)', functionCounter++); 1231 let constructor = isStatic ? function() {
1174 _foreign_helper.JS('', '#.constructor = #', prototype, constructor); 1232 this.$initialize();
1175 _foreign_helper.JS('', '#.prototype = #', constructor, prototype); 1233 } : isCsp ? function(a, b, c, d) {
1234 this.$initialize(a, b, c, d);
1235 } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + functi onCounter++);
1236 prototype.constructor = constructor;
1237 constructor.prototype = prototype;
1176 let trampoline = function; 1238 let trampoline = function;
1177 let isIntercepted = false; 1239 let isIntercepted = false;
1178 if (!dart.notNull(isStatic)) { 1240 if (!dart.notNull(isStatic)) {
1179 if (_foreign_helper.JS('bool', '#.length == 1', jsArguments)) { 1241 if (jsArguments.length == 1) {
1180 isIntercepted = true; 1242 isIntercepted = true;
1181 } 1243 }
1182 trampoline = forwardCallTo(receiver, function, isIntercepted); 1244 trampoline = forwardCallTo(receiver, function, isIntercepted);
1183 _foreign_helper.JS('', '#.$reflectionInfo = #', trampoline, reflectionIn fo); 1245 trampoline.$reflectionInfo = reflectionInfo;
1184 } else { 1246 } else {
1185 _foreign_helper.JS('', '#.$name = #', prototype, propertyName); 1247 prototype.$name = propertyName;
1186 } 1248 }
1187 let signatureFunction = null; 1249 let signatureFunction = null;
1188 if (_foreign_helper.JS('bool', 'typeof # == "number"', functionType)) { 1250 if (typeof functionType == "number") {
1189 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.METADATA, core.String)); 1251 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.METADATA, core.String));
1190 signatureFunction = _foreign_helper.JS('', '(function(s){return function (){return #[s]}})(#)', metadata, functionType); 1252 signatureFunction = function(s) {
1191 } else if (core.bool['&&'](!dart.notNull(isStatic), _foreign_helper.JS('bo ol', 'typeof # == "function"', functionType))) { 1253 return function() {
1254 return metadata[s];
1255 };
1256 }(functionType);
1257 } else if (dart.notNull(!dart.notNull(isStatic)) && dart.notNull(typeof fu nctionType == "function")) {
1192 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se lfOf); 1258 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se lfOf);
1193 signatureFunction = _foreign_helper.JS('', 'function(f,r){' + 'return fu nction(){' + 'return f.apply({$receiver:r(this)},arguments)' + '}' + '}(#,#)', f unctionType, getReceiver); 1259 signatureFunction = function(f, r) {
1260 return function() {
1261 return f.apply({$receiver: r(this)}, arguments);
1262 };
1263 }(functionType, getReceiver);
1194 } else { 1264 } else {
1195 throw 'Error in reflectionInfo.'; 1265 throw 'Error in reflectionInfo.';
1196 } 1266 }
1197 _foreign_helper.JS('', '#[#] = #', prototype, _foreign_helper.JS_SIGNATURE _NAME(), signatureFunction); 1267 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction;
1198 _foreign_helper.JS('', '#[#] = #', prototype, callName, trampoline); 1268 prototype[callName] = trampoline;
1199 for (let i = 1; i < functions.length; i++) { 1269 for (let i = 1; i < functions.length; i++) {
1200 let stub = functions.get(i); 1270 let stub = functions.get(i);
1201 let stubCallName = _foreign_helper.JS('String|Null', '#.$callName', stub ); 1271 let stubCallName = stub.$callName;
1202 if (stubCallName !== null) { 1272 if (stubCallName !== null) {
1203 _foreign_helper.JS('', '#[#] = #', prototype, stubCallName, isStatic ? stub : forwardCallTo(receiver, stub, isIntercepted)); 1273 prototype[stubCallName] = isStatic ? stub : forwardCallTo(receiver, st ub, isIntercepted);
1204 } 1274 }
1205 } 1275 }
1206 _foreign_helper.JS('', '#["call*"] = #', prototype, trampoline); 1276 prototype["call*"] = trampoline;
1207 return constructor; 1277 return constructor;
1208 } 1278 }
1209 static cspForwardCall(arity, isSuperCall, stubName, function) { 1279 static cspForwardCall(arity, isSuperCall, stubName, function) {
1210 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); 1280 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
1211 if (isSuperCall) 1281 if (isSuperCall)
1212 arity = -1; 1282 arity = -1;
1213 switch (arity) { 1283 switch (arity) {
1214 case 0: 1284 case 0:
1215 return _foreign_helper.JS('', 'function(n,S){' + 'return function(){' + 'return S(this)[n]()' + '}' + '}(#,#)', stubName, getSelf); 1285 return function(n, S) {
1286 return function() {
1287 return S(this)[n]();
1288 };
1289 }(stubName, getSelf);
1216 case 1: 1290 case 1:
1217 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a){' + 'return S(this)[n](a)' + '}' + '}(#,#)', stubName, getSelf); 1291 return function(n, S) {
1292 return function(a) {
1293 return S(this)[n](a);
1294 };
1295 }(stubName, getSelf);
1218 case 2: 1296 case 2:
1219 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b) {' + 'return S(this)[n](a,b)' + '}' + '}(#,#)', stubName, getSelf); 1297 return function(n, S) {
1298 return function(a, b) {
1299 return S(this)[n](a, b);
1300 };
1301 }(stubName, getSelf);
1220 case 3: 1302 case 3:
1221 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b, c){' + 'return S(this)[n](a,b,c)' + '}' + '}(#,#)', stubName, getSelf); 1303 return function(n, S) {
1304 return function(a, b, c) {
1305 return S(this)[n](a, b, c);
1306 };
1307 }(stubName, getSelf);
1222 case 4: 1308 case 4:
1223 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b, c,d){' + 'return S(this)[n](a,b,c,d)' + '}' + '}(#,#)', stubName, getSelf); 1309 return function(n, S) {
1310 return function(a, b, c, d) {
1311 return S(this)[n](a, b, c, d);
1312 };
1313 }(stubName, getSelf);
1224 case 5: 1314 case 5:
1225 return _foreign_helper.JS('', 'function(n,S){' + 'return function(a,b, c,d,e){' + 'return S(this)[n](a,b,c,d,e)' + '}' + '}(#,#)', stubName, getSelf); 1315 return function(n, S) {
1316 return function(a, b, c, d, e) {
1317 return S(this)[n](a, b, c, d, e);
1318 };
1319 }(stubName, getSelf);
1226 default: 1320 default:
1227 return _foreign_helper.JS('', 'function(f,s){' + 'return function(){' + 'return f.apply(s(this),arguments)' + '}' + '}(#,#)', function, getSelf); 1321 return function(f, s) {
1322 return function() {
1323 return f.apply(s(this), arguments);
1324 };
1325 }(function, getSelf);
1228 } 1326 }
1229 } 1327 }
1230 static get isCsp() { 1328 static get isCsp() {
1231 return dart.as(_foreign_helper.JS('bool', 'typeof dart_precompiled == "fun ction"'), core.bool); 1329 return typeof dart_precompiled == "function";
1232 } 1330 }
1233 static forwardCallTo(receiver, function, isIntercepted) { 1331 static forwardCallTo(receiver, function, isIntercepted) {
1234 if (isIntercepted) 1332 if (isIntercepted)
1235 return forwardInterceptedCallTo(receiver, function); 1333 return forwardInterceptedCallTo(receiver, function);
1236 let stubName = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', fu nction), core.String); 1334 let stubName = dart.as(function.$stubName, core.String);
1237 let arity = dart.as(_foreign_helper.JS('int', '#.length', function), core. int); 1335 let arity = function.length;
1238 let lookedUpFunction = _foreign_helper.JS("", "#[#]", receiver, stubName); 1336 let lookedUpFunction = receiver[stubName];
1239 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction) ); 1337 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction) );
1240 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart .notNull(arity >= 27)) { 1338 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart .notNull(arity >= 27)) {
1241 return cspForwardCall(arity, isSuperCall, stubName, function); 1339 return cspForwardCall(arity, isSuperCall, stubName, function);
1242 } 1340 }
1243 if (arity === 0) { 1341 if (arity === 0) {
1244 return _foreign_helper.JS('', '(new Function(#))()', 'return function(){ ' + `return this.${BoundClosure.selfFieldName()}.${stubName}();` + `${functionCo unter++}` + '}'); 1342 return new Function('return function(){' + `return this.${BoundClosure.s elfFieldName()}.${stubName}();` + `${functionCounter++}` + '}')();
1245 } 1343 }
1246 dart.assert(dart.notNull(1 <= arity) && dart.notNull(arity < 27)); 1344 dart.assert(dart.notNull(1 <= arity) && dart.notNull(arity < 27));
1247 let arguments = dart.as(_foreign_helper.JS('String', '"abcdefghijklmnopqrs tuvwxyz".split("").splice(0,#).join(",")', arity), core.String); 1345 let arguments = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).jo in(",");
1248 return _foreign_helper.JS('', '(new Function(#))()', `return function(${ar guments}){` + `return this.${BoundClosure.selfFieldName()}.${stubName}(${argumen ts});` + `${functionCounter++}` + '}'); 1346 return new Function(`return function(${arguments}){` + `return this.${Boun dClosure.selfFieldName()}.${stubName}(${arguments});` + `${functionCounter++}` + '}')();
1249 } 1347 }
1250 static cspForwardInterceptedCall(arity, isSuperCall, name, function) { 1348 static cspForwardInterceptedCall(arity, isSuperCall, name, function) {
1251 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); 1349 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
1252 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei verOf); 1350 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei verOf);
1253 if (isSuperCall) 1351 if (isSuperCall)
1254 arity = -1; 1352 arity = -1;
1255 switch (arity) { 1353 switch (arity) {
1256 case 0: 1354 case 0:
1257 throw new RuntimeError('Intercepted function with no arguments.'); 1355 throw new RuntimeError('Intercepted function with no arguments.');
1258 case 1: 1356 case 1:
1259 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(){ ' + 'return s(this)[n](r(this))' + '}' + '}(#,#,#)', name, getSelf, getReceiver) ; 1357 return function(n, s, r) {
1358 return function() {
1359 return s(this)[n](r(this));
1360 };
1361 }(name, getSelf, getReceiver);
1260 case 2: 1362 case 2:
1261 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a) {' + 'return s(this)[n](r(this),a)' + '}' + '}(#,#,#)', name, getSelf, getReceiv er); 1363 return function(n, s, r) {
1364 return function(a) {
1365 return s(this)[n](r(this), a);
1366 };
1367 }(name, getSelf, getReceiver);
1262 case 3: 1368 case 3:
1263 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a, b){' + 'return s(this)[n](r(this),a,b)' + '}' + '}(#,#,#)', name, getSelf, getRe ceiver); 1369 return function(n, s, r) {
1370 return function(a, b) {
1371 return s(this)[n](r(this), a, b);
1372 };
1373 }(name, getSelf, getReceiver);
1264 case 4: 1374 case 4:
1265 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a, b,c){' + 'return s(this)[n](r(this),a,b,c)' + '}' + '}(#,#,#)', name, getSelf, g etReceiver); 1375 return function(n, s, r) {
1376 return function(a, b, c) {
1377 return s(this)[n](r(this), a, b, c);
1378 };
1379 }(name, getSelf, getReceiver);
1266 case 5: 1380 case 5:
1267 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a, b,c,d){' + 'return s(this)[n](r(this),a,b,c,d)' + '}' + '}(#,#,#)', name, getSel f, getReceiver); 1381 return function(n, s, r) {
1382 return function(a, b, c, d) {
1383 return s(this)[n](r(this), a, b, c, d);
1384 };
1385 }(name, getSelf, getReceiver);
1268 case 6: 1386 case 6:
1269 return _foreign_helper.JS('', 'function(n,s,r){' + 'return function(a, b,c,d,e){' + 'return s(this)[n](r(this),a,b,c,d,e)' + '}' + '}(#,#,#)', name, ge tSelf, getReceiver); 1387 return function(n, s, r) {
1388 return function(a, b, c, d, e) {
1389 return s(this)[n](r(this), a, b, c, d, e);
1390 };
1391 }(name, getSelf, getReceiver);
1270 default: 1392 default:
1271 return _foreign_helper.JS('', 'function(f,s,r,a){' + 'return function( ){' + 'a=[r(this)];' + 'Array.prototype.push.apply(a,arguments);' + 'return f.ap ply(s(this),a)' + '}' + '}(#,#,#)', function, getSelf, getReceiver); 1393 return function(f, s, r, a) {
1394 return function() {
1395 a = [r(this)];
1396 Array.prototype.push.apply(a, arguments);
1397 return f.apply(s(this), a);
1398 };
1399 }(function, getSelf, getReceiver);
1272 } 1400 }
1273 } 1401 }
1274 static forwardInterceptedCallTo(receiver, function) { 1402 static forwardInterceptedCallTo(receiver, function) {
1275 let selfField = BoundClosure.selfFieldName(); 1403 let selfField = BoundClosure.selfFieldName();
1276 let receiverField = BoundClosure.receiverFieldName(); 1404 let receiverField = BoundClosure.receiverFieldName();
1277 let stubName = dart.as(_foreign_helper.JS('String|Null', '#.$stubName', fu nction), core.String); 1405 let stubName = dart.as(function.$stubName, core.String);
1278 let arity = dart.as(_foreign_helper.JS('int', '#.length', function), core. int); 1406 let arity = function.length;
1279 let isCsp = dart.as(_foreign_helper.JS('bool', 'typeof dart_precompiled == "function"'), core.bool); 1407 let isCsp = typeof dart_precompiled == "function";
1280 let lookedUpFunction = _foreign_helper.JS("", "#[#]", receiver, stubName); 1408 let lookedUpFunction = receiver[stubName];
1281 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction) ); 1409 let isSuperCall = !dart.notNull(core.identical(function, lookedUpFunction) );
1282 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart .notNull(arity >= 28)) { 1410 if (dart.notNull(dart.notNull(isCsp) || dart.notNull(isSuperCall)) || dart .notNull(arity >= 28)) {
1283 return cspForwardInterceptedCall(arity, isSuperCall, stubName, function) ; 1411 return cspForwardInterceptedCall(arity, isSuperCall, stubName, function) ;
1284 } 1412 }
1285 if (arity === 1) { 1413 if (arity === 1) {
1286 return _foreign_helper.JS('', '(new Function(#))()', 'return function(){ ' + `return this.${selfField}.${stubName}(this.${receiverField});` + `${function Counter++}` + '}'); 1414 return new Function('return function(){' + `return this.${selfField}.${s tubName}(this.${receiverField});` + `${functionCounter++}` + '}')();
1287 } 1415 }
1288 dart.assert(dart.notNull(1 < arity) && dart.notNull(arity < 28)); 1416 dart.assert(dart.notNull(1 < arity) && dart.notNull(arity < 28));
1289 let arguments = dart.as(_foreign_helper.JS('String', '"abcdefghijklmnopqrs tuvwxyz".split("").splice(0,#).join(",")', arity - 1), core.String); 1417 let arguments = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity - 1 ).join(",");
1290 return _foreign_helper.JS('', '(new Function(#))()', `return function(${ar guments}){` + `return this.${selfField}.${stubName}(this.${receiverField}, ${arg uments});` + `${functionCounter++}` + '}'); 1418 return new Function(`return function(${arguments}){` + `return this.${self Field}.${stubName}(this.${receiverField}, ${arguments});` + `${functionCounter++ }` + '}')();
1291 } 1419 }
1292 toString() { 1420 toString() {
1293 return "Closure"; 1421 return "Closure";
1294 } 1422 }
1295 } 1423 }
1296 Closure.FUNCTION_INDEX = 0; 1424 Closure.FUNCTION_INDEX = 0;
1297 Closure.NAME_INDEX = 1; 1425 Closure.NAME_INDEX = 1;
1298 Closure.CALL_NAME_INDEX = 2; 1426 Closure.CALL_NAME_INDEX = 2;
1299 Closure.REQUIRED_PARAMETER_INDEX = 3; 1427 Closure.REQUIRED_PARAMETER_INDEX = 3;
1300 Closure.OPTIONAL_PARAMETER_INDEX = 4; 1428 Closure.OPTIONAL_PARAMETER_INDEX = 4;
1301 Closure.DEFAULT_ARGUMENTS_INDEX = 5; 1429 Closure.DEFAULT_ARGUMENTS_INDEX = 5;
1302 Closure.functionCounter = 0; 1430 Closure.functionCounter = 0;
1303 // Function closureFromTearOff: (dynamic, dynamic, dynamic, dynamic, dynamic, dynamic) → dynamic 1431 // Function closureFromTearOff: (dynamic, dynamic, dynamic, dynamic, dynamic, dynamic) → dynamic
1304 function closureFromTearOff(receiver, functions, reflectionInfo, isStatic, jsA rguments, name) { 1432 function closureFromTearOff(receiver, functions, reflectionInfo, isStatic, jsA rguments, name) {
1305 return Closure.fromTearOff(receiver, _interceptors.JSArray.markFixedList(dar t.as(functions, core.List)), _interceptors.JSArray.markFixedList(dart.as(reflect ionInfo, core.List)), dart.as(_foreign_helper.JS('bool', '!!#', isStatic), core. bool), jsArguments, dart.as(_foreign_helper.JS('String', '#', name), core.String )); 1433 return Closure.fromTearOff(receiver, _interceptors.JSArray.markFixedList(dar t.as(functions, core.List)), _interceptors.JSArray.markFixedList(dart.as(reflect ionInfo, core.List)), !!isStatic, jsArguments, name);
1306 } 1434 }
1307 class TearOffClosure extends Closure { 1435 class TearOffClosure extends Closure {
1308 } 1436 }
1309 class BoundClosure extends TearOffClosure { 1437 class BoundClosure extends TearOffClosure {
1310 BoundClosure(_self, _target, _receiver, _name) { 1438 BoundClosure(_self, _target, _receiver, _name) {
1311 this._self = _self; 1439 this._self = _self;
1312 this._target = _target; 1440 this._target = _target;
1313 this._receiver = _receiver; 1441 this._receiver = _receiver;
1314 this._name = _name; 1442 this._name = _name;
1315 super.TearOffClosure(); 1443 super.TearOffClosure();
1316 } 1444 }
1317 ['=='](other) { 1445 ['=='](other) {
1318 if (core.identical(this, other)) 1446 if (core.identical(this, other))
1319 return true; 1447 return true;
1320 if (!dart.is(other, BoundClosure)) 1448 if (!dart.is(other, BoundClosure))
1321 return false; 1449 return false;
1322 return dart.as(_foreign_helper.JS('bool', '# === # && # === # && # === #', this._self, dart.dload(other, '_self'), this._target, dart.dload(other, '_targe t'), this._receiver, dart.dload(other, '_receiver')), core.bool); 1450 return this._self === dart.dload(other, '_self') && this._target === dart. dload(other, '_target') && this._receiver === dart.dload(other, '_receiver');
1323 } 1451 }
1324 get hashCode() { 1452 get hashCode() {
1325 let receiverHashCode = null; 1453 let receiverHashCode = null;
1326 if (this._receiver === null) { 1454 if (this._receiver === null) {
1327 receiverHashCode = Primitives.objectHashCode(this._self); 1455 receiverHashCode = Primitives.objectHashCode(this._self);
1328 } else if (!dart.equals(_foreign_helper.JS('String', 'typeof #', this._rec eiver), 'object')) { 1456 } else if (!dart.equals(typeof this._receiver, 'object')) {
1329 receiverHashCode = dart.as(dart.dload(this._receiver, 'hashCode'), core. int); 1457 receiverHashCode = dart.as(dart.dload(this._receiver, 'hashCode'), core. int);
1330 } else { 1458 } else {
1331 receiverHashCode = Primitives.objectHashCode(this._receiver); 1459 receiverHashCode = Primitives.objectHashCode(this._receiver);
1332 } 1460 }
1333 return receiverHashCode ^ Primitives.objectHashCode(this._target); 1461 return receiverHashCode ^ Primitives.objectHashCode(this._target);
1334 } 1462 }
1335 static selfOf(closure) { 1463 static selfOf(closure) {
1336 return closure._self; 1464 return closure._self;
1337 } 1465 }
1338 static targetOf(closure) { 1466 static targetOf(closure) {
(...skipping 12 matching lines...) Expand all
1351 return selfFieldNameCache; 1479 return selfFieldNameCache;
1352 } 1480 }
1353 static receiverFieldName() { 1481 static receiverFieldName() {
1354 if (receiverFieldNameCache === null) { 1482 if (receiverFieldNameCache === null) {
1355 receiverFieldNameCache = computeFieldNamed('receiver'); 1483 receiverFieldNameCache = computeFieldNamed('receiver');
1356 } 1484 }
1357 return receiverFieldNameCache; 1485 return receiverFieldNameCache;
1358 } 1486 }
1359 static computeFieldNamed(fieldName) { 1487 static computeFieldNamed(fieldName) {
1360 let template = new BoundClosure('self', 'target', 'receiver', 'name'); 1488 let template = new BoundClosure('self', 'target', 'receiver', 'name');
1361 let names = _interceptors.JSArray.markFixedList(dart.as(_foreign_helper.JS ('', 'Object.getOwnPropertyNames(#)', template), core.List)); 1489 let names = _interceptors.JSArray.markFixedList(dart.as(Object.getOwnPrope rtyNames(template), core.List));
1362 for (let i = 0; i < names.length; i++) { 1490 for (let i = 0; i < names.length; i++) {
1363 let name = names.get(i); 1491 let name = names.get(i);
1364 if (_foreign_helper.JS('bool', '#[#] === #', template, name, fieldName)) { 1492 if (template[name] === fieldName) {
1365 return dart.as(_foreign_helper.JS('String', '#', name), core.String); 1493 return name;
1366 } 1494 }
1367 } 1495 }
1368 } 1496 }
1369 } 1497 }
1370 BoundClosure.selfFieldNameCache = null; 1498 BoundClosure.selfFieldNameCache = null;
1371 BoundClosure.receiverFieldNameCache = null; 1499 BoundClosure.receiverFieldNameCache = null;
1372 // Function jsHasOwnProperty: (dynamic, String) → bool 1500 // Function jsHasOwnProperty: (dynamic, String) → bool
1373 function jsHasOwnProperty(jsObject, property) { 1501 function jsHasOwnProperty(jsObject, property) {
1374 return dart.as(_foreign_helper.JS('bool', '#.hasOwnProperty(#)', jsObject, p roperty), core.bool); 1502 return jsObject.hasOwnProperty(property);
1375 } 1503 }
1376 // Function jsPropertyAccess: (dynamic, String) → dynamic 1504 // Function jsPropertyAccess: (dynamic, String) → dynamic
1377 function jsPropertyAccess(jsObject, property) { 1505 function jsPropertyAccess(jsObject, property) {
1378 return _foreign_helper.JS('var', '#[#]', jsObject, property); 1506 return jsObject[property];
1379 } 1507 }
1380 // Function getFallThroughError: () → dynamic 1508 // Function getFallThroughError: () → dynamic
1381 function getFallThroughError() { 1509 function getFallThroughError() {
1382 return new FallThroughErrorImplementation(); 1510 return new FallThroughErrorImplementation();
1383 } 1511 }
1384 class Creates extends dart.Object { 1512 class Creates extends dart.Object {
1385 Creates(types) { 1513 Creates(types) {
1386 this.types = types; 1514 this.types = types;
1387 } 1515 }
1388 } 1516 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 // Function propertyTypeCastError: (dynamic, dynamic) → void 1610 // Function propertyTypeCastError: (dynamic, dynamic) → void
1483 function propertyTypeCastError(value, property) { 1611 function propertyTypeCastError(value, property) {
1484 let actualType = Primitives.objectTypeName(value); 1612 let actualType = Primitives.objectTypeName(value);
1485 let expectedType = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload (property, 'length')), core.String); 1613 let expectedType = dart.as(dart.dinvoke(property, 'substring', 3, dart.dload (property, 'length')), core.String);
1486 throw new CastErrorImplementation(actualType, expectedType); 1614 throw new CastErrorImplementation(actualType, expectedType);
1487 } 1615 }
1488 // Function propertyTypeCheck: (dynamic, dynamic) → dynamic 1616 // Function propertyTypeCheck: (dynamic, dynamic) → dynamic
1489 function propertyTypeCheck(value, property) { 1617 function propertyTypeCheck(value, property) {
1490 if (value === null) 1618 if (value === null)
1491 return value; 1619 return value;
1492 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) 1620 if (!!value[property])
1493 return value; 1621 return value;
1494 propertyTypeError(value, property); 1622 propertyTypeError(value, property);
1495 } 1623 }
1496 // Function propertyTypeCast: (dynamic, dynamic) → dynamic 1624 // Function propertyTypeCast: (dynamic, dynamic) → dynamic
1497 function propertyTypeCast(value, property) { 1625 function propertyTypeCast(value, property) {
1498 if (core.bool['||'](value === null, _foreign_helper.JS('bool', '!!#[#]', val ue, property))) 1626 if (dart.notNull(value === null) || dart.notNull(!!value[property]))
1499 return value; 1627 return value;
1500 propertyTypeCastError(value, property); 1628 propertyTypeCastError(value, property);
1501 } 1629 }
1502 // Function interceptedTypeCheck: (dynamic, dynamic) → dynamic 1630 // Function interceptedTypeCheck: (dynamic, dynamic) → dynamic
1503 function interceptedTypeCheck(value, property) { 1631 function interceptedTypeCheck(value, property) {
1504 if (value === null) 1632 if (value === null)
1505 return value; 1633 return value;
1506 if (core.bool['&&'](core.identical(_foreign_helper.JS('String', 'typeof #', value), 'object'), _foreign_helper.JS('bool', '#[#]', _interceptors.getIntercept or(value), property))) { 1634 if (dart.notNull(core.identical(typeof value, 'object')) && dart.notNull(_in terceptors.getInterceptor(value)[property])) {
1507 return value; 1635 return value;
1508 } 1636 }
1509 propertyTypeError(value, property); 1637 propertyTypeError(value, property);
1510 } 1638 }
1511 // Function interceptedTypeCast: (dynamic, dynamic) → dynamic 1639 // Function interceptedTypeCast: (dynamic, dynamic) → dynamic
1512 function interceptedTypeCast(value, property) { 1640 function interceptedTypeCast(value, property) {
1513 if (dart.notNull(value === null) || dart.notNull(dart.dbinary(_foreign_helpe r.JS('bool', 'typeof # === "object"', value), '&&', _foreign_helper.JS('bool', ' #[#]', _interceptors.getInterceptor(value), property)))) { 1641 if (dart.notNull(value === null) || dart.notNull(dart.notNull(typeof value = == "object") && dart.notNull(_interceptors.getInterceptor(value)[property]))) {
1514 return value; 1642 return value;
1515 } 1643 }
1516 propertyTypeCastError(value, property); 1644 propertyTypeCastError(value, property);
1517 } 1645 }
1518 // Function numberOrStringSuperTypeCheck: (dynamic, dynamic) → dynamic 1646 // Function numberOrStringSuperTypeCheck: (dynamic, dynamic) → dynamic
1519 function numberOrStringSuperTypeCheck(value, property) { 1647 function numberOrStringSuperTypeCheck(value, property) {
1520 if (value === null) 1648 if (value === null)
1521 return value; 1649 return value;
1522 if (typeof value == string) 1650 if (typeof value == string)
1523 return value; 1651 return value;
1524 if (dart.is(value, core.num)) 1652 if (dart.is(value, core.num))
1525 return value; 1653 return value;
1526 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) 1654 if (!!value[property])
1527 return value; 1655 return value;
1528 propertyTypeError(value, property); 1656 propertyTypeError(value, property);
1529 } 1657 }
1530 // Function numberOrStringSuperTypeCast: (dynamic, dynamic) → dynamic 1658 // Function numberOrStringSuperTypeCast: (dynamic, dynamic) → dynamic
1531 function numberOrStringSuperTypeCast(value, property) { 1659 function numberOrStringSuperTypeCast(value, property) {
1532 if (typeof value == string) 1660 if (typeof value == string)
1533 return value; 1661 return value;
1534 if (dart.is(value, core.num)) 1662 if (dart.is(value, core.num))
1535 return value; 1663 return value;
1536 return propertyTypeCast(value, property); 1664 return propertyTypeCast(value, property);
1537 } 1665 }
1538 // Function numberOrStringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic 1666 // Function numberOrStringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic
1539 function numberOrStringSuperNativeTypeCheck(value, property) { 1667 function numberOrStringSuperNativeTypeCheck(value, property) {
1540 if (value === null) 1668 if (value === null)
1541 return value; 1669 return value;
1542 if (typeof value == string) 1670 if (typeof value == string)
1543 return value; 1671 return value;
1544 if (dart.is(value, core.num)) 1672 if (dart.is(value, core.num))
1545 return value; 1673 return value;
1546 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1674 if (_interceptors.getInterceptor(value)[property])
1547 return value; 1675 return value;
1548 propertyTypeError(value, property); 1676 propertyTypeError(value, property);
1549 } 1677 }
1550 // Function numberOrStringSuperNativeTypeCast: (dynamic, dynamic) → dynamic 1678 // Function numberOrStringSuperNativeTypeCast: (dynamic, dynamic) → dynamic
1551 function numberOrStringSuperNativeTypeCast(value, property) { 1679 function numberOrStringSuperNativeTypeCast(value, property) {
1552 if (value === null) 1680 if (value === null)
1553 return value; 1681 return value;
1554 if (typeof value == string) 1682 if (typeof value == string)
1555 return value; 1683 return value;
1556 if (dart.is(value, core.num)) 1684 if (dart.is(value, core.num))
1557 return value; 1685 return value;
1558 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1686 if (_interceptors.getInterceptor(value)[property])
1559 return value; 1687 return value;
1560 propertyTypeCastError(value, property); 1688 propertyTypeCastError(value, property);
1561 } 1689 }
1562 // Function stringSuperTypeCheck: (dynamic, dynamic) → dynamic 1690 // Function stringSuperTypeCheck: (dynamic, dynamic) → dynamic
1563 function stringSuperTypeCheck(value, property) { 1691 function stringSuperTypeCheck(value, property) {
1564 if (value === null) 1692 if (value === null)
1565 return value; 1693 return value;
1566 if (typeof value == string) 1694 if (typeof value == string)
1567 return value; 1695 return value;
1568 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) 1696 if (!!value[property])
1569 return value; 1697 return value;
1570 propertyTypeError(value, property); 1698 propertyTypeError(value, property);
1571 } 1699 }
1572 // Function stringSuperTypeCast: (dynamic, dynamic) → dynamic 1700 // Function stringSuperTypeCast: (dynamic, dynamic) → dynamic
1573 function stringSuperTypeCast(value, property) { 1701 function stringSuperTypeCast(value, property) {
1574 if (typeof value == string) 1702 if (typeof value == string)
1575 return value; 1703 return value;
1576 return propertyTypeCast(value, property); 1704 return propertyTypeCast(value, property);
1577 } 1705 }
1578 // Function stringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic 1706 // Function stringSuperNativeTypeCheck: (dynamic, dynamic) → dynamic
1579 function stringSuperNativeTypeCheck(value, property) { 1707 function stringSuperNativeTypeCheck(value, property) {
1580 if (value === null) 1708 if (value === null)
1581 return value; 1709 return value;
1582 if (typeof value == string) 1710 if (typeof value == string)
1583 return value; 1711 return value;
1584 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1712 if (_interceptors.getInterceptor(value)[property])
1585 return value; 1713 return value;
1586 propertyTypeError(value, property); 1714 propertyTypeError(value, property);
1587 } 1715 }
1588 // Function stringSuperNativeTypeCast: (dynamic, dynamic) → dynamic 1716 // Function stringSuperNativeTypeCast: (dynamic, dynamic) → dynamic
1589 function stringSuperNativeTypeCast(value, property) { 1717 function stringSuperNativeTypeCast(value, property) {
1590 if (dart.notNull(typeof value == string) || dart.notNull(value === null)) 1718 if (dart.notNull(typeof value == string) || dart.notNull(value === null))
1591 return value; 1719 return value;
1592 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1720 if (_interceptors.getInterceptor(value)[property])
1593 return value; 1721 return value;
1594 propertyTypeCastError(value, property); 1722 propertyTypeCastError(value, property);
1595 } 1723 }
1596 // Function listTypeCheck: (dynamic) → dynamic 1724 // Function listTypeCheck: (dynamic) → dynamic
1597 function listTypeCheck(value) { 1725 function listTypeCheck(value) {
1598 if (value === null) 1726 if (value === null)
1599 return value; 1727 return value;
1600 if (dart.is(value, core.List)) 1728 if (dart.is(value, core.List))
1601 return value; 1729 return value;
1602 throw new TypeErrorImplementation(value, 'List'); 1730 throw new TypeErrorImplementation(value, 'List');
1603 } 1731 }
1604 // Function listTypeCast: (dynamic) → dynamic 1732 // Function listTypeCast: (dynamic) → dynamic
1605 function listTypeCast(value) { 1733 function listTypeCast(value) {
1606 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) 1734 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null))
1607 return value; 1735 return value;
1608 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'List'); 1736 throw new CastErrorImplementation(Primitives.objectTypeName(value), 'List');
1609 } 1737 }
1610 // Function listSuperTypeCheck: (dynamic, dynamic) → dynamic 1738 // Function listSuperTypeCheck: (dynamic, dynamic) → dynamic
1611 function listSuperTypeCheck(value, property) { 1739 function listSuperTypeCheck(value, property) {
1612 if (value === null) 1740 if (value === null)
1613 return value; 1741 return value;
1614 if (dart.is(value, core.List)) 1742 if (dart.is(value, core.List))
1615 return value; 1743 return value;
1616 if (_foreign_helper.JS('bool', '!!#[#]', value, property)) 1744 if (!!value[property])
1617 return value; 1745 return value;
1618 propertyTypeError(value, property); 1746 propertyTypeError(value, property);
1619 } 1747 }
1620 // Function listSuperTypeCast: (dynamic, dynamic) → dynamic 1748 // Function listSuperTypeCast: (dynamic, dynamic) → dynamic
1621 function listSuperTypeCast(value, property) { 1749 function listSuperTypeCast(value, property) {
1622 if (dart.is(value, core.List)) 1750 if (dart.is(value, core.List))
1623 return value; 1751 return value;
1624 return propertyTypeCast(value, property); 1752 return propertyTypeCast(value, property);
1625 } 1753 }
1626 // Function listSuperNativeTypeCheck: (dynamic, dynamic) → dynamic 1754 // Function listSuperNativeTypeCheck: (dynamic, dynamic) → dynamic
1627 function listSuperNativeTypeCheck(value, property) { 1755 function listSuperNativeTypeCheck(value, property) {
1628 if (value === null) 1756 if (value === null)
1629 return value; 1757 return value;
1630 if (dart.is(value, core.List)) 1758 if (dart.is(value, core.List))
1631 return value; 1759 return value;
1632 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1760 if (_interceptors.getInterceptor(value)[property])
1633 return value; 1761 return value;
1634 propertyTypeError(value, property); 1762 propertyTypeError(value, property);
1635 } 1763 }
1636 // Function listSuperNativeTypeCast: (dynamic, dynamic) → dynamic 1764 // Function listSuperNativeTypeCast: (dynamic, dynamic) → dynamic
1637 function listSuperNativeTypeCast(value, property) { 1765 function listSuperNativeTypeCast(value, property) {
1638 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null)) 1766 if (dart.notNull(dart.is(value, core.List)) || dart.notNull(value === null))
1639 return value; 1767 return value;
1640 if (_foreign_helper.JS('bool', '#[#]', _interceptors.getInterceptor(value), property)) 1768 if (_interceptors.getInterceptor(value)[property])
1641 return value; 1769 return value;
1642 propertyTypeCastError(value, property); 1770 propertyTypeCastError(value, property);
1643 } 1771 }
1644 // Function voidTypeCheck: (dynamic) → dynamic 1772 // Function voidTypeCheck: (dynamic) → dynamic
1645 function voidTypeCheck(value) { 1773 function voidTypeCheck(value) {
1646 if (value === null) 1774 if (value === null)
1647 return value; 1775 return value;
1648 throw new TypeErrorImplementation(value, 'void'); 1776 throw new TypeErrorImplementation(value, 'void');
1649 } 1777 }
1650 // Function checkMalformedType: (dynamic, dynamic) → dynamic 1778 // Function checkMalformedType: (dynamic, dynamic) → dynamic
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 super.RuntimeType(); 1872 super.RuntimeType();
1745 } 1873 }
1746 get isVoid() { 1874 get isVoid() {
1747 return dart.is(this.returnType, VoidRuntimeType); 1875 return dart.is(this.returnType, VoidRuntimeType);
1748 } 1876 }
1749 _isTest(expression) { 1877 _isTest(expression) {
1750 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression); 1878 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression);
1751 return functionTypeObject === null ? false : isFunctionSubtype(functionTyp eObject, this.toRti()); 1879 return functionTypeObject === null ? false : isFunctionSubtype(functionTyp eObject, this.toRti());
1752 } 1880 }
1753 _asCheck(expression) { 1881 _asCheck(expression) {
1754 return this._check(_foreign_helper.JS('', '#', expression), true); 1882 return this._check(expression, true);
1755 } 1883 }
1756 _assertCheck(expression) { 1884 _assertCheck(expression) {
1757 if (inAssert) 1885 if (inAssert)
1758 return null; 1886 return null;
1759 inAssert = true; 1887 inAssert = true;
1760 try { 1888 try {
1761 return this._check(_foreign_helper.JS('', '#', expression), false); 1889 return this._check(expression, false);
1762 } finally { 1890 } finally {
1763 inAssert = false; 1891 inAssert = false;
1764 } 1892 }
1765 } 1893 }
1766 _check(expression, isCast) { 1894 _check(expression, isCast) {
1767 if (expression === null) 1895 if (expression === null)
1768 return null; 1896 return null;
1769 if (this._isTest(expression)) 1897 if (this._isTest(expression))
1770 return expression; 1898 return expression;
1771 let self = new FunctionTypeInfoDecoderRing(this.toRti()).toString(); 1899 let self = new FunctionTypeInfoDecoderRing(this.toRti()).toString();
1772 if (isCast) { 1900 if (isCast) {
1773 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression) ; 1901 let functionTypeObject = this._extractFunctionTypeObjectFrom(expression) ;
1774 let pretty = null; 1902 let pretty = null;
1775 if (functionTypeObject !== null) { 1903 if (functionTypeObject !== null) {
1776 pretty = new FunctionTypeInfoDecoderRing(functionTypeObject).toString( ); 1904 pretty = new FunctionTypeInfoDecoderRing(functionTypeObject).toString( );
1777 } else { 1905 } else {
1778 pretty = Primitives.objectTypeName(expression); 1906 pretty = Primitives.objectTypeName(expression);
1779 } 1907 }
1780 throw new CastErrorImplementation(pretty, self); 1908 throw new CastErrorImplementation(pretty, self);
1781 } else { 1909 } else {
1782 throw new TypeErrorImplementation(expression, self); 1910 throw new TypeErrorImplementation(expression, self);
1783 } 1911 }
1784 } 1912 }
1785 _extractFunctionTypeObjectFrom(o) { 1913 _extractFunctionTypeObjectFrom(o) {
1786 let interceptor = _interceptors.getInterceptor(o); 1914 let interceptor = _interceptors.getInterceptor(o);
1787 return _foreign_helper.JS('bool', '# in #', _foreign_helper.JS_SIGNATURE_N AME(), interceptor) ? _foreign_helper.JS('', '#[#]()', interceptor, _foreign_hel per.JS_SIGNATURE_NAME()) : null; 1915 return _foreign_helper.JS_SIGNATURE_NAME() in interceptor ? interceptor[_f oreign_helper.JS_SIGNATURE_NAME()]() : null;
1788 } 1916 }
1789 toRti() { 1917 toRti() {
1790 let result = _foreign_helper.JS('=Object', '{ #: "dynafunc" }', _foreign_h elper.JS_FUNCTION_TYPE_TAG()); 1918 let result = {[_foreign_helper.JS_FUNCTION_TYPE_TAG()]: "dynafunc"};
1791 if (this.isVoid) { 1919 if (this.isVoid) {
1792 _foreign_helper.JS('', '#[#] = true', result, _foreign_helper.JS_FUNCTIO N_TYPE_VOID_RETURN_TAG()); 1920 result[_foreign_helper.JS_FUNCTION_TYPE_VOID_RETURN_TAG()] = true;
1793 } else { 1921 } else {
1794 if (!dart.is(this.returnType, DynamicRuntimeType)) { 1922 if (!dart.is(this.returnType, DynamicRuntimeType)) {
1795 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION _TYPE_RETURN_TYPE_TAG(), this.returnType.toRti()); 1923 result[_foreign_helper.JS_FUNCTION_TYPE_RETURN_TYPE_TAG()] = this.retu rnType.toRti();
1796 } 1924 }
1797 } 1925 }
1798 if (dart.notNull(this.parameterTypes !== null) && dart.notNull(!dart.notNu ll(this.parameterTypes.isEmpty))) { 1926 if (dart.notNull(this.parameterTypes !== null) && dart.notNull(!dart.notNu ll(this.parameterTypes.isEmpty))) {
1799 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T YPE_REQUIRED_PARAMETERS_TAG(), listToRti(this.parameterTypes)); 1927 result[_foreign_helper.JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG()] = lis tToRti(this.parameterTypes);
1800 } 1928 }
1801 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da rt.notNull(this.optionalParameterTypes.isEmpty))) { 1929 if (dart.notNull(this.optionalParameterTypes !== null) && dart.notNull(!da rt.notNull(this.optionalParameterTypes.isEmpty))) {
1802 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T YPE_OPTIONAL_PARAMETERS_TAG(), listToRti(this.optionalParameterTypes)); 1930 result[_foreign_helper.JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG()] = lis tToRti(this.optionalParameterTypes);
1803 } 1931 }
1804 if (this.namedParameters !== null) { 1932 if (this.namedParameters !== null) {
1805 let namedRti = _foreign_helper.JS('=Object', 'Object.create(null)'); 1933 let namedRti = Object.create(null);
1806 let keys = _js_names.extractKeys(this.namedParameters); 1934 let keys = _js_names.extractKeys(this.namedParameters);
1807 for (let i = 0; i < keys.length; i++) { 1935 for (let i = 0; i < keys.length; i++) {
1808 let name = keys.get(i); 1936 let name = keys.get(i);
1809 let rti = dart.dinvoke(_foreign_helper.JS('', '#[#]', this.namedParame ters, name), 'toRti'); 1937 let rti = dart.dinvoke(this.namedParameters[name], 'toRti');
1810 _foreign_helper.JS('', '#[#] = #', namedRti, name, rti); 1938 namedRti[name] = rti;
1811 } 1939 }
1812 _foreign_helper.JS('', '#[#] = #', result, _foreign_helper.JS_FUNCTION_T YPE_NAMED_PARAMETERS_TAG(), namedRti); 1940 result[_foreign_helper.JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG()] = namedR ti;
1813 } 1941 }
1814 return result; 1942 return result;
1815 } 1943 }
1816 static listToRti(list) { 1944 static listToRti(list) {
1817 list = _foreign_helper.JS('JSFixedArray', '#', list); 1945 list = list;
1818 let result = _foreign_helper.JS('JSExtendableArray', '[]'); 1946 let result = [];
1819 for (let i = 0; i['<'](dart.dload(list, 'length')); i++) { 1947 for (let i = 0; i['<'](dart.dload(list, 'length')); i++) {
1820 _foreign_helper.JS('', '#.push(#)', result, dart.dinvoke(dart.dindex(lis t, i), 'toRti')); 1948 result.push(dart.dinvoke(dart.dindex(list, i), 'toRti'));
1821 } 1949 }
1822 return result; 1950 return result;
1823 } 1951 }
1824 toString() { 1952 toString() {
1825 let result = '('; 1953 let result = '(';
1826 let needsComma = false; 1954 let needsComma = false;
1827 if (this.parameterTypes !== null) { 1955 if (this.parameterTypes !== null) {
1828 for (let i = 0; i < this.parameterTypes.length; i++) { 1956 for (let i = 0; i < this.parameterTypes.length; i++) {
1829 let type = this.parameterTypes.get(i); 1957 let type = this.parameterTypes.get(i);
1830 if (needsComma) 1958 if (needsComma)
(...skipping 18 matching lines...) Expand all
1849 } else if (this.namedParameters !== null) { 1977 } else if (this.namedParameters !== null) {
1850 if (needsComma) 1978 if (needsComma)
1851 result = ', '; 1979 result = ', ';
1852 needsComma = false; 1980 needsComma = false;
1853 result = '{'; 1981 result = '{';
1854 let keys = _js_names.extractKeys(this.namedParameters); 1982 let keys = _js_names.extractKeys(this.namedParameters);
1855 for (let i = 0; i < keys.length; i++) { 1983 for (let i = 0; i < keys.length; i++) {
1856 let name = keys.get(i); 1984 let name = keys.get(i);
1857 if (needsComma) 1985 if (needsComma)
1858 result = ', '; 1986 result = ', ';
1859 let rti = dart.dinvoke(_foreign_helper.JS('', '#[#]', this.namedParame ters, name), 'toRti'); 1987 let rti = dart.dinvoke(this.namedParameters[name], 'toRti');
1860 result = `${rti} ${_foreign_helper.JS("String", "#", name)}`; 1988 result = `${rti} ${name}`;
1861 needsComma = true; 1989 needsComma = true;
1862 } 1990 }
1863 result = '}'; 1991 result = '}';
1864 } 1992 }
1865 result = `) -> ${this.returnType}`; 1993 result = `) -> ${this.returnType}`;
1866 return result; 1994 return result;
1867 } 1995 }
1868 } 1996 }
1869 RuntimeFunctionType.inAssert = false; 1997 RuntimeFunctionType.inAssert = false;
1870 // Function buildFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunctionTy pe 1998 // Function buildFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunctionTy pe
1871 function buildFunctionType(returnType, parameterTypes, optionalParameterTypes) { 1999 function buildFunctionType(returnType, parameterTypes, optionalParameterTypes) {
1872 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par ameterTypes, core.List$(RuntimeType)), dart.as(optionalParameterTypes, core.List $(RuntimeType)), null); 2000 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par ameterTypes, core.List$(RuntimeType)), dart.as(optionalParameterTypes, core.List $(RuntimeType)), null);
1873 } 2001 }
1874 // Function buildNamedFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunct ionType 2002 // Function buildNamedFunctionType: (dynamic, dynamic, dynamic) → RuntimeFunct ionType
1875 function buildNamedFunctionType(returnType, parameterTypes, namedParameters) { 2003 function buildNamedFunctionType(returnType, parameterTypes, namedParameters) {
1876 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par ameterTypes, core.List$(RuntimeType)), null, namedParameters); 2004 return new RuntimeFunctionType(dart.as(returnType, RuntimeType), dart.as(par ameterTypes, core.List$(RuntimeType)), null, namedParameters);
1877 } 2005 }
1878 // Function buildInterfaceType: (dynamic, dynamic) → RuntimeType 2006 // Function buildInterfaceType: (dynamic, dynamic) → RuntimeType
1879 function buildInterfaceType(rti, typeArguments) { 2007 function buildInterfaceType(rti, typeArguments) {
1880 let name = dart.as(_foreign_helper.JS('String|Null', '#.name', rti), core.St ring); 2008 let name = dart.as(rti.name, core.String);
1881 if (core.bool['||'](typeArguments === null, dart.dload(typeArguments, 'isEmp ty'))) { 2009 if (core.bool['||'](typeArguments === null, dart.dload(typeArguments, 'isEmp ty'))) {
1882 return new RuntimeTypePlain(name); 2010 return new RuntimeTypePlain(name);
1883 } 2011 }
1884 return new RuntimeTypeGeneric(name, dart.as(typeArguments, core.List$(Runtim eType)), null); 2012 return new RuntimeTypeGeneric(name, dart.as(typeArguments, core.List$(Runtim eType)), null);
1885 } 2013 }
1886 class DynamicRuntimeType extends RuntimeType { 2014 class DynamicRuntimeType extends RuntimeType {
1887 DynamicRuntimeType() { 2015 DynamicRuntimeType() {
1888 super.RuntimeType(); 2016 super.RuntimeType();
1889 } 2017 }
1890 toString() { 2018 toString() {
(...skipping 17 matching lines...) Expand all
1908 toRti() { 2036 toRti() {
1909 return dart.throw_('internal error'); 2037 return dart.throw_('internal error');
1910 } 2038 }
1911 } 2039 }
1912 // Function getVoidRuntimeType: () → RuntimeType 2040 // Function getVoidRuntimeType: () → RuntimeType
1913 function getVoidRuntimeType() { 2041 function getVoidRuntimeType() {
1914 return new VoidRuntimeType(); 2042 return new VoidRuntimeType();
1915 } 2043 }
1916 // Function functionTypeTestMetaHelper: () → dynamic 2044 // Function functionTypeTestMetaHelper: () → dynamic
1917 function functionTypeTestMetaHelper() { 2045 function functionTypeTestMetaHelper() {
1918 let dyn = _foreign_helper.JS('', 'x'); 2046 let dyn = x;
1919 let dyn2 = _foreign_helper.JS('', 'x'); 2047 let dyn2 = x;
1920 let fixedListOrNull = dart.as(_foreign_helper.JS('JSFixedArray|Null', 'x'), core.List); 2048 let fixedListOrNull = dart.as(x, core.List);
1921 let fixedListOrNull2 = dart.as(_foreign_helper.JS('JSFixedArray|Null', 'x'), core.List); 2049 let fixedListOrNull2 = dart.as(x, core.List);
1922 let fixedList = dart.as(_foreign_helper.JS('JSFixedArray', 'x'), core.List); 2050 let fixedList = dart.as(x, core.List);
1923 let jsObject = _foreign_helper.JS('=Object', 'x'); 2051 let jsObject = x;
1924 buildFunctionType(dyn, fixedListOrNull, fixedListOrNull2); 2052 buildFunctionType(dyn, fixedListOrNull, fixedListOrNull2);
1925 buildNamedFunctionType(dyn, fixedList, jsObject); 2053 buildNamedFunctionType(dyn, fixedList, jsObject);
1926 buildInterfaceType(dyn, fixedListOrNull); 2054 buildInterfaceType(dyn, fixedListOrNull);
1927 getDynamicRuntimeType(); 2055 getDynamicRuntimeType();
1928 getVoidRuntimeType(); 2056 getVoidRuntimeType();
1929 convertRtiToRuntimeType(dyn); 2057 convertRtiToRuntimeType(dyn);
1930 dart.dinvoke(dyn, '_isTest', dyn2); 2058 dart.dinvoke(dyn, '_isTest', dyn2);
1931 dart.dinvoke(dyn, '_asCheck', dyn2); 2059 dart.dinvoke(dyn, '_asCheck', dyn2);
1932 dart.dinvoke(dyn, '_assertCheck', dyn2); 2060 dart.dinvoke(dyn, '_assertCheck', dyn2);
1933 } 2061 }
1934 // Function convertRtiToRuntimeType: (dynamic) → RuntimeType 2062 // Function convertRtiToRuntimeType: (dynamic) → RuntimeType
1935 function convertRtiToRuntimeType(rti) { 2063 function convertRtiToRuntimeType(rti) {
1936 if (rti === null) { 2064 if (rti === null) {
1937 return getDynamicRuntimeType(); 2065 return getDynamicRuntimeType();
1938 } else if (_foreign_helper.JS('bool', 'typeof # == "function"', rti)) { 2066 } else if (typeof rti == "function") {
1939 return new RuntimeTypePlain(dart.as(_foreign_helper.JS('String', 'rti.name '), core.String)); 2067 return new RuntimeTypePlain(rti.name);
1940 } else if (_foreign_helper.JS('bool', '#.constructor == Array', rti)) { 2068 } else if (rti.constructor == Array) {
1941 let list = dart.as(_foreign_helper.JS('JSFixedArray', '#', rti), core.List ); 2069 let list = dart.as(rti, core.List);
1942 let name = dart.as(_foreign_helper.JS('String', '#.name', list.get(0)), co re.String); 2070 let name = list.get(0).name;
1943 let arguments = new List.from([]); 2071 let arguments = new List.from([]);
1944 for (let i = 1; i < list.length; i++) { 2072 for (let i = 1; i < list.length; i++) {
1945 arguments.add(convertRtiToRuntimeType(list.get(i))); 2073 arguments.add(convertRtiToRuntimeType(list.get(i)));
1946 } 2074 }
1947 return new RuntimeTypeGeneric(name, dart.as(arguments, core.List$(RuntimeT ype)), rti); 2075 return new RuntimeTypeGeneric(name, dart.as(arguments, core.List$(RuntimeT ype)), rti);
1948 } else if (_foreign_helper.JS('bool', '"func" in #', rti)) { 2076 } else if ("func" in rti) {
1949 return new FunctionTypeInfoDecoderRing(rti).toRuntimeType(); 2077 return new FunctionTypeInfoDecoderRing(rti).toRuntimeType();
1950 } else { 2078 } else {
1951 throw new RuntimeError("Cannot convert " + `'${_foreign_helper.JS('String' , 'JSON.stringify(#)', rti)}' to RuntimeType.`); 2079 throw new RuntimeError("Cannot convert " + `'${JSON.stringify(rti)}' to Ru ntimeType.`);
1952 } 2080 }
1953 } 2081 }
1954 class RuntimeTypePlain extends RuntimeType { 2082 class RuntimeTypePlain extends RuntimeType {
1955 RuntimeTypePlain(name) { 2083 RuntimeTypePlain(name) {
1956 this.name = name; 2084 this.name = name;
1957 super.RuntimeType(); 2085 super.RuntimeType();
1958 } 2086 }
1959 toRti() { 2087 toRti() {
1960 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.ALL_CLASSES, core.String)); 2088 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.ALL_CLASSES, core.String));
1961 let rti = _foreign_helper.JS('', '#[#]', allClasses, this.name); 2089 let rti = allClasses[this.name];
1962 if (rti === null) 2090 if (rti === null)
1963 throw `no type for '${this.name}'`; 2091 throw `no type for '${this.name}'`;
1964 return rti; 2092 return rti;
1965 } 2093 }
1966 toString() { 2094 toString() {
1967 return this.name; 2095 return this.name;
1968 } 2096 }
1969 } 2097 }
1970 class RuntimeTypeGeneric extends RuntimeType { 2098 class RuntimeTypeGeneric extends RuntimeType {
1971 RuntimeTypeGeneric(name, arguments, rti) { 2099 RuntimeTypeGeneric(name, arguments, rti) {
1972 this.name = name; 2100 this.name = name;
1973 this.arguments = arguments; 2101 this.arguments = arguments;
1974 this.rti = rti; 2102 this.rti = rti;
1975 super.RuntimeType(); 2103 super.RuntimeType();
1976 } 2104 }
1977 toRti() { 2105 toRti() {
1978 if (this.rti !== null) 2106 if (this.rti !== null)
1979 return this.rti; 2107 return this.rti;
1980 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.ALL_CLASSES, core.String)); 2108 let allClasses = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.ALL_CLASSES, core.String));
1981 let result = _foreign_helper.JS('JSExtendableArray', '[#[#]]', allClasses, this.name); 2109 let result = [allClasses[this.name]];
1982 if (dart.dindex(result, 0) === null) { 2110 if (dart.dindex(result, 0) === null) {
1983 throw `no type for '${this.name}<...>'`; 2111 throw `no type for '${this.name}<...>'`;
1984 } 2112 }
1985 for (let argument of this.arguments) { 2113 for (let argument of this.arguments) {
1986 _foreign_helper.JS('', '#.push(#)', result, argument.toRti()); 2114 result.push(argument.toRti());
1987 } 2115 }
1988 return this.rti = result; 2116 return this.rti = result;
1989 } 2117 }
1990 toString() { 2118 toString() {
1991 return `${this.name}<${this.arguments.join(", ")}>`; 2119 return `${this.name}<${this.arguments.join(", ")}>`;
1992 } 2120 }
1993 } 2121 }
1994 class FunctionTypeInfoDecoderRing extends dart.Object { 2122 class FunctionTypeInfoDecoderRing extends dart.Object {
1995 FunctionTypeInfoDecoderRing(_typeData) { 2123 FunctionTypeInfoDecoderRing(_typeData) {
1996 this._typeData = _typeData; 2124 this._typeData = _typeData;
1997 this._cachedToString = null; 2125 this._cachedToString = null;
1998 } 2126 }
1999 get _hasReturnType() { 2127 get _hasReturnType() {
2000 return dart.as(_foreign_helper.JS('bool', '"ret" in #', this._typeData), c ore.bool); 2128 return "ret" in this._typeData;
2001 } 2129 }
2002 get _returnType() { 2130 get _returnType() {
2003 return _foreign_helper.JS('', '#.ret', this._typeData); 2131 return this._typeData.ret;
2004 } 2132 }
2005 get _isVoid() { 2133 get _isVoid() {
2006 return dart.as(_foreign_helper.JS('bool', '!!#.void', this._typeData), cor e.bool); 2134 return !!this._typeData["void"];
2007 } 2135 }
2008 get _hasArguments() { 2136 get _hasArguments() {
2009 return dart.as(_foreign_helper.JS('bool', '"args" in #', this._typeData), core.bool); 2137 return "args" in this._typeData;
2010 } 2138 }
2011 get _arguments() { 2139 get _arguments() {
2012 return dart.as(_foreign_helper.JS('JSExtendableArray', '#.args', this._typ eData), core.List); 2140 return dart.as(this._typeData.args, core.List);
2013 } 2141 }
2014 get _hasOptionalArguments() { 2142 get _hasOptionalArguments() {
2015 return dart.as(_foreign_helper.JS('bool', '"opt" in #', this._typeData), c ore.bool); 2143 return "opt" in this._typeData;
2016 } 2144 }
2017 get _optionalArguments() { 2145 get _optionalArguments() {
2018 return dart.as(_foreign_helper.JS('JSExtendableArray', '#.opt', this._type Data), core.List); 2146 return dart.as(this._typeData.opt, core.List);
2019 } 2147 }
2020 get _hasNamedArguments() { 2148 get _hasNamedArguments() {
2021 return dart.as(_foreign_helper.JS('bool', '"named" in #', this._typeData), core.bool); 2149 return "named" in this._typeData;
2022 } 2150 }
2023 get _namedArguments() { 2151 get _namedArguments() {
2024 return _foreign_helper.JS('=Object', '#.named', this._typeData); 2152 return this._typeData.named;
2025 } 2153 }
2026 toRuntimeType() { 2154 toRuntimeType() {
2027 return new DynamicRuntimeType(); 2155 return new DynamicRuntimeType();
2028 } 2156 }
2029 _convert(type) { 2157 _convert(type) {
2030 let result = runtimeTypeToString(type); 2158 let result = runtimeTypeToString(type);
2031 if (result !== null) 2159 if (result !== null)
2032 return result; 2160 return result;
2033 if (_foreign_helper.JS('bool', '"func" in #', type)) { 2161 if ("func" in type) {
2034 return new FunctionTypeInfoDecoderRing(type).toString(); 2162 return new FunctionTypeInfoDecoderRing(type).toString();
2035 } else { 2163 } else {
2036 throw 'bad type'; 2164 throw 'bad type';
2037 } 2165 }
2038 } 2166 }
2039 toString() { 2167 toString() {
2040 if (this._cachedToString !== null) 2168 if (this._cachedToString !== null)
2041 return this._cachedToString; 2169 return this._cachedToString;
2042 let s = "("; 2170 let s = "(";
2043 let sep = ''; 2171 let sep = '';
(...skipping 13 matching lines...) Expand all
2057 sep = ', '; 2185 sep = ', ';
2058 } 2186 }
2059 s = ']'; 2187 s = ']';
2060 } 2188 }
2061 if (this._hasNamedArguments) { 2189 if (this._hasNamedArguments) {
2062 s = `${sep}{`; 2190 s = `${sep}{`;
2063 sep = ''; 2191 sep = '';
2064 for (let name of _js_names.extractKeys(this._namedArguments)) { 2192 for (let name of _js_names.extractKeys(this._namedArguments)) {
2065 s = sep; 2193 s = sep;
2066 s = `${name}: `; 2194 s = `${name}: `;
2067 s = this._convert(_foreign_helper.JS('', '#[#]', this._namedArguments, name)); 2195 s = this._convert(this._namedArguments[name]);
2068 sep = ', '; 2196 sep = ', ';
2069 } 2197 }
2070 s = '}'; 2198 s = '}';
2071 } 2199 }
2072 s = ') -> '; 2200 s = ') -> ';
2073 if (this._isVoid) { 2201 if (this._isVoid) {
2074 s = 'void'; 2202 s = 'void';
2075 } else if (this._hasReturnType) { 2203 } else if (this._hasReturnType) {
2076 s = this._convert(this._returnType); 2204 s = this._convert(this._returnType);
2077 } else { 2205 } else {
2078 s = 'dynamic'; 2206 s = 'dynamic';
2079 } 2207 }
2080 return this._cachedToString = `${s}`; 2208 return this._cachedToString = `${s}`;
2081 } 2209 }
2082 } 2210 }
2083 class UnimplementedNoSuchMethodError extends core.Error { 2211 class UnimplementedNoSuchMethodError extends core.Error {
2084 UnimplementedNoSuchMethodError(_message) { 2212 UnimplementedNoSuchMethodError(_message) {
2085 this._message = _message; 2213 this._message = _message;
2086 super.Error(); 2214 super.Error();
2087 } 2215 }
2088 toString() { 2216 toString() {
2089 return `Unsupported operation: ${this._message}`; 2217 return `Unsupported operation: ${this._message}`;
2090 } 2218 }
2091 } 2219 }
2092 // Function random64: () → int 2220 // Function random64: () → int
2093 function random64() { 2221 function random64() {
2094 let int32a = dart.as(_foreign_helper.JS("int", "(Math.random() * 0x100000000 ) >>> 0"), core.int); 2222 let int32a = Math.random() * 0x100000000 >>> 0;
2095 let int32b = dart.as(_foreign_helper.JS("int", "(Math.random() * 0x100000000 ) >>> 0"), core.int); 2223 let int32b = Math.random() * 0x100000000 >>> 0;
2096 return int32a + int32b * 4294967296; 2224 return int32a + int32b * 4294967296;
2097 } 2225 }
2098 // Function jsonEncodeNative: (String) → String 2226 // Function jsonEncodeNative: (String) → String
2099 function jsonEncodeNative(string) { 2227 function jsonEncodeNative(string) {
2100 return dart.as(_foreign_helper.JS("String", "JSON.stringify(#)", string), co re.String); 2228 return JSON.stringify(string);
2101 } 2229 }
2102 // Function getIsolateAffinityTag: (String) → String 2230 // Function getIsolateAffinityTag: (String) → String
2103 function getIsolateAffinityTag(name) { 2231 function getIsolateAffinityTag(name) {
2104 let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em bedded_names.GET_ISOLATE_TAG, core.String)); 2232 let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em bedded_names.GET_ISOLATE_TAG, core.String));
2105 return dart.as(_foreign_helper.JS('String', '#(#)', isolateTagGetter, name), core.String); 2233 return isolateTagGetter(name);
2106 } 2234 }
2107 // Function _loadLibraryWrapper: (String) → () → Future<Null> 2235 // Function _loadLibraryWrapper: (String) → () → Future<Null>
2108 function _loadLibraryWrapper(loadId) { 2236 function _loadLibraryWrapper(loadId) {
2109 return () => loadDeferredLibrary(loadId); 2237 return () => loadDeferredLibrary(loadId);
2110 } 2238 }
2111 dart.defineLazyProperties(_js_helper, { 2239 dart.defineLazyProperties(_js_helper, {
2112 get _loadingLibraries() { 2240 get _loadingLibraries() {
2113 return dart.map(); 2241 return dart.map();
2114 }, 2242 },
2115 get _loadedLibraries() { 2243 get _loadedLibraries() {
2116 return new core.Set(); 2244 return new core.Set();
2117 } 2245 }
2118 }); 2246 });
2119 _js_helper.deferredLoadHook = null; 2247 _js_helper.deferredLoadHook = null;
2120 // Function loadDeferredLibrary: (String) → Future<Null> 2248 // Function loadDeferredLibrary: (String) → Future<Null>
2121 function loadDeferredLibrary(loadId) { 2249 function loadDeferredLibrary(loadId) {
2122 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_na mes.DEFERRED_LIBRARY_URIS, core.String)); 2250 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_na mes.DEFERRED_LIBRARY_URIS, core.String));
2123 let uris = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#[#]', uris Map, loadId), core.List$(core.String)); 2251 let uris = dart.as(urisMap[loadId], core.List$(core.String));
2124 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_ names.DEFERRED_LIBRARY_HASHES, core.String)); 2252 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedded_ names.DEFERRED_LIBRARY_HASHES, core.String));
2125 let hashes = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#[#]', ha shesMap, loadId), core.List$(core.String)); 2253 let hashes = dart.as(hashesMap[loadId], core.List$(core.String));
2126 if (uris === null) 2254 if (uris === null)
2127 return dart.as(new async.Future.value(null), async.Future$(core.Null)); 2255 return dart.as(new async.Future.value(null), async.Future$(core.Null));
2128 let indices = dart.as(new core.List.generate(uris.length, (i) => i), core.Li st$(core.int)); 2256 let indices = dart.as(new core.List.generate(uris.length, (i) => i), core.Li st$(core.int));
2129 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.IS_HUNK_LOADED, core.String)); 2257 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_embedd ed_names.IS_HUNK_LOADED, core.String));
2130 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e mbedded_names.IS_HUNK_INITIALIZED, core.String)); 2258 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e mbedded_names.IS_HUNK_INITIALIZED, core.String));
2131 let indicesToLoad = indices.where((i) => dart.throw_("Unimplemented PrefixEx pression: !JS('bool', '#(#)', isHunkLoaded, hashes[i])")).toList(); 2259 let indicesToLoad = indices.where((i) => !dart.notNull(isHunkLoaded(hashes.g et(i)))).toList();
2132 return dart.as(async.Future.wait(dart.as(indicesToLoad.map((i) => _loadHunk( uris.get(i))), core.Iterable$(async.Future))).then((_) => { 2260 return dart.as(async.Future.wait(dart.as(indicesToLoad.map((i) => _loadHunk( uris.get(i))), core.Iterable$(async.Future))).then((_) => {
2133 let indicesToInitialize = indices.where((i) => dart.throw_("Unimplemented PrefixExpression: !JS('bool', '#(#)', isHunkInitialized, hashes[i])")).toList(); 2261 let indicesToInitialize = indices.where((i) => !dart.notNull(isHunkInitial ized(hashes.get(i)))).toList();
2134 for (let i of indicesToInitialize) { 2262 for (let i of indicesToInitialize) {
2135 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_emb edded_names.INITIALIZE_LOADED_HUNK, core.String)); 2263 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_emb edded_names.INITIALIZE_LOADED_HUNK, core.String));
2136 _foreign_helper.JS('void', '#(#)', initializer, hashes.get(i)); 2264 initializer(hashes.get(i));
2137 } 2265 }
2138 let updated = _js_helper._loadedLibraries.add(loadId); 2266 let updated = _js_helper._loadedLibraries.add(loadId);
2139 if (dart.notNull(updated) && dart.notNull(_js_helper.deferredLoadHook !== null)) { 2267 if (dart.notNull(updated) && dart.notNull(_js_helper.deferredLoadHook !== null)) {
2140 _js_helper.deferredLoadHook(); 2268 _js_helper.deferredLoadHook();
2141 } 2269 }
2142 }), async.Future$(core.Null)); 2270 }), async.Future$(core.Null));
2143 } 2271 }
2144 // Function _loadHunk: (String) → Future<Null> 2272 // Function _loadHunk: (String) → Future<Null>
2145 function _loadHunk(hunkName) { 2273 function _loadHunk(hunkName) {
2146 let future = _js_helper._loadingLibraries.get(hunkName); 2274 let future = _js_helper._loadingLibraries.get(hunkName);
2147 if (future !== null) { 2275 if (future !== null) {
2148 return dart.as(future.then((_) => null), async.Future$(core.Null)); 2276 return dart.as(future.then((_) => null), async.Future$(core.Null));
2149 } 2277 }
2150 let uri = _isolate_helper.IsolateNatives.thisScript; 2278 let uri = _isolate_helper.IsolateNatives.thisScript;
2151 let index = uri.lastIndexOf('/'); 2279 let index = uri.lastIndexOf('/');
2152 uri = `${uri.substring(0, index + 1)}${hunkName}`; 2280 uri = `${uri.substring(0, index + 1)}${hunkName}`;
2153 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { 2281 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) {
2154 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { 2282 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => {
2155 try { 2283 try {
2156 _foreign_helper.JS('void', '(new Function(#))()', `load("${uri}")`); 2284 new Function(`load("${uri}")`)();
2157 } catch (error) { 2285 } catch (error) {
2158 let stackTrace = dart.stackTrace(error); 2286 let stackTrace = dart.stackTrace(error);
2159 throw new async.DeferredLoadException(`Loading ${uri} failed.`); 2287 throw new async.DeferredLoadException(`Loading ${uri} failed.`);
2160 } 2288 }
2161 2289
2162 return null; 2290 return null;
2163 })); 2291 }));
2164 } else if (_isolate_helper.isWorker()) { 2292 } else if (_isolate_helper.isWorker()) {
2165 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { 2293 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => {
2166 let completer = new async.Completer(); 2294 let completer = new async.Completer();
2167 _isolate_helper.enterJsAsync(); 2295 _isolate_helper.enterJsAsync();
2168 let leavingFuture = dart.as(completer.future.whenComplete(() => { 2296 let leavingFuture = dart.as(completer.future.whenComplete(() => {
2169 _isolate_helper.leaveJsAsync(); 2297 _isolate_helper.leaveJsAsync();
2170 }), async.Future$(core.Null)); 2298 }), async.Future$(core.Null));
2171 let index = uri.lastIndexOf('/'); 2299 let index = uri.lastIndexOf('/');
2172 uri = `${uri.substring(0, index + 1)}${hunkName}`; 2300 uri = `${uri.substring(0, index + 1)}${hunkName}`;
2173 let xhr = _foreign_helper.JS('dynamic', 'new XMLHttpRequest()'); 2301 let xhr = new XMLHttpRequest();
2174 _foreign_helper.JS('void', '#.open("GET", #)', xhr, uri); 2302 xhr.open("GET", uri);
2175 _foreign_helper.JS('void', '#.addEventListener("load", #, false)', xhr, convertDartClosureToJS((event) => { 2303 xhr.addEventListener("load", convertDartClosureToJS((event) => {
2176 if (!dart.equals(_foreign_helper.JS('int', '#.status', xhr), 200)) { 2304 if (xhr.status !== 200) {
2177 completer.completeError(new async.DeferredLoadException(`Loading ${u ri} failed.`)); 2305 completer.completeError(new async.DeferredLoadException(`Loading ${u ri} failed.`));
2178 return; 2306 return;
2179 } 2307 }
2180 let code = dart.as(_foreign_helper.JS('String', '#.responseText', xhr) , core.String); 2308 let code = xhr.responseText;
2181 try { 2309 try {
2182 _foreign_helper.JS('void', '(new Function(#))()', code); 2310 new Function(code)();
2183 } catch (error) { 2311 } catch (error) {
2184 let stackTrace = dart.stackTrace(error); 2312 let stackTrace = dart.stackTrace(error);
2185 completer.completeError(new async.DeferredLoadException(`Evaluating ${uri} failed.`)); 2313 completer.completeError(new async.DeferredLoadException(`Evaluating ${uri} failed.`));
2186 return; 2314 return;
2187 } 2315 }
2188 2316
2189 completer.complete(null); 2317 completer.complete(null);
2190 }, 1)); 2318 }, 1), false);
2191 let fail = convertDartClosureToJS((event) => { 2319 let fail = convertDartClosureToJS((event) => {
2192 new async.DeferredLoadException(`Loading ${uri} failed.`); 2320 new async.DeferredLoadException(`Loading ${uri} failed.`);
2193 }, 1); 2321 }, 1);
2194 _foreign_helper.JS('void', '#.addEventListener("error", #, false)', xhr, fail); 2322 xhr.addEventListener("error", fail, false);
2195 _foreign_helper.JS('void', '#.addEventListener("abort", #, false)', xhr, fail); 2323 xhr.addEventListener("abort", fail, false);
2196 _foreign_helper.JS('void', '#.send()', xhr); 2324 xhr.send();
2197 return leavingFuture; 2325 return leavingFuture;
2198 })); 2326 }));
2199 } 2327 }
2200 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => { 2328 return _js_helper._loadingLibraries.set(hunkName, new async.Future(() => {
2201 let completer = new async.Completer(); 2329 let completer = new async.Completer();
2202 let script = _foreign_helper.JS('', 'document.createElement("script")'); 2330 let script = document.createElement("script");
2203 _foreign_helper.JS('', '#.type = "text/javascript"', script); 2331 script.type = "text/javascript";
2204 _foreign_helper.JS('', '#.src = #', script, uri); 2332 script.src = uri;
2205 _foreign_helper.JS('', '#.addEventListener("load", #, false)', script, con vertDartClosureToJS((event) => { 2333 script.addEventListener("load", convertDartClosureToJS((event) => {
2206 completer.complete(null); 2334 completer.complete(null);
2207 }, 1)); 2335 }, 1), false);
2208 _foreign_helper.JS('', '#.addEventListener("error", #, false)', script, co nvertDartClosureToJS((event) => { 2336 script.addEventListener("error", convertDartClosureToJS((event) => {
2209 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`)); 2337 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`));
2210 }, 1)); 2338 }, 1), false);
2211 _foreign_helper.JS('', 'document.body.appendChild(#)', script); 2339 document.body.appendChild(script);
2212 return completer.future; 2340 return completer.future;
2213 })); 2341 }));
2214 } 2342 }
2215 class MainError extends core.Error { 2343 class MainError extends core.Error {
2216 MainError(_message) { 2344 MainError(_message) {
2217 this._message = _message; 2345 this._message = _message;
2218 super.Error(); 2346 super.Error();
2219 } 2347 }
2220 toString() { 2348 toString() {
2221 return `NoSuchMethodError: ${this._message}`; 2349 return `NoSuchMethodError: ${this._message}`;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 } 2439 }
2312 get(key) { 2440 get(key) {
2313 if (!dart.notNull(this.containsKey(key))) 2441 if (!dart.notNull(this.containsKey(key)))
2314 return dart.as(null, V); 2442 return dart.as(null, V);
2315 return dart.as(this._fetch(key), V); 2443 return dart.as(this._fetch(key), V);
2316 } 2444 }
2317 _fetch(key) { 2445 _fetch(key) {
2318 return jsPropertyAccess(this._jsObject, dart.as(key, core.String)); 2446 return jsPropertyAccess(this._jsObject, dart.as(key, core.String));
2319 } 2447 }
2320 forEach(f) { 2448 forEach(f) {
2321 let keys = _foreign_helper.JS('JSArray', '#', this._keys); 2449 let keys = this._keys;
2322 for (let i = 0; i['<'](dart.dload(keys, 'length')); i++) { 2450 for (let i = 0; i['<'](dart.dload(keys, 'length')); i++) {
2323 let key = dart.dindex(keys, i); 2451 let key = dart.dindex(keys, i);
2324 f(dart.as(key, K), dart.as(this._fetch(key), V)); 2452 f(dart.as(key, K), dart.as(this._fetch(key), V));
2325 } 2453 }
2326 } 2454 }
2327 get keys() { 2455 get keys() {
2328 return new _ConstantMapKeyIterable(this); 2456 return new _ConstantMapKeyIterable(this);
2329 } 2457 }
2330 get values() { 2458 get values() {
2331 return new _internal.MappedIterable(this._keys, dart.as(((key) => this._ fetch(key)).bind(this), dart.throw_("Unimplemented type (K) → V"))); 2459 return new _internal.MappedIterable(this._keys, dart.as(((key) => this._ fetch(key)).bind(this), dart.throw_("Unimplemented type (K) → V")));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 return _ConstantMapKeyIterable; 2500 return _ConstantMapKeyIterable;
2373 }); 2501 });
2374 let _ConstantMapKeyIterable = _ConstantMapKeyIterable$(dynamic); 2502 let _ConstantMapKeyIterable = _ConstantMapKeyIterable$(dynamic);
2375 let GeneralConstantMap$ = dart.generic(function(K, V) { 2503 let GeneralConstantMap$ = dart.generic(function(K, V) {
2376 class GeneralConstantMap extends ConstantMap$(K, V) { 2504 class GeneralConstantMap extends ConstantMap$(K, V) {
2377 GeneralConstantMap(_jsData) { 2505 GeneralConstantMap(_jsData) {
2378 this._jsData = _jsData; 2506 this._jsData = _jsData;
2379 super.ConstantMap$_(); 2507 super.ConstantMap$_();
2380 } 2508 }
2381 _getMap() { 2509 _getMap() {
2382 if (_foreign_helper.JS('bool', '!this.$map')) { 2510 if (!this.$map) {
2383 let backingMap = new collection.LinkedHashMap(); 2511 let backingMap = new collection.LinkedHashMap();
2384 _foreign_helper.JS('', 'this.$map = #', fillLiteralMap(this._jsData, b ackingMap)); 2512 this.$map = fillLiteralMap(this._jsData, backingMap);
2385 } 2513 }
2386 return dart.as(_foreign_helper.JS('Map', 'this.$map'), core.Map$(K, V)); 2514 return this.$map;
2387 } 2515 }
2388 containsValue(needle) { 2516 containsValue(needle) {
2389 return this._getMap().containsValue(needle); 2517 return this._getMap().containsValue(needle);
2390 } 2518 }
2391 containsKey(key) { 2519 containsKey(key) {
2392 return this._getMap().containsKey(key); 2520 return this._getMap().containsKey(key);
2393 } 2521 }
2394 get(key) { 2522 get(key) {
2395 return this._getMap().get(key); 2523 return this._getMap().get(key);
2396 } 2524 }
2397 forEach(f) { 2525 forEach(f) {
2398 this._getMap().forEach(f); 2526 this._getMap().forEach(f);
2399 } 2527 }
2400 get keys() { 2528 get keys() {
2401 return this._getMap().keys; 2529 return this._getMap().keys;
2402 } 2530 }
2403 get values() { 2531 get values() {
2404 return this._getMap().values; 2532 return this._getMap().values;
2405 } 2533 }
2406 get length() { 2534 get length() {
2407 return this._getMap().length; 2535 return this._getMap().length;
2408 } 2536 }
2409 } 2537 }
2410 return GeneralConstantMap; 2538 return GeneralConstantMap;
2411 }); 2539 });
2412 let GeneralConstantMap = GeneralConstantMap$(dynamic, dynamic); 2540 let GeneralConstantMap = GeneralConstantMap$(dynamic, dynamic);
2413 // Function contains: (String, String) → bool 2541 // Function contains: (String, String) → bool
2414 function contains(userAgent, name) { 2542 function contains(userAgent, name) {
2415 return !dart.equals(_foreign_helper.JS('int', '#.indexOf(#)', userAgent, nam e), -1); 2543 return userAgent.indexOf(name) !== -1;
2416 } 2544 }
2417 // Function arrayLength: (List<dynamic>) → int 2545 // Function arrayLength: (List<dynamic>) → int
2418 function arrayLength(array) { 2546 function arrayLength(array) {
2419 return dart.as(_foreign_helper.JS('int', '#.length', array), core.int); 2547 return array.length;
2420 } 2548 }
2421 // Function arrayGet: (List<dynamic>, int) → dynamic 2549 // Function arrayGet: (List<dynamic>, int) → dynamic
2422 function arrayGet(array, index) { 2550 function arrayGet(array, index) {
2423 return _foreign_helper.JS('var', '#[#]', array, index); 2551 return array[index];
2424 } 2552 }
2425 // Function arraySet: (List<dynamic>, int, dynamic) → void 2553 // Function arraySet: (List<dynamic>, int, dynamic) → void
2426 function arraySet(array, index, value) { 2554 function arraySet(array, index, value) {
2427 _foreign_helper.JS('var', '#[#] = #', array, index, value); 2555 array[index] = value;
2428 } 2556 }
2429 // Function propertyGet: (dynamic, String) → dynamic 2557 // Function propertyGet: (dynamic, String) → dynamic
2430 function propertyGet(object, property) { 2558 function propertyGet(object, property) {
2431 return _foreign_helper.JS('var', '#[#]', object, property); 2559 return object[property];
2432 } 2560 }
2433 // Function callHasOwnProperty: (dynamic, dynamic, String) → bool 2561 // Function callHasOwnProperty: (dynamic, dynamic, String) → bool
2434 function callHasOwnProperty(function, object, property) { 2562 function callHasOwnProperty(function, object, property) {
2435 return dart.as(_foreign_helper.JS('bool', '#.call(#, #)', function, object, property), core.bool); 2563 return function.call(object, property);
2436 } 2564 }
2437 // Function propertySet: (dynamic, String, dynamic) → void 2565 // Function propertySet: (dynamic, String, dynamic) → void
2438 function propertySet(object, property, value) { 2566 function propertySet(object, property, value) {
2439 _foreign_helper.JS('var', '#[#] = #', object, property, value); 2567 object[property] = value;
2440 } 2568 }
2441 // Function getPropertyFromPrototype: (dynamic, String) → dynamic 2569 // Function getPropertyFromPrototype: (dynamic, String) → dynamic
2442 function getPropertyFromPrototype(object, name) { 2570 function getPropertyFromPrototype(object, name) {
2443 return _foreign_helper.JS('var', 'Object.getPrototypeOf(#)[#]', object, name ); 2571 return Object.getPrototypeOf(object)[name];
2444 } 2572 }
2445 _js_helper.getTagFunction = null; 2573 _js_helper.getTagFunction = null;
2446 _js_helper.alternateTagFunction = null; 2574 _js_helper.alternateTagFunction = null;
2447 _js_helper.prototypeForTagFunction = null; 2575 _js_helper.prototypeForTagFunction = null;
2448 // Function toStringForNativeObject: (dynamic) → String 2576 // Function toStringForNativeObject: (dynamic) → String
2449 function toStringForNativeObject(obj) { 2577 function toStringForNativeObject(obj) {
2450 let name = dart.as(_js_helper.getTagFunction === null ? '<Unknown>' : _forei gn_helper.JS('String', '#', dart.dinvokef(_js_helper.getTagFunction, obj)), core .String); 2578 let name = _js_helper.getTagFunction === null ? '<Unknown>' : dart.dinvokef( _js_helper.getTagFunction, obj);
2451 return `Instance of ${name}`; 2579 return `Instance of ${name}`;
2452 } 2580 }
2453 // Function hashCodeForNativeObject: (dynamic) → int 2581 // Function hashCodeForNativeObject: (dynamic) → int
2454 function hashCodeForNativeObject(object) { 2582 function hashCodeForNativeObject(object) {
2455 return Primitives.objectHashCode(object); 2583 return Primitives.objectHashCode(object);
2456 } 2584 }
2457 // Function defineProperty: (dynamic, String, dynamic) → void 2585 // Function defineProperty: (dynamic, String, dynamic) → void
2458 function defineProperty(obj, property, value) { 2586 function defineProperty(obj, property, value) {
2459 _foreign_helper.JS('void', 'Object.defineProperty(#, #, ' + '{value: #, enum erable: false, writable: true, configurable: true})', obj, property, value); 2587 Object.defineProperty(obj, property, {value: value, enumerable: false, writa ble: true, configurable: true});
2460 } 2588 }
2461 // Function isDartObject: (dynamic) → bool 2589 // Function isDartObject: (dynamic) → bool
2462 function isDartObject(obj) { 2590 function isDartObject(obj) {
2463 return dart.as(_foreign_helper.JS('bool', '((#) instanceof (#))', obj, _fore ign_helper.JS_DART_OBJECT_CONSTRUCTOR()), core.bool); 2591 return obj instanceof _foreign_helper.JS_DART_OBJECT_CONSTRUCTOR();
2464 } 2592 }
2465 dart.copyProperties(_js_helper, { 2593 dart.copyProperties(_js_helper, {
2466 get interceptorsByTag() { 2594 get interceptorsByTag() {
2467 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_ names.INTERCEPTORS_BY_TAG, core.String)); 2595 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_ names.INTERCEPTORS_BY_TAG, core.String));
2468 }, 2596 },
2469 get leafTags() { 2597 get leafTags() {
2470 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_ names.LEAF_TAGS, core.String)); 2598 return _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', dart.as(_js_embedded_ names.LEAF_TAGS, core.String));
2471 } 2599 }
2472 }); 2600 });
2473 // Function findDispatchTagForInterceptorClass: (dynamic) → String 2601 // Function findDispatchTagForInterceptorClass: (dynamic) → String
2474 function findDispatchTagForInterceptorClass(interceptorClassConstructor) { 2602 function findDispatchTagForInterceptorClass(interceptorClassConstructor) {
2475 return dart.as(_foreign_helper.JS('', '#.#', interceptorClassConstructor, _j s_embedded_names.NATIVE_SUPERCLASS_TAG_NAME), core.String); 2603 return dart.as(interceptorClassConstructor[_js_embedded_names.NATIVE_SUPERCL ASS_TAG_NAME], core.String);
2476 } 2604 }
2477 _js_helper.dispatchRecordsForInstanceTags = null; 2605 _js_helper.dispatchRecordsForInstanceTags = null;
2478 _js_helper.interceptorsForUncacheableTags = null; 2606 _js_helper.interceptorsForUncacheableTags = null;
2479 // Function lookupInterceptor: (String) → dynamic 2607 // Function lookupInterceptor: (String) → dynamic
2480 function lookupInterceptor(tag) { 2608 function lookupInterceptor(tag) {
2481 return propertyGet(_js_helper.interceptorsByTag, tag); 2609 return propertyGet(_js_helper.interceptorsByTag, tag);
2482 } 2610 }
2483 let UNCACHED_MARK = '~'; 2611 let UNCACHED_MARK = '~';
2484 let INSTANCE_CACHED_MARK = '!'; 2612 let INSTANCE_CACHED_MARK = '!';
2485 let LEAF_MARK = '-'; 2613 let LEAF_MARK = '-';
(...skipping 18 matching lines...) Expand all
2504 return patchInstance(obj, record); 2632 return patchInstance(obj, record);
2505 interceptor = propertyGet(_js_helper.interceptorsForUncacheableTags, tag ); 2633 interceptor = propertyGet(_js_helper.interceptorsForUncacheableTags, tag );
2506 if (interceptor !== null) 2634 if (interceptor !== null)
2507 return interceptor; 2635 return interceptor;
2508 interceptorClass = lookupInterceptor(tag); 2636 interceptorClass = lookupInterceptor(tag);
2509 } 2637 }
2510 } 2638 }
2511 if (interceptorClass === null) { 2639 if (interceptorClass === null) {
2512 return null; 2640 return null;
2513 } 2641 }
2514 interceptor = _foreign_helper.JS('', '#.prototype', interceptorClass); 2642 interceptor = interceptorClass.prototype;
2515 let mark = _foreign_helper.JS('String|Null', '#[0]', tag); 2643 let mark = tag[0];
2516 if (dart.equals(mark, INSTANCE_CACHED_MARK)) { 2644 if (dart.equals(mark, INSTANCE_CACHED_MARK)) {
2517 record = makeLeafDispatchRecord(interceptor); 2645 record = makeLeafDispatchRecord(interceptor);
2518 propertySet(_js_helper.dispatchRecordsForInstanceTags, tag, record); 2646 propertySet(_js_helper.dispatchRecordsForInstanceTags, tag, record);
2519 return patchInstance(obj, record); 2647 return patchInstance(obj, record);
2520 } 2648 }
2521 if (dart.equals(mark, UNCACHED_MARK)) { 2649 if (dart.equals(mark, UNCACHED_MARK)) {
2522 propertySet(_js_helper.interceptorsForUncacheableTags, tag, interceptor); 2650 propertySet(_js_helper.interceptorsForUncacheableTags, tag, interceptor);
2523 return interceptor; 2651 return interceptor;
2524 } 2652 }
2525 if (dart.equals(mark, LEAF_MARK)) { 2653 if (dart.equals(mark, LEAF_MARK)) {
2526 return patchProto(obj, makeLeafDispatchRecord(interceptor)); 2654 return patchProto(obj, makeLeafDispatchRecord(interceptor));
2527 } 2655 }
2528 if (dart.equals(mark, INTERIOR_MARK)) { 2656 if (dart.equals(mark, INTERIOR_MARK)) {
2529 return patchInteriorProto(obj, interceptor); 2657 return patchInteriorProto(obj, interceptor);
2530 } 2658 }
2531 if (dart.equals(mark, DISCRIMINATED_MARK)) { 2659 if (dart.equals(mark, DISCRIMINATED_MARK)) {
2532 throw new core.UnimplementedError(tag); 2660 throw new core.UnimplementedError(tag);
2533 } 2661 }
2534 let isLeaf = _foreign_helper.JS('bool', '(#[#]) === true', _js_helper.leafTa gs, tag); 2662 let isLeaf = _js_helper.leafTags[tag] === true;
2535 if (isLeaf) { 2663 if (isLeaf) {
2536 return patchProto(obj, makeLeafDispatchRecord(interceptor)); 2664 return patchProto(obj, makeLeafDispatchRecord(interceptor));
2537 } else { 2665 } else {
2538 return patchInteriorProto(obj, interceptor); 2666 return patchInteriorProto(obj, interceptor);
2539 } 2667 }
2540 } 2668 }
2541 // Function patchInstance: (dynamic, dynamic) → dynamic 2669 // Function patchInstance: (dynamic, dynamic) → dynamic
2542 function patchInstance(obj, record) { 2670 function patchInstance(obj, record) {
2543 _interceptors.setDispatchProperty(obj, record); 2671 _interceptors.setDispatchProperty(obj, record);
2544 return _interceptors.dispatchRecordInterceptor(record); 2672 return _interceptors.dispatchRecordInterceptor(record);
2545 } 2673 }
2546 // Function patchProto: (dynamic, dynamic) → dynamic 2674 // Function patchProto: (dynamic, dynamic) → dynamic
2547 function patchProto(obj, record) { 2675 function patchProto(obj, record) {
2548 _interceptors.setDispatchProperty(_foreign_helper.JS('', 'Object.getPrototyp eOf(#)', obj), record); 2676 _interceptors.setDispatchProperty(Object.getPrototypeOf(obj), record);
2549 return _interceptors.dispatchRecordInterceptor(record); 2677 return _interceptors.dispatchRecordInterceptor(record);
2550 } 2678 }
2551 // Function patchInteriorProto: (dynamic, dynamic) → dynamic 2679 // Function patchInteriorProto: (dynamic, dynamic) → dynamic
2552 function patchInteriorProto(obj, interceptor) { 2680 function patchInteriorProto(obj, interceptor) {
2553 let proto = _foreign_helper.JS('', 'Object.getPrototypeOf(#)', obj); 2681 let proto = Object.getPrototypeOf(obj);
2554 let record = _interceptors.makeDispatchRecord(interceptor, proto, null, null ); 2682 let record = _interceptors.makeDispatchRecord(interceptor, proto, null, null );
2555 _interceptors.setDispatchProperty(proto, record); 2683 _interceptors.setDispatchProperty(proto, record);
2556 return interceptor; 2684 return interceptor;
2557 } 2685 }
2558 // Function makeLeafDispatchRecord: (dynamic) → dynamic 2686 // Function makeLeafDispatchRecord: (dynamic) → dynamic
2559 function makeLeafDispatchRecord(interceptor) { 2687 function makeLeafDispatchRecord(interceptor) {
2560 let fieldName = _foreign_helper.JS_IS_INDEXABLE_FIELD_NAME(); 2688 let fieldName = _foreign_helper.JS_IS_INDEXABLE_FIELD_NAME();
2561 let indexability = dart.as(_foreign_helper.JS('bool', '!!#[#]', interceptor, fieldName), core.bool); 2689 let indexability = !!interceptor[fieldName];
2562 return _interceptors.makeDispatchRecord(interceptor, false, null, indexabili ty); 2690 return _interceptors.makeDispatchRecord(interceptor, false, null, indexabili ty);
2563 } 2691 }
2564 // Function makeDefaultDispatchRecord: (dynamic, dynamic, dynamic) → dynamic 2692 // Function makeDefaultDispatchRecord: (dynamic, dynamic, dynamic) → dynamic
2565 function makeDefaultDispatchRecord(tag, interceptorClass, proto) { 2693 function makeDefaultDispatchRecord(tag, interceptorClass, proto) {
2566 let interceptor = _foreign_helper.JS('', '#.prototype', interceptorClass); 2694 let interceptor = interceptorClass.prototype;
2567 let isLeaf = _foreign_helper.JS('bool', '(#[#]) === true', _js_helper.leafTa gs, tag); 2695 let isLeaf = _js_helper.leafTags[tag] === true;
2568 if (isLeaf) { 2696 if (isLeaf) {
2569 return makeLeafDispatchRecord(interceptor); 2697 return makeLeafDispatchRecord(interceptor);
2570 } else { 2698 } else {
2571 return _interceptors.makeDispatchRecord(interceptor, proto, null, null); 2699 return _interceptors.makeDispatchRecord(interceptor, proto, null, null);
2572 } 2700 }
2573 } 2701 }
2574 // Function setNativeSubclassDispatchRecord: (dynamic, dynamic) → dynamic 2702 // Function setNativeSubclassDispatchRecord: (dynamic, dynamic) → dynamic
2575 function setNativeSubclassDispatchRecord(proto, interceptor) { 2703 function setNativeSubclassDispatchRecord(proto, interceptor) {
2576 _interceptors.setDispatchProperty(proto, makeLeafDispatchRecord(interceptor) ); 2704 _interceptors.setDispatchProperty(proto, makeLeafDispatchRecord(interceptor) );
2577 } 2705 }
2578 // Function constructorNameFallback: (dynamic) → String 2706 // Function constructorNameFallback: (dynamic) → String
2579 function constructorNameFallback(object) { 2707 function constructorNameFallback(object) {
2580 return dart.as(_foreign_helper.JS('String', '#(#)', _constructorNameFallback , object), core.String); 2708 return _constructorNameFallback(object);
2581 } 2709 }
2582 _js_helper.initNativeDispatchFlag = null; 2710 _js_helper.initNativeDispatchFlag = null;
2583 // Function initNativeDispatch: () → void 2711 // Function initNativeDispatch: () → void
2584 function initNativeDispatch() { 2712 function initNativeDispatch() {
2585 if (true === _js_helper.initNativeDispatchFlag) 2713 if (true === _js_helper.initNativeDispatchFlag)
2586 return; 2714 return;
2587 _js_helper.initNativeDispatchFlag = true; 2715 _js_helper.initNativeDispatchFlag = true;
2588 initNativeDispatchContinue(); 2716 initNativeDispatchContinue();
2589 } 2717 }
2590 // Function initNativeDispatchContinue: () → void 2718 // Function initNativeDispatchContinue: () → void
2591 function initNativeDispatchContinue() { 2719 function initNativeDispatchContinue() {
2592 _js_helper.dispatchRecordsForInstanceTags = _foreign_helper.JS('', 'Object.c reate(null)'); 2720 _js_helper.dispatchRecordsForInstanceTags = Object.create(null);
2593 _js_helper.interceptorsForUncacheableTags = _foreign_helper.JS('', 'Object.c reate(null)'); 2721 _js_helper.interceptorsForUncacheableTags = Object.create(null);
2594 initHooks(); 2722 initHooks();
2595 let map = _js_helper.interceptorsByTag; 2723 let map = _js_helper.interceptorsByTag;
2596 let tags = _foreign_helper.JS('JSMutableArray', 'Object.getOwnPropertyNames( #)', map); 2724 let tags = Object.getOwnPropertyNames(map);
2597 if (_foreign_helper.JS('bool', 'typeof window != "undefined"')) { 2725 if (typeof window != "undefined") {
2598 let context = _foreign_helper.JS('=Object', 'window'); 2726 let context = window;
2599 let fun = _foreign_helper.JS('=Object', 'function () {}'); 2727 let fun = function() {
2728 };
2600 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { 2729 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) {
2601 let tag = dart.dindex(tags, i); 2730 let tag = dart.dindex(tags, i);
2602 let proto = dart.dinvokef(_js_helper.prototypeForTagFunction, tag); 2731 let proto = dart.dinvokef(_js_helper.prototypeForTagFunction, tag);
2603 if (proto !== null) { 2732 if (proto !== null) {
2604 let interceptorClass = _foreign_helper.JS('', '#[#]', map, tag); 2733 let interceptorClass = map[tag];
2605 let record = makeDefaultDispatchRecord(tag, interceptorClass, proto); 2734 let record = makeDefaultDispatchRecord(tag, interceptorClass, proto);
2606 if (record !== null) { 2735 if (record !== null) {
2607 _interceptors.setDispatchProperty(proto, record); 2736 _interceptors.setDispatchProperty(proto, record);
2608 _foreign_helper.JS('', '#.prototype = #', fun, proto); 2737 fun.prototype = proto;
2609 } 2738 }
2610 } 2739 }
2611 } 2740 }
2612 } 2741 }
2613 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) { 2742 for (let i = 0; i['<'](dart.dload(tags, 'length')); i++) {
2614 let tag = _foreign_helper.JS('String', '#[#]', tags, i); 2743 let tag = tags[i];
2615 if (_foreign_helper.JS('bool', '/^[A-Za-z_]/.test(#)', tag)) { 2744 if (/^[A-Za-z_]/.test(tag)) {
2616 let interceptorClass = propertyGet(map, dart.as(tag, core.String)); 2745 let interceptorClass = propertyGet(map, tag);
2617 propertySet(map, dart.as(dart.dbinary(INSTANCE_CACHED_MARK, '+', tag), c ore.String), interceptorClass); 2746 propertySet(map, dart.as(dart.dbinary(INSTANCE_CACHED_MARK, '+', tag), c ore.String), interceptorClass);
2618 propertySet(map, dart.as(dart.dbinary(UNCACHED_MARK, '+', tag), core.Str ing), interceptorClass); 2747 propertySet(map, dart.as(dart.dbinary(UNCACHED_MARK, '+', tag), core.Str ing), interceptorClass);
2619 propertySet(map, dart.as(dart.dbinary(LEAF_MARK, '+', tag), core.String) , interceptorClass); 2748 propertySet(map, dart.as(dart.dbinary(LEAF_MARK, '+', tag), core.String) , interceptorClass);
2620 propertySet(map, dart.as(dart.dbinary(INTERIOR_MARK, '+', tag), core.Str ing), interceptorClass); 2749 propertySet(map, dart.as(dart.dbinary(INTERIOR_MARK, '+', tag), core.Str ing), interceptorClass);
2621 propertySet(map, dart.as(dart.dbinary(DISCRIMINATED_MARK, '+', tag), cor e.String), interceptorClass); 2750 propertySet(map, dart.as(dart.dbinary(DISCRIMINATED_MARK, '+', tag), cor e.String), interceptorClass);
2622 } 2751 }
2623 } 2752 }
2624 } 2753 }
2625 // Function initHooks: () → void 2754 // Function initHooks: () → void
2626 function initHooks() { 2755 function initHooks() {
2627 let hooks = _foreign_helper.JS('', '#()', _baseHooks); 2756 let hooks = _baseHooks();
2628 let _fallbackConstructorHooksTransformer = _foreign_helper.JS('', '#(#)', _f allbackConstructorHooksTransformerGenerator, _constructorNameFallback); 2757 let _fallbackConstructorHooksTransformer = _fallbackConstructorHooksTransfor merGenerator(_constructorNameFallback);
2629 hooks = applyHooksTransformer(_fallbackConstructorHooksTransformer, hooks); 2758 hooks = applyHooksTransformer(_fallbackConstructorHooksTransformer, hooks);
2630 hooks = applyHooksTransformer(_firefoxHooksTransformer, hooks); 2759 hooks = applyHooksTransformer(_firefoxHooksTransformer, hooks);
2631 hooks = applyHooksTransformer(_ieHooksTransformer, hooks); 2760 hooks = applyHooksTransformer(_ieHooksTransformer, hooks);
2632 hooks = applyHooksTransformer(_operaHooksTransformer, hooks); 2761 hooks = applyHooksTransformer(_operaHooksTransformer, hooks);
2633 hooks = applyHooksTransformer(_safariHooksTransformer, hooks); 2762 hooks = applyHooksTransformer(_safariHooksTransformer, hooks);
2634 hooks = applyHooksTransformer(_fixDocumentHooksTransformer, hooks); 2763 hooks = applyHooksTransformer(_fixDocumentHooksTransformer, hooks);
2635 hooks = applyHooksTransformer(_dartExperimentalFixupGetTagHooksTransformer, hooks); 2764 hooks = applyHooksTransformer(_dartExperimentalFixupGetTagHooksTransformer, hooks);
2636 if (_foreign_helper.JS('bool', 'typeof dartNativeDispatchHooksTransformer != "undefined"')) { 2765 if (typeof dartNativeDispatchHooksTransformer != "undefined") {
2637 let transformers = _foreign_helper.JS('', 'dartNativeDispatchHooksTransfor mer'); 2766 let transformers = dartNativeDispatchHooksTransformer;
2638 if (_foreign_helper.JS('bool', 'typeof # == "function"', transformers)) { 2767 if (typeof transformers == "function") {
2639 transformers = new List.from([transformers]); 2768 transformers = new List.from([transformers]);
2640 } 2769 }
2641 if (_foreign_helper.JS('bool', '#.constructor == Array', transformers)) { 2770 if (transformers.constructor == Array) {
2642 for (let i = 0; i['<'](_foreign_helper.JS('int', '#.length', transformer s)); i++) { 2771 for (let i = 0; i < transformers.length; i++) {
2643 let transformer = _foreign_helper.JS('', '#[#]', transformers, i); 2772 let transformer = transformers[i];
2644 if (_foreign_helper.JS('bool', 'typeof # == "function"', transformer)) { 2773 if (typeof transformer == "function") {
2645 hooks = applyHooksTransformer(transformer, hooks); 2774 hooks = applyHooksTransformer(transformer, hooks);
2646 } 2775 }
2647 } 2776 }
2648 } 2777 }
2649 } 2778 }
2650 let getTag = _foreign_helper.JS('', '#.getTag', hooks); 2779 let getTag = hooks.getTag;
2651 let getUnknownTag = _foreign_helper.JS('', '#.getUnknownTag', hooks); 2780 let getUnknownTag = hooks.getUnknownTag;
2652 let prototypeForTag = _foreign_helper.JS('', '#.prototypeForTag', hooks); 2781 let prototypeForTag = hooks.prototypeForTag;
2653 _js_helper.getTagFunction = (o) => _foreign_helper.JS('String|Null', '#(#)', getTag, o); 2782 _js_helper.getTagFunction = (o) => getTag(o);
2654 _js_helper.alternateTagFunction = (o, tag) => _foreign_helper.JS('String|Nul l', '#(#, #)', getUnknownTag, o, tag); 2783 _js_helper.alternateTagFunction = (o, tag) => getUnknownTag(o, tag);
2655 _js_helper.prototypeForTagFunction = (tag) => _foreign_helper.JS('', '#(#)', prototypeForTag, tag); 2784 _js_helper.prototypeForTagFunction = (tag) => prototypeForTag(tag);
2656 } 2785 }
2657 // Function applyHooksTransformer: (dynamic, dynamic) → dynamic 2786 // Function applyHooksTransformer: (dynamic, dynamic) → dynamic
2658 function applyHooksTransformer(transformer, hooks) { 2787 function applyHooksTransformer(transformer, hooks) {
2659 let newHooks = _foreign_helper.JS('=Object|Null', '#(#)', transformer, hooks ); 2788 let newHooks = transformer(hooks);
2660 return _foreign_helper.JS('', '# || #', newHooks, hooks); 2789 return newHooks || hooks;
2661 } 2790 }
2662 let _baseHooks = new _foreign_helper.JS_CONST('\nfunction() {\n function type NameInChrome(o) {\n var constructor = o.constructor;\n if (constructor) {\ n var name = constructor.name;\n if (name) return name;\n }\n va r s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1 );\n }\n function getUnknownTag(object, tag) {\n // This code really belong s in [getUnknownTagGenericBrowser] but having it\n // here allows [getUnknown Tag] to be tested on d8.\n if (/^HTML[A-Z].*Element$/.test(tag)) {\n // Check that it is not a simple JavaScript object.\n var name = Object.protot ype.toString.call(object);\n if (name == "[object Object]") return null;\n return "HTMLElement";\n }\n }\n function getUnknownTagGenericBrowser(o bject, tag) {\n if (self.HTMLElement && object instanceof HTMLElement) return "HTMLElement";\n return getUnknownTag(object, tag);\n }\n function prototy peForTag(tag) {\n if (typeof window == "undefined") return null;\n if (typ eof window[tag] == "undefined") return null;\n var constructor = window[tag]; \n if (typeof constructor != "function") return null;\n return constructor .prototype;\n }\n function discriminator(tag) { return null; }\n\n var isBrow ser = typeof navigator == "object";\n\n return {\n getTag: typeNameInChrome, \n getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,\n prototypeForTag: prototypeForTag,\n discriminator: discriminator };\n}'); 2791 let _baseHooks = new _foreign_helper.JS_CONST('\nfunction() {\n function type NameInChrome(o) {\n var constructor = o.constructor;\n if (constructor) {\ n var name = constructor.name;\n if (name) return name;\n }\n va r s = Object.prototype.toString.call(o);\n return s.substring(8, s.length - 1 );\n }\n function getUnknownTag(object, tag) {\n // This code really belong s in [getUnknownTagGenericBrowser] but having it\n // here allows [getUnknown Tag] to be tested on d8.\n if (/^HTML[A-Z].*Element$/.test(tag)) {\n // Check that it is not a simple JavaScript object.\n var name = Object.protot ype.toString.call(object);\n if (name == "[object Object]") return null;\n return "HTMLElement";\n }\n }\n function getUnknownTagGenericBrowser(o bject, tag) {\n if (self.HTMLElement && object instanceof HTMLElement) return "HTMLElement";\n return getUnknownTag(object, tag);\n }\n function prototy peForTag(tag) {\n if (typeof window == "undefined") return null;\n if (typ eof window[tag] == "undefined") return null;\n var constructor = window[tag]; \n if (typeof constructor != "function") return null;\n return constructor .prototype;\n }\n function discriminator(tag) { return null; }\n\n var isBrow ser = typeof navigator == "object";\n\n return {\n getTag: typeNameInChrome, \n getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,\n prototypeForTag: prototypeForTag,\n discriminator: discriminator };\n}');
2663 let _constructorNameFallback = new _foreign_helper.JS_CONST('\nfunction getTag Fallback(o) {\n var constructor = o.constructor;\n if (typeof constructor == " function") {\n var name = constructor.name;\n // If the name is a non-empt y string, we use that as the type name of this\n // object. There are variou s cases where that does not work, so we have to\n // detect them and fall thr ough to the toString() based implementation.\n\n if (typeof name == "string" &&\n\n // Sometimes the string is empty. This test also catches minified \n // shadow dom polyfil wrapper for Window on Firefox where the faked\n // constructor name does not \'stick\'. The shortest real DOM object\n // names have three characters (e.g. URL, CSS).\n name.length > 2 & &\n\n // On Firefox we often get "Object" as the constructor name, even f or\n // more specialized DOM objects.\n name !== "Object" &&\n\n // This can happen in Opera.\n name !== "Function.prototype") {\n return name;\n }\n }\n var s = Object.prototype.toString.call(o);\n re turn s.substring(8, s.length - 1);\n}'); 2792 let _constructorNameFallback = new _foreign_helper.JS_CONST('\nfunction getTag Fallback(o) {\n var constructor = o.constructor;\n if (typeof constructor == " function") {\n var name = constructor.name;\n // If the name is a non-empt y string, we use that as the type name of this\n // object. There are variou s cases where that does not work, so we have to\n // detect them and fall thr ough to the toString() based implementation.\n\n if (typeof name == "string" &&\n\n // Sometimes the string is empty. This test also catches minified \n // shadow dom polyfil wrapper for Window on Firefox where the faked\n // constructor name does not \'stick\'. The shortest real DOM object\n // names have three characters (e.g. URL, CSS).\n name.length > 2 & &\n\n // On Firefox we often get "Object" as the constructor name, even f or\n // more specialized DOM objects.\n name !== "Object" &&\n\n // This can happen in Opera.\n name !== "Function.prototype") {\n return name;\n }\n }\n var s = Object.prototype.toString.call(o);\n re turn s.substring(8, s.length - 1);\n}');
2664 let _fallbackConstructorHooksTransformerGenerator = new _foreign_helper.JS_CON ST('\nfunction(getTagFallback) {\n return function(hooks) {\n // If we are n ot in a browser, assume we are in d8.\n // TODO(sra): Recognize jsshell.\n if (typeof navigator != "object") return hooks;\n\n var ua = navigator.userA gent;\n // TODO(antonm): remove a reference to DumpRenderTree.\n if (ua.in dexOf("DumpRenderTree") >= 0) return hooks;\n if (ua.indexOf("Chrome") >= 0) {\n // Confirm constructor name is usable for dispatch.\n function con firm(p) {\n return typeof window == "object" && window[p] && window[p].na me == p;\n }\n if (confirm("Window") && confirm("HTMLElement")) return hooks;\n }\n\n hooks.getTag = getTagFallback;\n };\n}'); 2793 let _fallbackConstructorHooksTransformerGenerator = new _foreign_helper.JS_CON ST('\nfunction(getTagFallback) {\n return function(hooks) {\n // If we are n ot in a browser, assume we are in d8.\n // TODO(sra): Recognize jsshell.\n if (typeof navigator != "object") return hooks;\n\n var ua = navigator.userA gent;\n // TODO(antonm): remove a reference to DumpRenderTree.\n if (ua.in dexOf("DumpRenderTree") >= 0) return hooks;\n if (ua.indexOf("Chrome") >= 0) {\n // Confirm constructor name is usable for dispatch.\n function con firm(p) {\n return typeof window == "object" && window[p] && window[p].na me == p;\n }\n if (confirm("Window") && confirm("HTMLElement")) return hooks;\n }\n\n hooks.getTag = getTagFallback;\n };\n}');
2665 let _ieHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Trident/") == -1) return hooks;\n\n var getTag = hooks.getT ag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer" : "Clipboard",\n "HTMLDDElement": "HTMLElement",\n "HTMLDTElement": "HTMLE lement",\n "HTMLPhraseElement": "HTMLElement",\n "Position": "Geoposition" \n };\n\n function getTagIE(o) {\n var tag = getTag(o);\n var newTag = q uickMap[tag];\n if (newTag) return newTag;\n // Patches for types which re port themselves as Objects.\n if (tag == "Object") {\n if (window.DataVi ew && (o instanceof window.DataView)) return "DataView";\n }\n return tag; \n }\n\n function prototypeForTagIE(tag) {\n var constructor = window[tag]; \n if (constructor == null) return null;\n return constructor.prototype;\n }\n\n hooks.getTag = getTagIE;\n hooks.prototypeForTag = prototypeForTagIE;\ n}'); 2794 let _ieHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Trident/") == -1) return hooks;\n\n var getTag = hooks.getT ag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTransfer" : "Clipboard",\n "HTMLDDElement": "HTMLElement",\n "HTMLDTElement": "HTMLE lement",\n "HTMLPhraseElement": "HTMLElement",\n "Position": "Geoposition" \n };\n\n function getTagIE(o) {\n var tag = getTag(o);\n var newTag = q uickMap[tag];\n if (newTag) return newTag;\n // Patches for types which re port themselves as Objects.\n if (tag == "Object") {\n if (window.DataVi ew && (o instanceof window.DataView)) return "DataView";\n }\n return tag; \n }\n\n function prototypeForTagIE(tag) {\n var constructor = window[tag]; \n if (constructor == null) return null;\n return constructor.prototype;\n }\n\n hooks.getTag = getTagIE;\n hooks.prototypeForTag = prototypeForTagIE;\ n}');
2666 let _fixDocumentHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(ho oks) {\n var getTag = hooks.getTag;\n var prototypeForTag = hooks.prototypeFor Tag;\n function getTagFixed(o) {\n var tag = getTag(o);\n if (tag == "Doc ument") {\n // Some browsers and the polymer polyfill call both HTML and XM L documents\n // "Document", so we check for the xmlVersion property, which is the empty\n // string on HTML documents. Since both dart:html classes D ocument and\n // HtmlDocument share the same type, we must patch the instan ces and not\n // the prototype.\n if (!!o.xmlVersion) return "!Documen t";\n return "!HTMLDocument";\n }\n return tag;\n }\n\n function pr ototypeForTagFixed(tag) {\n if (tag == "Document") return null; // Do not pr e-patch Document.\n return prototypeForTag(tag);\n }\n\n hooks.getTag = get TagFixed;\n hooks.prototypeForTag = prototypeForTagFixed;\n}'); 2795 let _fixDocumentHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(ho oks) {\n var getTag = hooks.getTag;\n var prototypeForTag = hooks.prototypeFor Tag;\n function getTagFixed(o) {\n var tag = getTag(o);\n if (tag == "Doc ument") {\n // Some browsers and the polymer polyfill call both HTML and XM L documents\n // "Document", so we check for the xmlVersion property, which is the empty\n // string on HTML documents. Since both dart:html classes D ocument and\n // HtmlDocument share the same type, we must patch the instan ces and not\n // the prototype.\n if (!!o.xmlVersion) return "!Documen t";\n return "!HTMLDocument";\n }\n return tag;\n }\n\n function pr ototypeForTagFixed(tag) {\n if (tag == "Document") return null; // Do not pr e-patch Document.\n return prototypeForTag(tag);\n }\n\n hooks.getTag = get TagFixed;\n hooks.prototypeForTag = prototypeForTagFixed;\n}');
2667 let _firefoxHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Firefox") == -1) return hooks;\n\n var getTag = hooks. getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTrans fer": "Clipboard",\n "GeoGeolocation": "Geolocation",\n "Location": "!Loca tion", // Fixes issue 18151\n "WorkerMessageEvent": "MessageEve nt",\n "XMLDocument": "!Document"};\n\n function getTagFirefox(o) {\n var tag = getTag(o);\n return quickMap[tag] || tag;\n }\n\n hooks.getTag = get TagFirefox;\n}'); 2796 let _firefoxHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) {\n var userAgent = typeof navigator == "object" ? navigator.userAgent : "";\n if (userAgent.indexOf("Firefox") == -1) return hooks;\n\n var getTag = hooks. getTag;\n\n var quickMap = {\n "BeforeUnloadEvent": "Event",\n "DataTrans fer": "Clipboard",\n "GeoGeolocation": "Geolocation",\n "Location": "!Loca tion", // Fixes issue 18151\n "WorkerMessageEvent": "MessageEve nt",\n "XMLDocument": "!Document"};\n\n function getTagFirefox(o) {\n var tag = getTag(o);\n return quickMap[tag] || tag;\n }\n\n hooks.getTag = get TagFirefox;\n}');
2668 let _operaHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) { return hooks; }\n'); 2797 let _operaHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) { return hooks; }\n');
2669 let _safariHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) { return hooks; }\n'); 2798 let _safariHooksTransformer = new _foreign_helper.JS_CONST('\nfunction(hooks) { return hooks; }\n');
2670 let _dartExperimentalFixupGetTagHooksTransformer = new _foreign_helper.JS_CONS T('\nfunction(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function") return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}'); 2799 let _dartExperimentalFixupGetTagHooksTransformer = new _foreign_helper.JS_CONS T('\nfunction(hooks) {\n if (typeof dartExperimentalFixupGetTag != "function") return hooks;\n hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag);\n}');
2671 // Function regExpGetNative: (JSSyntaxRegExp) → dynamic 2800 // Function regExpGetNative: (JSSyntaxRegExp) → dynamic
2672 function regExpGetNative(regexp) { 2801 function regExpGetNative(regexp) {
2673 return regexp._nativeRegExp; 2802 return regexp._nativeRegExp;
2674 } 2803 }
2675 // Function regExpGetGlobalNative: (JSSyntaxRegExp) → dynamic 2804 // Function regExpGetGlobalNative: (JSSyntaxRegExp) → dynamic
2676 function regExpGetGlobalNative(regexp) { 2805 function regExpGetGlobalNative(regexp) {
2677 let nativeRegexp = regexp._nativeGlobalVersion; 2806 let nativeRegexp = regexp._nativeGlobalVersion;
2678 _foreign_helper.JS("void", "#.lastIndex = 0", nativeRegexp); 2807 nativeRegexp.lastIndex = 0;
2679 return nativeRegexp; 2808 return nativeRegexp;
2680 } 2809 }
2681 // Function regExpCaptureCount: (JSSyntaxRegExp) → int 2810 // Function regExpCaptureCount: (JSSyntaxRegExp) → int
2682 function regExpCaptureCount(regexp) { 2811 function regExpCaptureCount(regexp) {
2683 let nativeAnchoredRegExp = regexp._nativeAnchoredVersion; 2812 let nativeAnchoredRegExp = regexp._nativeAnchoredVersion;
2684 let match = _foreign_helper.JS('JSExtendableArray', "#.exec('')", nativeAnch oredRegExp); 2813 let match = nativeAnchoredRegExp.exec('');
2685 return dart.as(dart.dbinary(dart.dload(match, 'length'), '-', 2), core.int); 2814 return dart.as(dart.dbinary(dart.dload(match, 'length'), '-', 2), core.int);
2686 } 2815 }
2687 class JSSyntaxRegExp extends dart.Object { 2816 class JSSyntaxRegExp extends dart.Object {
2688 toString() { 2817 toString() {
2689 return `RegExp/${this.pattern}/`; 2818 return `RegExp/${this.pattern}/`;
2690 } 2819 }
2691 JSSyntaxRegExp(source, opt$) { 2820 JSSyntaxRegExp(source, opt$) {
2692 let multiLine = opt$.multiLine === void 0 ? false : opt$.multiLine; 2821 let multiLine = opt$.multiLine === void 0 ? false : opt$.multiLine;
2693 let caseSensitive = opt$.caseSensitive === void 0 ? true : opt$.caseSensit ive; 2822 let caseSensitive = opt$.caseSensitive === void 0 ? true : opt$.caseSensit ive;
2694 this.pattern = source; 2823 this.pattern = source;
2695 this._nativeRegExp = makeNative(source, multiLine, caseSensitive, false); 2824 this._nativeRegExp = makeNative(source, multiLine, caseSensitive, false);
2696 this._nativeGlobalRegExp = null; 2825 this._nativeGlobalRegExp = null;
2697 this._nativeAnchoredRegExp = null; 2826 this._nativeAnchoredRegExp = null;
2698 } 2827 }
2699 get _nativeGlobalVersion() { 2828 get _nativeGlobalVersion() {
2700 if (this._nativeGlobalRegExp !== null) 2829 if (this._nativeGlobalRegExp !== null)
2701 return this._nativeGlobalRegExp; 2830 return this._nativeGlobalRegExp;
2702 return this._nativeGlobalRegExp = makeNative(this.pattern, this._isMultiLi ne, this._isCaseSensitive, true); 2831 return this._nativeGlobalRegExp = makeNative(this.pattern, this._isMultiLi ne, this._isCaseSensitive, true);
2703 } 2832 }
2704 get _nativeAnchoredVersion() { 2833 get _nativeAnchoredVersion() {
2705 if (this._nativeAnchoredRegExp !== null) 2834 if (this._nativeAnchoredRegExp !== null)
2706 return this._nativeAnchoredRegExp; 2835 return this._nativeAnchoredRegExp;
2707 return this._nativeAnchoredRegExp = makeNative(`${this.pattern}|()`, this. _isMultiLine, this._isCaseSensitive, true); 2836 return this._nativeAnchoredRegExp = makeNative(`${this.pattern}|()`, this. _isMultiLine, this._isCaseSensitive, true);
2708 } 2837 }
2709 get _isMultiLine() { 2838 get _isMultiLine() {
2710 return dart.as(_foreign_helper.JS("bool", "#.multiline", this._nativeRegEx p), core.bool); 2839 return this._nativeRegExp.multiline;
2711 } 2840 }
2712 get _isCaseSensitive() { 2841 get _isCaseSensitive() {
2713 return dart.as(_foreign_helper.JS("bool", "!#.ignoreCase", this._nativeReg Exp), core.bool); 2842 return !this._nativeRegExp.ignoreCase;
2714 } 2843 }
2715 static makeNative(source, multiLine, caseSensitive, global) { 2844 static makeNative(source, multiLine, caseSensitive, global) {
2716 checkString(source); 2845 checkString(source);
2717 let m = multiLine ? 'm' : ''; 2846 let m = multiLine ? 'm' : '';
2718 let i = caseSensitive ? '' : 'i'; 2847 let i = caseSensitive ? '' : 'i';
2719 let g = global ? 'g' : ''; 2848 let g = global ? 'g' : '';
2720 let regexp = _foreign_helper.JS('', '(function() {' + 'try {' + 'return ne w RegExp(#, # + # + #);' + '} catch (e) {' + 'return e;' + '}' + '})()', source, m, i, g); 2849 let regexp = function() {
2721 if (_foreign_helper.JS('bool', '# instanceof RegExp', regexp)) 2850 try {
2851 return new RegExp(source, m + i + g);
2852 } catch (e) {
2853 return e;
2854 }
2855
2856 }();
2857 if (regexp instanceof RegExp)
2722 return regexp; 2858 return regexp;
2723 let errorMessage = dart.as(_foreign_helper.JS('String', 'String(#)', regex p), core.String); 2859 let errorMessage = String(regexp);
2724 throw new core.FormatException(`Illegal RegExp pattern: ${source}, ${error Message}`); 2860 throw new core.FormatException(`Illegal RegExp pattern: ${source}, ${error Message}`);
2725 } 2861 }
2726 firstMatch(string) { 2862 firstMatch(string) {
2727 let m = dart.as(_foreign_helper.JS('JSExtendableArray|Null', '#.exec(#)', this._nativeRegExp, checkString(string)), core.List$(core.String)); 2863 let m = dart.as(this._nativeRegExp.exec(checkString(string)), core.List$(c ore.String));
2728 if (m === null) 2864 if (m === null)
2729 return null; 2865 return null;
2730 return new _MatchImplementation(this, m); 2866 return new _MatchImplementation(this, m);
2731 } 2867 }
2732 hasMatch(string) { 2868 hasMatch(string) {
2733 return dart.as(_foreign_helper.JS('bool', '#.test(#)', this._nativeRegExp, checkString(string)), core.bool); 2869 return this._nativeRegExp.test(checkString(string));
2734 } 2870 }
2735 stringMatch(string) { 2871 stringMatch(string) {
2736 let match = this.firstMatch(string); 2872 let match = this.firstMatch(string);
2737 if (match !== null) 2873 if (match !== null)
2738 return match.group(0); 2874 return match.group(0);
2739 return null; 2875 return null;
2740 } 2876 }
2741 allMatches(string, start) { 2877 allMatches(string, start) {
2742 if (start === void 0) 2878 if (start === void 0)
2743 start = 0; 2879 start = 0;
2744 checkString(string); 2880 checkString(string);
2745 checkInt(start); 2881 checkInt(start);
2746 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { 2882 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) {
2747 throw new core.RangeError.range(start, 0, string.length); 2883 throw new core.RangeError.range(start, 0, string.length);
2748 } 2884 }
2749 return new _AllMatchesIterable(this, string, start); 2885 return new _AllMatchesIterable(this, string, start);
2750 } 2886 }
2751 _execGlobal(string, start) { 2887 _execGlobal(string, start) {
2752 let regexp = this._nativeGlobalVersion; 2888 let regexp = this._nativeGlobalVersion;
2753 _foreign_helper.JS("void", "#.lastIndex = #", regexp, start); 2889 regexp.lastIndex = start;
2754 let match = dart.as(_foreign_helper.JS("JSExtendableArray|Null", "#.exec(# )", regexp, string), core.List); 2890 let match = dart.as(regexp.exec(string), core.List);
2755 if (match === null) 2891 if (match === null)
2756 return null; 2892 return null;
2757 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g))); 2893 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g)));
2758 } 2894 }
2759 _execAnchored(string, start) { 2895 _execAnchored(string, start) {
2760 let regexp = this._nativeAnchoredVersion; 2896 let regexp = this._nativeAnchoredVersion;
2761 _foreign_helper.JS("void", "#.lastIndex = #", regexp, start); 2897 regexp.lastIndex = start;
2762 let match = dart.as(_foreign_helper.JS("JSExtendableArray|Null", "#.exec(# )", regexp, string), core.List); 2898 let match = dart.as(regexp.exec(string), core.List);
2763 if (match === null) 2899 if (match === null)
2764 return null; 2900 return null;
2765 if (match.get(match.length - 1) !== null) 2901 if (match.get(match.length - 1) !== null)
2766 return null; 2902 return null;
2767 match.length = 1; 2903 match.length = 1;
2768 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g))); 2904 return new _MatchImplementation(this, dart.as(match, core.List$(core.Strin g)));
2769 } 2905 }
2770 matchAsPrefix(string, start) { 2906 matchAsPrefix(string, start) {
2771 if (start === void 0) 2907 if (start === void 0)
2772 start = 0; 2908 start = 0;
2773 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) { 2909 if (dart.notNull(start < 0) || dart.notNull(start > string.length)) {
2774 throw new core.RangeError.range(start, 0, string.length); 2910 throw new core.RangeError.range(start, 0, string.length);
2775 } 2911 }
2776 return this._execAnchored(string, start); 2912 return this._execAnchored(string, start);
2777 } 2913 }
2778 get isMultiLine() { 2914 get isMultiLine() {
2779 return this._isMultiLine; 2915 return this._isMultiLine;
2780 } 2916 }
2781 get isCaseSensitive() { 2917 get isCaseSensitive() {
2782 return this._isCaseSensitive; 2918 return this._isCaseSensitive;
2783 } 2919 }
2784 } 2920 }
2785 class _MatchImplementation extends dart.Object { 2921 class _MatchImplementation extends dart.Object {
2786 _MatchImplementation(pattern, _match) { 2922 _MatchImplementation(pattern, _match) {
2787 this.pattern = pattern; 2923 this.pattern = pattern;
2788 this._match = _match; 2924 this._match = _match;
2789 dart.assert(typeof _foreign_helper.JS("var", "#.input", this._match) == st ring); 2925 dart.assert(typeof this._match.input == string);
2790 dart.assert(typeof _foreign_helper.JS("var", "#.index", this._match) == nu mber); 2926 dart.assert(typeof this._match.index == number);
2791 } 2927 }
2792 get input() { 2928 get input() {
2793 return dart.as(_foreign_helper.JS("String", "#.input", this._match), core. String); 2929 return this._match.input;
2794 } 2930 }
2795 get start() { 2931 get start() {
2796 return dart.as(_foreign_helper.JS("int", "#.index", this._match), core.int ); 2932 return this._match.index;
2797 } 2933 }
2798 get end() { 2934 get end() {
2799 return this.start + this._match.get(0).length; 2935 return this.start + this._match.get(0).length;
2800 } 2936 }
2801 group(index) { 2937 group(index) {
2802 return this._match.get(index); 2938 return this._match.get(index);
2803 } 2939 }
2804 get(index) { 2940 get(index) {
2805 return this.group(index); 2941 return this.group(index);
2806 } 2942 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 return !dart.equals(dart.dinvoke(receiver, 'indexOf', other, startIndex), -1); 3053 return !dart.equals(dart.dinvoke(receiver, 'indexOf', other, startIndex), -1);
2918 } else if (dart.is(other, JSSyntaxRegExp)) { 3054 } else if (dart.is(other, JSSyntaxRegExp)) {
2919 return dart.dinvoke(other, 'hasMatch', dart.dinvoke(receiver, 'substring', startIndex)); 3055 return dart.dinvoke(other, 'hasMatch', dart.dinvoke(receiver, 'substring', startIndex));
2920 } else { 3056 } else {
2921 let substr = dart.dinvoke(receiver, 'substring', startIndex); 3057 let substr = dart.dinvoke(receiver, 'substring', startIndex);
2922 return dart.dload(dart.dinvoke(other, 'allMatches', substr), 'isNotEmpty') ; 3058 return dart.dload(dart.dinvoke(other, 'allMatches', substr), 'isNotEmpty') ;
2923 } 3059 }
2924 } 3060 }
2925 // Function stringReplaceJS: (dynamic, dynamic, dynamic) → dynamic 3061 // Function stringReplaceJS: (dynamic, dynamic, dynamic) → dynamic
2926 function stringReplaceJS(receiver, replacer, to) { 3062 function stringReplaceJS(receiver, replacer, to) {
2927 to = _foreign_helper.JS('String', '#.replace(/\\$/g, "$$$$")', to); 3063 to = to.replace(/\$/g, "$$$$");
2928 return _foreign_helper.JS('String', '#.replace(#, #)', receiver, replacer, t o); 3064 return receiver.replace(replacer, to);
2929 } 3065 }
2930 // Function stringReplaceFirstRE: (dynamic, dynamic, dynamic, dynamic) → dynam ic 3066 // Function stringReplaceFirstRE: (dynamic, dynamic, dynamic, dynamic) → dynam ic
2931 function stringReplaceFirstRE(receiver, regexp, to, startIndex) { 3067 function stringReplaceFirstRE(receiver, regexp, to, startIndex) {
2932 let match = dart.dinvoke(regexp, '_execGlobal', receiver, startIndex); 3068 let match = dart.dinvoke(regexp, '_execGlobal', receiver, startIndex);
2933 if (match === null) 3069 if (match === null)
2934 return receiver; 3070 return receiver;
2935 let start = dart.dload(match, 'start'); 3071 let start = dart.dload(match, 'start');
2936 let end = dart.dload(match, 'end'); 3072 let end = dart.dload(match, 'end');
2937 return `${dart.dinvoke(receiver, 'substring', 0, start)}${to}${dart.dinvoke( receiver, 'substring', end)}`; 3073 return `${dart.dinvoke(receiver, 'substring', 0, start)}${to}${dart.dinvoke( receiver, 'substring', end)}`;
2938 } 3074 }
2939 let ESCAPE_REGEXP = '[[\\]{}()*+?.\\\\^$|]'; 3075 let ESCAPE_REGEXP = '[[\\]{}()*+?.\\\\^$|]';
2940 // Function stringReplaceAllUnchecked: (dynamic, dynamic, dynamic) → dynamic 3076 // Function stringReplaceAllUnchecked: (dynamic, dynamic, dynamic) → dynamic
2941 function stringReplaceAllUnchecked(receiver, from, to) { 3077 function stringReplaceAllUnchecked(receiver, from, to) {
2942 checkString(to); 3078 checkString(to);
2943 if (typeof from == string) { 3079 if (typeof from == string) {
2944 if (dart.equals(from, "")) { 3080 if (dart.equals(from, "")) {
2945 if (dart.equals(receiver, "")) { 3081 if (dart.equals(receiver, "")) {
2946 return to; 3082 return to;
2947 } else { 3083 } else {
2948 let result = new core.StringBuffer(); 3084 let result = new core.StringBuffer();
2949 let length = dart.as(dart.dload(receiver, 'length'), core.int); 3085 let length = dart.as(dart.dload(receiver, 'length'), core.int);
2950 result.write(to); 3086 result.write(to);
2951 for (let i = 0; i < length; i++) { 3087 for (let i = 0; i < length; i++) {
2952 result.write(dart.dindex(receiver, i)); 3088 result.write(dart.dindex(receiver, i));
2953 result.write(to); 3089 result.write(to);
2954 } 3090 }
2955 return result.toString(); 3091 return result.toString();
2956 } 3092 }
2957 } else { 3093 } else {
2958 let quoter = _foreign_helper.JS('', "new RegExp(#, 'g')", ESCAPE_REGEXP) ; 3094 let quoter = new RegExp(ESCAPE_REGEXP, 'g');
2959 let quoted = _foreign_helper.JS('String', '#.replace(#, "\\\\$&")', from , quoter); 3095 let quoted = from.replace(quoter, "\\$&");
2960 let replacer = _foreign_helper.JS('', "new RegExp(#, 'g')", quoted); 3096 let replacer = new RegExp(quoted, 'g');
2961 return stringReplaceJS(receiver, replacer, to); 3097 return stringReplaceJS(receiver, replacer, to);
2962 } 3098 }
2963 } else if (dart.is(from, JSSyntaxRegExp)) { 3099 } else if (dart.is(from, JSSyntaxRegExp)) {
2964 let re = regExpGetGlobalNative(dart.as(from, JSSyntaxRegExp)); 3100 let re = regExpGetGlobalNative(dart.as(from, JSSyntaxRegExp));
2965 return stringReplaceJS(receiver, re, to); 3101 return stringReplaceJS(receiver, re, to);
2966 } else { 3102 } else {
2967 checkNull(from); 3103 checkNull(from);
2968 throw "String.replaceAll(Pattern) UNIMPLEMENTED"; 3104 throw "String.replaceAll(Pattern) UNIMPLEMENTED";
2969 } 3105 }
2970 } 3106 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 return `${dart.dinvoke(receiver, 'substring', 0, index)}${to}` + `${dart.d invoke(receiver, 'substring', dart.dbinary(index, '+', dart.dload(from, 'length' )))}`; 3190 return `${dart.dinvoke(receiver, 'substring', 0, index)}${to}` + `${dart.d invoke(receiver, 'substring', dart.dbinary(index, '+', dart.dload(from, 'length' )))}`;
3055 } else if (dart.is(from, JSSyntaxRegExp)) { 3191 } else if (dart.is(from, JSSyntaxRegExp)) {
3056 return startIndex === 0 ? stringReplaceJS(receiver, regExpGetNative(dart.a s(from, JSSyntaxRegExp)), to) : stringReplaceFirstRE(receiver, from, to, startIn dex); 3192 return startIndex === 0 ? stringReplaceJS(receiver, regExpGetNative(dart.a s(from, JSSyntaxRegExp)), to) : stringReplaceFirstRE(receiver, from, to, startIn dex);
3057 } else { 3193 } else {
3058 checkNull(from); 3194 checkNull(from);
3059 throw "String.replace(Pattern) UNIMPLEMENTED"; 3195 throw "String.replace(Pattern) UNIMPLEMENTED";
3060 } 3196 }
3061 } 3197 }
3062 // Function stringJoinUnchecked: (dynamic, dynamic) → dynamic 3198 // Function stringJoinUnchecked: (dynamic, dynamic) → dynamic
3063 function stringJoinUnchecked(array, separator) { 3199 function stringJoinUnchecked(array, separator) {
3064 return _foreign_helper.JS('String', '#.join(#)', array, separator); 3200 return array.join(separator);
3065 } 3201 }
3066 // Function createRuntimeType: (String) → Type 3202 // Function createRuntimeType: (String) → Type
3067 function createRuntimeType(name) { 3203 function createRuntimeType(name) {
3068 return new TypeImpl(name); 3204 return new TypeImpl(name);
3069 } 3205 }
3070 class TypeImpl extends dart.Object { 3206 class TypeImpl extends dart.Object {
3071 TypeImpl(_typeName) { 3207 TypeImpl(_typeName) {
3072 this._typeName = _typeName; 3208 this._typeName = _typeName;
3073 this._unmangledName = null; 3209 this._unmangledName = null;
3074 } 3210 }
(...skipping 18 matching lines...) Expand all
3093 } 3229 }
3094 } 3230 }
3095 // Function getMangledTypeName: (TypeImpl) → dynamic 3231 // Function getMangledTypeName: (TypeImpl) → dynamic
3096 function getMangledTypeName(type) { 3232 function getMangledTypeName(type) {
3097 return type._typeName; 3233 return type._typeName;
3098 } 3234 }
3099 // Function setRuntimeTypeInfo: (Object, dynamic) → Object 3235 // Function setRuntimeTypeInfo: (Object, dynamic) → Object
3100 function setRuntimeTypeInfo(target, typeInfo) { 3236 function setRuntimeTypeInfo(target, typeInfo) {
3101 dart.assert(dart.notNull(typeInfo === null) || dart.notNull(isJsArray(typeIn fo))); 3237 dart.assert(dart.notNull(typeInfo === null) || dart.notNull(isJsArray(typeIn fo)));
3102 if (target !== null) 3238 if (target !== null)
3103 _foreign_helper.JS('var', '#.$builtinTypeInfo = #', target, typeInfo); 3239 target.$builtinTypeInfo = typeInfo;
3104 return target; 3240 return target;
3105 } 3241 }
3106 // Function getRuntimeTypeInfo: (Object) → dynamic 3242 // Function getRuntimeTypeInfo: (Object) → dynamic
3107 function getRuntimeTypeInfo(target) { 3243 function getRuntimeTypeInfo(target) {
3108 if (target === null) 3244 if (target === null)
3109 return null; 3245 return null;
3110 return _foreign_helper.JS('var', '#.$builtinTypeInfo', target); 3246 return target.$builtinTypeInfo;
3111 } 3247 }
3112 // Function getRuntimeTypeArguments: (dynamic, dynamic) → dynamic 3248 // Function getRuntimeTypeArguments: (dynamic, dynamic) → dynamic
3113 function getRuntimeTypeArguments(target, substitutionName) { 3249 function getRuntimeTypeArguments(target, substitutionName) {
3114 let substitution = getField(target, `${_foreign_helper.JS_OPERATOR_AS_PREFIX ()}${substitutionName}`); 3250 let substitution = getField(target, `${_foreign_helper.JS_OPERATOR_AS_PREFIX ()}${substitutionName}`);
3115 return substitute(substitution, getRuntimeTypeInfo(target)); 3251 return substitute(substitution, getRuntimeTypeInfo(target));
3116 } 3252 }
3117 // Function getRuntimeTypeArgument: (Object, String, int) → dynamic 3253 // Function getRuntimeTypeArgument: (Object, String, int) → dynamic
3118 function getRuntimeTypeArgument(target, substitutionName, index) { 3254 function getRuntimeTypeArgument(target, substitutionName, index) {
3119 let arguments = getRuntimeTypeArguments(target, substitutionName); 3255 let arguments = getRuntimeTypeArguments(target, substitutionName);
3120 return arguments === null ? null : getIndex(arguments, index); 3256 return arguments === null ? null : getIndex(arguments, index);
3121 } 3257 }
3122 // Function getTypeArgumentByIndex: (Object, int) → dynamic 3258 // Function getTypeArgumentByIndex: (Object, int) → dynamic
3123 function getTypeArgumentByIndex(target, index) { 3259 function getTypeArgumentByIndex(target, index) {
3124 let rti = getRuntimeTypeInfo(target); 3260 let rti = getRuntimeTypeInfo(target);
3125 return rti === null ? null : getIndex(rti, index); 3261 return rti === null ? null : getIndex(rti, index);
3126 } 3262 }
3127 // Function copyTypeArguments: (Object, Object) → void 3263 // Function copyTypeArguments: (Object, Object) → void
3128 function copyTypeArguments(source, target) { 3264 function copyTypeArguments(source, target) {
3129 _foreign_helper.JS('var', '#.$builtinTypeInfo = #.$builtinTypeInfo', target, source); 3265 target.$builtinTypeInfo = source.$builtinTypeInfo;
3130 } 3266 }
3131 // Function getClassName: (dynamic) → String 3267 // Function getClassName: (dynamic) → String
3132 function getClassName(object) { 3268 function getClassName(object) {
3133 return dart.as(_foreign_helper.JS('String', '#.constructor.builtin$cls', _in terceptors.getInterceptor(object)), core.String); 3269 return _interceptors.getInterceptor(object).constructor.builtin$cls;
3134 } 3270 }
3135 // Function getRuntimeTypeAsString: (dynamic, {onTypeVariable: (int) → String} ) → String 3271 // Function getRuntimeTypeAsString: (dynamic, {onTypeVariable: (int) → String} ) → String
3136 function getRuntimeTypeAsString(runtimeType, opt$) { 3272 function getRuntimeTypeAsString(runtimeType, opt$) {
3137 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari able; 3273 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari able;
3138 dart.assert(isJsArray(runtimeType)); 3274 dart.assert(isJsArray(runtimeType));
3139 let className = getConstructorName(getIndex(runtimeType, 0)); 3275 let className = getConstructorName(getIndex(runtimeType, 0));
3140 return `${className}` + `${joinArguments(runtimeType, 1, {onTypeVariable: on TypeVariable})}`; 3276 return `${className}` + `${joinArguments(runtimeType, 1, {onTypeVariable: on TypeVariable})}`;
3141 } 3277 }
3142 // Function getConstructorName: (dynamic) → String 3278 // Function getConstructorName: (dynamic) → String
3143 function getConstructorName(type) { 3279 function getConstructorName(type) {
3144 return dart.as(_foreign_helper.JS('String', '#.builtin$cls', type), core.Str ing); 3280 return type.builtin$cls;
3145 } 3281 }
3146 // Function runtimeTypeToString: (dynamic, {onTypeVariable: (int) → String}) → String 3282 // Function runtimeTypeToString: (dynamic, {onTypeVariable: (int) → String}) → String
3147 function runtimeTypeToString(type, opt$) { 3283 function runtimeTypeToString(type, opt$) {
3148 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari able; 3284 let onTypeVariable = opt$.onTypeVariable === void 0 ? null : opt$.onTypeVari able;
3149 if (type === null) { 3285 if (type === null) {
3150 return 'dynamic'; 3286 return 'dynamic';
3151 } else if (isJsArray(type)) { 3287 } else if (isJsArray(type)) {
3152 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable}); 3288 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable});
3153 } else if (isJsFunction(type)) { 3289 } else if (isJsFunction(type)) {
3154 return getConstructorName(type); 3290 return getConstructorName(type);
(...skipping 28 matching lines...) Expand all
3183 } 3319 }
3184 buffer.write(runtimeTypeToString(argument, {onTypeVariable: onTypeVariable })); 3320 buffer.write(runtimeTypeToString(argument, {onTypeVariable: onTypeVariable }));
3185 } 3321 }
3186 return allDynamic ? '' : `<${buffer}>`; 3322 return allDynamic ? '' : `<${buffer}>`;
3187 } 3323 }
3188 // Function getRuntimeTypeString: (dynamic) → String 3324 // Function getRuntimeTypeString: (dynamic) → String
3189 function getRuntimeTypeString(object) { 3325 function getRuntimeTypeString(object) {
3190 let className = getClassName(object); 3326 let className = getClassName(object);
3191 if (object === null) 3327 if (object === null)
3192 return className; 3328 return className;
3193 let typeInfo = _foreign_helper.JS('var', '#.$builtinTypeInfo', object); 3329 let typeInfo = object.$builtinTypeInfo;
3194 return `${className}${joinArguments(typeInfo, 0)}`; 3330 return `${className}${joinArguments(typeInfo, 0)}`;
3195 } 3331 }
3196 // Function getRuntimeType: (dynamic) → Type 3332 // Function getRuntimeType: (dynamic) → Type
3197 function getRuntimeType(object) { 3333 function getRuntimeType(object) {
3198 let type = getRuntimeTypeString(object); 3334 let type = getRuntimeTypeString(object);
3199 return new TypeImpl(type); 3335 return new TypeImpl(type);
3200 } 3336 }
3201 // Function substitute: (dynamic, dynamic) → dynamic 3337 // Function substitute: (dynamic, dynamic) → dynamic
3202 function substitute(substitution, arguments) { 3338 function substitute(substitution, arguments) {
3203 dart.assert(dart.notNull(substitution === null) || dart.notNull(isJsFunction (substitution))); 3339 dart.assert(dart.notNull(substitution === null) || dart.notNull(isJsFunction (substitution)));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3285 return dart.notNull(dart.notNull(type === null) || dart.notNull(dart.equals( getConstructorName(type), _foreign_helper.JS_OBJECT_CLASS_NAME()))) || dart.notN ull(dart.equals(getConstructorName(type), _foreign_helper.JS_NULL_CLASS_NAME())) ; 3421 return dart.notNull(dart.notNull(type === null) || dart.notNull(dart.equals( getConstructorName(type), _foreign_helper.JS_OBJECT_CLASS_NAME()))) || dart.notN ull(dart.equals(getConstructorName(type), _foreign_helper.JS_NULL_CLASS_NAME())) ;
3286 } 3422 }
3287 // Function checkSubtypeOfRuntimeType: (dynamic, dynamic) → bool 3423 // Function checkSubtypeOfRuntimeType: (dynamic, dynamic) → bool
3288 function checkSubtypeOfRuntimeType(o, t) { 3424 function checkSubtypeOfRuntimeType(o, t) {
3289 if (o === null) 3425 if (o === null)
3290 return isSupertypeOfNull(t); 3426 return isSupertypeOfNull(t);
3291 if (t === null) 3427 if (t === null)
3292 return true; 3428 return true;
3293 let rti = getRuntimeTypeInfo(o); 3429 let rti = getRuntimeTypeInfo(o);
3294 o = _interceptors.getInterceptor(o); 3430 o = _interceptors.getInterceptor(o);
3295 let type = _foreign_helper.JS('', '#.constructor', o); 3431 let type = o.constructor;
3296 if (rti !== null) { 3432 if (rti !== null) {
3297 rti = _foreign_helper.JS('JSExtendableArray', '#.slice()', rti); 3433 rti = rti.slice();
3298 _foreign_helper.JS('', '#.splice(0, 0, #)', rti, type); 3434 rti.splice(0, 0, type);
3299 type = rti; 3435 type = rti;
3300 } else if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { 3436 } else if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) {
3301 let signatureName = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}_${getField (t, _foreign_helper.JS_FUNCTION_TYPE_TAG())}`; 3437 let signatureName = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}_${getField (t, _foreign_helper.JS_FUNCTION_TYPE_TAG())}`;
3302 if (hasField(o, signatureName)) 3438 if (hasField(o, signatureName))
3303 return true; 3439 return true;
3304 let targetSignatureFunction = getField(o, `${_foreign_helper.JS_SIGNATURE_ NAME()}`); 3440 let targetSignatureFunction = getField(o, `${_foreign_helper.JS_SIGNATURE_ NAME()}`);
3305 if (targetSignatureFunction === null) 3441 if (targetSignatureFunction === null)
3306 return false; 3442 return false;
3307 type = invokeOn(targetSignatureFunction, o, null); 3443 type = invokeOn(targetSignatureFunction, o, null);
3308 return isFunctionSubtype(type, t); 3444 return isFunctionSubtype(type, t);
(...skipping 10 matching lines...) Expand all
3319 } 3455 }
3320 // Function assertSubtypeOfRuntimeType: (Object, dynamic) → Object 3456 // Function assertSubtypeOfRuntimeType: (Object, dynamic) → Object
3321 function assertSubtypeOfRuntimeType(object, type) { 3457 function assertSubtypeOfRuntimeType(object, type) {
3322 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype OfRuntimeType(object, type)))) { 3458 if (dart.notNull(object !== null) && dart.notNull(!dart.notNull(checkSubtype OfRuntimeType(object, type)))) {
3323 throw new TypeErrorImplementation(object, runtimeTypeToString(type)); 3459 throw new TypeErrorImplementation(object, runtimeTypeToString(type));
3324 } 3460 }
3325 return object; 3461 return object;
3326 } 3462 }
3327 // Function getArguments: (dynamic) → dynamic 3463 // Function getArguments: (dynamic) → dynamic
3328 function getArguments(type) { 3464 function getArguments(type) {
3329 return isJsArray(type) ? _foreign_helper.JS('var', '#.slice(1)', type) : nul l; 3465 return isJsArray(type) ? type.slice(1) : null;
3330 } 3466 }
3331 // Function isSubtype: (dynamic, dynamic) → bool 3467 // Function isSubtype: (dynamic, dynamic) → bool
3332 function isSubtype(s, t) { 3468 function isSubtype(s, t) {
3333 if (isIdentical(s, t)) 3469 if (isIdentical(s, t))
3334 return true; 3470 return true;
3335 if (dart.notNull(s === null) || dart.notNull(t === null)) 3471 if (dart.notNull(s === null) || dart.notNull(t === null))
3336 return true; 3472 return true;
3337 if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { 3473 if (hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) {
3338 return isFunctionSubtype(s, t); 3474 return isFunctionSubtype(s, t);
3339 } 3475 }
3340 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) { 3476 if (hasField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) {
3341 return dart.equals(getConstructorName(t), _foreign_helper.JS_FUNCTION_CLAS S_NAME()); 3477 return dart.equals(getConstructorName(t), _foreign_helper.JS_FUNCTION_CLAS S_NAME());
3342 } 3478 }
3343 let typeOfS = isJsArray(s) ? getIndex(s, 0) : s; 3479 let typeOfS = isJsArray(s) ? getIndex(s, 0) : s;
3344 let typeOfT = isJsArray(t) ? getIndex(t, 0) : t; 3480 let typeOfT = isJsArray(t) ? getIndex(t, 0) : t;
3345 let name = runtimeTypeToString(typeOfT); 3481 let name = runtimeTypeToString(typeOfT);
3346 let substitution = null; 3482 let substitution = null;
3347 if (isNotIdentical(typeOfT, typeOfS)) { 3483 if (isNotIdentical(typeOfT, typeOfS)) {
3348 let test = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}${name}`; 3484 let test = `${_foreign_helper.JS_OPERATOR_IS_PREFIX()}${name}`;
3349 let typeOfSPrototype = _foreign_helper.JS('', '#.prototype', typeOfS); 3485 let typeOfSPrototype = typeOfS.prototype;
3350 if (hasNoField(typeOfSPrototype, test)) 3486 if (hasNoField(typeOfSPrototype, test))
3351 return false; 3487 return false;
3352 let field = `${_foreign_helper.JS_OPERATOR_AS_PREFIX()}${runtimeTypeToStri ng(typeOfT)}`; 3488 let field = `${_foreign_helper.JS_OPERATOR_AS_PREFIX()}${runtimeTypeToStri ng(typeOfT)}`;
3353 substitution = getField(typeOfSPrototype, field); 3489 substitution = getField(typeOfSPrototype, field);
3354 } 3490 }
3355 if (dart.notNull(dart.notNull(!dart.notNull(isJsArray(s))) && dart.notNull(s ubstitution === null)) || dart.notNull(!dart.notNull(isJsArray(t)))) { 3491 if (dart.notNull(dart.notNull(!dart.notNull(isJsArray(s))) && dart.notNull(s ubstitution === null)) || dart.notNull(!dart.notNull(isJsArray(t)))) {
3356 return true; 3492 return true;
3357 } 3493 }
3358 return checkArguments(substitution, getArguments(s), getArguments(t)); 3494 return checkArguments(substitution, getArguments(s), getArguments(t));
3359 } 3495 }
(...skipping 28 matching lines...) Expand all
3388 return true; 3524 return true;
3389 } 3525 }
3390 // Function areAssignableMaps: (dynamic, dynamic) → bool 3526 // Function areAssignableMaps: (dynamic, dynamic) → bool
3391 function areAssignableMaps(s, t) { 3527 function areAssignableMaps(s, t) {
3392 if (t === null) 3528 if (t === null)
3393 return true; 3529 return true;
3394 if (s === null) 3530 if (s === null)
3395 return false; 3531 return false;
3396 dart.assert(isJsObject(s)); 3532 dart.assert(isJsObject(s));
3397 dart.assert(isJsObject(t)); 3533 dart.assert(isJsObject(t));
3398 let names = _interceptors.JSArray.markFixedList(dart.as(_foreign_helper.JS(' ', 'Object.getOwnPropertyNames(#)', t), core.List)); 3534 let names = _interceptors.JSArray.markFixedList(dart.as(Object.getOwnPropert yNames(t), core.List));
3399 for (let i = 0; i < names.length; i++) { 3535 for (let i = 0; i < names.length; i++) {
3400 let name = names.get(i); 3536 let name = names.get(i);
3401 if (_foreign_helper.JS('bool', '!Object.hasOwnProperty.call(#, #)', s, nam e)) { 3537 if (!Object.hasOwnProperty.call(s, name)) {
3402 return false; 3538 return false;
3403 } 3539 }
3404 let tType = _foreign_helper.JS('', '#[#]', t, name); 3540 let tType = t[name];
3405 let sType = _foreign_helper.JS('', '#[#]', s, name); 3541 let sType = s[name];
3406 if (!dart.notNull(isAssignable(tType, sType))) 3542 if (!dart.notNull(isAssignable(tType, sType)))
3407 return false; 3543 return false;
3408 } 3544 }
3409 return true; 3545 return true;
3410 } 3546 }
3411 // Function isFunctionSubtype: (dynamic, dynamic) → bool 3547 // Function isFunctionSubtype: (dynamic, dynamic) → bool
3412 function isFunctionSubtype(s, t) { 3548 function isFunctionSubtype(s, t) {
3413 dart.assert(hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)); 3549 dart.assert(hasField(t, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`));
3414 if (hasNoField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`)) 3550 if (hasNoField(s, `${_foreign_helper.JS_FUNCTION_TYPE_TAG()}`))
3415 return false; 3551 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3469 return areAssignableMaps(sNamedParameters, tNamedParameters); 3605 return areAssignableMaps(sNamedParameters, tNamedParameters);
3470 } 3606 }
3471 // Function invoke: (dynamic, dynamic) → dynamic 3607 // Function invoke: (dynamic, dynamic) → dynamic
3472 function invoke(function, arguments) { 3608 function invoke(function, arguments) {
3473 return invokeOn(function, null, arguments); 3609 return invokeOn(function, null, arguments);
3474 } 3610 }
3475 // Function invokeOn: (dynamic, dynamic, dynamic) → Object 3611 // Function invokeOn: (dynamic, dynamic, dynamic) → Object
3476 function invokeOn(function, receiver, arguments) { 3612 function invokeOn(function, receiver, arguments) {
3477 dart.assert(isJsFunction(function)); 3613 dart.assert(isJsFunction(function));
3478 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum ents))); 3614 dart.assert(dart.notNull(arguments === null) || dart.notNull(isJsArray(argum ents)));
3479 return _foreign_helper.JS('var', '#.apply(#, #)', function, receiver, argume nts); 3615 return function.apply(receiver, arguments);
3480 } 3616 }
3481 // Function call: (dynamic, String) → dynamic 3617 // Function call: (dynamic, String) → dynamic
3482 function call(object, name) { 3618 function call(object, name) {
3483 return _foreign_helper.JS('var', '#[#]()', object, name); 3619 return object[name]();
3484 } 3620 }
3485 // Function getField: (dynamic, String) → dynamic 3621 // Function getField: (dynamic, String) → dynamic
3486 function getField(object, name) { 3622 function getField(object, name) {
3487 return _foreign_helper.JS('var', '#[#]', object, name); 3623 return object[name];
3488 } 3624 }
3489 // Function getIndex: (dynamic, int) → dynamic 3625 // Function getIndex: (dynamic, int) → dynamic
3490 function getIndex(array, index) { 3626 function getIndex(array, index) {
3491 dart.assert(isJsArray(array)); 3627 dart.assert(isJsArray(array));
3492 return _foreign_helper.JS('var', '#[#]', array, index); 3628 return array[index];
3493 } 3629 }
3494 // Function getLength: (dynamic) → int 3630 // Function getLength: (dynamic) → int
3495 function getLength(array) { 3631 function getLength(array) {
3496 dart.assert(isJsArray(array)); 3632 dart.assert(isJsArray(array));
3497 return dart.as(_foreign_helper.JS('int', '#.length', array), core.int); 3633 return array.length;
3498 } 3634 }
3499 // Function isJsArray: (dynamic) → bool 3635 // Function isJsArray: (dynamic) → bool
3500 function isJsArray(value) { 3636 function isJsArray(value) {
3501 return dart.is(value, _interceptors.JSArray); 3637 return dart.is(value, _interceptors.JSArray);
3502 } 3638 }
3503 // Function hasField: (dynamic, dynamic) → dynamic 3639 // Function hasField: (dynamic, dynamic) → dynamic
3504 function hasField(object, name) { 3640 function hasField(object, name) {
3505 return _foreign_helper.JS('bool', '# in #', name, object); 3641 return name in object;
3506 } 3642 }
3507 // Function hasNoField: (dynamic, dynamic) → dynamic 3643 // Function hasNoField: (dynamic, dynamic) → dynamic
3508 function hasNoField(object, name) { 3644 function hasNoField(object, name) {
3509 return dart.throw_("Unimplemented PrefixExpression: !hasField(object, name)" ); 3645 return dart.throw_("Unimplemented PrefixExpression: !hasField(object, name)" );
3510 } 3646 }
3511 // Function isJsFunction: (dynamic) → bool 3647 // Function isJsFunction: (dynamic) → bool
3512 function isJsFunction(o) { 3648 function isJsFunction(o) {
3513 return dart.as(_foreign_helper.JS('bool', 'typeof # == "function"', o), core .bool); 3649 return typeof o == "function";
3514 } 3650 }
3515 // Function isJsObject: (dynamic) → bool 3651 // Function isJsObject: (dynamic) → bool
3516 function isJsObject(o) { 3652 function isJsObject(o) {
3517 return dart.as(_foreign_helper.JS('bool', "typeof # == 'object'", o), core.b ool); 3653 return typeof o == 'object';
3518 } 3654 }
3519 // Function isIdentical: (dynamic, dynamic) → bool 3655 // Function isIdentical: (dynamic, dynamic) → bool
3520 function isIdentical(s, t) { 3656 function isIdentical(s, t) {
3521 return dart.as(_foreign_helper.JS('bool', '# === #', s, t), core.bool); 3657 return s === t;
3522 } 3658 }
3523 // Function isNotIdentical: (dynamic, dynamic) → bool 3659 // Function isNotIdentical: (dynamic, dynamic) → bool
3524 function isNotIdentical(s, t) { 3660 function isNotIdentical(s, t) {
3525 return dart.as(_foreign_helper.JS('bool', '# !== #', s, t), core.bool); 3661 return s !== t;
3526 } 3662 }
3527 // Exports: 3663 // Exports:
3528 _js_helper.patch = patch; 3664 _js_helper.patch = patch;
3529 _js_helper.InternalMap = InternalMap; 3665 _js_helper.InternalMap = InternalMap;
3530 _js_helper.requiresPreamble = requiresPreamble; 3666 _js_helper.requiresPreamble = requiresPreamble;
3531 _js_helper.isJsIndexable = isJsIndexable; 3667 _js_helper.isJsIndexable = isJsIndexable;
3532 _js_helper.S = S; 3668 _js_helper.S = S;
3533 _js_helper.createInvocationMirror = createInvocationMirror; 3669 _js_helper.createInvocationMirror = createInvocationMirror;
3534 _js_helper.createUnmangledInvocationMirror = createUnmangledInvocationMirror; 3670 _js_helper.createUnmangledInvocationMirror = createUnmangledInvocationMirror;
3535 _js_helper.throwInvalidReflectionError = throwInvalidReflectionError; 3671 _js_helper.throwInvalidReflectionError = throwInvalidReflectionError;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 _js_helper.getIndex = getIndex; 3885 _js_helper.getIndex = getIndex;
3750 _js_helper.getLength = getLength; 3886 _js_helper.getLength = getLength;
3751 _js_helper.isJsArray = isJsArray; 3887 _js_helper.isJsArray = isJsArray;
3752 _js_helper.hasField = hasField; 3888 _js_helper.hasField = hasField;
3753 _js_helper.hasNoField = hasNoField; 3889 _js_helper.hasNoField = hasNoField;
3754 _js_helper.isJsFunction = isJsFunction; 3890 _js_helper.isJsFunction = isJsFunction;
3755 _js_helper.isJsObject = isJsObject; 3891 _js_helper.isJsObject = isJsObject;
3756 _js_helper.isIdentical = isIdentical; 3892 _js_helper.isIdentical = isIdentical;
3757 _js_helper.isNotIdentical = isNotIdentical; 3893 _js_helper.isNotIdentical = isNotIdentical;
3758 })(_js_helper || (_js_helper = {})); 3894 })(_js_helper || (_js_helper = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/_isolate_helper/_isolate_helper.js ('k') | test/codegen/expect/_js_names/_js_names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698