| Index: test/dart_codegen/expect/convert/convert
|
| diff --git a/test/dart_codegen/expect/convert/convert b/test/dart_codegen/expect/convert/convert
|
| index 1832079a4e01272c8b8b49f639901209438d3b69..8088229f07fe462fe2e80ac8aeb810c5a08515da 100644
|
| --- a/test/dart_codegen/expect/convert/convert
|
| +++ b/test/dart_codegen/expect/convert/convert
|
| @@ -1,266 +1,252 @@
|
| library dart.convert;
|
| -
|
| import 'dart:async' as DDC$async$;
|
| import 'package:dev_compiler/runtime/dart_logging_runtime.dart' as DDC$RT;
|
| import 'dart:async';
|
| -import 'dart:typed_data';
|
| -import 'dart:_internal' show MappedIterable, ListIterable;
|
| -import 'dart:collection' show Maps, LinkedHashMap;
|
| + import 'dart:typed_data';
|
| + import 'dart:_internal' show MappedIterable, ListIterable;
|
| + import 'dart:collection' show Maps, LinkedHashMap;
|
| part 'ascii.dart';
|
| -part 'byte_conversion.dart';
|
| -part 'chunked_conversion.dart';
|
| -part 'codec.dart';
|
| -part 'converter.dart';
|
| -part 'encoding.dart';
|
| -part 'html_escape.dart';
|
| -part 'json.dart';
|
| -part 'latin1.dart';
|
| -part 'line_splitter.dart';
|
| -part 'string_conversion.dart';
|
| -part 'utf.dart';
|
| -
|
| -_convertJsonToDart(json, reviver(key, value)) {
|
| - assert(reviver != null);
|
| - walk(e) {
|
| + part 'byte_conversion.dart';
|
| + part 'chunked_conversion.dart';
|
| + part 'codec.dart';
|
| + part 'converter.dart';
|
| + part 'encoding.dart';
|
| + part 'html_escape.dart';
|
| + part 'json.dart';
|
| + part 'latin1.dart';
|
| + part 'line_splitter.dart';
|
| + part 'string_conversion.dart';
|
| + part 'utf.dart';
|
| + _convertJsonToDart(json, reviver(key, value)) {
|
| + assert (reviver != null); walk(e) {
|
| if (JS('bool', '# == null', e) || JS('bool', 'typeof # != "object"', e)) {
|
| return e;
|
| - }
|
| - if (JS('bool', 'Object.getPrototypeOf(#) === Array.prototype', e)) {
|
| - for (int i = 0; i < JS('int', '#.length', e); i++) {
|
| + }
|
| + if (JS('bool', 'Object.getPrototypeOf(#) === Array.prototype', e)) {
|
| + for (int i = 0;
|
| + i < JS('int', '#.length', e);
|
| + i++) {
|
| var item = JS('', '#[#]', e, i);
|
| - JS('', '#[#]=#', e, i, reviver(i, walk(item)));
|
| + JS('', '#[#]=#', e, i, reviver(i, walk(item)));
|
| + }
|
| + return e;
|
| }
|
| - return e;
|
| - }
|
| - _JsonMap map = new _JsonMap(e);
|
| - var processed = map._processed;
|
| - List<String> keys = map._computeKeys();
|
| - for (int i = 0; i < keys.length; i++) {
|
| + _JsonMap map = new _JsonMap(e);
|
| + var processed = map._processed;
|
| + List<String> keys = map._computeKeys();
|
| + for (int i = 0;
|
| + i < keys.length;
|
| + i++) {
|
| String key = keys[i];
|
| - var revived = reviver(key, walk(JS('', '#[#]', e, key)));
|
| - JS('', '#[#]=#', processed, key, revived);
|
| + var revived = reviver(key, walk(JS('', '#[#]', e, key)));
|
| + JS('', '#[#]=#', processed, key, revived);
|
| + }
|
| + map._original = processed;
|
| + return map;
|
| }
|
| - map._original = processed;
|
| - return map;
|
| + return reviver(null, walk(json));
|
| }
|
| - return reviver(null, walk(json));
|
| -}
|
| -_convertJsonToDartLazy(object) {
|
| + _convertJsonToDartLazy(object) {
|
| if (object == null) return null;
|
| - if (JS('bool', 'typeof # != "object"', object)) {
|
| + if (JS('bool', 'typeof # != "object"', object)) {
|
| return object;
|
| - }
|
| - if (JS('bool', 'Object.getPrototypeOf(#) !== Array.prototype', object)) {
|
| + }
|
| + if (JS('bool', 'Object.getPrototypeOf(#) !== Array.prototype', object)) {
|
| return new _JsonMap(object);
|
| - }
|
| - for (int i = 0; i < JS('int', '#.length', object); i++) {
|
| + }
|
| + for (int i = 0;
|
| + i < JS('int', '#.length', object);
|
| + i++) {
|
| var item = JS('', '#[#]', object, i);
|
| - JS('', '#[#]=#', object, i, _convertJsonToDartLazy(item));
|
| - }
|
| - return object;
|
| -}
|
| -class _JsonMap implements LinkedHashMap {
|
| - var _original;
|
| - var _processed = _newJavaScriptObject();
|
| - var _data = null;
|
| - _JsonMap(this._original);
|
| - operator [](key) {
|
| - if (_isUpgraded) {
|
| - return _upgradedMap[key];
|
| - } else if (key is! String) {
|
| - return null;
|
| - } else {
|
| - var result = _getProperty(_processed, DDC$RT.cast(key, dynamic, String,
|
| - "CastGeneral", """line 173, column 45 of dart:convert: """,
|
| - key is String, true));
|
| - if (_isUnprocessed(result)) result = _process(DDC$RT.cast(key, dynamic,
|
| - String, "CastGeneral", """line 174, column 53 of dart:convert: """,
|
| - key is String, true));
|
| - return result;
|
| + JS('', '#[#]=#', object, i, _convertJsonToDartLazy(item));
|
| + }
|
| + return object;
|
| + }
|
| + class _JsonMap implements LinkedHashMap {var _original;
|
| + var _processed = _newJavaScriptObject();
|
| + var _data = null;
|
| + _JsonMap(this._original);
|
| + operator [](key) {
|
| + if (_isUpgraded) {
|
| + return _upgradedMap[key];
|
| + }
|
| + else if (key is! String) {
|
| + return null;
|
| + }
|
| + else {
|
| + var result = _getProperty(_processed, DDC$RT.cast(key, dynamic, String, "CastGeneral", """line 173, column 45 of dart:convert: """, key is String, true));
|
| + if (_isUnprocessed(result)) result = _process(DDC$RT.cast(key, dynamic, String, "CastGeneral", """line 174, column 53 of dart:convert: """, key is String, true));
|
| + return result;
|
| }
|
| }
|
| - int get length => _isUpgraded ? _upgradedMap.length : _computeKeys().length;
|
| - bool get isEmpty => length == 0;
|
| - bool get isNotEmpty => length > 0;
|
| - Iterable get keys {
|
| - if (_isUpgraded) return _upgradedMap.keys;
|
| - return new _JsonMapKeyIterable(this);
|
| + int get length => _isUpgraded ? _upgradedMap.length : _computeKeys().length;
|
| + bool get isEmpty => length == 0;
|
| + bool get isNotEmpty => length > 0;
|
| + Iterable get keys {
|
| + if (_isUpgraded) return _upgradedMap.keys;
|
| + return new _JsonMapKeyIterable(this);
|
| }
|
| - Iterable get values {
|
| - if (_isUpgraded) return _upgradedMap.values;
|
| - return new MappedIterable(_computeKeys(), (each) => this[each]);
|
| + Iterable get values {
|
| + if (_isUpgraded) return _upgradedMap.values;
|
| + return new MappedIterable(_computeKeys(), (each) => this[each]);
|
| }
|
| - operator []=(key, value) {
|
| - if (_isUpgraded) {
|
| - _upgradedMap[key] = value;
|
| - } else if (containsKey(key)) {
|
| - var processed = _processed;
|
| - _setProperty(processed, DDC$RT.cast(key, dynamic, String, "CastGeneral",
|
| - """line 201, column 31 of dart:convert: """, key is String, true),
|
| - value);
|
| - var original = _original;
|
| - if (!identical(original, processed)) {
|
| - _setProperty(original, DDC$RT.cast(key, dynamic, String, "CastGeneral",
|
| - """line 204, column 32 of dart:convert: """, key is String,
|
| - true), null);
|
| + operator []=(key, value) {
|
| + if (_isUpgraded) {
|
| + _upgradedMap[key] = value;
|
| + }
|
| + else if (containsKey(key)) {
|
| + var processed = _processed;
|
| + _setProperty(processed, DDC$RT.cast(key, dynamic, String, "CastGeneral", """line 201, column 31 of dart:convert: """, key is String, true), value);
|
| + var original = _original;
|
| + if (!identical(original, processed)) {
|
| + _setProperty(original, DDC$RT.cast(key, dynamic, String, "CastGeneral", """line 204, column 32 of dart:convert: """, key is String, true), null);
|
| }
|
| - } else {
|
| - _upgrade()[key] = value;
|
| }
|
| - }
|
| - void addAll(Map other) {
|
| - other.forEach((key, value) {
|
| - this[key] = value;
|
| - });
|
| - }
|
| - bool containsValue(value) {
|
| - if (_isUpgraded) return _upgradedMap.containsValue(value);
|
| - List<String> keys = _computeKeys();
|
| - for (int i = 0; i < keys.length; i++) {
|
| - String key = keys[i];
|
| - if (this[key] == value) return true;
|
| + else {
|
| + _upgrade()[key] = value;
|
| }
|
| - return false;
|
| - }
|
| - bool containsKey(key) {
|
| - if (_isUpgraded) return _upgradedMap.containsKey(key);
|
| - if (key is! String) return false;
|
| - return _hasProperty(_original, DDC$RT.cast(key, dynamic, String,
|
| - "CastGeneral", """line 230, column 36 of dart:convert: """,
|
| - key is String, true));
|
| }
|
| - putIfAbsent(key, ifAbsent()) {
|
| - if (containsKey(key)) return this[key];
|
| - var value = ifAbsent();
|
| + void addAll(Map other) {
|
| + other.forEach((key, value) {
|
| this[key] = value;
|
| - return value;
|
| - }
|
| - remove(Object key) {
|
| - if (!_isUpgraded && !containsKey(key)) return null;
|
| - return _upgrade().remove(key);
|
| - }
|
| - void clear() {
|
| - if (_isUpgraded) {
|
| - _upgradedMap.clear();
|
| - } else {
|
| - if (_data != null) {
|
| - _data.clear();
|
| + }
|
| + );
|
| + }
|
| + bool containsValue(value) {
|
| + if (_isUpgraded) return _upgradedMap.containsValue(value);
|
| + List<String> keys = _computeKeys();
|
| + for (int i = 0;
|
| + i < keys.length;
|
| + i++) {
|
| + String key = keys[i];
|
| + if (this[key] == value) return true;
|
| + }
|
| + return false;
|
| + }
|
| + bool containsKey(key) {
|
| + if (_isUpgraded) return _upgradedMap.containsKey(key);
|
| + if (key is! String) return false;
|
| + return _hasProperty(_original, DDC$RT.cast(key, dynamic, String, "CastGeneral", """line 230, column 36 of dart:convert: """, key is String, true));
|
| + }
|
| + putIfAbsent(key, ifAbsent()) {
|
| + if (containsKey(key)) return this[key];
|
| + var value = ifAbsent();
|
| + this[key] = value;
|
| + return value;
|
| + }
|
| + remove(Object key) {
|
| + if (!_isUpgraded && !containsKey(key)) return null;
|
| + return _upgrade().remove(key);
|
| + }
|
| + void clear() {
|
| + if (_isUpgraded) {
|
| + _upgradedMap.clear();
|
| + }
|
| + else {
|
| + if (_data != null) {
|
| + _data.clear();
|
| }
|
| - _original = _processed = null;
|
| - _data = {};
|
| + _original = _processed = null;
|
| + _data = {
|
| + }
|
| + ;
|
| }
|
| }
|
| - void forEach(void f(key, value)) {
|
| - if (_isUpgraded) return _upgradedMap.forEach(f);
|
| - List<String> keys = _computeKeys();
|
| - for (int i = 0; i < keys.length; i++) {
|
| - String key = keys[i];
|
| - var value = _getProperty(_processed, key);
|
| - if (_isUnprocessed(value)) {
|
| - value = _convertJsonToDartLazy(_getProperty(_original, key));
|
| - _setProperty(_processed, key, value);
|
| + void forEach(void f(key, value)) {
|
| + if (_isUpgraded) return _upgradedMap.forEach(f);
|
| + List<String> keys = _computeKeys();
|
| + for (int i = 0;
|
| + i < keys.length;
|
| + i++) {
|
| + String key = keys[i];
|
| + var value = _getProperty(_processed, key);
|
| + if (_isUnprocessed(value)) {
|
| + value = _convertJsonToDartLazy(_getProperty(_original, key));
|
| + _setProperty(_processed, key, value);
|
| }
|
| - f(key, value);
|
| - if (!identical(keys, _data)) {
|
| - throw new ConcurrentModificationError(this);
|
| + f(key, value);
|
| + if (!identical(keys, _data)) {
|
| + throw new ConcurrentModificationError(this);
|
| }
|
| }
|
| }
|
| - String toString() => Maps.mapToString(this);
|
| - bool get _isUpgraded => _processed == null;
|
| - Map get _upgradedMap {
|
| - assert(_isUpgraded);
|
| - return ((__x32) => DDC$RT.cast(__x32, dynamic,
|
| - DDC$RT.type((Map<dynamic, dynamic> _) {}), "CastGeneral",
|
| - """line 299, column 12 of dart:convert: """,
|
| - __x32 is Map<dynamic, dynamic>, true))(JS('LinkedHashMap', '#', _data));
|
| - }
|
| - List<String> _computeKeys() {
|
| - assert(!_isUpgraded);
|
| - List keys = DDC$RT.cast(_data, dynamic, DDC$RT.type((List<dynamic> _) {}),
|
| - "CastGeneral", """line 304, column 17 of dart:convert: """,
|
| - _data is List<dynamic>, true);
|
| - if (keys == null) {
|
| - keys = _data = _getPropertyNames(_original);
|
| + String toString() => Maps.mapToString(this);
|
| + bool get _isUpgraded => _processed == null;
|
| + Map get _upgradedMap {
|
| + assert (_isUpgraded); return ((__x32) => DDC$RT.cast(__x32, dynamic, DDC$RT.type((Map<dynamic, dynamic> _) {
|
| }
|
| - return ((__x33) => DDC$RT.cast(__x33, dynamic,
|
| - DDC$RT.type((List<String> _) {}), "CastGeneral",
|
| - """line 308, column 12 of dart:convert: """, __x33 is List<String>,
|
| - false))(JS('JSExtendableArray', '#', keys));
|
| + ), "CastGeneral", """line 299, column 12 of dart:convert: """, __x32 is Map<dynamic, dynamic>, true))(JS('LinkedHashMap', '#', _data));
|
| }
|
| - Map _upgrade() {
|
| - if (_isUpgraded) return _upgradedMap;
|
| - Map result = {};
|
| - List<String> keys = _computeKeys();
|
| - for (int i = 0; i < keys.length; i++) {
|
| - String key = keys[i];
|
| - result[key] = this[key];
|
| + List<String> _computeKeys() {
|
| + assert (!_isUpgraded); List keys = DDC$RT.cast(_data, dynamic, DDC$RT.type((List<dynamic> _) {
|
| }
|
| - if (keys.isEmpty) {
|
| - keys.add(null);
|
| - } else {
|
| - keys.clear();
|
| + ), "CastGeneral", """line 304, column 17 of dart:convert: """, _data is List<dynamic>, true);
|
| + if (keys == null) {
|
| + keys = _data = _getPropertyNames(_original);
|
| }
|
| - _original = _processed = null;
|
| - _data = result;
|
| - assert(_isUpgraded);
|
| - return result;
|
| - }
|
| - _process(String key) {
|
| - if (!_hasProperty(_original, key)) return null;
|
| - var result = _convertJsonToDartLazy(_getProperty(_original, key));
|
| - return _setProperty(_processed, key, result);
|
| + return ((__x33) => DDC$RT.cast(__x33, dynamic, DDC$RT.type((List<String> _) {
|
| + }
|
| + ), "CastGeneral", """line 308, column 12 of dart:convert: """, __x33 is List<String>, false))(JS('JSExtendableArray', '#', keys));
|
| }
|
| - static bool _hasProperty(object, String key) => ((__x34) => DDC$RT.cast(__x34,
|
| - dynamic, bool, "CastGeneral",
|
| - """line 352, column 10 of dart:convert: """, __x34 is bool, true))(
|
| - JS('bool', 'Object.prototype.hasOwnProperty.call(#,#)', object, key));
|
| - static _getProperty(object, String key) => JS('', '#[#]', object, key);
|
| - static _setProperty(object, String key, value) =>
|
| - JS('', '#[#]=#', object, key, value);
|
| - static List _getPropertyNames(object) => ((__x35) => DDC$RT.cast(__x35,
|
| - dynamic, DDC$RT.type((List<dynamic> _) {}), "CastGeneral",
|
| - """line 358, column 10 of dart:convert: """, __x35 is List<dynamic>,
|
| - true))(JS('JSExtendableArray', 'Object.keys(#)', object));
|
| - static bool _isUnprocessed(object) => ((__x36) => DDC$RT.cast(__x36, dynamic,
|
| - bool, "CastGeneral", """line 360, column 10 of dart:convert: """,
|
| - __x36 is bool, true))(JS('bool', 'typeof(#)=="undefined"', object));
|
| - static _newJavaScriptObject() => JS('=Object', 'Object.create(null)');
|
| + Map _upgrade() {
|
| + if (_isUpgraded) return _upgradedMap;
|
| + Map result = {
|
| + }
|
| + ;
|
| + List<String> keys = _computeKeys();
|
| + for (int i = 0;
|
| + i < keys.length;
|
| + i++) {
|
| + String key = keys[i];
|
| + result[key] = this[key];
|
| + }
|
| + if (keys.isEmpty) {
|
| + keys.add(null);
|
| + }
|
| + else {
|
| + keys.clear();
|
| + }
|
| + _original = _processed = null;
|
| + _data = result;
|
| + assert (_isUpgraded); return result;
|
| + }
|
| + _process(String key) {
|
| + if (!_hasProperty(_original, key)) return null;
|
| + var result = _convertJsonToDartLazy(_getProperty(_original, key));
|
| + return _setProperty(_processed, key, result);
|
| + }
|
| + static bool _hasProperty(object, String key) => ((__x34) => DDC$RT.cast(__x34, dynamic, bool, "CastGeneral", """line 352, column 10 of dart:convert: """, __x34 is bool, true))(JS('bool', 'Object.prototype.hasOwnProperty.call(#,#)', object, key));
|
| + static _getProperty(object, String key) => JS('', '#[#]', object, key);
|
| + static _setProperty(object, String key, value) => JS('', '#[#]=#', object, key, value);
|
| + static List _getPropertyNames(object) => ((__x35) => DDC$RT.cast(__x35, dynamic, DDC$RT.type((List<dynamic> _) {
|
| + }
|
| +), "CastGeneral", """line 358, column 10 of dart:convert: """, __x35 is List<dynamic>, true))(JS('JSExtendableArray', 'Object.keys(#)', object));
|
| + static bool _isUnprocessed(object) => ((__x36) => DDC$RT.cast(__x36, dynamic, bool, "CastGeneral", """line 360, column 10 of dart:convert: """, __x36 is bool, true))(JS('bool', 'typeof(#)=="undefined"', object));
|
| + static _newJavaScriptObject() => JS('=Object', 'Object.create(null)');
|
| }
|
| -class _JsonMapKeyIterable extends ListIterable {
|
| - final _JsonMap _parent;
|
| - _JsonMapKeyIterable(this._parent);
|
| - int get length => _parent.length;
|
| - String elementAt(int index) {
|
| - return ((__x37) => DDC$RT.cast(__x37, dynamic, String, "CastGeneral",
|
| - """line 372, column 12 of dart:convert: """, __x37 is String,
|
| - true))(_parent._isUpgraded
|
| - ? _parent.keys.elementAt(index)
|
| - : _parent._computeKeys()[index]);
|
| - }
|
| - Iterator get iterator {
|
| - return ((__x38) => DDC$RT.cast(__x38, Object,
|
| - DDC$RT.type((Iterator<dynamic> _) {}), "CastGeneral",
|
| - """line 380, column 12 of dart:convert: """,
|
| - __x38 is Iterator<dynamic>, true))(_parent._isUpgraded
|
| - ? _parent.keys.iterator
|
| - : _parent._computeKeys().iterator);
|
| - }
|
| - bool contains(Object key) => _parent.containsKey(key);
|
| + class _JsonMapKeyIterable extends ListIterable {final _JsonMap _parent;
|
| + _JsonMapKeyIterable(this._parent);
|
| + int get length => _parent.length;
|
| + String elementAt(int index) {
|
| +return ((__x37) => DDC$RT.cast(__x37, dynamic, String, "CastGeneral", """line 372, column 12 of dart:convert: """, __x37 is String, true))(_parent._isUpgraded ? _parent.keys.elementAt(index) : _parent._computeKeys()[index]);
|
| }
|
| -class _JsonDecoderSink extends _StringSinkConversionSink {
|
| - final _Reviver _reviver;
|
| - final Sink<Object> _sink;
|
| - _JsonDecoderSink(this._reviver, this._sink) : super(new StringBuffer());
|
| - void close() {
|
| - super.close();
|
| - StringBuffer buffer = DDC$RT.cast(_stringSink, StringSink, StringBuffer,
|
| - "CastGeneral", """line 404, column 27 of dart:convert: """,
|
| - _stringSink is StringBuffer, true);
|
| - String accumulated = buffer.toString();
|
| - buffer.clear();
|
| - Object decoded = _parseJson(accumulated, _reviver);
|
| - _sink.add(decoded);
|
| - _sink.close();
|
| + Iterator get iterator {
|
| +return ((__x38) => DDC$RT.cast(__x38, Object, DDC$RT.type((Iterator<dynamic> _) {
|
| }
|
| +), "CastGeneral", """line 380, column 12 of dart:convert: """, __x38 is Iterator<dynamic>, true))(_parent._isUpgraded ? _parent.keys.iterator : _parent._computeKeys().iterator);
|
| +}
|
| + bool contains(Object key) => _parent.containsKey(key);
|
| +}
|
| + class _JsonDecoderSink extends _StringSinkConversionSink {final _Reviver _reviver;
|
| + final Sink<Object> _sink;
|
| + _JsonDecoderSink(this._reviver, this._sink) : super(new StringBuffer());
|
| + void close() {
|
| +super.close();
|
| + StringBuffer buffer = DDC$RT.cast(_stringSink, StringSink, StringBuffer, "CastGeneral", """line 404, column 27 of dart:convert: """, _stringSink is StringBuffer, true);
|
| + String accumulated = buffer.toString();
|
| + buffer.clear();
|
| + Object decoded = _parseJson(accumulated, _reviver);
|
| + _sink.add(decoded);
|
| + _sink.close();
|
| +}
|
| }
|
|
|