| Index: lib/runtime/dart/js.js
|
| diff --git a/lib/runtime/dart/js.js b/lib/runtime/dart/js.js
|
| index c9124c970b8c0f022df85fef0191275be70c336c..7e2c215cad94c20c26afc94fb8a46c41238475f0 100644
|
| --- a/lib/runtime/dart/js.js
|
| +++ b/lib/runtime/dart/js.js
|
| @@ -9,7 +9,7 @@ dart_library.library('dart/js', null, /* Imports */[
|
| let dartx = dart.dartx;
|
| dart.defineLazyProperties(exports, {
|
| get context() {
|
| - return dart.as(_wrapToDart(dart.global), JsObject);
|
| + return dart.as(dart.dcall(_wrapToDart, dart.global), JsObject);
|
| }
|
| });
|
| let _jsObject = Symbol('_jsObject');
|
| @@ -23,71 +23,71 @@ dart_library.library('dart/js', null, /* Imports */[
|
| arguments$ = null;
|
| let ctor = constructor[_jsObject];
|
| if (arguments$ == null) {
|
| - return dart.as(_wrapToDart(new ctor()), JsObject);
|
| + return dart.as(dart.dcall(_wrapToDart, new ctor()), JsObject);
|
| }
|
| - return dart.as(_wrapToDart(new ctor(...arguments$)), JsObject);
|
| + return dart.as(dart.dcall(_wrapToDart, new ctor(...arguments$)), JsObject);
|
| }
|
| static fromBrowserObject(object) {
|
| if (dart.is(object, core.num) || typeof object == 'string' || typeof object == 'boolean' || object == null) {
|
| dart.throw(new core.ArgumentError("object cannot be a num, string, bool, or null"));
|
| }
|
| - return dart.as(_wrapToDart(_convertToJS(object)), JsObject);
|
| + return dart.as(dart.dcall(_wrapToDart, dart.dcall(_convertToJS, object)), JsObject);
|
| }
|
| static jsify(object) {
|
| if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) {
|
| dart.throw(new core.ArgumentError("object must be a Map or Iterable"));
|
| }
|
| - return dart.as(_wrapToDart(JsObject._convertDataTree(object)), JsObject);
|
| + return dart.as(dart.dcall(_wrapToDart, dart.dcall(JsObject._convertDataTree, object)), JsObject);
|
| }
|
| static _convertDataTree(data) {
|
| let _convertedObjects = collection.HashMap.identity();
|
| function _convert(o) {
|
| - if (dart.notNull(_convertedObjects.containsKey(o))) {
|
| - return _convertedObjects.get(o);
|
| + if (dart.notNull(dart.as(dart.dsend(_convertedObjects, 'containsKey', o), core.bool))) {
|
| + return dart.dindex(_convertedObjects, o);
|
| }
|
| if (dart.is(o, core.Map)) {
|
| let convertedMap = {};
|
| - _convertedObjects.set(o, convertedMap);
|
| + dart.dsetindex(_convertedObjects, o, convertedMap);
|
| for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) {
|
| - convertedMap[key] = _convert(dart.dindex(o, key));
|
| + convertedMap[key] = dart.dcall(_convert, dart.dindex(o, key));
|
| }
|
| return convertedMap;
|
| } else if (dart.is(o, core.Iterable)) {
|
| let convertedList = [];
|
| - _convertedObjects.set(o, convertedList);
|
| - convertedList[dartx.addAll](dart.as(dart.dsend(o, 'map', _convert), core.Iterable));
|
| + dart.dsetindex(_convertedObjects, o, convertedList);
|
| + dart.dsend(convertedList, 'addAll', dart.dsend(o, 'map', _convert));
|
| return convertedList;
|
| } else {
|
| - return _convertToJS(o);
|
| + return dart.dcall(_convertToJS, o);
|
| }
|
| }
|
| dart.fn(_convert);
|
| - return _convert(data);
|
| + return dart.dcall(_convert, data);
|
| }
|
| get(property) {
|
| if (!(typeof property == 'string') && !dart.is(property, core.num)) {
|
| dart.throw(new core.ArgumentError("property is not a String or num"));
|
| }
|
| - return _convertToDart(this[_jsObject][property]);
|
| + return dart.dcall(_convertToDart, this[_jsObject][property]);
|
| }
|
| set(property, value) {
|
| if (!(typeof property == 'string') && !dart.is(property, core.num)) {
|
| dart.throw(new core.ArgumentError("property is not a String or num"));
|
| }
|
| - this[_jsObject][property] = _convertToJS(value);
|
| + this[_jsObject][property] = dart.dcall(_convertToJS, value);
|
| return value;
|
| }
|
| get hashCode() {
|
| return 0;
|
| }
|
| ['=='](other) {
|
| - return dart.is(other, JsObject) && this[_jsObject] === dart.dload(other, _jsObject);
|
| + return dart.is(other, JsObject) && dart.notNull(dart.as(this[_jsObject] === dart.dload(other, _jsObject), core.bool));
|
| }
|
| hasProperty(property) {
|
| if (!(typeof property == 'string') && !dart.is(property, core.num)) {
|
| dart.throw(new core.ArgumentError("property is not a String or num"));
|
| }
|
| - return property in this[_jsObject];
|
| + return dart.as(property in this[_jsObject], core.bool);
|
| }
|
| deleteProperty(property) {
|
| if (!(typeof property == 'string') && !dart.is(property, core.num)) {
|
| @@ -96,13 +96,13 @@ dart_library.library('dart/js', null, /* Imports */[
|
| delete this[_jsObject][property];
|
| }
|
| instanceof(type) {
|
| - return this[_jsObject] instanceof _convertToJS(type);
|
| + return dart.as(this[_jsObject] instanceof dart.dcall(_convertToJS, type), core.bool);
|
| }
|
| toString() {
|
| try {
|
| - return String(this[_jsObject]);
|
| + return dart.as(String(this[_jsObject]), core.String);
|
| } catch (e) {
|
| - return super.toString();
|
| + return dart.dcall(super.toString);
|
| }
|
|
|
| }
|
| @@ -113,12 +113,12 @@ dart_library.library('dart/js', null, /* Imports */[
|
| dart.throw(new core.ArgumentError("method is not a String or num"));
|
| }
|
| if (args != null)
|
| - args = core.List.from(args[dartx.map](_convertToJS));
|
| + args = core.List.from(dart.dcall(args[dartx.map], _convertToJS));
|
| let fn = this[_jsObject][method];
|
| - if (!(fn instanceof Function)) {
|
| + if (!dart.notNull(dart.as(fn instanceof Function, core.bool))) {
|
| dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(dart.as(method, core.String)), args, dart.map()));
|
| }
|
| - return _convertToDart(fn.apply(this[_jsObject], args));
|
| + return dart.dcall(_convertToDart, fn.apply(this[_jsObject], args));
|
| }
|
| }
|
| dart.defineNamedConstructor(JsObject, '_fromJs');
|
| @@ -155,7 +155,7 @@ dart_library.library('dart/js', null, /* Imports */[
|
| }
|
| apply(args, opts) {
|
| let thisArg = opts && 'thisArg' in opts ? opts.thisArg : null;
|
| - return _convertToDart(this[_jsObject].apply(_convertToJS(thisArg), args == null ? null : core.List.from(args[dartx.map](_convertToJS))));
|
| + return dart.dcall(_convertToDart, this[_jsObject].apply(dart.dcall(_convertToJS, thisArg), args == null ? null : core.List.from(dart.dcall(args[dartx.map], _convertToJS))));
|
| }
|
| }
|
| dart.defineNamedConstructor(JsFunction, '_fromJs');
|
| @@ -176,7 +176,7 @@ dart_library.library('dart/js', null, /* Imports */[
|
| from(other) {
|
| super._fromJs((() => {
|
| let _ = [];
|
| - _[dartx.addAll](other[dartx.map](dart.as(_convertToJS, __CastType0)));
|
| + dart.dcall(_[dartx.addAll], dart.dcall(other[dartx.map], _convertToJS));
|
| return _;
|
| })());
|
| }
|
| @@ -202,23 +202,23 @@ dart_library.library('dart/js', null, /* Imports */[
|
| }
|
| }
|
| get(index) {
|
| - if (dart.is(index, core.num) && index == index[dartx.toInt]()) {
|
| - this[_checkIndex](index);
|
| + if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'toInt'))) {
|
| + dart.dcall(this[_checkIndex], index);
|
| }
|
| return dart.as(super.get(index), E);
|
| }
|
| set(index, value) {
|
| dart.as(value, E);
|
| - if (dart.is(index, core.num) && index == index[dartx.toInt]()) {
|
| - this[_checkIndex](index);
|
| + if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'toInt'))) {
|
| + dart.dcall(this[_checkIndex], index);
|
| }
|
| super.set(index, value);
|
| return value;
|
| }
|
| get length() {
|
| let len = this[_jsObject].length;
|
| - if (typeof len === "number" && len >>> 0 === len) {
|
| - return len;
|
| + if (dart.notNull(dart.as(typeof len === "number" && len >>> 0 === len, core.bool))) {
|
| + return dart.as(len, core.int);
|
| }
|
| dart.throw(new core.StateError('Bad JsArray length'));
|
| }
|
| @@ -227,50 +227,50 @@ dart_library.library('dart/js', null, /* Imports */[
|
| }
|
| add(value) {
|
| dart.as(value, E);
|
| - this.callMethod('push', [value]);
|
| + dart.dcall(this.callMethod, 'push', [value]);
|
| }
|
| addAll(iterable) {
|
| dart.as(iterable, core.Iterable$(E));
|
| - let list = iterable instanceof Array ? iterable : core.List.from(iterable);
|
| - this.callMethod('push', dart.as(list, core.List));
|
| + let list = dart.notNull(dart.as(iterable instanceof Array, core.bool)) ? iterable : core.List.from(iterable);
|
| + dart.dcall(this.callMethod, 'push', list);
|
| }
|
| insert(index, element) {
|
| dart.as(element, E);
|
| - this[_checkInsertIndex](index);
|
| - this.callMethod('splice', [index, 0, element]);
|
| + dart.dcall(this[_checkInsertIndex], index);
|
| + dart.dcall(this.callMethod, 'splice', [index, 0, element]);
|
| }
|
| removeAt(index) {
|
| - this[_checkIndex](index);
|
| - return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E);
|
| + dart.dcall(this[_checkIndex], index);
|
| + return dart.as(dart.dindex(dart.dcall(this.callMethod, 'splice', [index, 1]), 0), E);
|
| }
|
| removeLast() {
|
| if (this.length == 0)
|
| dart.throw(new core.RangeError(-1));
|
| - return dart.as(this.callMethod('pop'), E);
|
| + return dart.as(dart.dcall(this.callMethod, 'pop'), E);
|
| }
|
| removeRange(start, end) {
|
| - JsArray$()._checkRange(start, end, this.length);
|
| - this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start)]);
|
| + dart.dcall(JsArray$()._checkRange, start, end, this.length);
|
| + dart.dcall(this.callMethod, 'splice', [start, dart.notNull(end) - dart.notNull(start)]);
|
| }
|
| setRange(start, end, iterable, skipCount) {
|
| dart.as(iterable, core.Iterable$(E));
|
| if (skipCount === void 0)
|
| skipCount = 0;
|
| - JsArray$()._checkRange(start, end, this.length);
|
| + dart.dcall(JsArray$()._checkRange, start, end, this.length);
|
| let length = dart.notNull(end) - dart.notNull(start);
|
| if (length == 0)
|
| return;
|
| if (dart.notNull(skipCount) < 0)
|
| dart.throw(new core.ArgumentError(skipCount));
|
| let args = [start, length];
|
| - args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length));
|
| - this.callMethod('splice', args);
|
| + dart.dcall(args[dartx.addAll], dart.dcall(dart.dcall(iterable[dartx.skip], skipCount)[dartx.take], length));
|
| + dart.dcall(this.callMethod, 'splice', args);
|
| }
|
| sort(compare) {
|
| if (compare === void 0)
|
| compare = null;
|
| dart.as(compare, dart.functionType(core.int, [E, E]));
|
| - this.callMethod('sort', compare == null ? [] : [compare]);
|
| + dart.dcall(this.callMethod, 'sort', compare == null ? [] : [compare]);
|
| }
|
| }
|
| dart.defineNamedConstructor(JsArray, 'from');
|
| @@ -284,8 +284,8 @@ dart_library.library('dart/js', null, /* Imports */[
|
| methods: () => ({
|
| [_checkIndex]: [dart.dynamic, [core.int]],
|
| [_checkInsertIndex]: [dart.dynamic, [core.int]],
|
| - get: [E, [core.int]],
|
| - set: [dart.void, [core.int, E]],
|
| + get: [E, [dart.dynamic]],
|
| + set: [dart.void, [dart.dynamic, E]],
|
| add: [dart.void, [E]],
|
| addAll: [dart.void, [core.Iterable$(E)]],
|
| insert: [dart.void, [core.int, E]],
|
| @@ -315,7 +315,7 @@ dart_library.library('dart/js', null, /* Imports */[
|
| });
|
| let JsArray = JsArray$();
|
| function _isBrowserType(o) {
|
| - return o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || o instanceof ImageData || o instanceof Node || window.TypedData && o instanceof TypedData || o instanceof Window;
|
| + return dart.as(o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || o instanceof ImageData || o instanceof Node || window.TypedData && o instanceof TypedData || o instanceof Window, core.bool);
|
| }
|
| dart.fn(_isBrowserType, core.bool, [dart.dynamic]);
|
| let _dartObj = Symbol('_dartObj');
|
| @@ -328,16 +328,16 @@ dart_library.library('dart/js', null, /* Imports */[
|
| constructors: () => ({_DartObject: [_DartObject, [dart.dynamic]]})
|
| });
|
| function _convertToJS(o) {
|
| - if (o == null || typeof o == 'string' || dart.is(o, core.num) || typeof o == 'boolean' || dart.notNull(_isBrowserType(o))) {
|
| + if (o == null || typeof o == 'string' || dart.is(o, core.num) || typeof o == 'boolean' || dart.notNull(dart.dcall(_isBrowserType, o))) {
|
| return o;
|
| } else if (dart.is(o, core.DateTime)) {
|
| - return _js_helper.Primitives.lazyAsJsDate(o);
|
| + return dart.dcall(_js_helper.Primitives.lazyAsJsDate, o);
|
| } else if (dart.is(o, JsObject)) {
|
| return dart.dload(o, _jsObject);
|
| } else if (dart.is(o, core.Function)) {
|
| - return _putIfAbsent(exports._jsProxies, o, _wrapDartFunction);
|
| + return dart.dcall(_putIfAbsent, exports._jsProxies, o, _wrapDartFunction);
|
| } else {
|
| - return _putIfAbsent(exports._jsProxies, o, dart.fn(o => new _DartObject(o), _DartObject, [dart.dynamic]));
|
| + return dart.dcall(_putIfAbsent, exports._jsProxies, o, dart.fn(o => new _DartObject(o), _DartObject, [dart.dynamic]));
|
| }
|
| }
|
| dart.fn(_convertToJS);
|
| @@ -351,23 +351,23 @@ dart_library.library('dart/js', null, /* Imports */[
|
| }
|
| dart.fn(_wrapDartFunction);
|
| function _convertToDart(o) {
|
| - if (o == null || typeof o == "string" || typeof o == "number" || typeof o == "boolean" || dart.notNull(_isBrowserType(o))) {
|
| + if (dart.notNull(dart.as(o == null, core.bool)) || dart.notNull(dart.as(typeof o == "string", core.bool)) || dart.notNull(dart.as(typeof o == "number", core.bool)) || dart.notNull(dart.as(typeof o == "boolean", core.bool)) || dart.notNull(dart.dcall(_isBrowserType, o))) {
|
| return o;
|
| - } else if (o instanceof Date) {
|
| + } else if (dart.notNull(dart.as(o instanceof Date, core.bool))) {
|
| let ms = o.getTime();
|
| - return new core.DateTime.fromMillisecondsSinceEpoch(ms);
|
| - } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType(o)) {
|
| + return new core.DateTime.fromMillisecondsSinceEpoch(dart.as(ms, core.int));
|
| + } else if (dart.is(o, _DartObject) && dart.notNull(dart.as(dart.jsobject != dart.realRuntimeType(o), core.bool))) {
|
| return dart.dload(o, _dartObj);
|
| } else {
|
| - return _putIfAbsent(exports._dartProxies, o, _wrapToDart);
|
| + return dart.dcall(_putIfAbsent, exports._dartProxies, o, _wrapToDart);
|
| }
|
| }
|
| dart.fn(_convertToDart, core.Object, [dart.dynamic]);
|
| function _wrapToDart(o) {
|
| - if (typeof o == "function") {
|
| + if (dart.notNull(dart.as(typeof o == "function", core.bool))) {
|
| return new JsFunction._fromJs(o);
|
| }
|
| - if (o instanceof Array) {
|
| + if (dart.notNull(dart.as(o instanceof Array, core.bool))) {
|
| return new JsArray._fromJs(o);
|
| }
|
| return new JsObject._fromJs(o);
|
| @@ -390,11 +390,6 @@ dart_library.library('dart/js', null, /* Imports */[
|
| return value;
|
| }
|
| dart.fn(_putIfAbsent, core.Object, [dart.dynamic, dart.dynamic, dart.functionType(dart.dynamic, [dart.dynamic])]);
|
| - let __CastType0$ = dart.generic(function(E) {
|
| - let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.dynamic, [E]));
|
| - return __CastType0;
|
| - });
|
| - let __CastType0 = __CastType0$();
|
| // Exports:
|
| exports.JsObject = JsObject;
|
| exports.JsFunction = JsFunction;
|
|
|