From 89b3d920d6ea6ccc45e014b256f52800734fb24a Mon Sep 17 00:00:00 2001 From: John Messerly Date: Fri, 5 Jun 2015 12:12:27 -0700 Subject: [PATCH] fixes #206, add checking for unary ops fixes #207, checking for boolean conversions R=leafp@google.com, vsm@google.com Review URL: https://codereview.chromium.org/1147143007 --- .../lib/runtime/dart/_interceptors.js | 28 +- .../lib/runtime/dart/_internal.js | 70 ++--- .../lib/runtime/dart/_isolate_helper.js | 78 ++--- .../lib/runtime/dart/_js_helper.js | 56 ++-- .../lib/runtime/dart/_native_typed_data.js | 30 +- pkg/dev_compiler/lib/runtime/dart/async.js | 278 +++++++++--------- .../lib/runtime/dart/collection.js | 244 +++++++-------- pkg/dev_compiler/lib/runtime/dart/convert.js | 130 ++++---- pkg/dev_compiler/lib/runtime/dart/core.js | 158 +++++----- pkg/dev_compiler/lib/runtime/dart/math.js | 18 +- pkg/dev_compiler/lib/src/checker/checker.dart | 151 ++++++++-- .../lib/src/codegen/js_codegen.dart | 29 +- .../test/checker/checker_test.dart | 75 +++++ .../test/codegen/expect/opassign.txt | 12 + 14 files changed, 773 insertions(+), 584 deletions(-) diff --git a/pkg/dev_compiler/lib/runtime/dart/_interceptors.js b/pkg/dev_compiler/lib/runtime/dart/_interceptors.js index 9f5cd7eead63..58ebc1e15f63 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_interceptors.js +++ b/pkg/dev_compiler/lib/runtime/dart/_interceptors.js @@ -434,22 +434,22 @@ var math = dart.import(math); compareTo(b) { if (!dart.is(b, core.num)) throw new core.ArgumentError(b); - if (this[dartx['<']](b)) { + if (dart.notNull(this[dartx['<']](b))) { return -1; - } else if (this[dartx['>']](b)) { + } else if (dart.notNull(this[dartx['>']](b))) { return 1; } else if (dart.equals(this, b)) { if (dart.equals(this, 0)) { let bIsNegative = b[dartx.isNegative]; if (this[dartx.isNegative] == bIsNegative) return 0; - if (this[dartx.isNegative]) + if (dart.notNull(this[dartx.isNegative])) return -1; return 1; } return 0; - } else if (this[dartx.isNaN]) { - if (b[dartx.isNaN]) { + } else if (dart.notNull(this[dartx.isNaN])) { + if (dart.notNull(b[dartx.isNaN])) { return 0; } return 1; @@ -479,7 +479,7 @@ var math = dart.import(math); return Math.abs(this); } get sign() { - return this[dartx['>']](0) ? 1 : this[dartx['<']](0) ? -1 : this; + return dart.notNull(this[dartx['>']](0)) ? 1 : dart.notNull(this[dartx['<']](0)) ? -1 : this; } toInt() { if (dart.notNull(this[dartx['>=']](JSNumber._MIN_INT32)) && dart.notNull(this[dartx['<=']](JSNumber._MAX_INT32))) { @@ -509,14 +509,14 @@ var math = dart.import(math); return Math.floor(this); } roundToDouble() { - if (this[dartx['<']](0)) { + if (dart.notNull(this[dartx['<']](0))) { return -Math.round(-this); } else { return Math.round(this); } } truncateToDouble() { - return this[dartx['<']](0) ? this[dartx.ceilToDouble]() : this[dartx.floorToDouble](); + return dart.notNull(this[dartx['<']](0)) ? this[dartx.ceilToDouble]() : this[dartx.floorToDouble](); } clamp(lowerLimit, upperLimit) { if (!dart.is(lowerLimit, core.num)) @@ -541,7 +541,7 @@ var math = dart.import(math); throw new core.RangeError(fractionDigits); } let result = this.toFixed(fractionDigits); - if (dart.notNull(dart.equals(this, 0)) && dart.notNull(this[dartx.isNegative])) + if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `-${result}`; return result; } @@ -558,7 +558,7 @@ var math = dart.import(math); } else { result = this.toExponential(); } - if (dart.notNull(dart.equals(this, 0)) && dart.notNull(this[dartx.isNegative])) + if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `-${result}`; return result; } @@ -568,7 +568,7 @@ var math = dart.import(math); throw new core.RangeError(precision); } let result = this.toPrecision(precision); - if (dart.notNull(dart.equals(this, 0)) && dart.notNull(this[dartx.isNegative])) + if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `-${result}`; return result; } @@ -597,7 +597,7 @@ var math = dart.import(math); return dart.notNull(result) + "0"[dartx['*']](exponent); } toString() { - if (dart.notNull(dart.equals(this, 0)) && 1 / this < 0) { + if (dart.equals(this, 0) && 1 / this < 0) { return '-0.0'; } else { return "" + this; @@ -656,7 +656,7 @@ var math = dart.import(math); } } [_tdivFast](other) { - return this[_isInt32](this) ? this / other | 0 : (this / other)[dartx.toInt](); + return dart.notNull(this[_isInt32](this)) ? this / other | 0 : (this / other)[dartx.toInt](); } [_tdivSlow](other) { if (!dart.is(other, core.num)) @@ -801,7 +801,7 @@ var math = dart.import(math); return dart.notNull(this[dartx['&']](dart.notNull(signMask) - 1)) - dart.notNull(this[dartx['&']](signMask)); } get bitLength() { - let nonneg = this[dartx['<']](0) ? dart.notNull(this[dartx['unary-']]()) - 1 : this; + let nonneg = dart.notNull(this[dartx['<']](0)) ? dart.notNull(this[dartx['unary-']]()) - 1 : this; if (dart.notNull(nonneg) >= 4294967296) { nonneg = (dart.notNull(nonneg) / 4294967296).truncate(); return dart.notNull(JSInt._bitCount(JSInt._spread(nonneg))) + 32; diff --git a/pkg/dev_compiler/lib/runtime/dart/_internal.js b/pkg/dev_compiler/lib/runtime/dart/_internal.js index bd99268493db..e1ddf9fd76a0 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_internal.js +++ b/pkg/dev_compiler/lib/runtime/dart/_internal.js @@ -72,7 +72,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); dart.as(test, dart.functionType(core.bool, [E])); let length = this.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { - if (test(this.elementAt(i))) + if (dart.notNull(test(this.elementAt(i)))) return true; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -87,7 +87,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); let length = this.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let element = this.elementAt(i); - if (test(element)) + if (dart.notNull(test(element))) return element; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -104,7 +104,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); let length = this.length; for (let i = dart.notNull(length) - 1; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) { let element = this.elementAt(i); - if (test(element)) + if (dart.notNull(test(element))) return element; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -121,8 +121,8 @@ var _js_primitives = dart.lazyImport(_js_primitives); let matchFound = false; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let element = this.elementAt(i); - if (test(element)) { - if (matchFound) { + if (dart.notNull(test(element))) { + if (dart.notNull(matchFound)) { throw IterableElementError.tooMany(); } matchFound = true; @@ -132,7 +132,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); throw new core.ConcurrentModificationError(this); } } - if (matchFound) + if (dart.notNull(matchFound)) return match; throw IterableElementError.noElement(); } @@ -218,7 +218,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); toList(opts) { let growable = opts && 'growable' in opts ? opts.growable : true; let result = null; - if (growable) { + if (dart.notNull(growable)) { result = core.List$(E).new(); result.length = this.length; } else { @@ -363,7 +363,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); let length = dart.notNull(end) - dart.notNull(start); if (dart.notNull(length) < 0) length = 0; - let result = growable ? (() => { + let result = dart.notNull(growable) ? (() => { let _ = core.List$(E).new(); _.length = length; return _; @@ -498,7 +498,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); this[_current] = null; } moveNext() { - if (this[_iterator].moveNext()) { + if (dart.notNull(this[_iterator].moveNext())) { this[_current] = this[_f](this[_iterator].current); return true; } @@ -569,8 +569,8 @@ var _js_primitives = dart.lazyImport(_js_primitives); this[_f] = f; } moveNext() { - while (this[_iterator].moveNext()) { - if (this[_f](this[_iterator].current)) { + while (dart.notNull(this[_iterator].moveNext())) { + if (dart.notNull(this[_f](this[_iterator].current))) { return true; } } @@ -628,7 +628,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); return false; while (!dart.notNull(this[_currentExpansion].moveNext())) { this[_current] = null; - if (this[_iterator].moveNext()) { + if (dart.notNull(this[_iterator].moveNext())) { this[_currentExpansion] = null; this[_currentExpansion] = dart.as(dart.dcall(this[_f], this[_iterator].current)[dartx.iterator], core.Iterator$(T)); } else { @@ -756,7 +756,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); this[_isFinished] = false; } moveNext() { - if (this[_isFinished]) + if (dart.notNull(this[_isFinished])) return false; if (!dart.notNull(this[_iterator].moveNext()) || !dart.notNull(dart.dcall(this[_f], this[_iterator].current))) { this[_isFinished] = true; @@ -765,7 +765,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); return true; } get current() { - if (this[_isFinished]) + if (dart.notNull(this[_isFinished])) return null; return this[_iterator].current; } @@ -889,7 +889,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); moveNext() { if (!dart.notNull(this[_hasSkipped])) { this[_hasSkipped] = true; - while (this[_iterator].moveNext()) { + while (dart.notNull(this[_iterator].moveNext())) { if (!dart.notNull(dart.dcall(this[_f], this[_iterator].current))) return true; } @@ -1010,7 +1010,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); } toList(opts) { let growable = opts && 'growable' in opts ? opts.growable : true; - return growable ? dart.list([], E) : core.List$(E).new(0); + return dart.notNull(growable) ? dart.list([], E) : core.List$(E).new(0); } toSet() { return core.Set$(E).new(); @@ -1112,7 +1112,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); static any(iterable, f) { dart.as(f, dart.functionType(core.bool, [dart.bottom])); for (let e of iterable) { - if (dart.dcall(f, e)) + if (dart.notNull(dart.dcall(f, e))) return true; } return false; @@ -1131,7 +1131,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); if (!dart.notNull(iterator.moveNext())) throw IterableElementError.noElement(); let value = iterator.current; - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { value = dart.dcall(combine, value, iterator.current); } return value; @@ -1181,7 +1181,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); let result = null; do { result = it.current; - } while (it.moveNext()); + } while (dart.notNull(it.moveNext())); return result; } static single(iterable) { @@ -1189,7 +1189,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); if (!dart.notNull(it.moveNext())) throw IterableElementError.noElement(); let result = it.current; - if (it.moveNext()) + if (dart.notNull(it.moveNext())) throw IterableElementError.tooMany(); return result; } @@ -1197,7 +1197,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); dart.as(test, dart.functionType(core.bool, [dart.bottom])); dart.as(orElse, dart.functionType(core.Object, [])); for (let element of iterable) { - if (dart.dcall(test, element)) + if (dart.notNull(dart.dcall(test, element))) return element; } if (orElse != null) @@ -1210,12 +1210,12 @@ var _js_primitives = dart.lazyImport(_js_primitives); let result = null; let foundMatching = false; for (let element of iterable) { - if (dart.dcall(test, element)) { + if (dart.notNull(dart.dcall(test, element))) { result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; if (orElse != null) return orElse(); @@ -1226,7 +1226,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); dart.as(orElse, dart.functionType(core.Object, [])); for (let i = dart.notNull(list.length) - 1; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) { let element = list[dartx.get](i); - if (dart.dcall(test, element)) + if (dart.notNull(dart.dcall(test, element))) return element; } if (orElse != null) @@ -1238,15 +1238,15 @@ var _js_primitives = dart.lazyImport(_js_primitives); let result = null; let foundMatching = false; for (let element of iterable) { - if (dart.dcall(test, element)) { - if (foundMatching) { + if (dart.notNull(dart.dcall(test, element))) { + if (dart.notNull(foundMatching)) { throw IterableElementError.tooMany(); } result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; throw IterableElementError.noElement(); } @@ -1272,12 +1272,12 @@ var _js_primitives = dart.lazyImport(_js_primitives); static joinList(list, separator) { if (separator === void 0) separator = null; - if (list[dartx.isEmpty]) + if (dart.notNull(list[dartx.isEmpty])) return ""; if (list.length == 1) return `${list[dartx.get](0)}`; let buffer = new core.StringBuffer(); - if (separator[dartx.isEmpty]) { + if (dart.notNull(separator[dartx.isEmpty])) { for (let i = 0; dart.notNull(i) < dart.notNull(list.length); i = dart.notNull(i) + 1) { buffer.write(list[dartx.get](i)); } @@ -1455,7 +1455,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); larger = set; } for (let element of smaller) { - if (larger.contains(element)) { + if (dart.notNull(larger.contains(element))) { result.add(element); } } @@ -1797,7 +1797,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); this[_values] = values; } get(key) { - return this.containsKey(key) ? this[_values][dartx.get](dart.as(key, core.int)) : null; + return dart.notNull(this.containsKey(key)) ? this[_values][dartx.get](dart.as(key, core.int)) : null; } get length() { return this[_values].length; @@ -1950,7 +1950,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); } } static areEqual(a, b) { - if (core.identical(a, b)) + if (dart.notNull(core.identical(a, b))) return true; if (!dart.is(b, core.List)) return false; @@ -2115,7 +2115,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); let less = dart.notNull(left) + 1; let great = dart.notNull(right) - 1; let pivots_are_equal = dart.dcall(compare, pivot1, pivot2) == 0; - if (pivots_are_equal) { + if (dart.notNull(pivots_are_equal)) { let pivot = pivot1; for (let k = less; dart.notNull(k) <= dart.notNull(great); k = dart.notNull(k) + 1) { let ak = a[dartx.get](k); @@ -2214,7 +2214,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); a[dartx.set](dart.notNull(great) + 1, pivot2); Sort._doSort(a, left, dart.notNull(less) - 2, compare); Sort._doSort(a, dart.notNull(great) + 2, right, compare); - if (pivots_are_equal) { + if (dart.notNull(pivots_are_equal)) { return; } if (dart.notNull(less) < dart.notNull(index1) && dart.notNull(great) > dart.notNull(index5)) { @@ -2315,7 +2315,7 @@ var _js_primitives = dart.lazyImport(_js_primitives); static validatePublicSymbol(name) { if (dart.notNull(name[dartx.isEmpty]) || dart.notNull(Symbol.publicSymbolPattern.hasMatch(name))) return name; - if (name[dartx.startsWith]('_')) { + if (dart.notNull(name[dartx.startsWith]('_'))) { throw new core.ArgumentError(`"${name}" is a private identifier`); } throw new core.ArgumentError(`"${name}" is not a valid (qualified) symbol name`); diff --git a/pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js b/pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js index 87931301b9d0..42def362a172 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js +++ b/pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js @@ -37,7 +37,7 @@ var async = dart.import(async); this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); } serialize(x) { - if (this.isPrimitive(x)) + if (dart.notNull(this.isPrimitive(x))) return this.serializePrimitive(x); let serializationId = this.serializedObjectIds.get(x); if (serializationId != null) @@ -78,7 +78,7 @@ var async = dart.import(async); return ["ref", serializationId]; } isPrimitive(x) { - return dart.notNull(x == null) || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; + return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; } serializePrimitive(primitive) { return primitive; @@ -134,13 +134,13 @@ var async = dart.import(async); return ['js-object', keys, values]; } serializeWorkerSendPort(x) { - if (this[_serializeSendPorts]) { + if (dart.notNull(this[_serializeSendPorts])) { return ['sendport', x[_workerId], x[_isolateId], x[_receivePortId]]; } return ['raw sendport', x]; } serializeJsSendPort(x) { - if (this[_serializeSendPorts]) { + if (dart.notNull(this[_serializeSendPorts])) { let workerId = exports._globalState.currentManagerId; return ['sendport', workerId, x[_isolateId], x[_receivePort][_id]]; } @@ -194,7 +194,7 @@ var async = dart.import(async); this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); } deserialize(x) { - if (this.isPrimitive(x)) + if (dart.notNull(this.isPrimitive(x))) return this.deserializePrimitive(x); if (!dart.is(x, _interceptors.JSArray)) throw new core.ArgumentError(`Bad serialized message: ${x}`); @@ -258,7 +258,7 @@ var async = dart.import(async); } } isPrimitive(x) { - return dart.notNull(x == null) || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; + return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; } deserializePrimitive(x) { return x; @@ -435,7 +435,7 @@ var async = dart.import(async); throw new core.ArgumentError(`Arguments to main must be a List: ${args}`); } exports._globalState = new _Manager(dart.as(entry, core.Function)); - if (exports._globalState.isWorker) + if (dart.notNull(exports._globalState.isWorker)) return; let rootContext = new _IsolateContext(); exports._globalState.rootContext = rootContext; @@ -486,7 +486,7 @@ var async = dart.import(async); this.topEventLoop = new _EventLoop(); this.isolates = core.Map$(core.int, _IsolateContext).new(); this.managers = core.Map$(core.int, core.Object).new(); - if (this.isWorker) { + if (dart.notNull(this.isWorker)) { this.mainManager = new _MainManagerStub(); this[_nativeInitWorkerMessageHandler](); } @@ -576,8 +576,8 @@ var async = dart.import(async); if (!dart.notNull(this.isPaused)) return; this.pauseTokens.remove(resume); - if (this.pauseTokens.isEmpty) { - while (this.delayedEvents[dartx.isNotEmpty]) { + if (dart.notNull(this.pauseTokens.isEmpty)) { + while (dart.notNull(this.delayedEvents[dartx.isNotEmpty])) { let event = this.delayedEvents[dartx.removeLast](); exports._globalState.topEventLoop.prequeue(event); } @@ -589,7 +589,7 @@ var async = dart.import(async); if (this.doneHandlers == null) { this.doneHandlers = []; } - if (dart.dsend(this.doneHandlers, 'contains', responsePort)) + if (dart.notNull(dart.as(dart.dsend(this.doneHandlers, 'contains', responsePort), core.bool))) return; dart.dsend(this.doneHandlers, 'add', responsePort); } @@ -646,7 +646,7 @@ var async = dart.import(async); this.errorPorts.remove(port); } handleUncaughtError(error, stackTrace) { - if (this.errorPorts.isEmpty) { + if (dart.notNull(this.errorPorts.isEmpty)) { if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(this, exports._globalState.rootContext))) { return; } @@ -676,9 +676,9 @@ var async = dart.import(async); } catch (e) { let s = dart.stackTrace(e); this.handleUncaughtError(e, s); - if (this.errorsAreFatal) { + if (dart.notNull(this.errorsAreFatal)) { this.kill(); - if (core.identical(this, exports._globalState.rootContext)) { + if (dart.notNull(core.identical(this, exports._globalState.rootContext))) { throw e; } } @@ -689,7 +689,7 @@ var async = dart.import(async); if (old != null) old[_setGlobals](); if (this[_scheduledControlEvents] != null) { - while (dart.dload(this[_scheduledControlEvents], 'isNotEmpty')) { + while (dart.notNull(dart.as(dart.dload(this[_scheduledControlEvents], 'isNotEmpty'), core.bool))) { dart.dcall(dart.dsend(this[_scheduledControlEvents], 'removeFirst')); } } @@ -753,7 +753,7 @@ var async = dart.import(async); return this.ports.get(portId); } [_addRegistration](portId, port) { - if (this.ports.containsKey(portId)) { + if (dart.notNull(this.ports.containsKey(portId))) { throw core.Exception.new("Registry: ports must be registered only once."); } this.ports.set(portId, port); @@ -836,12 +836,12 @@ var async = dart.import(async); this.events.addFirst(event); } dequeue() { - if (this.events.isEmpty) + if (dart.notNull(this.events.isEmpty)) return null; return this.events.removeFirst(); } checkOpenReceivePortsFromCommandLine() { - if (dart.notNull(exports._globalState.rootContext != null) && dart.notNull(exports._globalState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNull(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.rootContext.ports.isEmpty)) { + if (exports._globalState.rootContext != null && dart.notNull(exports._globalState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNull(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.rootContext.ports.isEmpty)) { throw core.Exception.new("Program exited with open ReceivePorts."); } } @@ -865,7 +865,7 @@ var async = dart.import(async); dart.fn(next); next(); } else { - while (this.runIteration()) { + while (dart.notNull(this.runIteration())) { } } } @@ -902,7 +902,7 @@ var async = dart.import(async); this.message = message; } process() { - if (this.isolate.isPaused) { + if (dart.notNull(this.isolate.isPaused)) { this.isolate.delayedEvents[dartx.add](this); return; } @@ -943,11 +943,11 @@ var async = dart.import(async); if (currentScript != null) { return String(currentScript.src); } - if (_js_helper.Primitives.isD8) + if (dart.notNull(_js_helper.Primitives.isD8)) return IsolateNatives.computeThisScriptD8(); - if (_js_helper.Primitives.isJsshell) + if (dart.notNull(_js_helper.Primitives.isJsshell)) return IsolateNatives.computeThisScriptJsshell(); - if (exports._globalState.isWorker) + if (dart.notNull(exports._globalState.isWorker)) return IsolateNatives.computeThisScriptFromTrace(); return null; } @@ -1035,7 +1035,7 @@ var async = dart.import(async); } case 'print': { - if (exports._globalState.isWorker) { + if (dart.notNull(exports._globalState.isWorker)) { exports._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'print', msg: msg}))); } else { core.print(dart.dindex(msg, 'msg')); @@ -1057,7 +1057,7 @@ var async = dart.import(async); }, core.Object, [core.String])}); } static _log(msg) { - if (exports._globalState.isWorker) { + if (dart.notNull(exports._globalState.isWorker)) { exports._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'log', msg: msg}))); } else { try { @@ -1123,7 +1123,7 @@ var async = dart.import(async); static _startWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError) { if (args != null) args = core.List$(core.String).from(args); - if (exports._globalState.isWorker) { + if (dart.notNull(exports._globalState.isWorker)) { exports._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'spawn-worker', functionName: functionName, args: args, msg: message, uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort}))); } else { IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError); @@ -1162,7 +1162,7 @@ var async = dart.import(async); } }; dart.fn(runStartFunction, dart.void, []); - if (startPaused) { + if (dart.notNull(startPaused)) { context.addPause(context.pauseCapability, context.pauseCapability); exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'start isolate'); } else { @@ -1246,7 +1246,7 @@ var async = dart.import(async); this[_isolateId] = isolateId; } [_checkReplyTo](replyTo) { - if (dart.notNull(replyTo != null) && !dart.is(replyTo, _NativeJsSendPort) && !dart.is(replyTo, _WorkerSendPort)) { + if (replyTo != null && !dart.is(replyTo, _NativeJsSendPort) && !dart.is(replyTo, _WorkerSendPort)) { throw core.Exception.new("SendPort.send: Illegal replyTo port type"); } } @@ -1267,7 +1267,7 @@ var async = dart.import(async); let isolate = exports._globalState.isolates.get(this[_isolateId]); if (isolate == null) return; - if (this[_receivePort][_isClosed]) + if (dart.notNull(this[_receivePort][_isClosed])) return; let msg = _clone(message); if (dart.equals(isolate.controlPort, this[_receivePort])) { @@ -1281,7 +1281,7 @@ var async = dart.import(async); }), `receive ${message}`); } ['=='](other) { - return dart.is(other, _NativeJsSendPort) && dart.notNull(dart.equals(this[_receivePort], dart.dload(other, _receivePort))); + return dart.is(other, _NativeJsSendPort) && dart.equals(this[_receivePort], dart.dload(other, _receivePort)); } get hashCode() { return this[_receivePort][_id]; @@ -1300,7 +1300,7 @@ var async = dart.import(async); } send(message) { let workerMessage = _serializeMessage(dart.map({command: 'message', port: this, msg: message})); - if (exports._globalState.isWorker) { + if (dart.notNull(exports._globalState.isWorker)) { exports._globalState.mainManager.postMessage(workerMessage); } else { let manager = exports._globalState.managers.get(this[_workerId]); @@ -1356,14 +1356,14 @@ var async = dart.import(async); this[_handler] = null; } close() { - if (this[_isClosed]) + if (dart.notNull(this[_isClosed])) return; this[_isClosed] = true; this[_handler] = null; exports._globalState.currentContext.unregister(this[_id]); } [_add](dataEvent) { - if (this[_isClosed]) + if (dart.notNull(this[_isClosed])) return; dart.dcall(this[_handler], dataEvent); } @@ -1448,7 +1448,7 @@ var async = dart.import(async); this[_handle] = 1; exports._globalState.topEventLoop.enqueue(exports._globalState.currentContext, internalCallback, 'timer'); this[_inEventLoop] = true; - } else if (hasTimer()) { + } else if (dart.notNull(hasTimer())) { let internalCallback = () => { this[_handle] = null; leaveJsAsync(); @@ -1466,7 +1466,7 @@ var async = dart.import(async); this[_once] = false; this[_inEventLoop] = false; this[_handle] = null; - if (hasTimer()) { + if (dart.notNull(hasTimer())) { enterJsAsync(); this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.fn(() => { callback(this); @@ -1476,14 +1476,14 @@ var async = dart.import(async); } } cancel() { - if (hasTimer()) { - if (this[_inEventLoop]) { + if (dart.notNull(hasTimer())) { + if (dart.notNull(this[_inEventLoop])) { throw new core.UnsupportedError("Timer in event loop cannot be canceled."); } if (this[_handle] == null) return; leaveJsAsync(); - if (this[_once]) { + if (dart.notNull(this[_once])) { self.clearTimeout(this[_handle]); } else { self.clearInterval(this[_handle]); @@ -1529,7 +1529,7 @@ var async = dart.import(async); return hash; } ['=='](other) { - if (core.identical(other, this)) + if (dart.notNull(core.identical(other, this))) return true; if (dart.is(other, CapabilityImpl)) { return core.identical(this[_id], other[_id]); diff --git a/pkg/dev_compiler/lib/runtime/dart/_js_helper.js b/pkg/dev_compiler/lib/runtime/dart/_js_helper.js index 9d0e6d65fc13..528fdd52d696 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_js_helper.js +++ b/pkg/dev_compiler/lib/runtime/dart/_js_helper.js @@ -111,9 +111,9 @@ var _foreign_helper = dart.import(_foreign_helper); } static makeNative(source, multiLine, caseSensitive, global) { checkString(source); - let m = multiLine ? 'm' : ''; - let i = caseSensitive ? '' : 'i'; - let g = global ? 'g' : ''; + let m = dart.notNull(multiLine) ? 'm' : ''; + let i = dart.notNull(caseSensitive) ? '' : 'i'; + let g = dart.notNull(global) ? 'g' : ''; let regexp = function() { try { return new RegExp(source, m + i + g); @@ -501,7 +501,7 @@ var _foreign_helper = dart.import(_foreign_helper); startIndex = 0; if (typeof from == 'string') { let index = dart.dsend(receiver, 'indexOf', from, startIndex); - if (dart.dsend(index, '<', 0)) + if (dart.notNull(dart.as(dart.dsend(index, '<', 0), core.bool))) return receiver; return `${dart.dsend(receiver, 'substring', 0, index)}${to}` + `${dart.dsend(receiver, 'substring', dart.dsend(index, '+', dart.dload(from, 'length')))}`; } else if (dart.is(from, JSSyntaxRegExp)) { @@ -586,10 +586,10 @@ var _foreign_helper = dart.import(_foreign_helper); throw new core.RangeError(`Radix ${radix} not in range 2..36`); } if (match != null) { - if (radix == 10 && dart.notNull(dart.dindex(match, decimalIndex) != null)) { + if (radix == 10 && dart.dindex(match, decimalIndex) != null) { return parseInt(source, 10); } - if (dart.notNull(radix) < 10 || dart.notNull(dart.dindex(match, decimalIndex) == null)) { + if (dart.notNull(radix) < 10 || dart.dindex(match, decimalIndex) == null) { let maxCharCode = null; if (dart.notNull(radix) <= 10) { maxCharCode = 48 + dart.notNull(radix) - 1; @@ -618,7 +618,7 @@ var _foreign_helper = dart.import(_foreign_helper); return handleError(source); } let result = parseFloat(source); - if (result[dartx.isNaN]) { + if (dart.notNull(result[dartx.isNaN])) { let trimmed = source[dartx.trim](); if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') { return result; @@ -687,9 +687,9 @@ var _foreign_helper = dart.import(_foreign_helper); for (let i of dart.as(codePoints, core.Iterable)) { if (!(typeof i == 'number')) throw new core.ArgumentError(i); - if (dart.dsend(i, '<=', 65535)) { + if (dart.notNull(dart.as(dart.dsend(i, '<=', 65535), core.bool))) { a[dartx.add](dart.as(i, core.int)); - } else if (dart.dsend(i, '<=', 1114111)) { + } else if (dart.notNull(dart.as(dart.dsend(i, '<=', 1114111), core.bool))) { a[dartx.add]((55296)[dartx['+']](dart.as(dart.dsend(dart.dsend(dart.dsend(i, '-', 65536), '>>', 10), '&', 1023), core.num))); a[dartx.add]((56320)[dartx['+']](dart.as(dart.dsend(i, '&', 1023), core.num))); } else { @@ -702,19 +702,19 @@ var _foreign_helper = dart.import(_foreign_helper); for (let i of dart.as(charCodes, core.Iterable)) { if (!(typeof i == 'number')) throw new core.ArgumentError(i); - if (dart.dsend(i, '<', 0)) + if (dart.notNull(dart.as(dart.dsend(i, '<', 0), core.bool))) throw new core.ArgumentError(i); - if (dart.dsend(i, '>', 65535)) + if (dart.notNull(dart.as(dart.dsend(i, '>', 65535), core.bool))) return Primitives.stringFromCodePoints(charCodes); } return Primitives._fromCharCodeApply(dart.as(charCodes, core.List$(core.int))); } static stringFromCharCode(charCode) { if (0 <= dart.notNull(dart.as(charCode, core.num))) { - if (dart.dsend(charCode, '<=', 65535)) { + if (dart.notNull(dart.as(dart.dsend(charCode, '<=', 65535), core.bool))) { return String.fromCharCode(charCode); } - if (dart.dsend(charCode, '<=', 1114111)) { + if (dart.notNull(dart.as(dart.dsend(charCode, '<=', 1114111), core.bool))) { let bits = dart.dsend(charCode, '-', 65536); let low = (56320)[dartx['|']](dart.as(dart.dsend(bits, '&', 1023), core.int)); let high = (55296)[dartx['|']](dart.as(dart.dsend(bits, '>>', 10), core.int)); @@ -757,7 +757,7 @@ var _foreign_helper = dart.import(_foreign_helper); checkBool(isUtc); let jsMonth = dart.dsend(month, '-', 1); let value = null; - if (isUtc) { + if (dart.notNull(dart.as(isUtc, core.bool))) { value = Date.UTC(years, jsMonth, day, hours, minutes, seconds, milliseconds); } else { value = new Date(years, jsMonth, day, hours, minutes, seconds, milliseconds).valueOf(); @@ -771,7 +771,7 @@ var _foreign_helper = dart.import(_foreign_helper); } static patchUpY2K(value, years, isUtc) { let date = new Date(value); - if (isUtc) { + if (dart.notNull(dart.as(isUtc, core.bool))) { date.setUTCFullYear(years); } else { date.setFullYear(years); @@ -785,46 +785,46 @@ var _foreign_helper = dart.import(_foreign_helper); return receiver.date; } static getYear(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCFullYear() + 0 : Primitives.lazyAsJsDate(receiver).getFullYear() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCFullYear() + 0 : Primitives.lazyAsJsDate(receiver).getFullYear() + 0; } static getMonth(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCMonth() + 1 : Primitives.lazyAsJsDate(receiver).getMonth() + 1; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCMonth() + 1 : Primitives.lazyAsJsDate(receiver).getMonth() + 1; } static getDay(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCDate() + 0 : Primitives.lazyAsJsDate(receiver).getDate() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCDate() + 0 : Primitives.lazyAsJsDate(receiver).getDate() + 0; } static getHours(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCHours() + 0 : Primitives.lazyAsJsDate(receiver).getHours() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCHours() + 0 : Primitives.lazyAsJsDate(receiver).getHours() + 0; } static getMinutes(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCMinutes() + 0 : Primitives.lazyAsJsDate(receiver).getMinutes() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCMinutes() + 0 : Primitives.lazyAsJsDate(receiver).getMinutes() + 0; } static getSeconds(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCSeconds() + 0 : Primitives.lazyAsJsDate(receiver).getSeconds() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCSeconds() + 0 : Primitives.lazyAsJsDate(receiver).getSeconds() + 0; } static getMilliseconds(receiver) { - return dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCMilliseconds() + 0 : Primitives.lazyAsJsDate(receiver).getMilliseconds() + 0; + return dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCMilliseconds() + 0 : Primitives.lazyAsJsDate(receiver).getMilliseconds() + 0; } static getWeekday(receiver) { - let weekday = dart.dload(receiver, 'isUtc') ? Primitives.lazyAsJsDate(receiver).getUTCDay() + 0 : Primitives.lazyAsJsDate(receiver).getDay() + 0; + let weekday = dart.notNull(dart.as(dart.dload(receiver, 'isUtc'), core.bool)) ? Primitives.lazyAsJsDate(receiver).getUTCDay() + 0 : Primitives.lazyAsJsDate(receiver).getDay() + 0; return (dart.notNull(weekday) + 6) % 7 + 1; } static valueFromDateString(str) { if (!(typeof str == 'string')) throw new core.ArgumentError(str); let value = Date.parse(str); - if (value[dartx.isNaN]) + if (dart.notNull(value[dartx.isNaN])) throw new core.ArgumentError(str); return value; } static getProperty(object, key) { - if (dart.notNull(object == null) || typeof object == 'boolean' || dart.is(object, core.num) || typeof object == 'string') { + if (object == null || typeof object == 'boolean' || dart.is(object, core.num) || typeof object == 'string') { throw new core.ArgumentError(object); } return object[key]; } static setProperty(object, key, value) { - if (dart.notNull(object == null) || typeof object == 'boolean' || dart.is(object, core.num) || typeof object == 'string') { + if (object == null || typeof object == 'boolean' || dart.is(object, core.num) || typeof object == 'string') { throw new core.ArgumentError(object); } object[key] = value; @@ -971,7 +971,7 @@ var _foreign_helper = dart.import(_foreign_helper); super.Error(); } toString() { - return this[_message][dartx.isEmpty] ? 'Error' : `Error: ${this[_message]}`; + return dart.notNull(this[_message][dartx.isEmpty]) ? 'Error' : `Error: ${this[_message]}`; } } dart.setSignature(UnknownJsTypeError, { @@ -1003,7 +1003,7 @@ var _foreign_helper = dart.import(_foreign_helper); constructors: () => ({_StackTrace: [_StackTrace, [core.Object]]}) }); function objectHashCode(object) { - if (dart.notNull(object == null) || typeof object != 'object') { + if (object == null || typeof object != 'object') { return dart.hashCode(object); } else { return Primitives.objectHashCode(object); diff --git a/pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js b/pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js index cfca00015923..b07e3687f4f3 100644 --- a/pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js +++ b/pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js @@ -522,7 +522,7 @@ var math = dart.import(math); if (!(typeof offsetInBytes == 'number')) { throw new core.ArgumentError(`Invalid view offsetInBytes ${offsetInBytes}`); } - if (dart.notNull(length != null) && !(typeof length == 'number')) { + if (length != null && !(typeof length == 'number')) { throw new core.ArgumentError(`Invalid view length ${length}`); } } @@ -1347,42 +1347,42 @@ var math = dart.import(math); let _cy = dart.notNull(this.y) < dart.notNull(other.y); let _cz = dart.notNull(this.z) < dart.notNull(other.z); let _cw = dart.notNull(this.w) < dart.notNull(other.w); - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } lessThanOrEqual(other) { let _cx = dart.notNull(this.x) <= dart.notNull(other.x); let _cy = dart.notNull(this.y) <= dart.notNull(other.y); let _cz = dart.notNull(this.z) <= dart.notNull(other.z); let _cw = dart.notNull(this.w) <= dart.notNull(other.w); - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } greaterThan(other) { let _cx = dart.notNull(this.x) > dart.notNull(other.x); let _cy = dart.notNull(this.y) > dart.notNull(other.y); let _cz = dart.notNull(this.z) > dart.notNull(other.z); let _cw = dart.notNull(this.w) > dart.notNull(other.w); - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } greaterThanOrEqual(other) { let _cx = dart.notNull(this.x) >= dart.notNull(other.x); let _cy = dart.notNull(this.y) >= dart.notNull(other.y); let _cz = dart.notNull(this.z) >= dart.notNull(other.z); let _cw = dart.notNull(this.w) >= dart.notNull(other.w); - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } equal(other) { let _cx = this.x == other.x; let _cy = this.y == other.y; let _cz = this.z == other.z; let _cw = this.w == other.w; - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } notEqual(other) { let _cx = this.x != other.x; let _cy = this.y != other.y; let _cz = this.z != other.z; let _cw = this.w != other.w; - return new NativeInt32x4._truncated(_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0); + return new NativeInt32x4._truncated(dart.notNull(_cx) ? -1 : 0, dart.notNull(_cy) ? -1 : 0, dart.notNull(_cz) ? -1 : 0, dart.notNull(_cw) ? -1 : 0); } scale(s) { let _x = dart.notNull(s) * dart.notNull(this.x); @@ -1588,10 +1588,10 @@ var math = dart.import(math); throw new core.ArgumentError(w); } bool(x, y, z, w) { - this.x = x ? -1 : 0; - this.y = y ? -1 : 0; - this.z = z ? -1 : 0; - this.w = w ? -1 : 0; + this.x = dart.notNull(x) ? -1 : 0; + this.y = dart.notNull(y) ? -1 : 0; + this.z = dart.notNull(z) ? -1 : 0; + this.w = dart.notNull(w) ? -1 : 0; } static fromFloat32x4Bits(f) { let floatList = NativeFloat32x4._list; @@ -1697,19 +1697,19 @@ var math = dart.import(math); return this.w != 0; } withFlagX(flagX) { - let _x = flagX ? -1 : 0; + let _x = dart.notNull(flagX) ? -1 : 0; return new NativeInt32x4._truncated(_x, this.y, this.z, this.w); } withFlagY(flagY) { - let _y = flagY ? -1 : 0; + let _y = dart.notNull(flagY) ? -1 : 0; return new NativeInt32x4._truncated(this.x, _y, this.z, this.w); } withFlagZ(flagZ) { - let _z = flagZ ? -1 : 0; + let _z = dart.notNull(flagZ) ? -1 : 0; return new NativeInt32x4._truncated(this.x, this.y, _z, this.w); } withFlagW(flagW) { - let _w = flagW ? -1 : 0; + let _w = dart.notNull(flagW) ? -1 : 0; return new NativeInt32x4._truncated(this.x, this.y, this.z, _w); } select(trueValue, falseValue) { diff --git a/pkg/dev_compiler/lib/runtime/dart/async.js b/pkg/dev_compiler/lib/runtime/dart/async.js index f6198151b0e9..8a226ac94581 100644 --- a/pkg/dev_compiler/lib/runtime/dart/async.js +++ b/pkg/dev_compiler/lib/runtime/dart/async.js @@ -184,7 +184,7 @@ var collection = dart.import(collection); }, core.Object, [T]), {onError: dart.as(addError, core.Function), onDone: dart.bind(controller, 'close')}); }; dart.fn(onListen, dart.void, []); - if (this.isBroadcast) { + if (dart.notNull(this.isBroadcast)) { controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => { subscription.cancel(); }), sync: true}); @@ -224,7 +224,7 @@ var collection = dart.import(collection); }, core.Object, [T]), {onError: dart.as(eventSink[_addError], core.Function), onDone: dart.bind(controller, 'close')}); }; dart.fn(onListen, dart.void, []); - if (this.isBroadcast) { + if (dart.notNull(this.isBroadcast)) { controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => { subscription.cancel(); }), sync: true}); @@ -264,7 +264,7 @@ var collection = dart.import(collection); let subscription = null; subscription = this.listen(dart.fn(element => { dart.as(element, T); - if (seenFirst) { + if (dart.notNull(seenFirst)) { _runUserCode(dart.fn(() => combine(value, element), T, []), dart.fn(newValue => { dart.as(newValue, T); value = newValue; @@ -338,7 +338,7 @@ var collection = dart.import(collection); subscription = this.listen(dart.fn(element => { dart.as(element, T); _runUserCode(dart.fn(() => dart.equals(element, needle), core.bool, []), dart.fn(isMatch => { - if (isMatch) { + if (dart.notNull(isMatch)) { _cancelAndValue(subscription, future, true); } }, core.Object, [core.bool]), dart.as(_cancelAndErrorClosure(subscription, future), dart.functionType(core.Object, [dart.bottom, core.StackTrace]))); @@ -383,7 +383,7 @@ var collection = dart.import(collection); subscription = this.listen(dart.fn(element => { dart.as(element, T); _runUserCode(dart.fn(() => test(element), core.bool, []), dart.fn(isMatch => { - if (isMatch) { + if (dart.notNull(isMatch)) { _cancelAndValue(subscription, future, true); } }, core.Object, [core.bool]), dart.as(_cancelAndErrorClosure(subscription, future), dart.functionType(core.Object, [dart.bottom, core.StackTrace]))); @@ -486,7 +486,7 @@ var collection = dart.import(collection); foundResult = true; result = value; }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => { - if (foundResult) { + if (dart.notNull(foundResult)) { future[_complete](result); return; } @@ -507,7 +507,7 @@ var collection = dart.import(collection); let subscription = null; subscription = this.listen(dart.fn(value => { dart.as(value, T); - if (foundResult) { + if (dart.notNull(foundResult)) { try { throw _internal.IterableElementError.tooMany(); } catch (e) { @@ -520,7 +520,7 @@ var collection = dart.import(collection); foundResult = true; result = value; }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => { - if (foundResult) { + if (dart.notNull(foundResult)) { future[_complete](result); return; } @@ -543,7 +543,7 @@ var collection = dart.import(collection); subscription = this.listen(dart.fn(value => { dart.as(value, T); _runUserCode(dart.fn(() => test(value), core.bool, []), dart.fn(isMatch => { - if (isMatch) { + if (dart.notNull(isMatch)) { _cancelAndValue(subscription, future, value); } }, core.Object, [core.bool]), dart.as(_cancelAndErrorClosure(subscription, future), dart.functionType(core.Object, [dart.bottom, core.StackTrace]))); @@ -573,13 +573,13 @@ var collection = dart.import(collection); subscription = this.listen(dart.fn(value => { dart.as(value, T); _runUserCode(dart.fn(() => true == test(value), core.bool, []), dart.fn(isMatch => { - if (isMatch) { + if (dart.notNull(isMatch)) { foundResult = true; result = value; } }, core.Object, [core.bool]), dart.as(_cancelAndErrorClosure(subscription, future), dart.functionType(core.Object, [dart.bottom, core.StackTrace]))); }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => { - if (foundResult) { + if (dart.notNull(foundResult)) { future[_complete](result); return; } @@ -606,8 +606,8 @@ var collection = dart.import(collection); subscription = this.listen(dart.fn(value => { dart.as(value, T); _runUserCode(dart.fn(() => true == test(value), core.bool, []), dart.fn(isMatch => { - if (isMatch) { - if (foundResult) { + if (dart.notNull(isMatch)) { + if (dart.notNull(foundResult)) { try { throw _internal.IterableElementError.tooMany(); } catch (e) { @@ -622,7 +622,7 @@ var collection = dart.import(collection); } }, core.Object, [core.bool]), dart.as(_cancelAndErrorClosure(subscription, future), dart.functionType(core.Object, [dart.bottom, core.StackTrace]))); }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => { - if (foundResult) { + if (dart.notNull(foundResult)) { future[_complete](result); return; } @@ -708,7 +708,7 @@ var collection = dart.import(collection); return result; }; dart.fn(onCancel, Future, []); - controller = this.isBroadcast ? new _SyncBroadcastStreamController(onListen, onCancel) : new _SyncStreamController(onListen, dart.fn(() => { + controller = dart.notNull(this.isBroadcast) ? new _SyncBroadcastStreamController(onListen, onCancel) : new _SyncStreamController(onListen, dart.fn(() => { timer.cancel(); subscription.pause(); }), dart.fn(() => { @@ -812,7 +812,7 @@ var collection = dart.import(collection); return dart.notNull(dart.hashCode(this[_controller])) ^ 892482866; } ['=='](other) { - if (core.identical(this, other)) + if (dart.notNull(core.identical(this, other))) return true; if (!dart.is(other, _ControllerStream$())) return false; @@ -889,7 +889,7 @@ var collection = dart.import(collection); class _BufferingStreamSubscription extends core.Object { _BufferingStreamSubscription(onData, onError, onDone, cancelOnError) { this[_zone] = Zone.current; - this[_state] = cancelOnError ? _BufferingStreamSubscription$()._STATE_CANCEL_ON_ERROR : 0; + this[_state] = dart.notNull(cancelOnError) ? _BufferingStreamSubscription$()._STATE_CANCEL_ON_ERROR : 0; this[_onData] = null; this[_onError] = null; this[_onDone] = null; @@ -935,22 +935,22 @@ var collection = dart.import(collection); pause(resumeSignal) { if (resumeSignal === void 0) resumeSignal = null; - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return; let wasPaused = this[_isPaused]; let wasInputPaused = this[_isInputPaused]; this[_state] = dart.notNull(this[_state]) + dart.notNull(_BufferingStreamSubscription$()._STATE_PAUSE_COUNT) | dart.notNull(_BufferingStreamSubscription$()._STATE_INPUT_PAUSED); if (resumeSignal != null) resumeSignal.whenComplete(dart.bind(this, 'resume')); - if (!dart.notNull(wasPaused) && dart.notNull(this[_pending] != null)) + if (!dart.notNull(wasPaused) && this[_pending] != null) this[_pending].cancelSchedule(); if (!dart.notNull(wasInputPaused) && !dart.notNull(this[_inCallback])) this[_guardCallback](dart.bind(this, _onPause)); } resume() { - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return; - if (this[_isPaused]) { + if (dart.notNull(this[_isPaused])) { this[_decrementPauseCount](); if (!dart.notNull(this[_isPaused])) { if (dart.notNull(this[_hasPending]) && !dart.notNull(this[_pending].isEmpty)) { @@ -966,7 +966,7 @@ var collection = dart.import(collection); } cancel() { this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStreamSubscription$()._STATE_WAIT_FOR_CANCEL); - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return this[_cancelFuture]; this[_cancel](); return this[_cancelFuture]; @@ -1009,7 +1009,7 @@ var collection = dart.import(collection); return dart.notNull(this[_state]) < dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK); } get [_mayResumeInput]() { - return !dart.notNull(this[_isPaused]) && (dart.notNull(this[_pending] == null) || dart.notNull(this[_pending].isEmpty)); + return !dart.notNull(this[_isPaused]) && (this[_pending] == null || dart.notNull(this[_pending].isEmpty)); } get [_cancelOnError]() { return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscription$()._STATE_CANCEL_ON_ERROR)) != 0; @@ -1019,7 +1019,7 @@ var collection = dart.import(collection); } [_cancel]() { this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_CANCELED); - if (this[_hasPending]) { + if (dart.notNull(this[_hasPending])) { this[_pending].cancelSchedule(); } if (!dart.notNull(this[_inCallback])) @@ -1036,18 +1036,18 @@ var collection = dart.import(collection); [_add](data) { dart.as(data, T); dart.assert(!dart.notNull(this[_isClosed])); - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return; - if (this[_canFire]) { + if (dart.notNull(this[_canFire])) { this[_sendData](data); } else { this[_addPending](new _DelayedData(data)); } } [_addError](error, stackTrace) { - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return; - if (this[_canFire]) { + if (dart.notNull(this[_canFire])) { this[_sendError](error, stackTrace); } else { this[_addPending](new _DelayedError(error, stackTrace)); @@ -1055,10 +1055,10 @@ var collection = dart.import(collection); } [_close]() { dart.assert(!dart.notNull(this[_isClosed])); - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return; this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_CLOSED); - if (this[_canFire]) { + if (dart.notNull(this[_canFire])) { this[_sendDone](); } else { this[_addPending](dart.const(new _DelayedDone())); @@ -1114,7 +1114,7 @@ var collection = dart.import(collection); this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK); }; dart.fn(sendError, dart.void, []); - if (this[_cancelOnError]) { + if (dart.notNull(this[_cancelOnError])) { this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_WAIT_FOR_CANCEL); this[_cancel](); if (dart.is(this[_cancelFuture], Future)) { @@ -1164,7 +1164,7 @@ var collection = dart.import(collection); } } while (true) { - if (this[_isCanceled]) { + if (dart.notNull(this[_isCanceled])) { this[_pending] = null; return; } @@ -1172,7 +1172,7 @@ var collection = dart.import(collection); if (wasInputPaused == isInputPaused) break; this[_state] = dart.notNull(this[_state]) ^ dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK); - if (isInputPaused) { + if (dart.notNull(isInputPaused)) { this[_onPause](); } else { this[_onResume](); @@ -1379,24 +1379,24 @@ var collection = dart.import(collection); [_subscribe](onData, onError, onDone, cancelOnError) { dart.as(onData, dart.functionType(dart.void, [T])); dart.as(onDone, dart.functionType(dart.void, [])); - if (this.isClosed) { + if (dart.notNull(this.isClosed)) { if (onDone == null) onDone = _nullDoneHandler; return new (_DoneStreamSubscription$(T))(onDone); } let subscription = new (_BroadcastSubscription$(T))(this, onData, onError, onDone, cancelOnError); this[_addListener](dart.as(subscription, _BroadcastSubscription$(T))); - if (core.identical(this[_next], this[_previous])) { + if (dart.notNull(core.identical(this[_next], this[_previous]))) { _runGuarded(this[_onListen]); } return dart.as(subscription, StreamSubscription$(T)); } [_recordCancel](subscription) { dart.as(subscription, StreamSubscription$(T)); - if (core.identical(subscription[_next], subscription)) + if (dart.notNull(core.identical(subscription[_next], subscription))) return null; dart.assert(!dart.notNull(core.identical(subscription[_next], subscription))); - if (subscription[_isFiring]) { + if (dart.notNull(dart.as(subscription[_isFiring], core.bool))) { dart.dcall(subscription[_setRemoveAfterFiring]); } else { dart.assert(!dart.notNull(core.identical(subscription[_next], subscription))); @@ -1414,7 +1414,7 @@ var collection = dart.import(collection); dart.as(subscription, StreamSubscription$(T)); } [_addEventError]() { - if (this.isClosed) { + if (dart.notNull(this.isClosed)) { return new core.StateError("Cannot add new events after calling close"); } dart.assert(this[_isAddingStream]); @@ -1440,7 +1440,7 @@ var collection = dart.import(collection); this[_sendError](error, stackTrace); } close() { - if (this.isClosed) { + if (dart.notNull(this.isClosed)) { dart.assert(this[_doneFuture] != null); return this[_doneFuture]; } @@ -1479,22 +1479,22 @@ var collection = dart.import(collection); } [_forEachListener](action) { dart.as(action, dart.functionType(dart.void, [_BufferingStreamSubscription$(T)])); - if (this[_isFiring]) { + if (dart.notNull(this[_isFiring])) { throw new core.StateError("Cannot fire new event. Controller is already firing an event"); } - if (this[_isEmpty]) + if (dart.notNull(this[_isEmpty])) return; let id = dart.notNull(this[_state]) & dart.notNull(_BroadcastStreamController$()._STATE_EVENT_ID); this[_state] = dart.notNull(this[_state]) ^ (dart.notNull(_BroadcastStreamController$()._STATE_EVENT_ID) | dart.notNull(_BroadcastStreamController$()._STATE_FIRING)); let link = this[_next]; while (!dart.notNull(core.identical(link, this))) { let subscription = dart.as(link, _BroadcastSubscription$(T)); - if (subscription[_expectsEvent](id)) { + if (dart.notNull(subscription[_expectsEvent](id))) { subscription[_eventState] = dart.notNull(subscription[_eventState]) | dart.notNull(_BroadcastSubscription._STATE_FIRING); action(subscription); subscription[_toggleEventId](); link = subscription[_next]; - if (subscription[_removeAfterFiring]) { + if (dart.notNull(subscription[_removeAfterFiring])) { this[_removeListener](subscription); } subscription[_eventState] = dart.notNull(subscription[_eventState]) & ~dart.notNull(_BroadcastSubscription._STATE_FIRING); @@ -1503,7 +1503,7 @@ var collection = dart.import(collection); } } this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStreamController$()._STATE_FIRING); - if (this[_isEmpty]) { + if (dart.notNull(this[_isEmpty])) { this[_callOnCancel](); } } @@ -1553,14 +1553,14 @@ var collection = dart.import(collection); } [_sendData](data) { dart.as(data, T); - if (this[_isEmpty]) + if (dart.notNull(this[_isEmpty])) return; - if (this[_hasOneListener]) { + if (dart.notNull(this[_hasOneListener])) { this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStreamController._STATE_FIRING); let subscription = dart.as(this[_next], _BroadcastSubscription); subscription[_add](data); this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStreamController._STATE_FIRING); - if (this[_isEmpty]) { + if (dart.notNull(this[_isEmpty])) { this[_callOnCancel](); } return; @@ -1571,7 +1571,7 @@ var collection = dart.import(collection); }, core.Object, [_BufferingStreamSubscription$(T)])); } [_sendError](error, stackTrace) { - if (this[_isEmpty]) + if (dart.notNull(this[_isEmpty])) return; this[_forEachListener](dart.fn(subscription => { dart.as(subscription, _BufferingStreamSubscription$(T)); @@ -1652,7 +1652,7 @@ var collection = dart.import(collection); super._SyncBroadcastStreamController(onListen, onCancel); } get [_hasPending]() { - return dart.notNull(this[_pending] != null) && !dart.notNull(this[_pending].isEmpty); + return this[_pending] != null && !dart.notNull(this[_pending].isEmpty); } [_addPendingEvent](event) { if (this[_pending] == null) { @@ -1667,7 +1667,7 @@ var collection = dart.import(collection); return; } super.add(data); - while (this[_hasPending]) { + while (dart.notNull(this[_hasPending])) { this[_pending].handleNext(this); } } @@ -1681,7 +1681,7 @@ var collection = dart.import(collection); if (!dart.notNull(this[_mayAddEvent])) throw this[_addEventError](); this[_sendError](error, stackTrace); - while (this[_hasPending]) { + while (dart.notNull(this[_hasPending])) { this[_pending].handleNext(this); } } @@ -1696,7 +1696,7 @@ var collection = dart.import(collection); return result; } [_callOnCancel]() { - if (this[_hasPending]) { + if (dart.notNull(this[_hasPending])) { this[_pending].clear(); this[_pending] = null; } @@ -1919,7 +1919,7 @@ var collection = dart.import(collection); result[_completeWithValue](values); } } else { - if (dart.notNull(cleanUp != null) && dart.notNull(value != null)) { + if (cleanUp != null && value != null) { Future$().sync(dart.fn(() => { dart.dcall(cleanUp, value); })); @@ -1950,7 +1950,7 @@ var collection = dart.import(collection); let doneSignal = new _Future(); let nextIteration = null; nextIteration = Zone.current.bindUnaryCallback(dart.fn(keepGoing => { - if (keepGoing) { + if (dart.notNull(keepGoing)) { Future$().sync(f).then(dart.as(nextIteration, __CastType4), {onError: dart.bind(doneSignal, _completeError)}); } else { doneSignal[_complete](null); @@ -2258,7 +2258,7 @@ var collection = dart.import(collection); return this[_state] == _Future$()._ERROR; } set [_isChained](value) { - if (value) { + if (dart.notNull(value)) { dart.assert(!dart.notNull(this[_isComplete])); this[_state] = _Future$()._CHAINED; } else { @@ -2332,7 +2332,7 @@ var collection = dart.import(collection); } [_addListener](listener) { dart.assert(listener[_nextListener] == null); - if (this[_isComplete]) { + if (dart.notNull(this[_isComplete])) { this[_zone].scheduleMicrotask(dart.fn(() => { _Future$()._propagateToListeners(this, listener); })); @@ -2373,7 +2373,7 @@ var collection = dart.import(collection); dart.assert(dart.is(source, _Future$())); target[_isChained] = true; let listener = new _FutureListener.chain(target); - if (source[_isComplete]) { + if (dart.notNull(source[_isComplete])) { _Future$()._propagateToListeners(source, listener); } else { source[_addListener](listener); @@ -2447,7 +2447,7 @@ var collection = dart.import(collection); dart.assert(source[_isComplete]); let hasError = source[_hasError]; if (listeners == null) { - if (hasError) { + if (dart.notNull(hasError)) { let asyncError = source[_error]; source[_zone].handleUncaughtError(asyncError.error, asyncError.stackTrace); } @@ -2461,7 +2461,7 @@ var collection = dart.import(collection); } let listener = listeners; let listenerHasValue = true; - let sourceValue = hasError ? null : source[_value]; + let sourceValue = dart.notNull(hasError) ? null : source[_value]; let listenerValueOrError = sourceValue; let isPropagationAborted = false; if (dart.notNull(hasError) || dart.notNull(listener.handlesValue) || dart.notNull(listener.handlesComplete)) { @@ -2490,20 +2490,20 @@ var collection = dart.import(collection); let handleError = () => { let asyncError = source[_error]; let matchesTest = true; - if (listener.hasErrorTest) { + if (dart.notNull(listener.hasErrorTest)) { let test = listener[_errorTest]; try { matchesTest = dart.as(zone.runUnary(test, asyncError.error), core.bool); } catch (e) { let s = dart.stackTrace(e); - listenerValueOrError = core.identical(asyncError.error, e) ? asyncError : new AsyncError(e, s); + listenerValueOrError = dart.notNull(core.identical(asyncError.error, e)) ? asyncError : new AsyncError(e, s); listenerHasValue = false; return; } } let errorCallback = listener[_onError]; - if (dart.notNull(matchesTest) && dart.notNull(errorCallback != null)) { + if (dart.notNull(matchesTest) && errorCallback != null) { try { if (dart.is(errorCallback, ZoneBinaryCallback)) { listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asyncError.stackTrace); @@ -2512,7 +2512,7 @@ var collection = dart.import(collection); } } catch (e) { let s = dart.stackTrace(e); - listenerValueOrError = core.identical(asyncError.error, e) ? asyncError : new AsyncError(e, s); + listenerValueOrError = dart.notNull(core.identical(asyncError.error, e)) ? asyncError : new AsyncError(e, s); listenerHasValue = false; return; } @@ -2558,24 +2558,24 @@ var collection = dart.import(collection); }; dart.fn(handleWhenCompleteCallback, dart.void, []); if (!dart.notNull(hasError)) { - if (listener.handlesValue) { + if (dart.notNull(listener.handlesValue)) { listenerHasValue = handleValueCallback(); } } else { handleError(); } - if (listener.handlesComplete) { + if (dart.notNull(listener.handlesComplete)) { handleWhenCompleteCallback(); } if (oldZone != null) Zone._leave(oldZone); - if (isPropagationAborted) + if (dart.notNull(isPropagationAborted)) return; if (dart.notNull(listenerHasValue) && !dart.notNull(core.identical(sourceValue, listenerValueOrError)) && dart.is(listenerValueOrError, Future)) { let chainSource = dart.as(listenerValueOrError, Future); let result = listener.result; if (dart.is(chainSource, _Future$())) { - if (chainSource[_isComplete]) { + if (dart.notNull(chainSource[_isComplete])) { result[_isChained] = true; source = chainSource; listeners = new _FutureListener.chain(result); @@ -2591,7 +2591,7 @@ var collection = dart.import(collection); } let result = listener.result; listeners = result[_removeListeners](); - if (listenerHasValue) { + if (dart.notNull(listenerHasValue)) { result[_setValue](listenerValueOrError); } else { let asyncError = dart.as(listenerValueOrError, AsyncError); @@ -2603,7 +2603,7 @@ var collection = dart.import(collection); timeout(timeLimit, opts) { let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; dart.as(onTimeout, dart.functionType(core.Object, [])); - if (this[_isComplete]) + if (dart.notNull(this[_isComplete])) return new (_Future$()).immediate(this); let result = new (_Future$())(); let timer = null; @@ -2626,12 +2626,12 @@ var collection = dart.import(collection); } this.then(dart.fn(v => { dart.as(v, T); - if (timer.isActive) { + if (dart.notNull(timer.isActive)) { timer.cancel(); result[_completeWithValue](v); } }, core.Object, [T]), {onError: dart.fn((e, s) => { - if (timer.isActive) { + if (dart.notNull(timer.isActive)) { timer.cancel(); result[_completeError](e, dart.as(s, core.StackTrace)); } @@ -2757,7 +2757,7 @@ var collection = dart.import(collection); } dart.fn(_schedulePriorityAsyncCallback, dart.void, [core.Object]); function scheduleMicrotask(callback) { - if (core.identical(_ROOT_ZONE, Zone.current)) { + if (dart.notNull(core.identical(_ROOT_ZONE, Zone.current))) { _rootScheduleMicrotask(null, null, _ROOT_ZONE, callback); return; } @@ -2772,7 +2772,7 @@ var collection = dart.import(collection); if (self.scheduleImmediate != null) { return _AsyncRun._scheduleImmediateJsOverride; } - if (dart.notNull(self.MutationObserver != null) && dart.notNull(self.document != null)) { + if (self.MutationObserver != null && self.document != null) { let div = self.document.createElement("div"); let span = self.document.createElement("span"); let storedCallback = null; @@ -2966,16 +2966,16 @@ var collection = dart.import(collection); let onResume = opts && 'onResume' in opts ? opts.onResume : null; let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; let sync = opts && 'sync' in opts ? opts.sync : false; - if (dart.notNull(onListen == null) && dart.notNull(onPause == null) && dart.notNull(onResume == null) && dart.notNull(onCancel == null)) { - return dart.as(sync ? new _NoCallbackSyncStreamController() : new _NoCallbackAsyncStreamController(), StreamController$(T)); + if (onListen == null && onPause == null && onResume == null && onCancel == null) { + return dart.as(dart.notNull(sync) ? new _NoCallbackSyncStreamController() : new _NoCallbackAsyncStreamController(), StreamController$(T)); } - return sync ? new (_SyncStreamController$(T))(onListen, onPause, onResume, onCancel) : new (_AsyncStreamController$(T))(onListen, onPause, onResume, onCancel); + return dart.notNull(sync) ? new (_SyncStreamController$(T))(onListen, onPause, onResume, onCancel) : new (_AsyncStreamController$(T))(onListen, onPause, onResume, onCancel); } static broadcast(opts) { let onListen = opts && 'onListen' in opts ? opts.onListen : null; let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null; let sync = opts && 'sync' in opts ? opts.sync : false; - return sync ? new (_SyncBroadcastStreamController$(T))(onListen, onCancel) : new (_AsyncBroadcastStreamController$(T))(onListen, onCancel); + return dart.notNull(sync) ? new (_SyncBroadcastStreamController$(T))(onListen, onCancel) : new (_AsyncBroadcastStreamController$(T))(onListen, onCancel); } } StreamController[dart.implements] = () => [StreamSink$(T)]; @@ -3043,7 +3043,7 @@ var collection = dart.import(collection); return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._STATE_CLOSED)) != 0; } get isPaused() { - return this.hasListener ? this[_subscription][_isInputPaused] : !dart.notNull(this[_isCanceled]); + return dart.notNull(this.hasListener) ? this[_subscription][_isInputPaused] : !dart.notNull(this[_isCanceled]); } get [_isAddingStream]() { return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._STATE_ADDSTREAM)) != 0; @@ -3073,14 +3073,14 @@ var collection = dart.import(collection); } get [_subscription]() { dart.assert(this.hasListener); - if (this[_isAddingStream]) { + if (dart.notNull(this[_isAddingStream])) { let addState = dart.as(this[_varData], _StreamControllerAddStreamState); return dart.as(addState.varData, _ControllerSubscription); } return dart.as(this[_varData], _ControllerSubscription); } [_badEventState]() { - if (this.isClosed) { + if (dart.notNull(this.isClosed)) { return new core.StateError("Cannot add event after closing"); } dart.assert(this[_isAddingStream]); @@ -3091,7 +3091,7 @@ var collection = dart.import(collection); let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true; if (!dart.notNull(this[_mayAddEvent])) throw this[_badEventState](); - if (this[_isCanceled]) + if (dart.notNull(this[_isCanceled])) return new _Future.immediate(null); let addState = new _StreamControllerAddStreamState(this, this[_varData], source, cancelOnError); this[_varData] = addState; @@ -3103,7 +3103,7 @@ var collection = dart.import(collection); } [_ensureDoneFuture]() { if (this[_doneFuture] == null) { - this[_doneFuture] = this[_isCanceled] ? Future._nullFuture : new _Future(); + this[_doneFuture] = dart.notNull(this[_isCanceled]) ? Future._nullFuture : new _Future(); } return this[_doneFuture]; } @@ -3127,7 +3127,7 @@ var collection = dart.import(collection); this[_addError](error, stackTrace); } close() { - if (this.isClosed) { + if (dart.notNull(this.isClosed)) { return this[_ensureDoneFuture](); } if (!dart.notNull(this[_mayAddEvent])) @@ -3137,24 +3137,24 @@ var collection = dart.import(collection); } [_closeUnchecked]() { this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamController$()._STATE_CLOSED); - if (this.hasListener) { + if (dart.notNull(this.hasListener)) { this[_sendDone](); - } else if (this[_isInitialState]) { + } else if (dart.notNull(this[_isInitialState])) { this[_ensurePendingEvents]().add(dart.const(new _DelayedDone())); } } [_add](value) { dart.as(value, T); - if (this.hasListener) { + if (dart.notNull(this.hasListener)) { this[_sendData](value); - } else if (this[_isInitialState]) { + } else if (dart.notNull(this[_isInitialState])) { this[_ensurePendingEvents]().add(new (_DelayedData$(T))(value)); } } [_addError](error, stackTrace) { - if (this.hasListener) { + if (dart.notNull(this.hasListener)) { this[_sendError](error, stackTrace); - } else if (this[_isInitialState]) { + } else if (dart.notNull(this[_isInitialState])) { this[_ensurePendingEvents]().add(new _DelayedError(error, stackTrace)); } } @@ -3174,7 +3174,7 @@ var collection = dart.import(collection); let subscription = new _ControllerSubscription(this, onData, onError, onDone, cancelOnError); let pendingEvents = this[_pendingEvents]; this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamController$()._STATE_SUBSCRIBED); - if (this[_isAddingStream]) { + if (dart.notNull(this[_isAddingStream])) { let addState = dart.as(this[_varData], _StreamControllerAddStreamState); addState.varData = subscription; addState.resume(); @@ -3190,7 +3190,7 @@ var collection = dart.import(collection); [_recordCancel](subscription) { dart.as(subscription, StreamSubscription$(T)); let result = null; - if (this[_isAddingStream]) { + if (dart.notNull(this[_isAddingStream])) { let addState = dart.as(this[_varData], _StreamControllerAddStreamState); result = addState.cancel(); } @@ -3211,7 +3211,7 @@ var collection = dart.import(collection); } } let complete = () => { - if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_doneFuture][_mayComplete])) { + if (this[_doneFuture] != null && dart.notNull(this[_doneFuture][_mayComplete])) { this[_doneFuture][_asyncComplete](null); } }; @@ -3225,7 +3225,7 @@ var collection = dart.import(collection); } [_recordPause](subscription) { dart.as(subscription, StreamSubscription$(T)); - if (this[_isAddingStream]) { + if (dart.notNull(this[_isAddingStream])) { let addState = dart.as(this[_varData], _StreamControllerAddStreamState); addState.pause(); } @@ -3233,7 +3233,7 @@ var collection = dart.import(collection); } [_recordResume](subscription) { dart.as(subscription, StreamSubscription$(T)); - if (this[_isAddingStream]) { + if (dart.notNull(this[_isAddingStream])) { let addState = dart.as(this[_varData], _StreamControllerAddStreamState); addState.resume(); } @@ -3426,7 +3426,7 @@ var collection = dart.import(collection); class _AddStreamState extends core.Object { _AddStreamState(controller, source, cancelOnError) { this.addStreamFuture = new _Future(); - this.addSubscription = source.listen(dart.bind(controller, _add), {onError: cancelOnError ? dart.as(_AddStreamState$().makeErrorHandler(controller), core.Function) : dart.bind(controller, _addError), onDone: dart.bind(controller, _close), cancelOnError: cancelOnError}); + this.addSubscription = source.listen(dart.bind(controller, _add), {onError: dart.notNull(cancelOnError) ? dart.as(_AddStreamState$().makeErrorHandler(controller), core.Function) : dart.bind(controller, _addError), onDone: dart.bind(controller, _close), cancelOnError: cancelOnError}); } static makeErrorHandler(controller) { return dart.fn((e, s) => { @@ -3473,7 +3473,7 @@ var collection = dart.import(collection); _StreamControllerAddStreamState(controller, varData, source, cancelOnError) { this.varData = varData; super._AddStreamState(dart.as(controller, _EventSink$(T)), source, cancelOnError); - if (controller.isPaused) { + if (dart.notNull(controller.isPaused)) { this.addSubscription.pause(); } } @@ -3514,7 +3514,7 @@ var collection = dart.import(collection); [_createSubscription](onData, onError, onDone, cancelOnError) { dart.as(onData, dart.functionType(dart.void, [T])); dart.as(onDone, dart.functionType(dart.void, [])); - if (this[_isUsed]) + if (dart.notNull(this[_isUsed])) throw new core.StateError("Stream has already been listened to."); this[_isUsed] = true; return dart.as((() => { @@ -3543,10 +3543,10 @@ var collection = dart.import(collection); return dart.notNull(this[_state]) >= dart.notNull(_PendingEvents._STATE_SCHEDULED); } schedule(dispatch) { - if (this.isScheduled) + if (dart.notNull(this.isScheduled)) return; dart.assert(!dart.notNull(this.isEmpty)); - if (this[_eventScheduled]) { + if (dart.notNull(this[_eventScheduled])) { dart.assert(this[_state] == _PendingEvents._STATE_CANCELED); this[_state] = _PendingEvents._STATE_SCHEDULED; return; @@ -3561,7 +3561,7 @@ var collection = dart.import(collection); this[_state] = _PendingEvents._STATE_SCHEDULED; } cancelSchedule() { - if (this.isScheduled) + if (dart.notNull(this.isScheduled)) this[_state] = _PendingEvents._STATE_CANCELED; } } @@ -3603,7 +3603,7 @@ var collection = dart.import(collection); } } clear() { - if (this.isScheduled) + if (dart.notNull(this.isScheduled)) this.cancelSchedule(); this[_iterator] = null; } @@ -3724,7 +3724,7 @@ var collection = dart.import(collection); event.perform(dispatch); } clear() { - if (this.isScheduled) + if (dart.notNull(this.isScheduled)) this.cancelSchedule(); this.firstPendingEvent = this.lastPendingEvent = null; } @@ -3784,7 +3784,7 @@ var collection = dart.import(collection); return dart.notNull(this[_state]) >= dart.notNull(_DoneStreamSubscription$()._PAUSED); } [_schedule]() { - if (this[_isScheduled]) + if (dart.notNull(this[_isScheduled])) return; this[_zone].scheduleMicrotask(dart.bind(this, _sendDone)); this[_state] = dart.notNull(this[_state]) | dart.notNull(_DoneStreamSubscription$()._SCHEDULED); @@ -3805,7 +3805,7 @@ var collection = dart.import(collection); resumeSignal.whenComplete(dart.bind(this, 'resume')); } resume() { - if (this.isPaused) { + if (dart.notNull(this.isPaused)) { this[_state] = dart.notNull(this[_state]) - dart.notNull(_DoneStreamSubscription$()._PAUSED); if (!dart.notNull(this.isPaused) && !dart.notNull(this[_isSent])) { this[_schedule](); @@ -3826,7 +3826,7 @@ var collection = dart.import(collection); } [_sendDone]() { this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_DoneStreamSubscription$()._SCHEDULED); - if (this.isPaused) + if (dart.notNull(this.isPaused)) return; this[_state] = dart.notNull(this[_state]) | dart.notNull(_DoneStreamSubscription$()._DONE_SENT); if (this[_onDone] != null) @@ -3882,7 +3882,7 @@ var collection = dart.import(collection); let onDone = opts && 'onDone' in opts ? opts.onDone : null; dart.as(onDone, dart.functionType(dart.void, [])); let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; - if (dart.notNull(this[_controller] == null) || dart.notNull(this[_controller].isClosed)) { + if (this[_controller] == null || dart.notNull(this[_controller].isClosed)) { return new (_DoneStreamSubscription$(T))(onDone); } if (this[_subscription] == null) { @@ -3892,11 +3892,11 @@ var collection = dart.import(collection); return this[_controller][_subscribe](onData, onError, onDone, cancelOnError); } [_onCancel]() { - let shutdown = dart.notNull(this[_controller] == null) || dart.notNull(this[_controller].isClosed); + let shutdown = this[_controller] == null || dart.notNull(this[_controller].isClosed); if (this[_onCancelHandler] != null) { this[_zone].runUnary(this[_onCancelHandler], new _BroadcastSubscriptionWrapper(this)); } - if (shutdown) { + if (dart.notNull(shutdown)) { if (this[_subscription] != null) { this[_subscription].cancel(); this[_subscription] = null; @@ -4249,12 +4249,12 @@ var collection = dart.import(collection); } [_add](data) { dart.as(data, T); - if (this[_isClosed]) + if (dart.notNull(this[_isClosed])) return; super[_add](data); } [_addError](error, stackTrace) { - if (this[_isClosed]) + if (dart.notNull(this[_isClosed])) return; super[_addError](error, stackTrace); } @@ -4332,7 +4332,7 @@ var collection = dart.import(collection); return; } - if (satisfies) { + if (dart.notNull(satisfies)) { sink[_add](inputEvent); } } @@ -4427,12 +4427,12 @@ var collection = dart.import(collection); } } - if (matches) { + if (dart.notNull(matches)) { try { _invokeErrorHandler(this[_transform], error, stackTrace); } catch (e) { let s = dart.stackTrace(e); - if (core.identical(e, error)) { + if (dart.notNull(core.identical(e, error))) { sink[_addError](error, stackTrace); } else { _addErrorWithReplacement(sink, e, s); @@ -4499,7 +4499,7 @@ var collection = dart.import(collection); return; } - if (satisfies) { + if (dart.notNull(satisfies)) { sink[_add](inputEvent); } else { sink[_close](); @@ -4549,7 +4549,7 @@ var collection = dart.import(collection); [_handleData](inputEvent, sink) { dart.as(inputEvent, T); dart.as(sink, _EventSink$(T)); - if (this[_hasFailed]) { + if (dart.notNull(this[_hasFailed])) { sink[_add](inputEvent); return; } @@ -4592,7 +4592,7 @@ var collection = dart.import(collection); [_handleData](inputEvent, sink) { dart.as(inputEvent, T); dart.as(sink, _EventSink$(T)); - if (core.identical(this[_previous], _DistinctStream$()._SENTINEL)) { + if (dart.notNull(core.identical(this[_previous], _DistinctStream$()._SENTINEL))) { this[_previous] = inputEvent; return sink[_add](inputEvent); } else { @@ -4676,33 +4676,33 @@ var collection = dart.import(collection); } [_add](data) { dart.as(data, T); - if (this[_isClosed]) { + if (dart.notNull(this[_isClosed])) { throw new core.StateError("Stream is already closed"); } super[_add](data); } [_addError](error, stackTrace) { - if (this[_isClosed]) { + if (dart.notNull(this[_isClosed])) { throw new core.StateError("Stream is already closed"); } super[_addError](error, stackTrace); } [_close]() { - if (this[_isClosed]) { + if (dart.notNull(this[_isClosed])) { throw new core.StateError("Stream is already closed"); } super[_close](); } [_onPause]() { - if (this[_isSubscribed]) + if (dart.notNull(this[_isSubscribed])) this[_subscription].pause(); } [_onResume]() { - if (this[_isSubscribed]) + if (dart.notNull(this[_isSubscribed])) this[_subscription].resume(); } [_onCancel]() { - if (this[_isSubscribed]) { + if (dart.notNull(this[_isSubscribed])) { let subscription = this[_subscription]; this[_subscription] = null; subscription.cancel(); @@ -4726,7 +4726,7 @@ var collection = dart.import(collection); this[_transformerSink].addError(error, dart.as(stackTrace, core.StackTrace)); } catch (e) { let s = dart.stackTrace(e); - if (core.identical(e, error)) { + if (dart.notNull(core.identical(e, error))) { this[_addError](error, dart.as(stackTrace, core.StackTrace)); } else { this[_addError](e, s); @@ -5205,7 +5205,7 @@ var collection = dart.import(collection); } runGuarded(f) { try { - if (core.identical(_ROOT_ZONE, Zone._current)) { + if (dart.notNull(core.identical(_ROOT_ZONE, Zone._current))) { return f(); } return _rootRun(null, null, this, f); @@ -5217,7 +5217,7 @@ var collection = dart.import(collection); } runUnaryGuarded(f, arg) { try { - if (core.identical(_ROOT_ZONE, Zone._current)) { + if (dart.notNull(core.identical(_ROOT_ZONE, Zone._current))) { return dart.dcall(f, arg); } return _rootRunUnary(null, null, this, f, arg); @@ -5229,7 +5229,7 @@ var collection = dart.import(collection); } runBinaryGuarded(f, arg1, arg2) { try { - if (core.identical(_ROOT_ZONE, Zone._current)) { + if (dart.notNull(core.identical(_ROOT_ZONE, Zone._current))) { return dart.dcall(f, arg1, arg2); } return _rootRunBinary(null, null, this, f, arg1, arg2); @@ -5241,7 +5241,7 @@ var collection = dart.import(collection); } bindCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn(() => this.runGuarded(f)); } else { return dart.fn(() => this.run(f)); @@ -5249,7 +5249,7 @@ var collection = dart.import(collection); } bindUnaryCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn(arg => this.runUnaryGuarded(f, arg)); } else { return dart.fn(arg => this.runUnary(f, arg)); @@ -5257,7 +5257,7 @@ var collection = dart.import(collection); } bindBinaryCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2)); } else { return dart.fn((arg1, arg2) => this.runBinary(f, arg1, arg2)); @@ -5275,17 +5275,17 @@ var collection = dart.import(collection); return _rootFork(null, null, this, specification, zoneValues); } run(f) { - if (core.identical(Zone._current, _ROOT_ZONE)) + if (dart.notNull(core.identical(Zone._current, _ROOT_ZONE))) return f(); return _rootRun(null, null, this, f); } runUnary(f, arg) { - if (core.identical(Zone._current, _ROOT_ZONE)) + if (dart.notNull(core.identical(Zone._current, _ROOT_ZONE))) return dart.dcall(f, arg); return _rootRunUnary(null, null, this, f, arg); } runBinary(f, arg1, arg2) { - if (core.identical(Zone._current, _ROOT_ZONE)) + if (dart.notNull(core.identical(Zone._current, _ROOT_ZONE))) return dart.dcall(f, arg1, arg2); return _rootRunBinary(null, null, this, f, arg1, arg2); } @@ -5391,7 +5391,7 @@ var collection = dart.import(collection); errorCallback(zone, error, stackTrace) { let implementation = this[_delegationTarget][_errorCallback]; let implZone = implementation.zone; - if (core.identical(implZone, _ROOT_ZONE)) + if (dart.notNull(core.identical(implZone, _ROOT_ZONE))) return null; return dart.as(dart.dcall(implementation.function, implZone, _parentDelegate(implZone), zone, error, stackTrace), AsyncError); } @@ -5513,7 +5513,7 @@ var collection = dart.import(collection); bindCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; let registered = this.registerCallback(f); - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn(() => this.runGuarded(registered)); } else { return dart.fn(() => this.run(registered)); @@ -5522,7 +5522,7 @@ var collection = dart.import(collection); bindUnaryCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; let registered = this.registerUnaryCallback(f); - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn(arg => this.runUnaryGuarded(registered, arg)); } else { return dart.fn(arg => this.runUnary(registered, arg)); @@ -5531,7 +5531,7 @@ var collection = dart.import(collection); bindBinaryCallback(f, opts) { let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; let registered = this.registerBinaryCallback(f); - if (runGuarded) { + if (dart.notNull(runGuarded)) { return dart.fn((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2)); } else { return dart.fn((arg1, arg2) => this.runBinary(registered, arg1, arg2)); @@ -5539,7 +5539,7 @@ var collection = dart.import(collection); } get(key) { let result = this[_map].get(key); - if (dart.notNull(result != null) || dart.notNull(this[_map].containsKey(key))) + if (result != null || dart.notNull(this[_map].containsKey(key))) return result; if (this.parent != null) { let value = this.parent.get(key); @@ -5605,7 +5605,7 @@ var collection = dart.import(collection); let implementation = this[_errorCallback]; dart.assert(implementation != null); let implementationZone = implementation.zone; - if (core.identical(implementationZone, _ROOT_ZONE)) + if (dart.notNull(core.identical(implementationZone, _ROOT_ZONE))) return null; let parentDelegate = _parentDelegate(dart.as(implementationZone, _Zone)); return dart.as(dart.dcall(implementation.function, implementationZone, parentDelegate, this, error, stackTrace), AsyncError); @@ -5828,7 +5828,7 @@ var collection = dart.import(collection); return self.parent.runUnary(dart.as(onError, __CastType38), error); } catch (e) { let s = dart.stackTrace(e); - if (core.identical(e, error)) { + if (dart.notNull(core.identical(e, error))) { return parent.handleUncaughtError(zone, error, stackTrace); } else { return parent.handleUncaughtError(zone, e, s); diff --git a/pkg/dev_compiler/lib/runtime/dart/collection.js b/pkg/dev_compiler/lib/runtime/dart/collection.js index f3f099e0179a..0d50f21e34bb 100644 --- a/pkg/dev_compiler/lib/runtime/dart/collection.js +++ b/pkg/dev_compiler/lib/runtime/dart/collection.js @@ -143,7 +143,7 @@ var math = dart.lazyImport(math); dart.as(test, dart.functionType(core.bool, [E])); let toRemove = []; for (let element of this) { - if (test(element)) + if (dart.notNull(test(element))) toRemove[dartx.add](element); } this.removeAll(toRemove); @@ -181,14 +181,14 @@ var math = dart.lazyImport(math); difference(other) { let result = this.toSet(); for (let element of this) { - if (other.contains(element)) + if (dart.notNull(other.contains(element))) result.remove(element); } return result; } toList(opts) { let growable = opts && 'growable' in opts ? opts.growable : true; - let result = growable ? (() => { + let result = dart.notNull(growable) ? (() => { let _ = core.List$(E).new(); _.length = this.length; return _; @@ -238,7 +238,7 @@ var math = dart.lazyImport(math); throw _internal.IterableElementError.noElement(); } let value = iterator.current; - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { value = combine(value, iterator.current); } return value; @@ -268,10 +268,10 @@ var math = dart.lazyImport(math); if (separator == null || separator == "") { do { buffer.write(`${iterator.current}`); - } while (iterator.moveNext()); + } while (dart.notNull(iterator.moveNext())); } else { buffer.write(`${iterator.current}`); - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { buffer.write(separator); buffer.write(`${iterator.current}`); } @@ -281,7 +281,7 @@ var math = dart.lazyImport(math); any(test) { dart.as(test, dart.functionType(core.bool, [E])); for (let element of this) { - if (test(element)) + if (dart.notNull(test(element))) return true; } return false; @@ -315,7 +315,7 @@ var math = dart.lazyImport(math); let result = null; do { result = it.current; - } while (it.moveNext()); + } while (dart.notNull(it.moveNext())); return result; } firstWhere(test, opts) { @@ -323,7 +323,7 @@ var math = dart.lazyImport(math); let orElse = opts && 'orElse' in opts ? opts.orElse : null; dart.as(orElse, dart.functionType(E, [])); for (let element of this) { - if (test(element)) + if (dart.notNull(test(element))) return element; } if (orElse != null) @@ -337,12 +337,12 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { + if (dart.notNull(test(element))) { result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; if (orElse != null) return orElse(); @@ -353,15 +353,15 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { - if (foundMatching) { + if (dart.notNull(test(element))) { + if (dart.notNull(foundMatching)) { throw _internal.IterableElementError.tooMany(); } result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; throw _internal.IterableElementError.noElement(); } @@ -466,7 +466,7 @@ var math = dart.lazyImport(math); intersection(other) { let result = this[_newSet](); for (let element of this) { - if (other.contains(element)) + if (dart.notNull(other.contains(element))) result.add(element); } return result; @@ -576,7 +576,7 @@ var math = dart.lazyImport(math); throw _internal.IterableElementError.noElement(); } let value = iterator.current; - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { value = combine(value, iterator.current); } return value; @@ -606,10 +606,10 @@ var math = dart.lazyImport(math); if (separator == null || separator == "") { do { buffer.write(`${iterator.current}`); - } while (iterator.moveNext()); + } while (dart.notNull(iterator.moveNext())); } else { buffer.write(`${iterator.current}`); - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { buffer.write(separator); buffer.write(`${iterator.current}`); } @@ -619,7 +619,7 @@ var math = dart.lazyImport(math); any(f) { dart.as(f, dart.functionType(core.bool, [E])); for (let element of this) { - if (f(element)) + if (dart.notNull(f(element))) return true; } return false; @@ -635,7 +635,7 @@ var math = dart.lazyImport(math); dart.assert(!dart.is(this, _internal.EfficientLength)); let count = 0; let it = this[dartx.iterator]; - while (it.moveNext()) { + while (dart.notNull(it.moveNext())) { count = dart.notNull(count) + 1; } return count; @@ -675,7 +675,7 @@ var math = dart.lazyImport(math); let result = null; do { result = it.current; - } while (it.moveNext()); + } while (dart.notNull(it.moveNext())); return result; } get single() { @@ -683,7 +683,7 @@ var math = dart.lazyImport(math); if (!dart.notNull(it.moveNext())) throw _internal.IterableElementError.noElement(); let result = it.current; - if (it.moveNext()) + if (dart.notNull(it.moveNext())) throw _internal.IterableElementError.tooMany(); return result; } @@ -692,7 +692,7 @@ var math = dart.lazyImport(math); let orElse = opts && 'orElse' in opts ? opts.orElse : null; dart.as(orElse, dart.functionType(E, [])); for (let element of this) { - if (test(element)) + if (dart.notNull(test(element))) return element; } if (orElse != null) @@ -706,12 +706,12 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { + if (dart.notNull(test(element))) { result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; if (orElse != null) return orElse(); @@ -722,15 +722,15 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { - if (foundMatching) { + if (dart.notNull(test(element))) { + if (dart.notNull(foundMatching)) { throw _internal.IterableElementError.tooMany(); } result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; throw _internal.IterableElementError.noElement(); } @@ -844,7 +844,7 @@ var math = dart.lazyImport(math); throw _internal.IterableElementError.noElement(); } let value = iterator.current; - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { value = combine(value, iterator.current); } return value; @@ -874,10 +874,10 @@ var math = dart.lazyImport(math); if (separator == null || separator == "") { do { buffer.write(`${iterator.current}`); - } while (iterator.moveNext()); + } while (dart.notNull(iterator.moveNext())); } else { buffer.write(`${iterator.current}`); - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { buffer.write(separator); buffer.write(`${iterator.current}`); } @@ -887,7 +887,7 @@ var math = dart.lazyImport(math); any(f) { dart.as(f, dart.functionType(core.bool, [E])); for (let element of this) { - if (f(element)) + if (dart.notNull(f(element))) return true; } return false; @@ -903,7 +903,7 @@ var math = dart.lazyImport(math); dart.assert(!dart.is(this, _internal.EfficientLength)); let count = 0; let it = this[dartx.iterator]; - while (it.moveNext()) { + while (dart.notNull(it.moveNext())) { count = dart.notNull(count) + 1; } return count; @@ -943,7 +943,7 @@ var math = dart.lazyImport(math); let result = null; do { result = it.current; - } while (it.moveNext()); + } while (dart.notNull(it.moveNext())); return result; } get single() { @@ -951,7 +951,7 @@ var math = dart.lazyImport(math); if (!dart.notNull(it.moveNext())) throw _internal.IterableElementError.noElement(); let result = it.current; - if (it.moveNext()) + if (dart.notNull(it.moveNext())) throw _internal.IterableElementError.tooMany(); return result; } @@ -960,7 +960,7 @@ var math = dart.lazyImport(math); let orElse = opts && 'orElse' in opts ? opts.orElse : null; dart.as(orElse, dart.functionType(E, [])); for (let element of this) { - if (test(element)) + if (dart.notNull(test(element))) return element; } if (orElse != null) @@ -974,12 +974,12 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { + if (dart.notNull(test(element))) { result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; if (orElse != null) return orElse(); @@ -990,15 +990,15 @@ var math = dart.lazyImport(math); let result = null; let foundMatching = false; for (let element of this) { - if (test(element)) { - if (foundMatching) { + if (dart.notNull(test(element))) { + if (dart.notNull(foundMatching)) { throw _internal.IterableElementError.tooMany(); } result = element; foundMatching = true; } } - if (foundMatching) + if (dart.notNull(foundMatching)) return result; throw _internal.IterableElementError.noElement(); } @@ -1022,7 +1022,7 @@ var math = dart.lazyImport(math); leftDelimiter = '('; if (rightDelimiter === void 0) rightDelimiter = ')'; - if (IterableBase$()._isToStringVisiting(iterable)) { + if (dart.notNull(IterableBase$()._isToStringVisiting(iterable))) { if (leftDelimiter == "(" && rightDelimiter == ")") { return "(...)"; } @@ -1048,7 +1048,7 @@ var math = dart.lazyImport(math); leftDelimiter = '('; if (rightDelimiter === void 0) rightDelimiter = ')'; - if (IterableBase$()._isToStringVisiting(iterable)) { + if (dart.notNull(IterableBase$()._isToStringVisiting(iterable))) { return `${leftDelimiter}...${rightDelimiter}`; } let buffer = new core.StringBuffer(leftDelimiter); @@ -1064,7 +1064,7 @@ var math = dart.lazyImport(math); } static _isToStringVisiting(o) { for (let i = 0; dart.notNull(i) < dart.notNull(IterableBase$()._toStringVisiting.length); i = dart.notNull(i) + 1) { - if (core.identical(o, IterableBase$()._toStringVisiting[dartx.get](i))) + if (dart.notNull(core.identical(o, IterableBase$()._toStringVisiting[dartx.get](i)))) return true; } return false; @@ -1111,7 +1111,7 @@ var math = dart.lazyImport(math); ultimate = it.current; count = dart.notNull(count) + 1; dart.assert(dart.notNull(count) < dart.notNull(MAX_COUNT)); - while (it.moveNext()) { + while (dart.notNull(it.moveNext())) { penultimate = ultimate; ultimate = it.current; count = dart.notNull(count) + 1; @@ -1243,7 +1243,7 @@ var math = dart.lazyImport(math); return result; } [_move]() { - if (this[_iterator].moveNext()) { + if (dart.notNull(this[_iterator].moveNext())) { this[_state] = HasNextIterator$()._HAS_NEXT_AND_NEXT_IN_CURRENT; } else { this[_state] = HasNextIterator$()._NO_NEXT; @@ -1446,19 +1446,19 @@ var math = dart.lazyImport(math); this[_length] = 0; } get first() { - if (core.identical(this[_next], this)) { + if (dart.notNull(core.identical(this[_next], this))) { throw new core.StateError('No such element'); } return dart.as(this[_next], E); } get last() { - if (core.identical(this[_previous], this)) { + if (dart.notNull(core.identical(this[_previous], this))) { throw new core.StateError('No such element'); } return dart.as(this[_previous], E); } get single() { - if (core.identical(this[_previous], this)) { + if (dart.notNull(core.identical(this[_previous], this))) { throw new core.StateError('No such element'); } if (!dart.notNull(core.identical(this[_previous], this[_next]))) { @@ -1544,7 +1544,7 @@ var math = dart.lazyImport(math); return this[_current]; } moveNext() { - if (core.identical(this[_next], this[_list])) { + if (dart.notNull(core.identical(this[_next], this[_list]))) { this[_current] = null; return false; } @@ -1584,13 +1584,13 @@ var math = dart.lazyImport(math); this[_list][_unlink](this); } get next() { - if (core.identical(this[_next], this[_list])) + if (dart.notNull(core.identical(this[_next], this[_list]))) return null; let result = dart.as(this[_next], E); return result; } get previous() { - if (core.identical(this[_previous], this[_list])) + if (dart.notNull(core.identical(this[_previous], this[_list]))) return null; return dart.as(this[_previous], E); } @@ -1685,7 +1685,7 @@ var math = dart.lazyImport(math); dart.as(test, dart.functionType(core.bool, [E])); let length = this.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { - if (test(this.get(i))) + if (dart.notNull(test(this.get(i)))) return true; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -1700,7 +1700,7 @@ var math = dart.lazyImport(math); let length = this.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let element = this.get(i); - if (test(element)) + if (dart.notNull(test(element))) return element; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -1717,7 +1717,7 @@ var math = dart.lazyImport(math); let length = this.length; for (let i = dart.notNull(length) - 1; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) { let element = this.get(i); - if (test(element)) + if (dart.notNull(test(element))) return element; if (length != this.length) { throw new core.ConcurrentModificationError(this); @@ -1734,8 +1734,8 @@ var math = dart.lazyImport(math); let matchFound = false; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let element = this.get(i); - if (test(element)) { - if (matchFound) { + if (dart.notNull(test(element))) { + if (dart.notNull(matchFound)) { throw _internal.IterableElementError.tooMany(); } matchFound = true; @@ -1745,7 +1745,7 @@ var math = dart.lazyImport(math); throw new core.ConcurrentModificationError(this); } } - if (matchFound) + if (dart.notNull(matchFound)) return match; throw _internal.IterableElementError.noElement(); } @@ -1813,7 +1813,7 @@ var math = dart.lazyImport(math); toList(opts) { let growable = opts && 'growable' in opts ? opts.growable : true; let result = null; - if (growable) { + if (dart.notNull(growable)) { result = core.List$(E).new(); result.length = this.length; } else { @@ -2237,7 +2237,7 @@ var math = dart.lazyImport(math); putIfAbsent(key, ifAbsent) { dart.as(key, K); dart.as(ifAbsent, dart.functionType(V, [])); - if (this.keys[dartx.contains](key)) { + if (dart.notNull(this.keys[dartx.contains](key))) { return this.get(key); } return this.set(key, ifAbsent()); @@ -2374,7 +2374,7 @@ var math = dart.lazyImport(math); this[_current] = null; } moveNext() { - if (this[_keys].moveNext()) { + if (dart.notNull(this[_keys].moveNext())) { this[_current] = dart.as(this[_map].get(this[_keys].current), V); return true; } @@ -2491,7 +2491,7 @@ var math = dart.lazyImport(math); return false; } static putIfAbsent(map, key, ifAbsent) { - if (map.containsKey(key)) { + if (dart.notNull(map.containsKey(key))) { return map.get(key); } let v = ifAbsent(); @@ -2521,7 +2521,7 @@ var math = dart.lazyImport(math); return map.keys[dartx.isNotEmpty]; } static mapToString(m) { - if (IterableBase._isToStringVisiting(m)) { + if (dart.notNull(IterableBase._isToStringVisiting(m))) { return '{...}'; } let result = new core.StringBuffer(); @@ -2777,7 +2777,7 @@ var math = dart.lazyImport(math); let entry = this[_sentinel][_next]; while (!dart.notNull(core.identical(entry, this[_sentinel]))) { let next = entry[_next]; - if (core.identical(removeMatching, test(entry.element))) { + if (dart.notNull(core.identical(removeMatching, test(entry.element)))) { entry.remove(); this[_elementCount] = dart.notNull(this[_elementCount]) - 1; } @@ -2799,7 +2799,7 @@ var math = dart.lazyImport(math); return this[_sentinel][_previous].element; } get single() { - if (core.identical(this[_sentinel][_next], this[_sentinel][_previous])) { + if (dart.notNull(core.identical(this[_sentinel][_next], this[_sentinel][_previous]))) { return this[_sentinel][_next].element; } throw _internal.IterableElementError.tooMany(); @@ -2988,7 +2988,7 @@ var math = dart.lazyImport(math); toList(opts) { let growable = opts && 'growable' in opts ? opts.growable : true; let list = null; - if (growable) { + if (dart.notNull(growable)) { list = core.List$(E).new(); list.length = this.length; } else { @@ -3049,7 +3049,7 @@ var math = dart.lazyImport(math); let element = this[_table][dartx.get](i); let remove = core.identical(removeMatching, test(element)); this[_checkModification](modificationCount); - if (remove) { + if (dart.notNull(remove)) { i = this[_remove](i); modificationCount = this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1; } else { @@ -3600,7 +3600,7 @@ var math = dart.lazyImport(math); forEach(f) { dart.as(f, dart.functionType(dart.void, [K, V])); let nodes = new (_SplayTreeNodeIterator$(K))(this); - while (nodes.moveNext()) { + while (dart.notNull(nodes.moveNext())) { let node = dart.as(nodes.current, _SplayTreeMapNode$(K, V)); f(node.key, node.value); } @@ -3624,7 +3624,7 @@ var math = dart.lazyImport(math); if (initialSplayCount != this[_splayCount]) { throw new core.ConcurrentModificationError(this); } - if (dart.notNull(node.right != null) && dart.notNull(visit(dart.as(node.right, _SplayTreeMapNode)))) + if (node.right != null && dart.notNull(visit(dart.as(node.right, _SplayTreeMapNode)))) return true; node = dart.as(node.left, _SplayTreeMapNode); } @@ -3775,11 +3775,11 @@ var math = dart.lazyImport(math); if (this[_modificationCount] != this[_tree][_modificationCount]) { throw new core.ConcurrentModificationError(this[_tree]); } - if (this[_workList][dartx.isEmpty]) { + if (dart.notNull(this[_workList][dartx.isEmpty])) { this[_currentNode] = null; return false; } - if (this[_tree][_splayCount] != this[_splayCount] && dart.notNull(this[_currentNode] != null)) { + if (this[_tree][_splayCount] != this[_splayCount] && this[_currentNode] != null) { this[_rebuildWorkList](this[_currentNode]); } this[_currentNode] = this[_workList][dartx.removeLast](); @@ -3999,7 +3999,7 @@ var math = dart.lazyImport(math); } removeAll(elements) { for (let element of elements) { - if (this[_validKey](element)) + if (dart.notNull(this[_validKey](element))) this[_remove](dart.as(element, E)); } } @@ -4030,7 +4030,7 @@ var math = dart.lazyImport(math); intersection(other) { let result = new (SplayTreeSet$(E))(this[_comparator], this[_validKey]); for (let element of this) { - if (other.contains(element)) + if (dart.notNull(other.contains(element))) result.add(element); } return result; @@ -4140,10 +4140,10 @@ var math = dart.lazyImport(math); return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => this.get(each), V, [core.Object])); } containsKey(key) { - if (_HashMap$()._isStringKey(key)) { + if (dart.notNull(_HashMap$()._isStringKey(key))) { let strings = this[_strings]; return strings == null ? false : _HashMap$()._hasTableEntry(strings, key); - } else if (_HashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_HashMap$()._isNumericKey(key))) { let nums = this[_nums]; return nums == null ? false : _HashMap$()._hasTableEntry(nums, key); } else { @@ -4169,10 +4169,10 @@ var math = dart.lazyImport(math); }, core.Object, [K, V])); } get(key) { - if (_HashMap$()._isStringKey(key)) { + if (dart.notNull(_HashMap$()._isStringKey(key))) { let strings = this[_strings]; return strings == null ? null : dart.as(_HashMap$()._getTableEntry(strings, key), V); - } else if (_HashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_HashMap$()._isNumericKey(key))) { let nums = this[_nums]; return nums == null ? null : dart.as(_HashMap$()._getTableEntry(nums, key), V); } else { @@ -4190,12 +4190,12 @@ var math = dart.lazyImport(math); set(key, value) { dart.as(key, K); dart.as(value, V); - if (_HashMap$()._isStringKey(key)) { + if (dart.notNull(_HashMap$()._isStringKey(key))) { let strings = this[_strings]; if (strings == null) this[_strings] = strings = _HashMap$()._newHashTable(); this[_addHashTableEntry](strings, key, value); - } else if (_HashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_HashMap$()._isNumericKey(key))) { let nums = this[_nums]; if (nums == null) this[_nums] = nums = _HashMap$()._newHashTable(); @@ -4230,16 +4230,16 @@ var math = dart.lazyImport(math); putIfAbsent(key, ifAbsent) { dart.as(key, K); dart.as(ifAbsent, dart.functionType(V, [])); - if (this.containsKey(key)) + if (dart.notNull(this.containsKey(key))) return this.get(key); let value = ifAbsent(); this.set(key, value); return value; } remove(key) { - if (_HashMap$()._isStringKey(key)) { + if (dart.notNull(_HashMap$()._isStringKey(key))) { return this[_removeHashTableEntry](this[_strings], key); - } else if (_HashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_HashMap$()._isNumericKey(key))) { return this[_removeHashTableEntry](this[_nums], key); } else { return this[_remove](key); @@ -4327,7 +4327,7 @@ var math = dart.lazyImport(math); _HashMap$()._setTableEntry(table, key, value); } [_removeHashTableEntry](table, key) { - if (dart.notNull(table != null) && dart.notNull(_HashMap$()._hasTableEntry(table, key))) { + if (table != null && dart.notNull(_HashMap$()._hasTableEntry(table, key))) { let value = dart.as(_HashMap$()._getTableEntry(table, key), V); _HashMap$()._deleteTableEntry(table, key); this[_length] = dart.notNull(this[_length]) - 1; @@ -4338,7 +4338,7 @@ var math = dart.lazyImport(math); } } static _isStringKey(key) { - return typeof key == 'string' && dart.notNull(!dart.equals(key, '__proto__')); + return typeof key == 'string' && !dart.equals(key, '__proto__'); } static _isNumericKey(key) { return dart.is(key, core.num) && (key & 0x3ffffff) === key; @@ -4437,7 +4437,7 @@ var math = dart.lazyImport(math); return -1; let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) { - if (core.identical(bucket[i], key)) + if (dart.notNull(core.identical(bucket[i], key))) return i; } return -1; @@ -4484,7 +4484,7 @@ var math = dart.lazyImport(math); return -1; let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 2) { - if (this[_equals](dart.as(bucket[i], K), dart.as(key, K))) + if (dart.notNull(this[_equals](dart.as(bucket[i], K), dart.as(key, K)))) return i; } return -1; @@ -4616,13 +4616,13 @@ var math = dart.lazyImport(math); return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => this.get(each), V, [core.Object])); } containsKey(key) { - if (_LinkedHashMap$()._isStringKey(key)) { + if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) { let strings = this[_strings]; if (strings == null) return false; let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), LinkedHashMapCell); return cell != null; - } else if (_LinkedHashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) { let nums = this[_nums]; if (nums == null) return false; @@ -4651,13 +4651,13 @@ var math = dart.lazyImport(math); }, core.Object, [K, V])); } get(key) { - if (_LinkedHashMap$()._isStringKey(key)) { + if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) { let strings = this[_strings]; if (strings == null) return null; let cell = dart.as(_LinkedHashMap$()._getTableEntry(strings, key), LinkedHashMapCell); return cell == null ? null : dart.as(cell[_value], V); - } else if (_LinkedHashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) { let nums = this[_nums]; if (nums == null) return null; @@ -4681,12 +4681,12 @@ var math = dart.lazyImport(math); set(key, value) { dart.as(key, K); dart.as(value, V); - if (_LinkedHashMap$()._isStringKey(key)) { + if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) { let strings = this[_strings]; if (strings == null) this[_strings] = strings = _LinkedHashMap$()._newHashTable(); this[_addHashTableEntry](strings, key, value); - } else if (_LinkedHashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) { let nums = this[_nums]; if (nums == null) this[_nums] = nums = _LinkedHashMap$()._newHashTable(); @@ -4720,16 +4720,16 @@ var math = dart.lazyImport(math); putIfAbsent(key, ifAbsent) { dart.as(key, K); dart.as(ifAbsent, dart.functionType(V, [])); - if (this.containsKey(key)) + if (dart.notNull(this.containsKey(key))) return this.get(key); let value = ifAbsent(); this.set(key, value); return value; } remove(key) { - if (_LinkedHashMap$()._isStringKey(key)) { + if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) { return this[_removeHashTableEntry](this[_strings], key); - } else if (_LinkedHashMap$()._isNumericKey(key)) { + } else if (dart.notNull(_LinkedHashMap$()._isNumericKey(key))) { return this[_removeHashTableEntry](this[_nums], key); } else { return this[_remove](key); @@ -4823,7 +4823,7 @@ var math = dart.lazyImport(math); this[_modified](); } static _isStringKey(key) { - return typeof key == 'string' && dart.notNull(!dart.equals(key, '__proto__')); + return typeof key == 'string' && !dart.equals(key, '__proto__'); } static _isNumericKey(key) { return dart.is(key, core.num) && (key & 0x3ffffff) === key; @@ -4920,7 +4920,7 @@ var math = dart.lazyImport(math); let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let cell = dart.as(bucket[i], LinkedHashMapCell); - if (core.identical(cell[_key], key)) + if (dart.notNull(core.identical(cell[_key], key))) return i; } return -1; @@ -4966,7 +4966,7 @@ var math = dart.lazyImport(math); let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let cell = dart.as(bucket[i], LinkedHashMapCell); - if (this[_equals](dart.as(cell[_key], K), dart.as(key, K))) + if (dart.notNull(this[_equals](dart.as(cell[_key], K), dart.as(key, K)))) return i; } return -1; @@ -5103,10 +5103,10 @@ var math = dart.lazyImport(math); return !dart.notNull(this.isEmpty); } contains(object) { - if (_HashSet$()._isStringElement(object)) { + if (dart.notNull(_HashSet$()._isStringElement(object))) { let strings = this[_strings]; return strings == null ? false : _HashSet$()._hasTableEntry(strings, object); - } else if (_HashSet$()._isNumericElement(object)) { + } else if (dart.notNull(_HashSet$()._isNumericElement(object))) { let nums = this[_nums]; return nums == null ? false : _HashSet$()._hasTableEntry(nums, object); } else { @@ -5122,7 +5122,7 @@ var math = dart.lazyImport(math); } lookup(object) { if (dart.notNull(_HashSet$()._isStringElement(object)) || dart.notNull(_HashSet$()._isNumericElement(object))) { - return dart.as(this.contains(object) ? object : null, E); + return dart.as(dart.notNull(this.contains(object)) ? object : null, E); } return this[_lookup](object); } @@ -5138,12 +5138,12 @@ var math = dart.lazyImport(math); } add(element) { dart.as(element, E); - if (_HashSet$()._isStringElement(element)) { + if (dart.notNull(_HashSet$()._isStringElement(element))) { let strings = this[_strings]; if (strings == null) this[_strings] = strings = _HashSet$()._newHashTable(); return this[_addHashTableEntry](strings, element); - } else if (_HashSet$()._isNumericElement(element)) { + } else if (dart.notNull(_HashSet$()._isNumericElement(element))) { let nums = this[_nums]; if (nums == null) this[_nums] = nums = _HashSet$()._newHashTable(); @@ -5178,9 +5178,9 @@ var math = dart.lazyImport(math); } } remove(object) { - if (_HashSet$()._isStringElement(object)) { + if (dart.notNull(_HashSet$()._isStringElement(object))) { return this[_removeHashTableEntry](this[_strings], object); - } else if (_HashSet$()._isNumericElement(object)) { + } else if (dart.notNull(_HashSet$()._isNumericElement(object))) { return this[_removeHashTableEntry](this[_nums], object); } else { return this[_remove](object); @@ -5249,7 +5249,7 @@ var math = dart.lazyImport(math); } [_addHashTableEntry](table, element) { dart.as(element, E); - if (_HashSet$()._hasTableEntry(table, element)) + if (dart.notNull(_HashSet$()._hasTableEntry(table, element))) return false; _HashSet$()._setTableEntry(table, element, 0); this[_length] = dart.notNull(this[_length]) + 1; @@ -5257,7 +5257,7 @@ var math = dart.lazyImport(math); return true; } [_removeHashTableEntry](table, element) { - if (dart.notNull(table != null) && dart.notNull(_HashSet$()._hasTableEntry(table, element))) { + if (table != null && dart.notNull(_HashSet$()._hasTableEntry(table, element))) { _HashSet$()._deleteTableEntry(table, element); this[_length] = dart.notNull(this[_length]) - 1; this[_elements] = null; @@ -5267,7 +5267,7 @@ var math = dart.lazyImport(math); } } static _isStringElement(element) { - return typeof element == 'string' && dart.notNull(!dart.equals(element, '__proto__')); + return typeof element == 'string' && !dart.equals(element, '__proto__'); } static _isNumericElement(element) { return dart.is(element, core.num) && (element & 0x3ffffff) === element; @@ -5365,7 +5365,7 @@ var math = dart.lazyImport(math); return -1; let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { - if (core.identical(bucket[i], element)) + if (dart.notNull(core.identical(bucket[i], element))) return i; } return -1; @@ -5395,7 +5395,7 @@ var math = dart.lazyImport(math); return -1; let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { - if (this[_equality](dart.as(bucket[i], E), dart.as(element, E))) + if (dart.notNull(this[_equality](dart.as(bucket[i], E), dart.as(element, E)))) return i; } return -1; @@ -5499,13 +5499,13 @@ var math = dart.lazyImport(math); return !dart.notNull(this.isEmpty); } contains(object) { - if (_LinkedHashSet$()._isStringElement(object)) { + if (dart.notNull(_LinkedHashSet$()._isStringElement(object))) { let strings = this[_strings]; if (strings == null) return false; let cell = dart.as(_LinkedHashSet$()._getTableEntry(strings, object), LinkedHashSetCell); return cell != null; - } else if (_LinkedHashSet$()._isNumericElement(object)) { + } else if (dart.notNull(_LinkedHashSet$()._isNumericElement(object))) { let nums = this[_nums]; if (nums == null) return false; @@ -5524,7 +5524,7 @@ var math = dart.lazyImport(math); } lookup(object) { if (dart.notNull(_LinkedHashSet$()._isStringElement(object)) || dart.notNull(_LinkedHashSet$()._isNumericElement(object))) { - return dart.as(this.contains(object) ? object : null, E); + return dart.as(dart.notNull(this.contains(object)) ? object : null, E); } else { return this[_lookup](object); } @@ -5563,12 +5563,12 @@ var math = dart.lazyImport(math); } add(element) { dart.as(element, E); - if (_LinkedHashSet$()._isStringElement(element)) { + if (dart.notNull(_LinkedHashSet$()._isStringElement(element))) { let strings = this[_strings]; if (strings == null) this[_strings] = strings = _LinkedHashSet$()._newHashTable(); return this[_addHashTableEntry](strings, element); - } else if (_LinkedHashSet$()._isNumericElement(element)) { + } else if (dart.notNull(_LinkedHashSet$()._isNumericElement(element))) { let nums = this[_nums]; if (nums == null) this[_nums] = nums = _LinkedHashSet$()._newHashTable(); @@ -5597,9 +5597,9 @@ var math = dart.lazyImport(math); return true; } remove(object) { - if (_LinkedHashSet$()._isStringElement(object)) { + if (dart.notNull(_LinkedHashSet$()._isStringElement(object))) { return this[_removeHashTableEntry](this[_strings], object); - } else if (_LinkedHashSet$()._isNumericElement(object)) { + } else if (dart.notNull(_LinkedHashSet$()._isNumericElement(object))) { return this[_removeHashTableEntry](this[_nums], object); } else { return this[_remove](object); @@ -5636,7 +5636,7 @@ var math = dart.lazyImport(math); if (modifications != this[_modifications]) { throw new core.ConcurrentModificationError(this); } - if (shouldRemove) + if (dart.notNull(shouldRemove)) this.remove(element); cell = next; } @@ -5702,7 +5702,7 @@ var math = dart.lazyImport(math); this[_modified](); } static _isStringElement(element) { - return typeof element == 'string' && dart.notNull(!dart.equals(element, '__proto__')); + return typeof element == 'string' && !dart.equals(element, '__proto__'); } static _isNumericElement(element) { return dart.is(element, core.num) && (element & 0x3ffffff) === element; @@ -5810,7 +5810,7 @@ var math = dart.lazyImport(math); let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let cell = dart.as(bucket[i], LinkedHashSetCell); - if (core.identical(cell[_element], element)) + if (dart.notNull(core.identical(cell[_element], element))) return i; } return -1; @@ -5839,7 +5839,7 @@ var math = dart.lazyImport(math); let length = bucket.length; for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) { let cell = dart.as(bucket[i], LinkedHashSetCell); - if (this[_equality](dart.as(cell[_element], E), dart.as(element, E))) + if (dart.notNull(this[_equality](dart.as(cell[_element], E), dart.as(element, E)))) return i; } return -1; @@ -5875,7 +5875,7 @@ var math = dart.lazyImport(math); } removeAll(elements) { for (let element of elements) { - if (this[_validKey](element)) { + if (dart.notNull(this[_validKey](element))) { super[_remove](element); } } diff --git a/pkg/dev_compiler/lib/runtime/dart/convert.js b/pkg/dev_compiler/lib/runtime/dart/convert.js index 95e6904ca147..8d7498043298 100644 --- a/pkg/dev_compiler/lib/runtime/dart/convert.js +++ b/pkg/dev_compiler/lib/runtime/dart/convert.js @@ -74,7 +74,7 @@ var collection = dart.import(collection); let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : null; if (allowInvalid == null) allowInvalid = this[_allowInvalid]; - if (allowInvalid) { + if (dart.notNull(allowInvalid)) { return dart.const(new AsciiDecoder({allowInvalid: true})).convert(bytes); } else { return dart.const(new AsciiDecoder({allowInvalid: false})).convert(bytes); @@ -84,7 +84,7 @@ var collection = dart.import(collection); return dart.const(new AsciiEncoder()); } get decoder() { - return this[_allowInvalid] ? dart.const(new AsciiDecoder({allowInvalid: true})) : dart.const(new AsciiDecoder({allowInvalid: false})); + return dart.notNull(this[_allowInvalid]) ? dart.const(new AsciiDecoder({allowInvalid: true})) : dart.const(new AsciiDecoder({allowInvalid: false})); } } dart.setSignature(AsciiCodec, { @@ -212,7 +212,7 @@ var collection = dart.import(collection); } } this[_sink].add(source[dartx.codeUnits][dartx.sublist](start, end)); - if (isLast) { + if (dart.notNull(isLast)) { this.close(); } } @@ -286,7 +286,7 @@ var collection = dart.import(collection); } else { stringSink = StringConversionSink.from(sink); } - if (this[_allowInvalid]) { + if (dart.notNull(this[_allowInvalid])) { return new _ErrorHandlingAsciiDecoderSink(stringSink.asUtf8Sink(false)); } else { return new _SimpleAsciiDecoderSink(stringSink); @@ -339,7 +339,7 @@ var collection = dart.import(collection); } addSlice(chunk, start, end, isLast) { this.add(chunk[dartx.sublist](start, end)); - if (isLast) + if (dart.notNull(isLast)) this.close(); } } @@ -369,7 +369,7 @@ var collection = dart.import(collection); } if (dart.notNull(start) < dart.notNull(end)) { this[_utf8Sink].addSlice(source, start, end, isLast); - } else if (isLast) { + } else if (dart.notNull(isLast)) { this.close(); } } @@ -405,7 +405,7 @@ var collection = dart.import(collection); } this.add(source); } - if (isLast) + if (dart.notNull(isLast)) this.close(); } } @@ -693,31 +693,31 @@ var collection = dart.import(collection); } case '"': { - if (this.mode.escapeQuot) + if (dart.notNull(this.mode.escapeQuot)) replace = '"'; break; } case "'": { - if (this.mode.escapeApos) + if (dart.notNull(this.mode.escapeApos)) replace = '''; break; } case '<': { - if (this.mode.escapeLtGt) + if (dart.notNull(this.mode.escapeLtGt)) replace = '<'; break; } case '>': { - if (this.mode.escapeLtGt) + if (dart.notNull(this.mode.escapeLtGt)) replace = '>'; break; } case '/': { - if (this.mode.escapeSlash) + if (dart.notNull(this.mode.escapeSlash)) replace = '/'; break; } @@ -762,7 +762,7 @@ var collection = dart.import(collection); this[_sink].addSlice(chunk, start, end, isLast); } else { this[_sink].add(val); - if (isLast) + if (dart.notNull(isLast)) this[_sink].close(); } } @@ -927,7 +927,7 @@ var collection = dart.import(collection); static _utf8Encode(string) { if (string == null) return null; - if (string[dartx.isEmpty]) + if (dart.notNull(string[dartx.isEmpty])) return typed_data.Uint8List.new(0); checkAscii: { for (let i = 0; dart.notNull(i) < dart.notNull(string.length); i = dart.notNull(i) + 1) { @@ -1002,7 +1002,7 @@ var collection = dart.import(collection); super.ChunkedConversionSink(); } add(o) { - if (this[_isDone]) { + if (dart.notNull(this[_isDone])) { throw new core.StateError("Only one call to add allowed"); } this[_isDone] = true; @@ -1033,7 +1033,7 @@ var collection = dart.import(collection); this[_sink].addSlice(chunk, start, end, false); } add(object) { - if (this[_isDone]) { + if (dart.notNull(this[_isDone])) { throw new core.StateError("Only one call to add allowed"); } this[_isDone] = true; @@ -1176,7 +1176,7 @@ var collection = dart.import(collection); } [_checkCycle](object) { for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen].length); i = dart.notNull(i) + 1) { - if (core.identical(object, this[_seen][dartx.get](i))) { + if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) { throw new JsonCyclicError(object); } } @@ -1188,7 +1188,7 @@ var collection = dart.import(collection); this[_seen][dartx.removeLast](); } writeObject(object) { - if (this.writeJsonValue(object)) + if (dart.notNull(this.writeJsonValue(object))) return; this[_checkCycle](object); try { @@ -1204,14 +1204,14 @@ var collection = dart.import(collection); } writeJsonValue(object) { if (dart.is(object, core.num)) { - if (dart.dsend(dart.dload(object, 'isFinite'), '!')) + if (!dart.notNull(dart.as(dart.dload(object, 'isFinite'), core.bool))) return false; this.writeNumber(dart.as(object, core.num)); return true; - } else if (core.identical(object, true)) { + } else if (dart.notNull(core.identical(object, true))) { this.writeString('true'); return true; - } else if (core.identical(object, false)) { + } else if (dart.notNull(core.identical(object, false))) { this.writeString('false'); return true; } else if (object == null) { @@ -1294,7 +1294,7 @@ var collection = dart.import(collection); this[_indentLevel] = 0; } writeList(list) { - if (list[dartx.isEmpty]) { + if (dart.notNull(list[dartx.isEmpty])) { this.writeString('[]'); } else { this.writeString('[\n'); @@ -1313,7 +1313,7 @@ var collection = dart.import(collection); } } writeMap(map) { - if (map.isEmpty) { + if (dart.notNull(map.isEmpty)) { this.writeString('{}'); } else { this.writeString('{\n'); @@ -1569,7 +1569,7 @@ var collection = dart.import(collection); let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : null; if (allowInvalid == null) allowInvalid = this[_allowInvalid]; - if (allowInvalid) { + if (dart.notNull(allowInvalid)) { return dart.const(new Latin1Decoder({allowInvalid: true})).convert(bytes); } else { return dart.const(new Latin1Decoder({allowInvalid: false})).convert(bytes); @@ -1579,7 +1579,7 @@ var collection = dart.import(collection); return dart.const(new Latin1Encoder()); } get decoder() { - return this[_allowInvalid] ? dart.const(new Latin1Decoder({allowInvalid: true})) : dart.const(new Latin1Decoder({allowInvalid: false})); + return dart.notNull(this[_allowInvalid]) ? dart.const(new Latin1Decoder({allowInvalid: true})) : dart.const(new Latin1Decoder({allowInvalid: false})); } } dart.setSignature(Latin1Codec, { @@ -1630,7 +1630,7 @@ var collection = dart.import(collection); } [_addSliceToSink](source, start, end, isLast) { this[_sink].add(core.String.fromCharCodes(source, start, end)); - if (isLast) + if (dart.notNull(isLast)) this.close(); } addSlice(source, start, end, isLast) { @@ -1644,7 +1644,7 @@ var collection = dart.import(collection); if (dart.notNull(start) < dart.notNull(end)) { this[_addSliceToSink](source, start, end, isLast); } - if (isLast) { + if (dart.notNull(isLast)) { this.close(); } } @@ -1675,7 +1675,7 @@ var collection = dart.import(collection); if (dart.notNull(start) < dart.notNull(end)) { this[_addSliceToSink](source, start, end, isLast); } - if (isLast) { + if (dart.notNull(isLast)) { this.close(); } } @@ -1720,7 +1720,7 @@ var collection = dart.import(collection); this[_carry] = null; } this[_carry] = _LineSplitterSink._addSlice(chunk, start, end, isLast, dart.bind(this[_sink], 'add')); - if (isLast) + if (dart.notNull(isLast)) this[_sink].close(); } close() { @@ -1752,7 +1752,7 @@ var collection = dart.import(collection); } if (pos != start) { let carry = chunk[dartx.substring](start, pos); - if (isLast) { + if (dart.notNull(isLast)) { adder(carry); } else { return carry; @@ -1846,7 +1846,7 @@ var collection = dart.import(collection); this[_buffer] = new core.StringBuffer(); } close() { - if (this[_buffer].isNotEmpty) + if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush](); this[_chunkedSink].close(); } @@ -1856,7 +1856,7 @@ var collection = dart.import(collection); this[_flush](); } write(o) { - if (this[_buffer].isNotEmpty) + if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush](); let str = dart.toString(o); this[_chunkedSink].add(dart.toString(o)); @@ -1871,18 +1871,18 @@ var collection = dart.import(collection); writeAll(objects, separator) { if (separator === void 0) separator = ""; - if (this[_buffer].isNotEmpty) + if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush](); let iterator = objects[dartx.iterator]; if (!dart.notNull(iterator.moveNext())) return; - if (separator[dartx.isEmpty]) { + if (dart.notNull(separator[dartx.isEmpty])) { do { this[_chunkedSink].add(dart.toString(iterator.current)); - } while (iterator.moveNext()); + } while (dart.notNull(iterator.moveNext())); } else { this[_chunkedSink].add(dart.toString(iterator.current)); - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { this.write(separator); this[_chunkedSink].add(dart.toString(iterator.current)); } @@ -1921,7 +1921,7 @@ var collection = dart.import(collection); } else { this[_stringSink].write(str); } - if (isLast) + if (dart.notNull(isLast)) this.close(); } add(str) { @@ -1972,7 +1972,7 @@ var collection = dart.import(collection); } else { this.add(str[dartx.substring](start, end)); } - if (isLast) + if (dart.notNull(isLast)) this.close(); } close() { @@ -2003,7 +2003,7 @@ var collection = dart.import(collection); } addSlice(codeUnits, startIndex, endIndex, isLast) { this[_decoder].convert(codeUnits, startIndex, endIndex); - if (isLast) + if (dart.notNull(isLast)) this.close(); } } @@ -2027,7 +2027,7 @@ var collection = dart.import(collection); } close() { this[_decoder].close(); - if (this[_buffer].isNotEmpty) { + if (dart.notNull(this[_buffer].isNotEmpty)) { let accumulated = dart.toString(this[_buffer]); this[_buffer].clear(); this[_chunkedSink].addSlice(accumulated, 0, accumulated.length, true); @@ -2040,13 +2040,13 @@ var collection = dart.import(collection); } addSlice(chunk, startIndex, endIndex, isLast) { this[_decoder].convert(chunk, startIndex, endIndex); - if (this[_buffer].isNotEmpty) { + if (dart.notNull(this[_buffer].isNotEmpty)) { let accumulated = dart.toString(this[_buffer]); this[_chunkedSink].addSlice(accumulated, 0, accumulated.length, isLast); this[_buffer].clear(); return; } - if (isLast) + if (dart.notNull(isLast)) this.close(); } } @@ -2152,7 +2152,7 @@ var collection = dart.import(collection); return typed_data.Uint8List.new(size); } [_writeSurrogate](leadingSurrogate, nextCodeUnit) { - if (_isTailSurrogate(nextCodeUnit)) { + if (dart.notNull(_isTailSurrogate(nextCodeUnit))) { let rune = _combineSurrogatePair(leadingSurrogate, nextCodeUnit); dart.assert(dart.notNull(rune) > dart.notNull(_THREE_BYTE_LIMIT)); dart.assert(dart.notNull(rune) <= dart.notNull(_FOUR_BYTE_LIMIT)); @@ -2211,12 +2211,12 @@ var collection = dart.import(collection); this[_bufferIndex] = dart.notNull(x) + 1; return x; })(), codeUnit); - } else if (_isLeadSurrogate(codeUnit)) { + } else if (dart.notNull(_isLeadSurrogate(codeUnit))) { if (dart.notNull(this[_bufferIndex]) + 3 >= dart.notNull(this[_buffer].length)) break; let nextCodeUnit = str[dartx.codeUnitAt](dart.notNull(stringIndex) + 1); let wasCombined = this[_writeSurrogate](codeUnit, nextCodeUnit); - if (wasCombined) { + if (dart.notNull(wasCombined)) { stringIndex = dart.notNull(stringIndex) + 1; } } else { @@ -2299,7 +2299,7 @@ var collection = dart.import(collection); } let wasCombined = this[_writeSurrogate](this[_carry], nextCodeUnit); dart.assert(!dart.notNull(wasCombined) || start != end); - if (wasCombined) { + if (dart.notNull(wasCombined)) { start = dart.notNull(start) + 1; } this[_carry] = 0; @@ -2319,7 +2319,7 @@ var collection = dart.import(collection); this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice); this[_bufferIndex] = 0; } while (dart.notNull(start) < dart.notNull(end)); - if (isLast) + if (dart.notNull(isLast)) this.close(); } } @@ -2421,7 +2421,7 @@ var collection = dart.import(collection); this.flush(); } flush() { - if (this.hasPartialInput) { + if (dart.notNull(this.hasPartialInput)) { if (!dart.notNull(this[_allowMalformed])) { throw new core.FormatException("Unfinished UTF-8 octet sequence"); } @@ -2619,19 +2619,19 @@ var collection = dart.import(collection); this[_data] = null; } get(key) { - if (this[_isUpgraded]) { + if (dart.notNull(this[_isUpgraded])) { return this[_upgradedMap].get(key); } else if (!(typeof key == 'string')) { return null; } else { let result = _JsonMap._getProperty(this[_processed], dart.as(key, core.String)); - if (_JsonMap._isUnprocessed(result)) + if (dart.notNull(_JsonMap._isUnprocessed(result))) result = this[_process](dart.as(key, core.String)); return result; } } get length() { - return this[_isUpgraded] ? this[_upgradedMap].length : this[_computeKeys]().length; + return dart.notNull(this[_isUpgraded]) ? this[_upgradedMap].length : this[_computeKeys]().length; } get isEmpty() { return this.length == 0; @@ -2640,19 +2640,19 @@ var collection = dart.import(collection); return dart.notNull(this.length) > 0; } get keys() { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].keys; return new _JsonMapKeyIterable(this); } get values() { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].values; return _internal.MappedIterable.new(this[_computeKeys](), dart.fn(each => this.get(each))); } set(key, value) { - if (this[_isUpgraded]) { + if (dart.notNull(this[_isUpgraded])) { this[_upgradedMap].set(key, value); - } else if (this.containsKey(key)) { + } else if (dart.notNull(this.containsKey(key))) { let processed = this[_processed]; _JsonMap._setProperty(processed, dart.as(key, core.String), value); let original = this[_original]; @@ -2669,7 +2669,7 @@ var collection = dart.import(collection); })); } containsValue(value) { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].containsValue(value); let keys = this[_computeKeys](); for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notNull(i) + 1) { @@ -2680,14 +2680,14 @@ var collection = dart.import(collection); return false; } containsKey(key) { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].containsKey(key); if (!(typeof key == 'string')) return false; return _JsonMap._hasProperty(this[_original], dart.as(key, core.String)); } putIfAbsent(key, ifAbsent) { - if (this.containsKey(key)) + if (dart.notNull(this.containsKey(key))) return this.get(key); let value = ifAbsent(); this.set(key, value); @@ -2699,7 +2699,7 @@ var collection = dart.import(collection); return this[_upgrade]().remove(key); } clear() { - if (this[_isUpgraded]) { + if (dart.notNull(this[_isUpgraded])) { this[_upgradedMap].clear(); } else { if (this[_data] != null) { @@ -2710,13 +2710,13 @@ var collection = dart.import(collection); } } forEach(f) { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].forEach(f); let keys = this[_computeKeys](); for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notNull(i) + 1) { let key = keys[dartx.get](i); let value = _JsonMap._getProperty(this[_processed], key); - if (_JsonMap._isUnprocessed(value)) { + if (dart.notNull(_JsonMap._isUnprocessed(value))) { value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key)); _JsonMap._setProperty(this[_processed], key, value); } @@ -2745,7 +2745,7 @@ var collection = dart.import(collection); return dart.as(keys, core.List$(core.String)); } [_upgrade]() { - if (this[_isUpgraded]) + if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap]; let result = dart.map(); let keys = this[_computeKeys](); @@ -2753,7 +2753,7 @@ var collection = dart.import(collection); let key = keys[dartx.get](i); result.set(key, this.get(key)); } - if (keys[dartx.isEmpty]) { + if (dart.notNull(keys[dartx.isEmpty])) { keys[dartx.add](null); } else { keys[dartx.clear](); @@ -2825,10 +2825,10 @@ var collection = dart.import(collection); return this[_parent].length; } elementAt(index) { - return this[_parent][_isUpgraded] ? dart.as(this[_parent].keys[dartx.elementAt](index), core.String) : this[_parent][_computeKeys]()[dartx.get](index); + return dart.notNull(this[_parent][_isUpgraded]) ? dart.as(this[_parent].keys[dartx.elementAt](index), core.String) : this[_parent][_computeKeys]()[dartx.get](index); } get iterator() { - return this[_parent][_isUpgraded] ? this[_parent].keys[dartx.iterator] : this[_parent][_computeKeys]()[dartx.iterator]; + return dart.notNull(this[_parent][_isUpgraded]) ? this[_parent].keys[dartx.iterator] : this[_parent][_computeKeys]()[dartx.iterator]; } contains(key) { return this[_parent].containsKey(key); diff --git a/pkg/dev_compiler/lib/runtime/dart/core.js b/pkg/dev_compiler/lib/runtime/dart/core.js index b6f2913d5874..21455b57da6b 100644 --- a/pkg/dev_compiler/lib/runtime/dart/core.js +++ b/pkg/dev_compiler/lib/runtime/dart/core.js @@ -174,7 +174,7 @@ var convert = dart.lazyImport(convert); if (millisecondsSinceEpoch == null) { throw new FormatException("Time out of range", formattedString); } - if (addOneMillisecond) { + if (dart.notNull(addOneMillisecond)) { millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1; } return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, {isUtc: isUtc}); @@ -213,13 +213,13 @@ var convert = dart.lazyImport(convert); return this.millisecondsSinceEpoch; } toLocal() { - if (this.isUtc) { + if (dart.notNull(this.isUtc)) { return new DateTime.fromMillisecondsSinceEpoch(this.millisecondsSinceEpoch, {isUtc: false}); } return this; } toUtc() { - if (this.isUtc) + if (dart.notNull(this.isUtc)) return this; return new DateTime.fromMillisecondsSinceEpoch(this.millisecondsSinceEpoch, {isUtc: true}); } @@ -262,7 +262,7 @@ var convert = dart.lazyImport(convert); let min = DateTime._twoDigits(this.minute); let sec = DateTime._twoDigits(this.second); let ms = DateTime._threeDigits(this.millisecond); - if (this.isUtc) { + if (dart.notNull(this.isUtc)) { return `${y}-${m}-${d} ${h}:${min}:${sec}.${ms}Z`; } else { return `${y}-${m}-${d} ${h}:${min}:${sec}.${ms}`; @@ -276,7 +276,7 @@ var convert = dart.lazyImport(convert); let min = DateTime._twoDigits(this.minute); let sec = DateTime._twoDigits(this.second); let ms = DateTime._threeDigits(this.millisecond); - if (this.isUtc) { + if (dart.notNull(this.isUtc)) { return `${y}-${m}-${d}T${h}:${min}:${sec}.${ms}Z`; } else { return `${y}-${m}-${d}T${h}:${min}:${sec}.${ms}`; @@ -307,12 +307,12 @@ var convert = dart.lazyImport(convert); return dart.as(_js_helper.Primitives.valueFromDecomposedDate(year, month, day, hour, minute, second, millisecond, isUtc), int); } get timeZoneName() { - if (this.isUtc) + if (dart.notNull(this.isUtc)) return "UTC"; return _js_helper.Primitives.getTimeZoneName(this); } get timeZoneOffset() { - if (this.isUtc) + if (dart.notNull(this.isUtc)) return new Duration(); return new Duration({minutes: _js_helper.Primitives.getTimeZoneOffsetInMinutes(this)}); } @@ -602,7 +602,7 @@ var convert = dart.lazyImport(convert); Error() { } static safeToString(object) { - if (dart.is(object, num) || typeof object == 'boolean' || dart.notNull(null == object)) { + if (dart.is(object, num) || typeof object == 'boolean' || null == object) { return dart.toString(object); } if (typeof object == 'string') { @@ -836,7 +836,7 @@ var convert = dart.lazyImport(convert); dart.assert(this[_hasValue]); let target = Error.safeToString(this.indexable); let explanation = `index should be less than ${this.length}`; - if (dart.dsend(this.invalidValue, '<', 0)) { + if (dart.notNull(dart.as(dart.dsend(this.invalidValue, '<', 0), bool))) { explanation = "index must not be negative"; } return `RangeError: ${this.message} (${target}[${this.invalidValue}]): ${explanation}`; @@ -1413,7 +1413,7 @@ var convert = dart.lazyImport(convert); } static filled(length, fill) { let result = List$(E).new(length); - if (length != 0 && dart.notNull(fill != null)) { + if (length != 0 && fill != null) { for (let i = 0; dart.notNull(i) < dart.notNull(result.length); i = dart.notNull(i) + 1) { result[dartx.set](i, fill); } @@ -1426,14 +1426,14 @@ var convert = dart.lazyImport(convert); for (let e of elements) { list[dartx.add](dart.as(e, E)); } - if (growable) + if (dart.notNull(growable)) return list; return dart.as(_internal.makeListFixedLength(list), List$(E)); } static generate(length, generator, opts) { let growable = opts && 'growable' in opts ? opts.growable : true; let result = null; - if (growable) { + if (dart.notNull(growable)) { result = dart.list([], E); result.length = length; } else { @@ -1564,7 +1564,7 @@ var convert = dart.lazyImport(convert); Stopwatch._initTicker(); } start() { - if (this.isRunning) + if (dart.notNull(this.isRunning)) return; if (this[_start] == null) { this[_start] = Stopwatch._now(); @@ -1671,7 +1671,7 @@ var convert = dart.lazyImport(convert); } let list = []; if (end == null) { - while (it.moveNext()) + while (dart.notNull(it.moveNext())) list[dartx.add](it.current); } else { for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) + 1) { @@ -1712,7 +1712,7 @@ var convert = dart.lazyImport(convert); let code = this.string[dartx.codeUnitAt](dart.notNull(length) - 1); if (dart.notNull(_isTrailSurrogate(code)) && dart.notNull(this.string.length) > 1) { let previousCode = this.string[dartx.codeUnitAt](dart.notNull(length) - 2); - if (_isLeadSurrogate(previousCode)) { + if (dart.notNull(_isLeadSurrogate(previousCode))) { return _combineSurrogatePair(previousCode, code); } } @@ -1800,7 +1800,7 @@ var convert = dart.lazyImport(convert); let nextPosition = dart.notNull(this[_position]) + 1; if (dart.notNull(_isLeadSurrogate(codeUnit)) && dart.notNull(nextPosition) < dart.notNull(this.string.length)) { let nextCodeUnit = this.string[dartx.codeUnitAt](nextPosition); - if (_isTrailSurrogate(nextCodeUnit)) { + if (dart.notNull(_isTrailSurrogate(nextCodeUnit))) { this[_nextPosition] = dart.notNull(nextPosition) + 1; this[_currentCodePoint] = _combineSurrogatePair(codeUnit, nextCodeUnit); return true; @@ -1820,7 +1820,7 @@ var convert = dart.lazyImport(convert); let codeUnit = this.string[dartx.codeUnitAt](position); if (dart.notNull(_isTrailSurrogate(codeUnit)) && dart.notNull(position) > 0) { let prevCodeUnit = this.string[dartx.codeUnitAt](dart.notNull(position) - 1); - if (_isLeadSurrogate(prevCodeUnit)) { + if (dart.notNull(_isLeadSurrogate(prevCodeUnit))) { this[_position] = dart.notNull(position) - 1; this[_currentCodePoint] = _combineSurrogatePair(prevCodeUnit, codeUnit); return true; @@ -1874,13 +1874,13 @@ var convert = dart.lazyImport(convert); let iterator = objects[dartx.iterator]; if (!dart.notNull(iterator.moveNext())) return; - if (separator[dartx.isEmpty]) { + if (dart.notNull(separator[dartx.isEmpty])) { do { this.write(iterator.current); - } while (iterator.moveNext()); + } while (dart.notNull(iterator.moveNext())); } else { this.write(iterator.current); - while (iterator.moveNext()) { + while (dart.notNull(iterator.moveNext())) { this.write(separator); this.write(iterator.current); } @@ -1953,7 +1953,7 @@ var convert = dart.lazyImport(convert); get host() { if (this[_host] == null) return ""; - if (this[_host][dartx.startsWith]('[')) { + if (dart.notNull(this[_host][dartx.startsWith]('['))) { return this[_host][dartx.substring](1, dart.notNull(this[_host].length) - 1); } return this[_host]; @@ -1981,7 +1981,7 @@ var convert = dart.lazyImport(convert); } static parse(uri) { let isRegName = ch => { - return dart.notNull(ch) < 128 && dart.notNull(!dart.equals(dart.dsend(Uri._regNameTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0)); + return dart.notNull(ch) < 128 && !dart.equals(dart.dsend(Uri._regNameTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0); }; dart.fn(isRegName, bool, [int]); let EOI = -1; @@ -2227,7 +2227,7 @@ var convert = dart.lazyImport(convert); for (; dart.notNull(hostEnd) < dart.notNull(authority.length); hostEnd = dart.notNull(hostEnd) + 1) { if (authority[dartx.codeUnitAt](hostEnd) == Uri._COLON) { let portString = authority[dartx.substring](dart.notNull(hostEnd) + 1); - if (portString[dartx.isNotEmpty]) + if (dart.notNull(portString[dartx.isNotEmpty])) port = int.parse(portString); break; } @@ -2239,7 +2239,7 @@ var convert = dart.lazyImport(convert); static file(path, opts) { let windows = opts && 'windows' in opts ? opts.windows : null; windows = windows == null ? Uri._isWindows : windows; - return windows ? dart.as(Uri._makeWindowsFileUrl(path), Uri) : dart.as(Uri._makeFileUri(path), Uri); + return dart.notNull(windows) ? dart.as(Uri._makeWindowsFileUrl(path), Uri) : dart.as(Uri._makeFileUri(path), Uri); } static get base() { let uri = _js_helper.Primitives.currentUri(); @@ -2252,8 +2252,8 @@ var convert = dart.lazyImport(convert); } static _checkNonWindowsPathReservedCharacters(segments, argumentError) { segments[dartx.forEach](dart.fn(segment => { - if (dart.dsend(segment, 'contains', "/")) { - if (argumentError) { + if (dart.notNull(dart.as(dart.dsend(segment, 'contains', "/"), bool))) { + if (dart.notNull(argumentError)) { throw new ArgumentError(`Illegal path character ${segment}`); } else { throw new UnsupportedError(`Illegal path character ${segment}`); @@ -2265,8 +2265,8 @@ var convert = dart.lazyImport(convert); if (firstSegment === void 0) firstSegment = 0; segments[dartx.skip](firstSegment)[dartx.forEach](dart.fn(segment => { - if (dart.dsend(segment, 'contains', RegExp.new('["*/:<>?\\\\|]'))) { - if (argumentError) { + if (dart.notNull(dart.as(dart.dsend(segment, 'contains', RegExp.new('["*/:<>?\\\\|]')), bool))) { + if (dart.notNull(argumentError)) { throw new ArgumentError("Illegal character in path"); } else { throw new UnsupportedError("Illegal character in path"); @@ -2278,7 +2278,7 @@ var convert = dart.lazyImport(convert); if (dart.notNull(Uri._UPPER_CASE_A) <= dart.notNull(charCode) && dart.notNull(charCode) <= dart.notNull(Uri._UPPER_CASE_Z) || dart.notNull(Uri._LOWER_CASE_A) <= dart.notNull(charCode) && dart.notNull(charCode) <= dart.notNull(Uri._LOWER_CASE_Z)) { return; } - if (argumentError) { + if (dart.notNull(argumentError)) { throw new ArgumentError("Illegal drive letter " + dart.notNull(String.fromCharCode(charCode))); } else { throw new UnsupportedError("Illegal drive letter " + dart.notNull(String.fromCharCode(charCode))); @@ -2286,15 +2286,15 @@ var convert = dart.lazyImport(convert); } static _makeFileUri(path) { let sep = "/"; - if (path[dartx.startsWith](sep)) { + if (dart.notNull(path[dartx.startsWith](sep))) { return Uri.new({scheme: "file", pathSegments: path[dartx.split](sep)}); } else { return Uri.new({pathSegments: path[dartx.split](sep)}); } } static _makeWindowsFileUrl(path) { - if (path[dartx.startsWith]("\\\\?\\")) { - if (path[dartx.startsWith]("\\\\?\\UNC\\")) { + if (dart.notNull(path[dartx.startsWith]("\\\\?\\"))) { + if (dart.notNull(path[dartx.startsWith]("\\\\?\\UNC\\"))) { path = `\\${path[dartx.substring](7)}`; } else { path = path[dartx.substring](4); @@ -2361,19 +2361,19 @@ var convert = dart.lazyImport(convert); port = Uri._makePort(port, scheme); } else { port = this[_port]; - if (schemeChanged) { + if (dart.notNull(schemeChanged)) { port = Uri._makePort(port, scheme); } } if (host != null) { host = Uri._makeHost(host, 0, host.length, false); - } else if (this.hasAuthority) { + } else if (dart.notNull(this.hasAuthority)) { host = this.host; } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || dart.notNull(isFile)) { host = ""; } let ensureLeadingSlash = host != null; - if (path != null || dart.notNull(pathSegments != null)) { + if (path != null || pathSegments != null) { path = Uri._makePath(path, 0, Uri._stringOrNullLength(path), pathSegments, ensureLeadingSlash, isFile); } else { path = this.path; @@ -2381,14 +2381,14 @@ var convert = dart.lazyImport(convert); path = `/${path}`; } } - if (query != null || dart.notNull(queryParameters != null)) { + if (query != null || queryParameters != null) { query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryParameters); - } else if (this.hasQuery) { + } else if (dart.notNull(this.hasQuery)) { query = this.query; } if (fragment != null) { fragment = Uri._makeFragment(fragment, 0, fragment.length); - } else if (this.hasFragment) { + } else if (dart.notNull(this.hasFragment)) { fragment = this.fragment; } return new Uri._internal(scheme, userInfo, host, port, path, query, fragment); @@ -2434,7 +2434,7 @@ var convert = dart.lazyImport(convert); return Uri._normalizeRegName(host, start, end); } static _isRegNameChar(char) { - return dart.notNull(char) < 127 && dart.notNull(!dart.equals(dart.dsend(Uri._regNameTable[dartx.get](dart.notNull(char) >> 4), '&', 1 << (dart.notNull(char) & 15)), 0)); + return dart.notNull(char) < 127 && !dart.equals(dart.dsend(Uri._regNameTable[dartx.get](dart.notNull(char) >> 4), '&', 1 << (dart.notNull(char) & 15)), 0); } static _normalizeRegName(host, start, end) { let buffer = null; @@ -2466,7 +2466,7 @@ var convert = dart.lazyImport(convert); index = dart.notNull(index) + dart.notNull(sourceLength); sectionStart = index; isNormalized = true; - } else if (Uri._isRegNameChar(char)) { + } else if (dart.notNull(Uri._isRegNameChar(char))) { if (dart.notNull(isNormalized) && dart.notNull(Uri._UPPER_CASE_A) <= dart.notNull(char) && dart.notNull(Uri._UPPER_CASE_Z) >= dart.notNull(char)) { if (buffer == null) buffer = new StringBuffer(); @@ -2477,7 +2477,7 @@ var convert = dart.lazyImport(convert); isNormalized = false; } index = dart.notNull(index) + 1; - } else if (Uri._isGeneralDelimiter(char)) { + } else if (dart.notNull(Uri._isGeneralDelimiter(char))) { Uri._fail(host, index, "Invalid character"); } else { let sourceLength = 1; @@ -2537,9 +2537,9 @@ var convert = dart.lazyImport(convert); return Uri._normalize(userInfo, start, end, dart.as(Uri._userinfoTable, List$(int))); } static _makePath(path, start, end, pathSegments, ensureLeadingSlash, isFile) { - if (path == null && dart.notNull(pathSegments == null)) - return isFile ? "/" : ""; - if (path != null && dart.notNull(pathSegments != null)) { + if (path == null && pathSegments == null) + return dart.notNull(isFile) ? "/" : ""; + if (path != null && pathSegments != null) { throw new ArgumentError('Both path and pathSegments specified'); } let result = null; @@ -2548,18 +2548,18 @@ var convert = dart.lazyImport(convert); } else { result = pathSegments[dartx.map](dart.fn(s => Uri._uriEncode(dart.as(Uri._pathCharTable, List$(int)), dart.as(s, String)), String, [Object]))[dartx.join]("/"); } - if (dart.dload(result, 'isEmpty')) { - if (isFile) + if (dart.notNull(dart.as(dart.dload(result, 'isEmpty'), bool))) { + if (dart.notNull(isFile)) return "/"; - } else if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash)) && dart.notNull(!dart.equals(dart.dsend(result, 'codeUnitAt', 0), Uri._SLASH))) { + } else if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash)) && !dart.equals(dart.dsend(result, 'codeUnitAt', 0), Uri._SLASH)) { return `/${result}`; } return dart.as(result, String); } static _makeQuery(query, start, end, queryParameters) { - if (query == null && dart.notNull(queryParameters == null)) + if (query == null && queryParameters == null) return null; - if (query != null && dart.notNull(queryParameters != null)) { + if (query != null && queryParameters != null) { throw new ArgumentError('Both query and queryParameters specified'); } if (query != null) @@ -2572,7 +2572,7 @@ var convert = dart.lazyImport(convert); } first = false; result.write(Uri.encodeQueryComponent(dart.as(key, String))); - if (dart.notNull(value != null) && dart.notNull(dart.dsend(dart.dload(value, 'isEmpty'), '!'))) { + if (value != null && !dart.notNull(dart.as(dart.dload(value, 'isEmpty'), bool))) { result.write("="); result.write(Uri.encodeQueryComponent(dart.as(value, String))); } @@ -2611,7 +2611,7 @@ var convert = dart.lazyImport(convert); return "%"; } let value = dart.notNull(Uri._hexValue(firstDigit)) * 16 + dart.notNull(Uri._hexValue(secondDigit)); - if (Uri._isUnreservedChar(value)) { + if (dart.notNull(Uri._isUnreservedChar(value))) { if (dart.notNull(lowerCase) && dart.notNull(Uri._UPPER_CASE_A) <= dart.notNull(value) && dart.notNull(Uri._UPPER_CASE_Z) >= dart.notNull(value)) { value = dart.notNull(value) | 32; } @@ -2623,13 +2623,13 @@ var convert = dart.lazyImport(convert); return null; } static _isUnreservedChar(ch) { - return dart.notNull(ch) < 127 && dart.notNull(!dart.equals(dart.dsend(Uri._unreservedTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0)); + return dart.notNull(ch) < 127 && !dart.equals(dart.dsend(Uri._unreservedTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0); } static _escapeChar(char) { dart.assert(dart.dsend(char, '<=', 1114111)); let hexDigits = "0123456789ABCDEF"; let codeUnits = null; - if (dart.dsend(char, '<', 128)) { + if (dart.notNull(dart.as(dart.dsend(char, '<', 128), bool))) { codeUnits = List.new(3); codeUnits[dartx.set](0, Uri._PERCENT); codeUnits[dartx.set](1, hexDigits[dartx.codeUnitAt](dart.as(dart.dsend(char, '>>', 4), int))); @@ -2637,10 +2637,10 @@ var convert = dart.lazyImport(convert); } else { let flag = 192; let encodedBytes = 2; - if (dart.dsend(char, '>', 2047)) { + if (dart.notNull(dart.as(dart.dsend(char, '>', 2047), bool))) { flag = 224; encodedBytes = 3; - if (dart.dsend(char, '>', 65535)) { + if (dart.notNull(dart.as(dart.dsend(char, '>', 65535), bool))) { encodedBytes = 4; flag = 240; } @@ -2681,7 +2681,7 @@ var convert = dart.lazyImport(convert); } else { sourceLength = 3; } - } else if (Uri._isGeneralDelimiter(char)) { + } else if (dart.notNull(Uri._isGeneralDelimiter(char))) { Uri._fail(component, index, "Invalid character"); } else { sourceLength = 1; @@ -2713,20 +2713,20 @@ var convert = dart.lazyImport(convert); return dart.toString(buffer); } static _isSchemeCharacter(ch) { - return dart.notNull(ch) < 128 && dart.notNull(!dart.equals(dart.dsend(Uri._schemeTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0)); + return dart.notNull(ch) < 128 && !dart.equals(dart.dsend(Uri._schemeTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0); } static _isGeneralDelimiter(ch) { - return dart.notNull(ch) <= dart.notNull(Uri._RIGHT_BRACKET) && dart.notNull(!dart.equals(dart.dsend(Uri._genDelimitersTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0)); + return dart.notNull(ch) <= dart.notNull(Uri._RIGHT_BRACKET) && !dart.equals(dart.dsend(Uri._genDelimitersTable[dartx.get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0); } get isAbsolute() { return this.scheme != "" && this.fragment == ""; } [_merge](base, reference) { - if (base[dartx.isEmpty]) + if (dart.notNull(base[dartx.isEmpty])) return `/${reference}`; let backCount = 0; let refStart = 0; - while (reference[dartx.startsWith]("../", refStart)) { + while (dart.notNull(reference[dartx.startsWith]("../", refStart))) { refStart = dart.notNull(refStart) + 3; backCount = dart.notNull(backCount) + 1; } @@ -2768,7 +2768,7 @@ var convert = dart.lazyImport(convert); output[dartx.add](segment); } } - if (appendSlash) + if (dart.notNull(appendSlash)) output[dartx.add](""); return output[dartx.join]("/"); } @@ -2782,41 +2782,41 @@ var convert = dart.lazyImport(convert); let targetPort = null; let targetPath = null; let targetQuery = null; - if (reference.scheme[dartx.isNotEmpty]) { + if (dart.notNull(reference.scheme[dartx.isNotEmpty])) { targetScheme = reference.scheme; - if (reference.hasAuthority) { + if (dart.notNull(reference.hasAuthority)) { targetUserInfo = reference.userInfo; targetHost = reference.host; - targetPort = reference.hasPort ? reference.port : null; + targetPort = dart.notNull(reference.hasPort) ? reference.port : null; } targetPath = this[_removeDotSegments](reference.path); - if (reference.hasQuery) { + if (dart.notNull(reference.hasQuery)) { targetQuery = reference.query; } } else { targetScheme = this.scheme; - if (reference.hasAuthority) { + if (dart.notNull(reference.hasAuthority)) { targetUserInfo = reference.userInfo; targetHost = reference.host; - targetPort = Uri._makePort(reference.hasPort ? reference.port : null, targetScheme); + targetPort = Uri._makePort(dart.notNull(reference.hasPort) ? reference.port : null, targetScheme); targetPath = this[_removeDotSegments](reference.path); - if (reference.hasQuery) + if (dart.notNull(reference.hasQuery)) targetQuery = reference.query; } else { if (reference.path == "") { targetPath = this[_path]; - if (reference.hasQuery) { + if (dart.notNull(reference.hasQuery)) { targetQuery = reference.query; } else { targetQuery = this[_query]; } } else { - if (reference.path[dartx.startsWith]("/")) { + if (dart.notNull(reference.path[dartx.startsWith]("/"))) { targetPath = this[_removeDotSegments](reference.path); } else { targetPath = this[_removeDotSegments](this[_merge](this[_path], reference.path)); } - if (reference.hasQuery) + if (dart.notNull(reference.hasQuery)) targetQuery = reference.query; } targetUserInfo = this[_userInfo]; @@ -2824,7 +2824,7 @@ var convert = dart.lazyImport(convert); targetPort = this[_port]; } } - let fragment = reference.hasFragment ? reference.fragment : null; + let fragment = dart.notNull(reference.hasFragment) ? reference.fragment : null; return new Uri._internal(targetScheme, targetUserInfo, targetHost, targetPort, targetPath, targetQuery, fragment); } get hasAuthority() { @@ -2863,7 +2863,7 @@ var convert = dart.lazyImport(convert); } if (windows == null) windows = Uri._isWindows; - return windows ? this[_toWindowsFilePath]() : this[_toFilePath](); + return dart.notNull(windows) ? this[_toWindowsFilePath]() : this[_toFilePath](); } [_toFilePath]() { if (this.host != "") { @@ -2871,7 +2871,7 @@ var convert = dart.lazyImport(convert); } Uri._checkNonWindowsPathReservedCharacters(this.pathSegments, false); let result = new StringBuffer(); - if (this[_isPathAbsolute]) + if (dart.notNull(this[_isPathAbsolute])) result.write("/"); result.writeAll(this.pathSegments, "/"); return dart.toString(result); @@ -2905,7 +2905,7 @@ var convert = dart.lazyImport(convert); return this.path[dartx.startsWith]('/'); } [_writeAuthority](ss) { - if (this[_userInfo][dartx.isNotEmpty]) { + if (dart.notNull(this[_userInfo][dartx.isNotEmpty])) { ss.write(this[_userInfo]); ss.write("@"); } @@ -3045,7 +3045,7 @@ var convert = dart.lazyImport(convert); partStart = i; } if (i == partStart) { - if (wildcardSeen) { + if (dart.notNull(wildcardSeen)) { error('only one wildcard `::` is allowed', i); } wildcardSeen = true; @@ -3078,7 +3078,7 @@ var convert = dart.lazyImport(convert); } } - if (wildcardSeen) { + if (dart.notNull(wildcardSeen)) { if (dart.notNull(parts.length) > 7) { error('an address with a wildcard must have less than 7 parts'); } @@ -3153,8 +3153,8 @@ var convert = dart.lazyImport(convert); simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS; } let bytes = null; - if (simple) { - if (dart.notNull(dart.equals(encoding, convert.UTF8)) || dart.notNull(dart.equals(encoding, convert.LATIN1))) { + if (dart.notNull(simple)) { + if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert.LATIN1)) { return text; } else { bytes = text[dartx.codeUnits]; diff --git a/pkg/dev_compiler/lib/runtime/dart/math.js b/pkg/dev_compiler/lib/runtime/dart/math.js index 75011d864d0c..0f5f2d7b2d8d 100644 --- a/pkg/dev_compiler/lib/runtime/dart/math.js +++ b/pkg/dev_compiler/lib/runtime/dart/math.js @@ -42,7 +42,7 @@ var _js_helper = dart.lazyImport(_js_helper); ['=='](other) { if (!dart.is(other, Point$())) return false; - return dart.notNull(dart.equals(this.x, dart.dload(other, 'x'))) && dart.notNull(dart.equals(this.y, dart.dload(other, 'y'))); + return dart.equals(this.x, dart.dload(other, 'x')) && dart.equals(this.y, dart.dload(other, 'y')); } get hashCode() { return _JenkinsSmiHash.hash2(dart.hashCode(this.x), dart.hashCode(this.y)); @@ -113,7 +113,7 @@ var _js_helper = dart.lazyImport(_js_helper); ['=='](other) { if (!dart.is(other, Rectangle)) return false; - return dart.notNull(dart.equals(this.left, dart.dload(other, 'left'))) && dart.notNull(dart.equals(this.top, dart.dload(other, 'top'))) && dart.notNull(dart.equals(this.right, dart.dload(other, 'right'))) && dart.notNull(dart.equals(this.bottom, dart.dload(other, 'bottom'))); + return dart.equals(this.left, dart.dload(other, 'left')) && dart.equals(this.top, dart.dload(other, 'top')) && dart.equals(this.right, dart.dload(other, 'right')) && dart.equals(this.bottom, dart.dload(other, 'bottom')); } get hashCode() { return _JenkinsSmiHash.hash4(dart.hashCode(this.left), dart.hashCode(this.top), dart.hashCode(this.right), dart.hashCode(this.bottom)); @@ -179,8 +179,8 @@ var _js_helper = dart.lazyImport(_js_helper); Rectangle(left, top, width, height) { this.left = left; this.top = top; - this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0 : width, T); - this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']()) * 0 : height, T); + this.width = dart.as(dart.notNull(width['<'](0)) ? dart.notNull(width['unary-']()) * 0 : width, T); + this.height = dart.as(dart.notNull(height['<'](0)) ? dart.notNull(height['unary-']()) * 0 : height, T); super._RectangleBase(); } static fromPoints(a, b) { @@ -207,8 +207,8 @@ var _js_helper = dart.lazyImport(_js_helper); MutableRectangle(left, top, width, height) { this.left = left; this.top = top; - this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); - this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height, T); + this[_width] = dart.as(dart.notNull(width['<'](0)) ? _clampToZero(width) : width, T); + this[_height] = dart.as(dart.notNull(height['<'](0)) ? _clampToZero(height) : height, T); super._RectangleBase(); } static fromPoints(a, b) { @@ -223,7 +223,7 @@ var _js_helper = dart.lazyImport(_js_helper); } set width(width) { dart.as(width, T); - if (width['<'](0)) + if (dart.notNull(width['<'](0))) width = dart.as(_clampToZero(width), T); this[_width] = width; } @@ -232,7 +232,7 @@ var _js_helper = dart.lazyImport(_js_helper); } set height(height) { dart.as(height, T); - if (height['<'](0)) + if (dart.notNull(height['<'](0))) height = dart.as(_clampToZero(height), T); this[_height] = height; } @@ -297,7 +297,7 @@ var _js_helper = dart.lazyImport(_js_helper); return dart.notNull(a) + dart.notNull(b); } } - if (b[dartx.isNaN]) + if (dart.notNull(b[dartx.isNaN])) return b; return a; } diff --git a/pkg/dev_compiler/lib/src/checker/checker.dart b/pkg/dev_compiler/lib/src/checker/checker.dart index 9d328979a567..78b1a20e68d0 100644 --- a/pkg/dev_compiler/lib/src/checker/checker.dart +++ b/pkg/dev_compiler/lib/src/checker/checker.dart @@ -348,7 +348,7 @@ class CodeChecker extends RecursiveAstVisitor { _overrideChecker = new _OverrideChecker(rules, reporter, options); @override - visitCompilationUnit(CompilationUnit unit) { + void visitCompilationUnit(CompilationUnit unit) { void report(Expression expr) { _reporter.log(new MissingTypeError(expr)); } @@ -379,17 +379,20 @@ class CodeChecker extends RecursiveAstVisitor { _constantContext = o; } - visitComment(Comment node) { + @override + void visitComment(Comment node) { // skip, no need to do typechecking inside comments (they may contain // comment references which would require resolution). } - visitClassDeclaration(ClassDeclaration node) { + @override + void visitClassDeclaration(ClassDeclaration node) { _overrideChecker.check(node); super.visitClassDeclaration(node); } - visitAssignmentExpression(AssignmentExpression node) { + @override + void visitAssignmentExpression(AssignmentExpression node) { var token = node.operator; if (token.type != TokenType.EQ) { _checkCompoundAssignment(node); @@ -402,7 +405,7 @@ class CodeChecker extends RecursiveAstVisitor { /// Check constructor declaration to ensure correct super call placement. @override - visitConstructorDeclaration(ConstructorDeclaration node) { + void visitConstructorDeclaration(ConstructorDeclaration node) { _visitMaybeConst(node, (node) { node.visitChildren(this); @@ -417,7 +420,7 @@ class CodeChecker extends RecursiveAstVisitor { } @override - visitConstructorFieldInitializer(ConstructorFieldInitializer node) { + void visitConstructorFieldInitializer(ConstructorFieldInitializer node) { var field = node.fieldName; DartType staticType = _rules.elementType(field.staticElement); node.expression = checkAssignment(node.expression, staticType); @@ -425,7 +428,7 @@ class CodeChecker extends RecursiveAstVisitor { } @override - visitForEachStatement(ForEachStatement node) { + void visitForEachStatement(ForEachStatement node) { // Check that the expression is an Iterable. var expr = node.iterable; var iterableType = _rules.provider.iterableType; @@ -438,7 +441,43 @@ class CodeChecker extends RecursiveAstVisitor { node.visitChildren(this); } - @override visitListLiteral(ListLiteral node) { + @override + void visitForStatement(ForStatement node) { + if (node.condition != null) { + node.condition = checkBoolean(node.condition); + } + node.visitChildren(this); + } + + @override + void visitIfStatement(IfStatement node) { + node.condition = checkBoolean(node.condition); + node.visitChildren(this); + } + + @override + void visitDoStatement(DoStatement node) { + node.condition = checkBoolean(node.condition); + node.visitChildren(this); + } + + @override + void visitWhileStatement(WhileStatement node) { + node.condition = checkBoolean(node.condition); + node.visitChildren(this); + } + + @override + void visitSwitchStatement(SwitchStatement node) { + // SwitchStatement defines a boolean conversion to check the result of the + // case value == the switch value, but in dev_compiler we require a boolean + // return type from an overridden == operator (because Object.==), so + // checking in SwitchStatement shouldn't be necessary. + node.visitChildren(this); + } + + @override + void visitListLiteral(ListLiteral node) { var type = _rules.provider.dynamicType; if (node.typeArguments != null) { var targs = node.typeArguments.arguments; @@ -451,7 +490,8 @@ class CodeChecker extends RecursiveAstVisitor { super.visitListLiteral(node); } - @override visitMapLiteral(MapLiteral node) { + @override + void visitMapLiteral(MapLiteral node) { var ktype = _rules.provider.dynamicType; var vtype = _rules.provider.dynamicType; if (node.typeArguments != null) { @@ -513,24 +553,29 @@ class CodeChecker extends RecursiveAstVisitor { } } - visitMethodInvocation(MethodInvocation node) { + @override + void visitMethodInvocation(MethodInvocation node) { checkFunctionApplication(node, node.methodName, node.argumentList); node.visitChildren(this); } - visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { + @override + void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { checkFunctionApplication(node, node.function, node.argumentList); node.visitChildren(this); } - visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { + @override + void visitRedirectingConstructorInvocation( + RedirectingConstructorInvocation node) { var type = node.staticElement.type; bool checked = checkArgumentList(node.argumentList, type); assert(checked); node.visitChildren(this); } - visitSuperConstructorInvocation(SuperConstructorInvocation node) { + @override + void visitSuperConstructorInvocation(SuperConstructorInvocation node) { var element = node.staticElement; if (element == null) { _recordMessage(new MissingTypeError(node)); @@ -568,24 +613,28 @@ class CodeChecker extends RecursiveAstVisitor { return checkAssignment(expression, type); } - visitExpressionFunctionBody(ExpressionFunctionBody node) { + @override + void visitExpressionFunctionBody(ExpressionFunctionBody node) { node.expression = _checkReturn(node.expression, node); node.visitChildren(this); } - visitReturnStatement(ReturnStatement node) { + @override + void visitReturnStatement(ReturnStatement node) { node.expression = _checkReturn(node.expression, node); node.visitChildren(this); } - visitPropertyAccess(PropertyAccess node) { + @override + void visitPropertyAccess(PropertyAccess node) { if (node.staticType.isDynamic && _rules.isDynamicTarget(node.realTarget)) { _recordDynamicInvoke(node); } node.visitChildren(this); } - visitPrefixedIdentifier(PrefixedIdentifier node) { + @override + void visitPrefixedIdentifier(PrefixedIdentifier node) { final target = node.prefix; if (_rules.isDynamicTarget(target)) { _recordDynamicInvoke(node); @@ -593,7 +642,8 @@ class CodeChecker extends RecursiveAstVisitor { node.visitChildren(this); } - @override visitDefaultFormalParameter(DefaultFormalParameter node) { + @override + void visitDefaultFormalParameter(DefaultFormalParameter node) { _visitMaybeConst(node, (node) { // Check that defaults have the proper subtype. var parameter = node.parameter; @@ -615,7 +665,8 @@ class CodeChecker extends RecursiveAstVisitor { }); } - visitFieldFormalParameter(FieldFormalParameter node) { + @override + void visitFieldFormalParameter(FieldFormalParameter node) { var element = node.element; var typeName = node.type; if (typeName != null) { @@ -633,7 +684,7 @@ class CodeChecker extends RecursiveAstVisitor { } @override - visitInstanceCreationExpression(InstanceCreationExpression node) { + void visitInstanceCreationExpression(InstanceCreationExpression node) { _visitMaybeConst(node, (node) { var arguments = node.argumentList; var element = node.staticElement; @@ -648,7 +699,7 @@ class CodeChecker extends RecursiveAstVisitor { } @override - visitVariableDeclarationList(VariableDeclarationList node) { + void visitVariableDeclarationList(VariableDeclarationList node) { _visitMaybeConst(node, (node) { TypeName type = node.type; if (type == null) { @@ -682,7 +733,7 @@ class CodeChecker extends RecursiveAstVisitor { } @override - visitVariableDeclaration(VariableDeclaration node) { + void visitVariableDeclaration(VariableDeclaration node) { _visitMaybeConst(node, super.visitVariableDeclaration); } @@ -693,19 +744,52 @@ class CodeChecker extends RecursiveAstVisitor { } } - visitAsExpression(AsExpression node) { + @override + void visitAsExpression(AsExpression node) { // We could do the same check as the IsExpression below, but that is // potentially too conservative. Instead, at runtime, we must fail hard // if the Dart as and the DDC as would return different values. node.visitChildren(this); } - visitIsExpression(IsExpression node) { + @override + void visitIsExpression(IsExpression node) { _checkRuntimeTypeCheck(node, node.type); node.visitChildren(this); } - visitBinaryExpression(BinaryExpression node) { + @override + void visitPrefixExpression(PrefixExpression node) { + if (node.operator.type == TokenType.BANG) { + node.operand = checkBoolean(node.operand); + } else { + _checkUnary(node); + } + node.visitChildren(this); + } + + @override + void visitPostfixExpression(PostfixExpression node) { + _checkUnary(node); + node.visitChildren(this); + } + + void _checkUnary(/*PrefixExpression|PostfixExpression*/ node) { + var op = node.operator; + if (op.isUserDefinableOperator || + op.type == TokenType.PLUS_PLUS || + op.type == TokenType.MINUS_MINUS) { + if (_rules.isDynamicTarget(node.operand)) { + _recordDynamicInvoke(node); + } + // For ++ and --, even if it is not dynamic, we still need to check + // that the user defined method accepts an `int` as the RHS. + // We assume Analyzer has done this already. + } + } + + @override + void visitBinaryExpression(BinaryExpression node) { var op = node.operator; if (op.isUserDefinableOperator) { if (_rules.isDynamicTarget(node.leftOperand)) { @@ -734,9 +818,8 @@ class CodeChecker extends RecursiveAstVisitor { switch (op.type) { case TokenType.AMPERSAND_AMPERSAND: case TokenType.BAR_BAR: - var boolType = _rules.provider.boolType; - node.leftOperand = checkArgument(node.leftOperand, boolType); - node.rightOperand = checkArgument(node.rightOperand, boolType); + node.leftOperand = checkBoolean(node.leftOperand); + node.rightOperand = checkBoolean(node.rightOperand); break; case TokenType.BANG_EQ: break; @@ -747,6 +830,12 @@ class CodeChecker extends RecursiveAstVisitor { node.visitChildren(this); } + @override + void visitConditionalExpression(ConditionalExpression node) { + node.condition = checkBoolean(node.condition); + node.visitChildren(this); + } + @override void visitIndexExpression(IndexExpression node) { if (_rules.isDynamicTarget(node.target)) { @@ -771,6 +860,12 @@ class CodeChecker extends RecursiveAstVisitor { return (name == null) ? _rules.provider.dynamicType : name.type; } + /// Analyzer checks boolean conversions, but we need to check too, because + /// it uses the default assignability rules that allow `dynamic` and `Object` + /// to be assigned to bool with no message. + Expression checkBoolean(Expression expr) => + checkAssignment(expr, _rules.provider.boolType); + Expression checkAssignment(Expression expr, DartType type) { if (expr is ParenthesizedExpression) { expr.expression = checkAssignment(expr.expression, type); diff --git a/pkg/dev_compiler/lib/src/codegen/js_codegen.dart b/pkg/dev_compiler/lib/src/codegen/js_codegen.dart index f89564d9eaa1..95fcf811ffe8 100644 --- a/pkg/dev_compiler/lib/src/codegen/js_codegen.dart +++ b/pkg/dev_compiler/lib/src/codegen/js_codegen.dart @@ -1798,8 +1798,16 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { } DartType type = null; if (expr is BinaryExpression) { + switch (expr.operator.type) { + case TokenType.EQ_EQ: + case TokenType.BANG_EQ: + case TokenType.AMPERSAND_AMPERSAND: + case TokenType.BAR_BAR: + return true; + } type = getStaticType(expr.leftOperand); } else if (expr is PrefixExpression) { + if (expr.operator.type == TokenType.BANG) return true; type = getStaticType(expr.operand); } else if (expr is PostfixExpression) { type = getStaticType(expr.operand); @@ -1835,11 +1843,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { } JS.Expression notNull(Expression expr) { - if (_isNonNullableExpression(expr)) { - return _visit(expr); - } else { - return js.call('dart.notNull(#)', _visit(expr)); - } + if (expr == null) return null; + var jsExpr = _visit(expr); + if (_isNonNullableExpression(expr)) return jsExpr; + return js.call('dart.notNull(#)', jsExpr); } @override @@ -2202,7 +2209,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { @override visitConditionalExpression(ConditionalExpression node) { return js.call('# ? # : #', [ - _visit(node.condition), + notNull(node.condition), _visit(node.thenExpression), _visit(node.elseExpression) ]); @@ -2229,7 +2236,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { @override JS.If visitIfStatement(IfStatement node) { - return new JS.If(_visit(node.condition), _visit(node.thenStatement), + return new JS.If(notNull(node.condition), _visit(node.thenStatement), _visit(node.elseStatement)); } @@ -2239,17 +2246,17 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { if (init == null) init = _visit(node.variables); var update = _visitListToBinary(node.updaters, ','); if (update != null) update = update.toVoidExpression(); - return new JS.For(init, _visit(node.condition), update, _visit(node.body)); + return new JS.For(init, notNull(node.condition), update, _visit(node.body)); } @override JS.While visitWhileStatement(WhileStatement node) { - return new JS.While(_visit(node.condition), _visit(node.body)); + return new JS.While(notNull(node.condition), _visit(node.body)); } @override JS.Do visitDoStatement(DoStatement node) { - return new JS.Do(_visit(node.body), _visit(node.condition)); + return new JS.Do(_visit(node.body), notNull(node.condition)); } @override @@ -2558,7 +2565,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { /// /// For user-defined operators the following names are allowed: /// - /// <, >, <=, >=, ==, -, +, /, ˜/, *, %, |, ˆ, &, <<, >>, []=, [], ˜ + /// <, >, <=, >=, ==, -, +, /, ~/, *, %, |, ^, &, <<, >>, []=, [], ~ /// /// They generate code like: /// diff --git a/pkg/dev_compiler/test/checker/checker_test.dart b/pkg/dev_compiler/test/checker/checker_test.dart index 40c2e0fe9a2f..e587876f8a7f 100644 --- a/pkg/dev_compiler/test/checker/checker_test.dart +++ b/pkg/dev_compiler/test/checker/checker_test.dart @@ -39,11 +39,50 @@ void main() { } } void main() { + Object obj = 42; + dynamic dyn = 42; + int i = 42; + + // Check the boolean conversion of the condition. + print((/*severe:StaticTypeError*/i) ? false : true); + print((/*warning:DownCastImplicit*/obj) ? false : true); + print((/*info:DynamicCast*/dyn) ? false : true); } ''' }); }); + test('if/for/do/while statements use boolean conversion', () => testChecker({ + '/main.dart': ''' + main() { + dynamic d = 42; + Object obj = 42; + int i = 42; + bool b = false; + + if (b) {} + if (/*info:DynamicCast*/dyn) {} + if (/*warning:DownCastImplicit*/obj) {} + if (/*severe:StaticTypeError*/i) {} + + while (b) {} + while (/*info:DynamicCast*/dyn) {} + while (/*warning:DownCastImplicit*/obj) {} + while (/*severe:StaticTypeError*/i) {} + + do {} while (b); + do {} while (/*info:DynamicCast*/dyn); + do {} while (/*warning:DownCastImplicit*/obj); + do {} while (/*severe:StaticTypeError*/i); + + for (;b;) {} + for (;/*info:DynamicCast*/dyn;) {} + for (;/*warning:DownCastImplicit*/obj;) {} + for (;/*severe:StaticTypeError*/i;) {} + } + ''' + })); + test('dynamic invocation', () { testChecker({ '/main.dart': ''' @@ -1924,6 +1963,42 @@ void main() { }, inferFromOverrides: true); }); + test('unary operators', () => testChecker({ + '/main.dart': ''' + class A { + A operator ~() {} + A operator +(int x) {} + A operator -(int x) {} + A operator -() {} + } + + foo() => new A(); + + test() { + A a = new A(); + var c = foo(); + + ~a; + (/*info:DynamicInvoke*/~d); + + !/*severe:StaticTypeError*/a; + !/*info:DynamicCast*/d; + + -a; + (/*info:DynamicInvoke*/-d); + + ++a; + --a; + (/*info:DynamicInvoke*/++d); + (/*info:DynamicInvoke*/--d); + + a++; + a--; + (/*info:DynamicInvoke*/d++); + (/*info:DynamicInvoke*/d--); + }''' + })); + test('binary and index operators', () { testChecker({ '/main.dart': ''' diff --git a/pkg/dev_compiler/test/codegen/expect/opassign.txt b/pkg/dev_compiler/test/codegen/expect/opassign.txt index 53b91a05e0d3..0aa69fb412d0 100644 --- a/pkg/dev_compiler/test/codegen/expect/opassign.txt +++ b/pkg/dev_compiler/test/codegen/expect/opassign.txt @@ -1,7 +1,19 @@ // Messages from compiling opassign.dart +info: line 21, column 3 of test/codegen/opassign.dart: [DynamicInvoke] ++f[index] requires dynamic invoke + ++f[index]; + ^^^^^^^^^^ +info: line 22, column 16 of test/codegen/opassign.dart: [DynamicInvoke] f[index]++ requires dynamic invoke + forcePostfix(f[index]++); + ^^^^^^^^^^ +info: line 25, column 3 of test/codegen/opassign.dart: [DynamicInvoke] ++foo.x requires dynamic invoke + ++foo.x; + ^^^^^^^ info: line 25, column 5 of test/codegen/opassign.dart: [DynamicInvoke] foo.x requires dynamic invoke ++foo.x; ^^^^^ +info: line 26, column 16 of test/codegen/opassign.dart: [DynamicInvoke] foo.x++ requires dynamic invoke + forcePostfix(foo.x++); + ^^^^^^^ info: line 26, column 16 of test/codegen/opassign.dart: [DynamicInvoke] foo.x requires dynamic invoke forcePostfix(foo.x++); ^^^^^