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

Unified Diff: test/dart_codegen/expect/convert/convert

Issue 961493003: don't run dart gen on JS patch code (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5fd3affe6bcc3f357ca4c44c855519aa57e5b9e5 100644
--- a/test/dart_codegen/expect/convert/convert
+++ b/test/dart_codegen/expect/convert/convert
@@ -4,8 +4,6 @@ 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;
part 'ascii.dart';
part 'byte_conversion.dart';
part 'chunked_conversion.dart';
@@ -18,249 +16,3 @@ 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++) {
- var item = JS('', '#[#]', e, i);
- JS('', '#[#]=#', e, i, reviver(i, walk(item)));
- }
- return e;
- }
- _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);
- }
- map._original = processed;
- return map;
- }
- return reviver(null, walk(json));
-}
-_convertJsonToDartLazy(object) {
- if (object == null) return null;
- if (JS('bool', 'typeof # != "object"', object)) {
- return object;
- }
- if (JS('bool', 'Object.getPrototypeOf(#) !== Array.prototype', object)) {
- return new _JsonMap(object);
- }
- 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;
- }
- }
- 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]);
- }
- 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;
- }
- 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 = {};
- }
- }
- 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);
- }
- }
- }
- 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);
- }
- 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));
- }
- 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 _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();
- }
-}
« no previous file with comments | « test/dart_codegen/expect/collection/linked_hash_set.dart ('k') | test/dart_codegen/expect/convert/json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698