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

Side by Side Diff: lib/runtime/dart/_runtime.js

Issue 1633003002: Add --modules=node support (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merged master Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/_js_mirrors.js ('k') | lib/runtime/dart/html.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('dart/_runtime', null, /* Imports */[ 1 dart_library.library('dart/_runtime', null, /* Imports */[
2 ], /* Lazy imports */[ 2 ], /* Lazy imports */[
3 'dart/core', 3 'dart/core',
4 'dart/_interceptors', 4 'dart/_interceptors',
5 'dart/_js_helper', 5 'dart/_js_helper',
6 'dart/async', 6 'dart/async',
7 'dart/collection' 7 'dart/collection'
8 ], function(exports, core, _interceptors, _js_helper, async$, collection) { 8 ], function(exports, core, _interceptors, _js_helper, async, collection) {
9 'use strict'; 9 'use strict';
10 function mixin(base, ...mixins) { 10 function mixin(base, ...mixins) {
11 class Mixin extends base { 11 class Mixin extends base {
12 [base.name](...args) { 12 [base.name](...args) {
13 for (let i = mixins.length - 1; i >= 0; i--) { 13 for (let i = mixins.length - 1; i >= 0; i--) {
14 let mixin = mixins[i]; 14 let mixin = mixins[i];
15 let init = mixin.prototype[mixin.name]; 15 let init = mixin.prototype[mixin.name];
16 if (init) init.call(this); 16 if (init) init.call(this);
17 } 17 }
18 let init = base.prototype[base.name]; 18 let init = base.prototype[base.name];
(...skipping 12 matching lines...) Expand all
31 return s; 31 return s;
32 } 32 }
33 }); 33 });
34 Mixin[_mixins] = mixins; 34 Mixin[_mixins] = mixins;
35 return Mixin; 35 return Mixin;
36 } 36 }
37 function getMixins(clazz) { 37 function getMixins(clazz) {
38 return clazz[_mixins]; 38 return clazz[_mixins];
39 } 39 }
40 function getImplements(clazz) { 40 function getImplements(clazz) {
41 return clazz[implements$]; 41 return clazz[implements_];
42 } 42 }
43 const _typeArguments = Symbol("typeArguments"); 43 const _typeArguments = Symbol("typeArguments");
44 const _originalDeclaration = Symbol("originalDeclaration"); 44 const _originalDeclaration = Symbol("originalDeclaration");
45 function generic(typeConstructor) { 45 function generic(typeConstructor) {
46 let length = typeConstructor.length; 46 let length = typeConstructor.length;
47 if (length < 1) { 47 if (length < 1) {
48 throwInternalError('must have at least one generic type argument'); 48 throwInternalError('must have at least one generic type argument');
49 } 49 }
50 let resultMap = new Map(); 50 let resultMap = new Map();
51 function makeGenericType(...args) { 51 function makeGenericType(...args) {
52 if (args.length != length && args.length != 0) { 52 if (args.length != length && args.length != 0) {
53 throwInternalError('requires ' + length + ' or 0 type arguments'); 53 throwInternalError('requires ' + length + ' or 0 type arguments');
54 } 54 }
55 while (args.length < length) 55 while (args.length < length)
56 args.push(dynamic); 56 args.push(dynamicR);
57 let value = resultMap; 57 let value = resultMap;
58 for (let i = 0; i < length; i++) { 58 for (let i = 0; i < length; i++) {
59 let arg = args[i]; 59 let arg = args[i];
60 if (arg == null) { 60 if (arg == null) {
61 throwInternalError('type arguments should not be null: ' + typeConstru ctor); 61 throwInternalError('type arguments should not be null: ' + typeConstru ctor);
62 } 62 }
63 let map = value; 63 let map = value;
64 value = map.get(arg); 64 value = map.get(arg);
65 if (value === void 0) { 65 if (value === void 0) {
66 if (i + 1 == length) { 66 if (i + 1 == length) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 let sigCtor = cls[_constructorSig]; 104 let sigCtor = cls[_constructorSig];
105 if (sigCtor === void 0) return void 0; 105 if (sigCtor === void 0) return void 0;
106 let parts = sigCtor[name]; 106 let parts = sigCtor[name];
107 if (parts === void 0) return void 0; 107 if (parts === void 0) return void 0;
108 return definiteFunctionType.apply(null, parts); 108 return definiteFunctionType.apply(null, parts);
109 } 109 }
110 function bind(obj, name, f) { 110 function bind(obj, name, f) {
111 if (f === void 0) f = obj[name]; 111 if (f === void 0) f = obj[name];
112 f = f.bind(obj); 112 f = f.bind(obj);
113 let sig = getMethodType(obj, name); 113 let sig = getMethodType(obj, name);
114 assert(sig); 114 assert_(sig);
115 tag(f, sig); 115 tag(f, sig);
116 return f; 116 return f;
117 } 117 }
118 function _setMethodSignature(f, sigF) { 118 function _setMethodSignature(f, sigF) {
119 defineMemoizedGetter(f, _methodSig, () => { 119 defineMemoizedGetter(f, _methodSig, () => {
120 let sigObj = sigF(); 120 let sigObj = sigF();
121 sigObj.__proto__ = f.__proto__[_methodSig]; 121 sigObj.__proto__ = f.__proto__[_methodSig];
122 return sigObj; 122 return sigObj;
123 }); 123 });
124 } 124 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 let sym = dartx[name]; 178 let sym = dartx[name];
179 if (!sym) dartx[name] = sym = Symbol('dartx.' + name); 179 if (!sym) dartx[name] = sym = Symbol('dartx.' + name);
180 return sym; 180 return sym;
181 } 181 }
182 function defineExtensionNames(names) { 182 function defineExtensionNames(names) {
183 return names.forEach(getExtensionSymbol); 183 return names.forEach(getExtensionSymbol);
184 } 184 }
185 function registerExtension(jsType, dartExtType) { 185 function registerExtension(jsType, dartExtType) {
186 let extProto = dartExtType.prototype; 186 let extProto = dartExtType.prototype;
187 let jsProto = jsType.prototype; 187 let jsProto = jsType.prototype;
188 assert(jsProto[_extensionType] === void 0); 188 assert_(jsProto[_extensionType] === void 0);
189 jsProto[_extensionType] = extProto; 189 jsProto[_extensionType] = extProto;
190 let dartObjProto = core.Object.prototype; 190 let dartObjProto = core.Object.prototype;
191 while (extProto !== dartObjProto && extProto !== jsProto) { 191 while (extProto !== dartObjProto && extProto !== jsProto) {
192 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); 192 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto));
193 extProto = extProto.__proto__; 193 extProto = extProto.__proto__;
194 } 194 }
195 let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; 195 let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get;
196 assert(originalSigFn); 196 assert_(originalSigFn);
197 defineMemoizedGetter(jsType, _methodSig, originalSigFn); 197 defineMemoizedGetter(jsType, _methodSig, originalSigFn);
198 } 198 }
199 function defineExtensionMembers(type, methodNames) { 199 function defineExtensionMembers(type, methodNames) {
200 let proto = type.prototype; 200 let proto = type.prototype;
201 for (let name of methodNames) { 201 for (let name of methodNames) {
202 let method = getOwnPropertyDescriptor(proto, name); 202 let method = getOwnPropertyDescriptor(proto, name);
203 defineProperty(proto, getExtensionSymbol(name), method); 203 defineProperty(proto, getExtensionSymbol(name), method);
204 } 204 }
205 let originalSigFn = getOwnPropertyDescriptor(type, _methodSig).get; 205 let originalSigFn = getOwnPropertyDescriptor(type, _methodSig).get;
206 defineMemoizedGetter(type, _methodSig, function() { 206 defineMemoizedGetter(type, _methodSig, function() {
(...skipping 15 matching lines...) Expand all
222 obj.__proto__ = type.prototype; 222 obj.__proto__ = type.prototype;
223 return obj; 223 return obj;
224 } 224 }
225 function list(obj, elementType) { 225 function list(obj, elementType) {
226 return setType(obj, getGenericClass(_interceptors.JSArray)(elementType)); 226 return setType(obj, getGenericClass(_interceptors.JSArray)(elementType));
227 } 227 }
228 function setBaseClass(derived, base) { 228 function setBaseClass(derived, base) {
229 derived.prototype.__proto__ = base.prototype; 229 derived.prototype.__proto__ = base.prototype;
230 } 230 }
231 function throwCastError(actual, type) { 231 function throwCastError(actual, type) {
232 throw$(new _js_helper.CastErrorImplementation(actual, type)); 232 throw_(new _js_helper.CastErrorImplementation(actual, type));
233 } 233 }
234 function throwAssertionError() { 234 function throwAssertionError() {
235 throw$(new core.AssertionError()); 235 throw_(new core.AssertionError());
236 } 236 }
237 function throwNullValueError() { 237 function throwNullValueError() {
238 throw$(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Va lue>'), null, null, null)); 238 throw_(new core.NoSuchMethodError(null, new core.Symbol('<Unexpected Null Va lue>'), null, null, null));
239 } 239 }
240 const _jsIterator = Symbol("_jsIterator"); 240 const _jsIterator = Symbol("_jsIterator");
241 const _current = Symbol("_current"); 241 const _current = Symbol("_current");
242 function syncStar(gen, E, ...args) { 242 function syncStar(gen, E, ...args) {
243 const SyncIterable_E = getGenericClass(_js_helper.SyncIterable)(E); 243 const SyncIterable_E = getGenericClass(_js_helper.SyncIterable)(E);
244 return new SyncIterable_E(gen, args); 244 return new SyncIterable_E(gen, args);
245 } 245 }
246 function async(gen, T, ...args) { 246 function async_(gen, T, ...args) {
247 let iter; 247 let iter;
248 function onValue(res) { 248 function onValue(res) {
249 if (res === void 0) res = null; 249 if (res === void 0) res = null;
250 return next(iter.next(res)); 250 return next(iter.next(res));
251 } 251 }
252 function onError(err) { 252 function onError(err) {
253 return next(iter.throw(err)); 253 return next(iter.throw(err));
254 } 254 }
255 function next(ret) { 255 function next(ret) {
256 if (ret.done) return ret.value; 256 if (ret.done) return ret.value;
257 let future = ret.value; 257 let future = ret.value;
258 if (!instanceOf(future, getGenericClass(async$.Future))) { 258 if (!instanceOf(future, getGenericClass(async.Future))) {
259 future = async$.Future.value(future); 259 future = async.Future.value(future);
260 } 260 }
261 return future.then(onValue, {onError: onError}); 261 return future.then(onValue, {onError: onError});
262 } 262 }
263 return getGenericClass(async$.Future)(T).new(function() { 263 return getGenericClass(async.Future)(T).new(function() {
264 iter = gen(...args)[Symbol.iterator](); 264 iter = gen(...args)[Symbol.iterator]();
265 return onValue(); 265 return onValue();
266 }); 266 });
267 } 267 }
268 const _AsyncStarStreamController = class _AsyncStarStreamController { 268 const _AsyncStarStreamController = class _AsyncStarStreamController {
269 constructor(generator, T, args) { 269 constructor(generator, T, args) {
270 this.isAdding = false; 270 this.isAdding = false;
271 this.isWaiting = false; 271 this.isWaiting = false;
272 this.isScheduled = false; 272 this.isScheduled = false;
273 this.isSuspendedAtYield = false; 273 this.isSuspendedAtYield = false;
274 this.canceler = null; 274 this.canceler = null;
275 this.iterator = generator(this, ...args)[Symbol.iterator](); 275 this.iterator = generator(this, ...args)[Symbol.iterator]();
276 this.controller = getGenericClass(async$.StreamController)(T).new({ 276 this.controller = getGenericClass(async.StreamController)(T).new({
277 onListen: (() => this.scheduleGenerator()).bind(this), 277 onListen: (() => this.scheduleGenerator()).bind(this),
278 onResume: (() => this.onResume()).bind(this), 278 onResume: (() => this.onResume()).bind(this),
279 onCancel: (() => this.onCancel()).bind(this) 279 onCancel: (() => this.onCancel()).bind(this)
280 }); 280 });
281 } 281 }
282 onResume() { 282 onResume() {
283 if (this.isSuspendedAtYield) { 283 if (this.isSuspendedAtYield) {
284 this.scheduleGenerator(); 284 this.scheduleGenerator();
285 } 285 }
286 } 286 }
287 onCancel() { 287 onCancel() {
288 if (this.controller.isClosed) { 288 if (this.controller.isClosed) {
289 return null; 289 return null;
290 } 290 }
291 if (this.canceler == null) { 291 if (this.canceler == null) {
292 this.canceler = async$.Completer.new(); 292 this.canceler = async.Completer.new();
293 this.scheduleGenerator(); 293 this.scheduleGenerator();
294 } 294 }
295 return this.canceler.future; 295 return this.canceler.future;
296 } 296 }
297 close() { 297 close() {
298 if (this.canceler != null && !this.canceler.isCompleted) { 298 if (this.canceler != null && !this.canceler.isCompleted) {
299 this.canceler.complete(); 299 this.canceler.complete();
300 } 300 }
301 this.controller.close(); 301 this.controller.close();
302 } 302 }
303 scheduleGenerator() { 303 scheduleGenerator() {
304 if (this.isScheduled || this.controller.isPaused || this.isAdding || this. isWaiting) { 304 if (this.isScheduled || this.controller.isPaused || this.isAdding || this. isWaiting) {
305 return; 305 return;
306 } 306 }
307 this.isScheduled = true; 307 this.isScheduled = true;
308 async$.scheduleMicrotask((() => this.runBody()).bind(this)); 308 async.scheduleMicrotask((() => this.runBody()).bind(this));
309 } 309 }
310 runBody(opt_awaitValue) { 310 runBody(opt_awaitValue) {
311 this.isScheduled = false; 311 this.isScheduled = false;
312 this.isSuspendedAtYield = false; 312 this.isSuspendedAtYield = false;
313 this.isWaiting = false; 313 this.isWaiting = false;
314 let iter; 314 let iter;
315 try { 315 try {
316 iter = this.iterator.next(opt_awaitValue); 316 iter = this.iterator.next(opt_awaitValue);
317 } catch (e) { 317 } catch (e) {
318 this.addError(e, stackTrace(e)); 318 this.addError(e, stackTrace(e));
319 this.close(); 319 this.close();
320 return; 320 return;
321 } 321 }
322 322
323 if (iter.done) { 323 if (iter.done) {
324 this.close(); 324 this.close();
325 return; 325 return;
326 } 326 }
327 if (this.isSuspendedAtYield || this.isAdding) return; 327 if (this.isSuspendedAtYield || this.isAdding) return;
328 this.isWaiting = true; 328 this.isWaiting = true;
329 let future = iter.value; 329 let future = iter.value;
330 if (!instanceOf(future, getGenericClass(async$.Future))) { 330 if (!instanceOf(future, getGenericClass(async.Future))) {
331 future = async$.Future.value(future); 331 future = async.Future.value(future);
332 } 332 }
333 return future.then((x => this.runBody(x)).bind(this), { 333 return future.then((x => this.runBody(x)).bind(this), {
334 onError: ((e, s) => this.throwError(e, s)).bind(this) 334 onError: ((e, s) => this.throwError(e, s)).bind(this)
335 }); 335 });
336 } 336 }
337 add(event) { 337 add(event) {
338 if (!this.controller.hasListener) return true; 338 if (!this.controller.hasListener) return true;
339 this.controller.add(event); 339 this.controller.add(event);
340 this.scheduleGenerator(); 340 this.scheduleGenerator();
341 this.isSuspendedAtYield = true; 341 this.isSuspendedAtYield = true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (names.length == 0) return false; 412 if (names.length == 0) return false;
413 for (var name of names) { 413 for (var name of names) {
414 if (!hasOwnProperty.call(type.named, name)) { 414 if (!hasOwnProperty.call(type.named, name)) {
415 return false; 415 return false;
416 } 416 }
417 if (!instanceOfOrNull(opts[name], type.named[name])) return false; 417 if (!instanceOfOrNull(opts[name], type.named[name])) return false;
418 } 418 }
419 return true; 419 return true;
420 } 420 }
421 function throwNoSuchMethod(obj, name, pArgs, nArgs, extras) { 421 function throwNoSuchMethod(obj, name, pArgs, nArgs, extras) {
422 throw$(new core.NoSuchMethodError(obj, name, pArgs, nArgs, extras)); 422 throw_(new core.NoSuchMethodError(obj, name, pArgs, nArgs, extras));
423 } 423 }
424 function throwNoSuchMethodFunc(obj, name, pArgs, opt_func) { 424 function throwNoSuchMethodFunc(obj, name, pArgs, opt_func) {
425 if (obj === void 0) obj = opt_func; 425 if (obj === void 0) obj = opt_func;
426 throwNoSuchMethod(obj, name, pArgs); 426 throwNoSuchMethod(obj, name, pArgs);
427 } 427 }
428 function checkAndCall(f, ftype, obj, args, name) { 428 function checkAndCall(f, ftype, obj, args, name) {
429 let originalFunction = f; 429 let originalFunction = f;
430 if (!(f instanceof Function)) { 430 if (!(f instanceof Function)) {
431 if (f != null) { 431 if (f != null) {
432 ftype = getMethodType(f, 'call'); 432 ftype = getMethodType(f, 'call');
(...skipping 28 matching lines...) Expand all
461 return callMethod(obj, method, args, method); 461 return callMethod(obj, method, args, method);
462 } 462 }
463 function dindex(obj, index) { 463 function dindex(obj, index) {
464 return callMethod(obj, 'get', [index], '[]'); 464 return callMethod(obj, 'get', [index], '[]');
465 } 465 }
466 function dsetindex(obj, index, value) { 466 function dsetindex(obj, index, value) {
467 callMethod(obj, 'set', [index, value], '[]='); 467 callMethod(obj, 'set', [index, value], '[]=');
468 return value; 468 return value;
469 } 469 }
470 function _ignoreTypeFailure(actual, type) { 470 function _ignoreTypeFailure(actual, type) {
471 if (isSubtype(type, core.Iterable) && isSubtype(actual, core.Iterable) || is Subtype(type, async$.Future) && isSubtype(actual, async$.Future) || isSubtype(ty pe, core.Map) && isSubtype(actual, core.Map) || isSubtype(type, core.Function) & & isSubtype(actual, core.Function) || isSubtype(type, async$.Stream) && isSubtyp e(actual, async$.Stream) || isSubtype(type, async$.StreamSubscription) && isSubt ype(actual, async$.StreamSubscription)) { 471 if (isSubtype(type, core.Iterable) && isSubtype(actual, core.Iterable) || is Subtype(type, async.Future) && isSubtype(actual, async.Future) || isSubtype(type , core.Map) && isSubtype(actual, core.Map) || isSubtype(type, core.Function) && isSubtype(actual, core.Function) || isSubtype(type, async.Stream) && isSubtype(a ctual, async.Stream) || isSubtype(type, async.StreamSubscription) && isSubtype(a ctual, async.StreamSubscription)) {
472 console.warn('Ignoring cast fail from ' + typeName(actual) + ' to ' + type Name(type)); 472 console.warn('Ignoring cast fail from ' + typeName(actual) + ' to ' + type Name(type));
473 return true; 473 return true;
474 } 474 }
475 return false; 475 return false;
476 } 476 }
477 function strongInstanceOf(obj, type, ignoreFromWhiteList) { 477 function strongInstanceOf(obj, type, ignoreFromWhiteList) {
478 let actual = realRuntimeType(obj); 478 let actual = realRuntimeType(obj);
479 if (isSubtype(actual, type) || actual == jsobject) return true; 479 if (isSubtype(actual, type) || actual == jsobject) return true;
480 if (ignoreFromWhiteList == void 0) return false; 480 if (ignoreFromWhiteList == void 0) return false;
481 if (isGroundType(type)) return false; 481 if (isGroundType(type)) return false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 let value = values[i + 1]; 528 let value = values[i + 1];
529 map.set(key, value); 529 map.set(key, value);
530 } 530 }
531 } else if (typeof values === 'object') { 531 } else if (typeof values === 'object') {
532 for (let key of getOwnPropertyNames(values)) { 532 for (let key of getOwnPropertyNames(values)) {
533 map.set(key, values[key]); 533 map.set(key, values[key]);
534 } 534 }
535 } 535 }
536 return map; 536 return map;
537 } 537 }
538 function assert(condition) { 538 function assert_(condition) {
539 if (!condition) throwAssertionError(); 539 if (!condition) throwAssertionError();
540 } 540 }
541 const _stack = new WeakMap(); 541 const _stack = new WeakMap();
542 function throw$(obj) { 542 function throw_(obj) {
543 if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) { 543 if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) {
544 _stack.set(obj, new Error()); 544 _stack.set(obj, new Error());
545 } 545 }
546 throw obj; 546 throw obj;
547 } 547 }
548 function getError(exception) { 548 function getError(exception) {
549 var stack = _stack.get(exception); 549 var stack = _stack.get(exception);
550 return stack !== void 0 ? stack : exception; 550 return stack !== void 0 ? stack : exception;
551 } 551 }
552 function stackPrint(exception) { 552 function stackPrint(exception) {
(...skipping 20 matching lines...) Expand all
573 map.set(k, value = new Map()); 573 map.set(k, value = new Map());
574 } 574 }
575 map = value; 575 map = value;
576 } 576 }
577 if (map.has(_value)) return map.get(_value); 577 if (map.has(_value)) return map.get(_value);
578 let value = valueFn(); 578 let value = valueFn();
579 map.set(_value, value); 579 map.set(_value, value);
580 return value; 580 return value;
581 } 581 }
582 const constants = new Map(); 582 const constants = new Map();
583 function const$(obj) { 583 function const_(obj) {
584 let objectKey = [realRuntimeType(obj)]; 584 let objectKey = [realRuntimeType(obj)];
585 for (let name of getOwnNamesAndSymbols(obj)) { 585 for (let name of getOwnNamesAndSymbols(obj)) {
586 objectKey.push(name); 586 objectKey.push(name);
587 objectKey.push(obj[name]); 587 objectKey.push(obj[name]);
588 } 588 }
589 return multiKeyPutIfAbsent(constants, objectKey, () => obj); 589 return multiKeyPutIfAbsent(constants, objectKey, () => obj);
590 } 590 }
591 function hashCode(obj) { 591 function hashCode(obj) {
592 if (obj == null) { 592 if (obj == null) {
593 return 0; 593 return 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 return {done: done, value: done ? void 0 : i.current}; 635 return {done: done, value: done ? void 0 : i.current};
636 } 636 }
637 }; 637 };
638 function fn(closure, ...args) { 638 function fn(closure, ...args) {
639 if (args.length == 1) { 639 if (args.length == 1) {
640 defineLazyProperty(closure, _runtimeType, {get: args[0]}); 640 defineLazyProperty(closure, _runtimeType, {get: args[0]});
641 return closure; 641 return closure;
642 } 642 }
643 let t; 643 let t;
644 if (args.length == 0) { 644 if (args.length == 0) {
645 t = definiteFunctionType(dynamic, Array(closure.length).fill(dynamic)); 645 t = definiteFunctionType(dynamicR, Array(closure.length).fill(dynamicR));
646 } else { 646 } else {
647 t = definiteFunctionType.apply(null, args); 647 t = definiteFunctionType.apply(null, args);
648 } 648 }
649 tag(closure, t); 649 tag(closure, t);
650 return closure; 650 return closure;
651 } 651 }
652 const _runtimeType = Symbol("_runtimeType"); 652 const _runtimeType = Symbol("_runtimeType");
653 function checkPrimitiveType(obj) { 653 function checkPrimitiveType(obj) {
654 switch (typeof obj) { 654 switch (typeof obj) {
655 case "undefined": 655 case "undefined":
(...skipping 19 matching lines...) Expand all
675 } 675 }
676 if (obj === null) return core.Null; 676 if (obj === null) return core.Null;
677 return null; 677 return null;
678 } 678 }
679 function runtimeType(obj) { 679 function runtimeType(obj) {
680 let result = checkPrimitiveType(obj); 680 let result = checkPrimitiveType(obj);
681 if (result !== null) return result; 681 if (result !== null) return result;
682 return obj.runtimeType; 682 return obj.runtimeType;
683 } 683 }
684 function getFunctionType(obj) { 684 function getFunctionType(obj) {
685 let args = Array(obj.length).fill(dynamic); 685 let args = Array(obj.length).fill(dynamicR);
686 return definiteFunctionType(bottom, args); 686 return definiteFunctionType(bottom, args);
687 } 687 }
688 function realRuntimeType(obj) { 688 function realRuntimeType(obj) {
689 let result = checkPrimitiveType(obj); 689 let result = checkPrimitiveType(obj);
690 if (result !== null) return result; 690 if (result !== null) return result;
691 result = obj[_runtimeType]; 691 result = obj[_runtimeType];
692 if (result) return result; 692 if (result) return result;
693 result = obj.constructor; 693 result = obj.constructor;
694 if (result == Function) { 694 if (result == Function) {
695 return jsobject; 695 return jsobject;
(...skipping 21 matching lines...) Expand all
717 let cache = null; 717 let cache = null;
718 function getter() { 718 function getter() {
719 if (compute == null) return cache; 719 if (compute == null) return cache;
720 cache = compute(); 720 cache = compute();
721 compute = null; 721 compute = null;
722 return cache; 722 return cache;
723 } 723 }
724 tagComputed(value, getter); 724 tagComputed(value, getter);
725 } 725 }
726 const _mixins = Symbol("mixins"); 726 const _mixins = Symbol("mixins");
727 const implements$ = Symbol("implements"); 727 const implements_ = Symbol("implements");
728 const metadata = Symbol("metadata"); 728 const metadata = Symbol("metadata");
729 const TypeRep = class TypeRep extends LazyTagged(() => core.Type) { 729 const TypeRep = class TypeRep extends LazyTagged(() => core.Type) {
730 get name() { 730 get name() {
731 return this.toString(); 731 return this.toString();
732 } 732 }
733 }; 733 };
734 const Dynamic = class Dynamic extends TypeRep { 734 const Dynamic = class Dynamic extends TypeRep {
735 toString() { 735 toString() {
736 return "dynamic"; 736 return "dynamic";
737 } 737 }
738 }; 738 };
739 const dynamic = new Dynamic(); 739 const dynamicR = new Dynamic();
740 const Void = class Void extends TypeRep { 740 const Void = class Void extends TypeRep {
741 toString() { 741 toString() {
742 return "void"; 742 return "void";
743 } 743 }
744 }; 744 };
745 const void$ = new Void(); 745 const voidR = new Void();
746 const Bottom = class Bottom extends TypeRep { 746 const Bottom = class Bottom extends TypeRep {
747 toString() { 747 toString() {
748 return "bottom"; 748 return "bottom";
749 } 749 }
750 }; 750 };
751 const bottom = new Bottom(); 751 const bottom = new Bottom();
752 const JSObject = class JSObject extends TypeRep { 752 const JSObject = class JSObject extends TypeRep {
753 toString() { 753 toString() {
754 return "NativeJavaScriptObject"; 754 return "NativeJavaScriptObject";
755 } 755 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 } 822 }
823 return result; 823 return result;
824 } 824 }
825 this.args = process(this.args, this.metadata); 825 this.args = process(this.args, this.metadata);
826 this.optionals = process(this.optionals, this.metadata); 826 this.optionals = process(this.optionals, this.metadata);
827 this._canonize(); 827 this._canonize();
828 } 828 }
829 _canonize() { 829 _canonize() {
830 if (this.definite) return; 830 if (this.definite) return;
831 function replace(a) { 831 function replace(a) {
832 return a == dynamic ? bottom : a; 832 return a == dynamicR ? bottom : a;
833 } 833 }
834 this.args = this.args.map(replace); 834 this.args = this.args.map(replace);
835 if (this.optionals.length > 0) { 835 if (this.optionals.length > 0) {
836 this.optionals = this.optionals.map(replace); 836 this.optionals = this.optionals.map(replace);
837 } 837 }
838 if (Object.keys(this.named).length > 0) { 838 if (Object.keys(this.named).length > 0) {
839 let r = {}; 839 let r = {};
840 for (let name of getOwnPropertyNames(this.named)) { 840 for (let name of getOwnPropertyNames(this.named)) {
841 r[name] = replace(this.named[name]); 841 r[name] = replace(this.named[name]);
842 } 842 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 function isFunctionType(type) { 928 function isFunctionType(type) {
929 return type instanceof AbstractFunctionType || type == core.Function; 929 return type instanceof AbstractFunctionType || type == core.Function;
930 } 930 }
931 function isFunctionSubType(ft1, ft2) { 931 function isFunctionSubType(ft1, ft2) {
932 if (ft2 == core.Function) { 932 if (ft2 == core.Function) {
933 return true; 933 return true;
934 } 934 }
935 let ret1 = ft1.returnType; 935 let ret1 = ft1.returnType;
936 let ret2 = ft2.returnType; 936 let ret2 = ft2.returnType;
937 if (!isSubtype_(ret1, ret2)) { 937 if (!isSubtype_(ret1, ret2)) {
938 if (ret2 != void$) { 938 if (ret2 != voidR) {
939 return false; 939 return false;
940 } 940 }
941 } 941 }
942 let args1 = ft1.args; 942 let args1 = ft1.args;
943 let args2 = ft2.args; 943 let args2 = ft2.args;
944 if (args1.length > args2.length) { 944 if (args1.length > args2.length) {
945 return false; 945 return false;
946 } 946 }
947 for (let i = 0; i < args1.length; ++i) { 947 for (let i = 0; i < args1.length; ++i) {
948 if (!isSubtype_(args2[i], args1[i])) { 948 if (!isSubtype_(args2[i], args1[i])) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 subtypeMap.set(t1, map = new Map()); 1001 subtypeMap.set(t1, map = new Map());
1002 } 1002 }
1003 result = isSubtype_(t1, t2); 1003 result = isSubtype_(t1, t2);
1004 map.set(t2, result); 1004 map.set(t2, result);
1005 return result; 1005 return result;
1006 } 1006 }
1007 function _isBottom(type) { 1007 function _isBottom(type) {
1008 return type == bottom; 1008 return type == bottom;
1009 } 1009 }
1010 function _isTop(type) { 1010 function _isTop(type) {
1011 return type == core.Object || type == dynamic; 1011 return type == core.Object || type == dynamicR;
1012 } 1012 }
1013 function isSubtype_(t1, t2) { 1013 function isSubtype_(t1, t2) {
1014 t1 = canonicalType(t1); 1014 t1 = canonicalType(t1);
1015 t2 = canonicalType(t2); 1015 t2 = canonicalType(t2);
1016 if (t1 == t2) return true; 1016 if (t1 == t2) return true;
1017 if (_isTop(t2) || _isBottom(t1)) { 1017 if (_isTop(t2) || _isBottom(t1)) {
1018 return true; 1018 return true;
1019 } 1019 }
1020 if (_isTop(t1) || _isBottom(t2)) { 1020 if (_isTop(t1) || _isBottom(t2)) {
1021 return false; 1021 return false;
1022 } 1022 }
1023 if (isClassSubType(t1, t2)) { 1023 if (isClassSubType(t1, t2)) {
1024 return true; 1024 return true;
1025 } 1025 }
1026 if (isFunctionType(t1) && isFunctionType(t2)) { 1026 if (isFunctionType(t1) && isFunctionType(t2)) {
1027 return isFunctionSubType(t1, t2); 1027 return isFunctionSubType(t1, t2);
1028 } 1028 }
1029 return false; 1029 return false;
1030 } 1030 }
1031 function isClassSubType(t1, t2) { 1031 function isClassSubType(t1, t2) {
1032 t1 = canonicalType(t1); 1032 t1 = canonicalType(t1);
1033 assert(t2 == canonicalType(t2)); 1033 assert_(t2 == canonicalType(t2));
1034 if (t1 == t2) return true; 1034 if (t1 == t2) return true;
1035 if (t1 == core.Object) return false; 1035 if (t1 == core.Object) return false;
1036 if (t1 == null) return t2 == core.Object || t2 == dynamic; 1036 if (t1 == null) return t2 == core.Object || t2 == dynamicR;
1037 let raw1 = getGenericClass(t1); 1037 let raw1 = getGenericClass(t1);
1038 let raw2 = getGenericClass(t2); 1038 let raw2 = getGenericClass(t2);
1039 if (raw1 != null && raw1 == raw2) { 1039 if (raw1 != null && raw1 == raw2) {
1040 let typeArguments1 = getGenericArgs(t1); 1040 let typeArguments1 = getGenericArgs(t1);
1041 let typeArguments2 = getGenericArgs(t2); 1041 let typeArguments2 = getGenericArgs(t2);
1042 let length = typeArguments1.length; 1042 let length = typeArguments1.length;
1043 if (typeArguments2.length == 0) { 1043 if (typeArguments2.length == 0) {
1044 return true; 1044 return true;
1045 } else if (length == 0) { 1045 } else if (length == 0) {
1046 return false; 1046 return false;
1047 } 1047 }
1048 assert(length == typeArguments2.length); 1048 assert_(length == typeArguments2.length);
1049 for (let i = 0; i < length; ++i) { 1049 for (let i = 0; i < length; ++i) {
1050 if (!isSubtype(typeArguments1[i], typeArguments2[i])) { 1050 if (!isSubtype(typeArguments1[i], typeArguments2[i])) {
1051 return false; 1051 return false;
1052 } 1052 }
1053 } 1053 }
1054 return true; 1054 return true;
1055 } 1055 }
1056 if (isClassSubType(t1.__proto__, t2)) return true; 1056 if (isClassSubType(t1.__proto__, t2)) return true;
1057 let mixins = getMixins(t1); 1057 let mixins = getMixins(t1);
1058 if (mixins) { 1058 if (mixins) {
(...skipping 20 matching lines...) Expand all
1079 } 1079 }
1080 let names = getOwnPropertyNames(type.named); 1080 let names = getOwnPropertyNames(type.named);
1081 for (let i = 0; i < names.length; ++i) { 1081 for (let i = 0; i < names.length; ++i) {
1082 if (!_isBottom(type.named[names[i]])) return false; 1082 if (!_isBottom(type.named[names[i]])) return false;
1083 } 1083 }
1084 return true; 1084 return true;
1085 } 1085 }
1086 let typeArgs = getGenericArgs(type); 1086 let typeArgs = getGenericArgs(type);
1087 if (!typeArgs) return true; 1087 if (!typeArgs) return true;
1088 for (let t of typeArgs) { 1088 for (let t of typeArgs) {
1089 if (t != core.Object && t != dynamic) return false; 1089 if (t != core.Object && t != dynamicR) return false;
1090 } 1090 }
1091 return true; 1091 return true;
1092 } 1092 }
1093 const defineProperty = Object.defineProperty; 1093 const defineProperty = Object.defineProperty;
1094 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 1094 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1095 const getOwnPropertyNames = Object.getOwnPropertyNames; 1095 const getOwnPropertyNames = Object.getOwnPropertyNames;
1096 const getOwnPropertySymbols = Object.getOwnPropertySymbols; 1096 const getOwnPropertySymbols = Object.getOwnPropertySymbols;
1097 const hasOwnProperty = Object.prototype.hasOwnProperty; 1097 const hasOwnProperty = Object.prototype.hasOwnProperty;
1098 const StrongModeError = (function() { 1098 const StrongModeError = (function() {
1099 function StrongModeError(message) { 1099 function StrongModeError(message) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 defineProperty(to, name, desc); 1154 defineProperty(to, name, desc);
1155 } else { 1155 } else {
1156 defineLazyProperty(to, name, () => from[name]); 1156 defineLazyProperty(to, name, () => from[name]);
1157 } 1157 }
1158 } 1158 }
1159 return to; 1159 return to;
1160 } 1160 }
1161 function copyProperties(to, from) { 1161 function copyProperties(to, from) {
1162 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); 1162 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from));
1163 } 1163 }
1164 function export$(to, from, show, hide) { 1164 function export_(to, from, show, hide) {
1165 if (show == void 0 || show.length == 0) { 1165 if (show == void 0 || show.length == 0) {
1166 show = getOwnNamesAndSymbols(from); 1166 show = getOwnNamesAndSymbols(from);
1167 } 1167 }
1168 if (hide != void 0) { 1168 if (hide != void 0) {
1169 var hideMap = new Set(hide); 1169 var hideMap = new Set(hide);
1170 show = show.filter(k => !hideMap.has(k)); 1170 show = show.filter(k => !hideMap.has(k));
1171 } 1171 }
1172 return copyTheseProperties(to, from, show); 1172 return copyTheseProperties(to, from, show);
1173 } 1173 }
1174 const defineLazyClass = defineLazy; 1174 const defineLazyClass = defineLazy;
1175 const defineLazyProperties = defineLazy; 1175 const defineLazyProperties = defineLazy;
1176 const defineLazyClassGeneric = defineLazyProperty; 1176 const defineLazyClassGeneric = defineLazyProperty;
1177 const as = cast; 1177 const as_ = cast;
1178 const is = instanceOf; 1178 const is_ = instanceOf;
1179 const global = typeof window == "undefined" ? global : window; 1179 const global_ = typeof window == "undefined" ? global : window;
1180 const JsSymbol = Symbol; 1180 const JsSymbol = Symbol;
1181 // Exports: 1181 // Exports:
1182 exports.mixin = mixin; 1182 exports.mixin = mixin;
1183 exports.getMixins = getMixins; 1183 exports.getMixins = getMixins;
1184 exports.getImplements = getImplements; 1184 exports.getImplements = getImplements;
1185 exports.generic = generic; 1185 exports.generic = generic;
1186 exports.getGenericClass = getGenericClass; 1186 exports.getGenericClass = getGenericClass;
1187 exports.getGenericArgs = getGenericArgs; 1187 exports.getGenericArgs = getGenericArgs;
1188 exports.getMethodType = getMethodType; 1188 exports.getMethodType = getMethodType;
1189 exports.classGetConstructorType = classGetConstructorType; 1189 exports.classGetConstructorType = classGetConstructorType;
1190 exports.bind = bind; 1190 exports.bind = bind;
1191 exports.setSignature = setSignature; 1191 exports.setSignature = setSignature;
1192 exports.hasMethod = hasMethod; 1192 exports.hasMethod = hasMethod;
1193 exports.virtualField = virtualField; 1193 exports.virtualField = virtualField;
1194 exports.defineNamedConstructor = defineNamedConstructor; 1194 exports.defineNamedConstructor = defineNamedConstructor;
1195 exports.dartx = dartx; 1195 exports.dartx = dartx;
1196 exports.getExtensionSymbol = getExtensionSymbol; 1196 exports.getExtensionSymbol = getExtensionSymbol;
1197 exports.defineExtensionNames = defineExtensionNames; 1197 exports.defineExtensionNames = defineExtensionNames;
1198 exports.registerExtension = registerExtension; 1198 exports.registerExtension = registerExtension;
1199 exports.defineExtensionMembers = defineExtensionMembers; 1199 exports.defineExtensionMembers = defineExtensionMembers;
1200 exports.canonicalMember = canonicalMember; 1200 exports.canonicalMember = canonicalMember;
1201 exports.setType = setType; 1201 exports.setType = setType;
1202 exports.list = list; 1202 exports.list = list;
1203 exports.setBaseClass = setBaseClass; 1203 exports.setBaseClass = setBaseClass;
1204 exports.throwCastError = throwCastError; 1204 exports.throwCastError = throwCastError;
1205 exports.throwAssertionError = throwAssertionError; 1205 exports.throwAssertionError = throwAssertionError;
1206 exports.throwNullValueError = throwNullValueError; 1206 exports.throwNullValueError = throwNullValueError;
1207 exports.syncStar = syncStar; 1207 exports.syncStar = syncStar;
1208 exports.async = async; 1208 exports.async = async_;
1209 exports.asyncStar = asyncStar; 1209 exports.asyncStar = asyncStar;
1210 exports.dload = dload; 1210 exports.dload = dload;
1211 exports.dput = dput; 1211 exports.dput = dput;
1212 exports.checkApply = checkApply; 1212 exports.checkApply = checkApply;
1213 exports.throwNoSuchMethod = throwNoSuchMethod; 1213 exports.throwNoSuchMethod = throwNoSuchMethod;
1214 exports.throwNoSuchMethodFunc = throwNoSuchMethodFunc; 1214 exports.throwNoSuchMethodFunc = throwNoSuchMethodFunc;
1215 exports.checkAndCall = checkAndCall; 1215 exports.checkAndCall = checkAndCall;
1216 exports.dcall = dcall; 1216 exports.dcall = dcall;
1217 exports.callMethod = callMethod; 1217 exports.callMethod = callMethod;
1218 exports.dsend = dsend; 1218 exports.dsend = dsend;
1219 exports.dindex = dindex; 1219 exports.dindex = dindex;
1220 exports.dsetindex = dsetindex; 1220 exports.dsetindex = dsetindex;
1221 exports.strongInstanceOf = strongInstanceOf; 1221 exports.strongInstanceOf = strongInstanceOf;
1222 exports.instanceOfOrNull = instanceOfOrNull; 1222 exports.instanceOfOrNull = instanceOfOrNull;
1223 exports.instanceOf = instanceOf; 1223 exports.instanceOf = instanceOf;
1224 exports.cast = cast; 1224 exports.cast = cast;
1225 exports.asInt = asInt; 1225 exports.asInt = asInt;
1226 exports.arity = arity; 1226 exports.arity = arity;
1227 exports.equals = equals; 1227 exports.equals = equals;
1228 exports.notNull = notNull; 1228 exports.notNull = notNull;
1229 exports.map = map; 1229 exports.map = map;
1230 exports.assert = assert; 1230 exports.assert = assert_;
1231 exports.throw = throw$; 1231 exports.throw = throw_;
1232 exports.getError = getError; 1232 exports.getError = getError;
1233 exports.stackPrint = stackPrint; 1233 exports.stackPrint = stackPrint;
1234 exports.stackTrace = stackTrace; 1234 exports.stackTrace = stackTrace;
1235 exports.nullSafe = nullSafe; 1235 exports.nullSafe = nullSafe;
1236 exports.multiKeyPutIfAbsent = multiKeyPutIfAbsent; 1236 exports.multiKeyPutIfAbsent = multiKeyPutIfAbsent;
1237 exports.constants = constants; 1237 exports.constants = constants;
1238 exports.const = const$; 1238 exports.const = const_;
1239 exports.hashCode = hashCode; 1239 exports.hashCode = hashCode;
1240 exports.toString = toString; 1240 exports.toString = toString;
1241 exports.noSuchMethod = noSuchMethod; 1241 exports.noSuchMethod = noSuchMethod;
1242 exports.JsIterator = JsIterator; 1242 exports.JsIterator = JsIterator;
1243 exports.fn = fn; 1243 exports.fn = fn;
1244 exports.checkPrimitiveType = checkPrimitiveType; 1244 exports.checkPrimitiveType = checkPrimitiveType;
1245 exports.runtimeType = runtimeType; 1245 exports.runtimeType = runtimeType;
1246 exports.getFunctionType = getFunctionType; 1246 exports.getFunctionType = getFunctionType;
1247 exports.realRuntimeType = realRuntimeType; 1247 exports.realRuntimeType = realRuntimeType;
1248 exports.LazyTagged = LazyTagged; 1248 exports.LazyTagged = LazyTagged;
1249 exports.read = read; 1249 exports.read = read;
1250 exports.tag = tag; 1250 exports.tag = tag;
1251 exports.tagComputed = tagComputed; 1251 exports.tagComputed = tagComputed;
1252 exports.tagMemoized = tagMemoized; 1252 exports.tagMemoized = tagMemoized;
1253 exports.implements = implements$; 1253 exports.implements = implements_;
1254 exports.metadata = metadata; 1254 exports.metadata = metadata;
1255 exports.TypeRep = TypeRep; 1255 exports.TypeRep = TypeRep;
1256 exports.Dynamic = Dynamic; 1256 exports.Dynamic = Dynamic;
1257 exports.dynamic = dynamic; 1257 exports.dynamic = dynamicR;
1258 exports.Void = Void; 1258 exports.Void = Void;
1259 exports.void = void$; 1259 exports.void = voidR;
1260 exports.Bottom = Bottom; 1260 exports.Bottom = Bottom;
1261 exports.bottom = bottom; 1261 exports.bottom = bottom;
1262 exports.JSObject = JSObject; 1262 exports.JSObject = JSObject;
1263 exports.jsobject = jsobject; 1263 exports.jsobject = jsobject;
1264 exports.AbstractFunctionType = AbstractFunctionType; 1264 exports.AbstractFunctionType = AbstractFunctionType;
1265 exports.FunctionType = FunctionType; 1265 exports.FunctionType = FunctionType;
1266 exports.Typedef = Typedef; 1266 exports.Typedef = Typedef;
1267 exports.functionType = functionType; 1267 exports.functionType = functionType;
1268 exports.definiteFunctionType = definiteFunctionType; 1268 exports.definiteFunctionType = definiteFunctionType;
1269 exports.typedef = typedef; 1269 exports.typedef = typedef;
(...skipping 15 matching lines...) Expand all
1285 exports.StrongModeError = StrongModeError; 1285 exports.StrongModeError = StrongModeError;
1286 exports.throwStrongModeError = throwStrongModeError; 1286 exports.throwStrongModeError = throwStrongModeError;
1287 exports.throwInternalError = throwInternalError; 1287 exports.throwInternalError = throwInternalError;
1288 exports.getOwnNamesAndSymbols = getOwnNamesAndSymbols; 1288 exports.getOwnNamesAndSymbols = getOwnNamesAndSymbols;
1289 exports.safeGetOwnProperty = safeGetOwnProperty; 1289 exports.safeGetOwnProperty = safeGetOwnProperty;
1290 exports.defineLazyProperty = defineLazyProperty; 1290 exports.defineLazyProperty = defineLazyProperty;
1291 exports.defineLazy = defineLazy; 1291 exports.defineLazy = defineLazy;
1292 exports.defineMemoizedGetter = defineMemoizedGetter; 1292 exports.defineMemoizedGetter = defineMemoizedGetter;
1293 exports.copyTheseProperties = copyTheseProperties; 1293 exports.copyTheseProperties = copyTheseProperties;
1294 exports.copyProperties = copyProperties; 1294 exports.copyProperties = copyProperties;
1295 exports.export = export$; 1295 exports.export = export_;
1296 exports.defineLazyClass = defineLazyClass; 1296 exports.defineLazyClass = defineLazyClass;
1297 exports.defineLazyProperties = defineLazyProperties; 1297 exports.defineLazyProperties = defineLazyProperties;
1298 exports.defineLazyClassGeneric = defineLazyClassGeneric; 1298 exports.defineLazyClassGeneric = defineLazyClassGeneric;
1299 exports.as = as; 1299 exports.as = as_;
1300 exports.is = is; 1300 exports.is = is_;
1301 exports.global = global; 1301 exports.global = global_;
1302 exports.JsSymbol = JsSymbol; 1302 exports.JsSymbol = JsSymbol;
1303 }); 1303 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/_js_mirrors.js ('k') | lib/runtime/dart/html.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698