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

Side by Side Diff: test/codegen/expect/dart/convert.js

Issue 1010893004: Allow S->T <: dynamic->T (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase and address comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/codegen/expect/dart/collection.js ('k') | test/codegen/expect/dart/core.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var convert; 1 var convert;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 let ASCII = new AsciiCodec(); 4 let ASCII = new AsciiCodec();
5 let _ASCII_MASK = 127; 5 let _ASCII_MASK = 127;
6 let _allowInvalid = Symbol('_allowInvalid'); 6 let _allowInvalid = Symbol('_allowInvalid');
7 class AsciiCodec extends Encoding { 7 class AsciiCodec extends Encoding {
8 AsciiCodec(opt$) { 8 AsciiCodec(opt$) {
9 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d; 9 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d;
10 this[_allowInvalid] = allowInvalid; 10 this[_allowInvalid] = allowInvalid;
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (reviver === null) 611 if (reviver === null)
612 return this.decoder.convert(source); 612 return this.decoder.convert(source);
613 return new JsonDecoder(reviver).convert(source); 613 return new JsonDecoder(reviver).convert(source);
614 } 614 }
615 encode(value, opt$) { 615 encode(value, opt$) {
616 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable; 616 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable;
617 if (toEncodable === null) 617 if (toEncodable === null)
618 toEncodable = this[_toEncodable]; 618 toEncodable = this[_toEncodable];
619 if (toEncodable === null) 619 if (toEncodable === null)
620 return this.encoder.convert(value); 620 return this.encoder.convert(value);
621 return new JsonEncoder(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))).convert(value); 621 return new JsonEncoder(dart.closureWrap(toEncodable, "(Object) → Object")) .convert(value);
622 } 622 }
623 get encoder() { 623 get encoder() {
624 if (this[_toEncodable] === null) 624 if (this[_toEncodable] === null)
625 return new JsonEncoder(); 625 return new JsonEncoder();
626 return new JsonEncoder(dart.as(this[_toEncodable], dart.throw_("Unimplemen ted type (Object) → Object"))); 626 return new JsonEncoder(dart.closureWrap(this[_toEncodable], "(Object) → Ob ject"));
627 } 627 }
628 get decoder() { 628 get decoder() {
629 if (this[_reviver] === null) 629 if (this[_reviver] === null)
630 return new JsonDecoder(); 630 return new JsonDecoder();
631 return new JsonDecoder(this[_reviver]); 631 return new JsonDecoder(this[_reviver]);
632 } 632 }
633 } 633 }
634 dart.defineNamedConstructor(JsonCodec, 'withReviver'); 634 dart.defineNamedConstructor(JsonCodec, 'withReviver');
635 class JsonEncoder extends Converter$(core.Object, core.String) { 635 class JsonEncoder extends Converter$(core.Object, core.String) {
636 JsonEncoder(toEncodable) { 636 JsonEncoder(toEncodable) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 for (let i = 1; dart.notNull(i) < dart.notNull(list.length); i = dart.no tNull(i) + 1) { 958 for (let i = 1; dart.notNull(i) < dart.notNull(list.length); i = dart.no tNull(i) + 1) {
959 this.writeString(','); 959 this.writeString(',');
960 this.writeObject(list.get(i)); 960 this.writeObject(list.get(i));
961 } 961 }
962 } 962 }
963 this.writeString(']'); 963 this.writeString(']');
964 } 964 }
965 writeMap(map) { 965 writeMap(map) {
966 this.writeString('{'); 966 this.writeString('{');
967 let separator = '"'; 967 let separator = '"';
968 map.forEach(((key, value) => { 968 map.forEach(dart.closureWrap(((key, value) => {
969 this.writeString(separator); 969 this.writeString(separator);
970 separator = ',"'; 970 separator = ',"';
971 this.writeStringContent(key); 971 this.writeStringContent(key);
972 this.writeString('":'); 972 this.writeString('":');
973 this.writeObject(value); 973 this.writeObject(value);
974 }).bind(this)); 974 }).bind(this), "(String, Object) → void"));
975 this.writeString('}'); 975 this.writeString('}');
976 } 976 }
977 } 977 }
978 _JsonStringifier.BACKSPACE = 8; 978 _JsonStringifier.BACKSPACE = 8;
979 _JsonStringifier.TAB = 9; 979 _JsonStringifier.TAB = 9;
980 _JsonStringifier.NEWLINE = 10; 980 _JsonStringifier.NEWLINE = 10;
981 _JsonStringifier.CARRIAGE_RETURN = 13; 981 _JsonStringifier.CARRIAGE_RETURN = 13;
982 _JsonStringifier.FORM_FEED = 12; 982 _JsonStringifier.FORM_FEED = 12;
983 _JsonStringifier.QUOTE = 34; 983 _JsonStringifier.QUOTE = 34;
984 _JsonStringifier.CHAR_0 = 48; 984 _JsonStringifier.CHAR_0 = 48;
(...skipping 28 matching lines...) Expand all
1013 this.writeString(']'); 1013 this.writeString(']');
1014 } 1014 }
1015 } 1015 }
1016 writeMap(map) { 1016 writeMap(map) {
1017 if (map.isEmpty) { 1017 if (map.isEmpty) {
1018 this.writeString('{}'); 1018 this.writeString('{}');
1019 } else { 1019 } else {
1020 this.writeString('{\n'); 1020 this.writeString('{\n');
1021 this[_indentLevel] = dart.notNull(this[_indentLevel]) + 1; 1021 this[_indentLevel] = dart.notNull(this[_indentLevel]) + 1;
1022 let first = true; 1022 let first = true;
1023 map.forEach(dart.as(((key, value) => { 1023 map.forEach(((key, value) => {
1024 if (!dart.notNull(first)) { 1024 if (!dart.notNull(first)) {
1025 this.writeString(",\n"); 1025 this.writeString(",\n");
1026 } 1026 }
1027 this.writeIndentation(this[_indentLevel]); 1027 this.writeIndentation(this[_indentLevel]);
1028 this.writeString('"'); 1028 this.writeString('"');
1029 this.writeStringContent(key); 1029 this.writeStringContent(key);
1030 this.writeString('": '); 1030 this.writeString('": ');
1031 this.writeObject(value); 1031 this.writeObject(value);
1032 first = false; 1032 first = false;
1033 }).bind(this), dart.throw_("Unimplemented type (dynamic, dynamic) → void "))); 1033 }).bind(this));
1034 this.writeString('\n'); 1034 this.writeString('\n');
1035 this[_indentLevel] = dart.notNull(this[_indentLevel]) - 1; 1035 this[_indentLevel] = dart.notNull(this[_indentLevel]) - 1;
1036 this.writeIndentation(this[_indentLevel]); 1036 this.writeIndentation(this[_indentLevel]);
1037 this.writeString('}'); 1037 this.writeString('}');
1038 } 1038 }
1039 } 1039 }
1040 } 1040 }
1041 class _JsonStringStringifier extends _JsonStringifier { 1041 class _JsonStringStringifier extends _JsonStringifier {
1042 _JsonStringStringifier($_sink, _toEncodable) { 1042 _JsonStringStringifier($_sink, _toEncodable) {
1043 this[_sink] = $_sink; 1043 this[_sink] = $_sink;
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 function _convertJsonToDart(json, reviver) { 2025 function _convertJsonToDart(json, reviver) {
2026 dart.assert(reviver !== null); 2026 dart.assert(reviver !== null);
2027 // Function walk: (dynamic) → dynamic 2027 // Function walk: (dynamic) → dynamic
2028 function walk(e) { 2028 function walk(e) {
2029 if (e == null || typeof e != "object") { 2029 if (e == null || typeof e != "object") {
2030 return e; 2030 return e;
2031 } 2031 }
2032 if (Object.getPrototypeOf(e) === Array.prototype) { 2032 if (Object.getPrototypeOf(e) === Array.prototype) {
2033 for (let i = 0; dart.notNull(i) < e.length; i = dart.notNull(i) + 1) { 2033 for (let i = 0; dart.notNull(i) < e.length; i = dart.notNull(i) + 1) {
2034 let item = e[i]; 2034 let item = e[i];
2035 e[i] = reviver(i, walk(item)); 2035 e[i] = dart.dinvokef(reviver, i, walk(item));
2036 } 2036 }
2037 return e; 2037 return e;
2038 } 2038 }
2039 let map = new _JsonMap(e); 2039 let map = new _JsonMap(e);
2040 let processed = map[_processed]; 2040 let processed = map[_processed];
2041 let keys = map._computeKeys(); 2041 let keys = map._computeKeys();
2042 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN ull(i) + 1) { 2042 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN ull(i) + 1) {
2043 let key = keys.get(i); 2043 let key = keys.get(i);
2044 let revived = reviver(key, walk(e[key])); 2044 let revived = dart.dinvokef(reviver, key, walk(e[key]));
2045 processed[key] = revived; 2045 processed[key] = revived;
2046 } 2046 }
2047 map[_original] = processed; 2047 map[_original] = processed;
2048 return map; 2048 return map;
2049 } 2049 }
2050 return reviver(null, walk(json)); 2050 return dart.dinvokef(reviver, null, walk(json));
2051 } 2051 }
2052 // Function _convertJsonToDartLazy: (dynamic) → dynamic 2052 // Function _convertJsonToDartLazy: (dynamic) → dynamic
2053 function _convertJsonToDartLazy(object) { 2053 function _convertJsonToDartLazy(object) {
2054 if (object === null) 2054 if (object === null)
2055 return null; 2055 return null;
2056 if (typeof object != "object") { 2056 if (typeof object != "object") {
2057 return object; 2057 return object;
2058 } 2058 }
2059 if (Object.getPrototypeOf(object) !== Array.prototype) { 2059 if (Object.getPrototypeOf(object) !== Array.prototype) {
2060 return new _JsonMap(object); 2060 return new _JsonMap(object);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 if (this[_isUpgraded]) 2178 if (this[_isUpgraded])
2179 return this[_upgradedMap].forEach(f); 2179 return this[_upgradedMap].forEach(f);
2180 let keys = this[_computeKeys](); 2180 let keys = this[_computeKeys]();
2181 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN ull(i) + 1) { 2181 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN ull(i) + 1) {
2182 let key = keys.get(i); 2182 let key = keys.get(i);
2183 let value = _getProperty(this[_processed], key); 2183 let value = _getProperty(this[_processed], key);
2184 if (_isUnprocessed(value)) { 2184 if (_isUnprocessed(value)) {
2185 value = _convertJsonToDartLazy(_getProperty(this[_original], key)); 2185 value = _convertJsonToDartLazy(_getProperty(this[_original], key));
2186 _setProperty(this[_processed], key, value); 2186 _setProperty(this[_processed], key, value);
2187 } 2187 }
2188 f(key, value); 2188 dart.dinvokef(f, key, value);
2189 if (!dart.notNull(core.identical(keys, this[_data]))) { 2189 if (!dart.notNull(core.identical(keys, this[_data]))) {
2190 throw new core.ConcurrentModificationError(this); 2190 throw new core.ConcurrentModificationError(this);
2191 } 2191 }
2192 } 2192 }
2193 } 2193 }
2194 toString() { 2194 toString() {
2195 return collection.Maps.mapToString(this); 2195 return collection.Maps.mapToString(this);
2196 } 2196 }
2197 get [_isUpgraded]() { 2197 get [_isUpgraded]() {
2198 return this[_processed] === null; 2198 return this[_processed] === null;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 exports.ClosableStringSink = ClosableStringSink; 2321 exports.ClosableStringSink = ClosableStringSink;
2322 exports.StringConversionSinkBase = StringConversionSinkBase; 2322 exports.StringConversionSinkBase = StringConversionSinkBase;
2323 exports.StringConversionSinkMixin = StringConversionSinkMixin; 2323 exports.StringConversionSinkMixin = StringConversionSinkMixin;
2324 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2324 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2325 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2325 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2326 exports.UTF8 = UTF8; 2326 exports.UTF8 = UTF8;
2327 exports.Utf8Codec = Utf8Codec; 2327 exports.Utf8Codec = Utf8Codec;
2328 exports.Utf8Encoder = Utf8Encoder; 2328 exports.Utf8Encoder = Utf8Encoder;
2329 exports.Utf8Decoder = Utf8Decoder; 2329 exports.Utf8Decoder = Utf8Decoder;
2330 })(convert || (convert = {})); 2330 })(convert || (convert = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/dart/collection.js ('k') | test/codegen/expect/dart/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698