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

Side by Side Diff: test/dart_codegen/expect/convert/json.dart

Issue 1038583004: Rationalize coercions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase 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
OLDNEW
1 part of dart.convert; 1 part of dart.convert;
2 class JsonUnsupportedObjectError extends Error {final unsupportedObject; 2 class JsonUnsupportedObjectError extends Error {final unsupportedObject;
3 final cause; 3 final cause;
4 JsonUnsupportedObjectError(this.unsupportedObject, { 4 JsonUnsupportedObjectError(this.unsupportedObject, {
5 this.cause} 5 this.cause}
6 ); 6 );
7 String toString() { 7 String toString() {
8 if (cause != null) { 8 if (cause != null) {
9 return "Converting object to an encodable object failed."; 9 return "Converting object to an encodable object failed.";
10 } 10 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 JsonDecoder get decoder { 54 JsonDecoder get decoder {
55 if (_reviver == null) return const JsonDecoder(); 55 if (_reviver == null) return const JsonDecoder();
56 return new JsonDecoder(_reviver); 56 return new JsonDecoder(_reviver);
57 } 57 }
58 } 58 }
59 class JsonEncoder extends Converter<Object, String> {final String indent; 59 class JsonEncoder extends Converter<Object, String> {final String indent;
60 final Function _toEncodable; 60 final Function _toEncodable;
61 const JsonEncoder([Object toEncodable(Object nonSerializable)]) : this.indent = null, this._toEncodable = toEncodable; 61 const JsonEncoder([Object toEncodable(Object nonSerializable)]) : this.indent = null, this._toEncodable = toEncodable;
62 const JsonEncoder.withIndent(this.indent, [Object toEncodable(Object nonSeriali zable)]) : this._toEncodable = toEncodable; 62 const JsonEncoder.withIndent(this.indent, [Object toEncodable(Object nonSeriali zable)]) : this._toEncodable = toEncodable;
63 String convert(Object object) => _JsonStringStringifier.stringify(object, DEVC$ RT.cast(_toEncodable, Function, __t9, "CastGeneral", """line 243, column 48 of d art:convert/json.dart: """, _toEncodable is __t9, true), indent); 63 String convert(Object object) => _JsonStringStringifier.stringify(object, DEVC$ RT.cast(_toEncodable, Function, __t9, "ImplicitCast", """line 243, column 48 of dart:convert/json.dart: """, _toEncodable is __t9, true), indent);
64 ChunkedConversionSink<Object> startChunkedConversion(Sink<String> sink) { 64 ChunkedConversionSink<Object> startChunkedConversion(Sink<String> sink) {
65 if (sink is! StringConversionSink) { 65 if (sink is! StringConversionSink) {
66 sink = new StringConversionSink.from(sink); 66 sink = new StringConversionSink.from(sink);
67 } 67 }
68 else if (sink is _Utf8EncoderSink) { 68 else if (sink is _Utf8EncoderSink) {
69 return new _JsonUtf8EncoderSink(sink._sink, _toEncodable, JsonUtf8Encoder._utf8E ncode(indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); 69 return new _JsonUtf8EncoderSink(sink._sink, _toEncodable, JsonUtf8Encoder._utf8E ncode(indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE);
70 } 70 }
71 return new _JsonEncoderSink(DEVC$RT.cast(sink, DEVC$RT.type((Sink<String> _) { 71 return new _JsonEncoderSink(DEVC$RT.cast(sink, DEVC$RT.type((Sink<String> _) {
72 } 72 }
73 ), StringConversionSink, "CastGeneral", """line 262, column 33 of dart:convert/j son.dart: """, sink is StringConversionSink, true), _toEncodable, indent); 73 ), StringConversionSink, "ImplicitCast", """line 262, column 33 of dart:convert/ json.dart: """, sink is StringConversionSink, true), _toEncodable, indent);
74 } 74 }
75 Stream<String> bind(Stream<Object> stream) => ((__x12) => DEVC$RT.cast(__x12, D EVC$RT.type((DDC$async$.Stream<dynamic> _) { 75 Stream<String> bind(Stream<Object> stream) => ((__x12) => DEVC$RT.cast(__x12, D EVC$RT.type((DDC$async$.Stream<dynamic> _) {
76 } 76 }
77 ), DEVC$RT.type((DDC$async$.Stream<String> _) { 77 ), DEVC$RT.type((DDC$async$.Stream<String> _) {
78 } 78 }
79 ), "CastDynamic", """line 266, column 49 of dart:convert/json.dart: """, __x12 i s DDC$async$.Stream<String>, false))(super.bind(stream)); 79 ), "CompositeCast", """line 266, column 49 of dart:convert/json.dart: """, __x12 is DDC$async$.Stream<String>, false))(super.bind(stream));
80 Converter<Object, dynamic> fuse(Converter<String, dynamic> other) { 80 Converter<Object, dynamic> fuse(Converter<String, dynamic> other) {
81 if (other is Utf8Encoder) { 81 if (other is Utf8Encoder) {
82 return new JsonUtf8Encoder(indent, DEVC$RT.cast(_toEncodable, Function, __t13, " CastGeneral", """line 270, column 42 of dart:convert/json.dart: """, _toEncodabl e is __t13, false)); 82 return new JsonUtf8Encoder(indent, DEVC$RT.cast(_toEncodable, Function, __t13, " CompositeCast", """line 270, column 42 of dart:convert/json.dart: """, _toEncoda ble is __t13, false));
83 } 83 }
84 return super.fuse(other); 84 return super.fuse(other);
85 } 85 }
86 } 86 }
87 class JsonUtf8Encoder extends Converter<Object, List<int>> {static const int DE FAULT_BUFFER_SIZE = 256; 87 class JsonUtf8Encoder extends Converter<Object, List<int>> {static const int DE FAULT_BUFFER_SIZE = 256;
88 final List<int> _indent; 88 final List<int> _indent;
89 final Function _toEncodable; 89 final Function _toEncodable;
90 final int _bufferSize; 90 final int _bufferSize;
91 JsonUtf8Encoder([String indent, toEncodable(Object object), int bufferSize = DE FAULT_BUFFER_SIZE]) : _indent = _utf8Encode(indent), _toEncodable = toEncodable, _bufferSize = bufferSize; 91 JsonUtf8Encoder([String indent, toEncodable(Object object), int bufferSize = DE FAULT_BUFFER_SIZE]) : _indent = _utf8Encode(indent), _toEncodable = toEncodable, _bufferSize = bufferSize;
92 static List<int> _utf8Encode(String string) { 92 static List<int> _utf8Encode(String string) {
93 if (string == null) return null; 93 if (string == null) return null;
94 if (string.isEmpty) return new Uint8List(0); 94 if (string.isEmpty) return new Uint8List(0);
95 checkAscii: { 95 checkAscii: {
96 for (int i = 0; i < string.length; i++) { 96 for (int i = 0; i < string.length; i++) {
97 if (string.codeUnitAt(i) >= 0x80) break checkAscii; 97 if (string.codeUnitAt(i) >= 0x80) break checkAscii;
98 } 98 }
99 return string.codeUnits; 99 return string.codeUnits;
100 } 100 }
101 return UTF8.encode(string); 101 return UTF8.encode(string);
102 } 102 }
103 List<int> convert(Object object) { 103 List<int> convert(Object object) {
104 List<List<int>> bytes = ((__x15) => DEVC$RT.cast(__x15, DEVC$RT.type((List<dynam ic> _) { 104 List<List<int>> bytes = ((__x15) => DEVC$RT.cast(__x15, DEVC$RT.type((List<dynam ic> _) {
105 } 105 }
106 ), DEVC$RT.type((List<List<int>> _) { 106 ), DEVC$RT.type((List<List<int>> _) {
107 } 107 }
108 ), "CastLiteral", """line 338, column 29 of dart:convert/json.dart: """, __x15 i s List<List<int>>, false))([]); 108 ), "InferableLiteral", """line 338, column 29 of dart:convert/json.dart: """, __ x15 is List<List<int>>, false))([]);
109 void addChunk(Uint8List chunk, int start, int end) { 109 void addChunk(Uint8List chunk, int start, int end) {
110 if (start > 0 || end < chunk.length) { 110 if (start > 0 || end < chunk.length) {
111 int length = end - start; 111 int length = end - start;
112 chunk = new Uint8List.view(chunk.buffer, chunk.offsetInBytes + start, length); 112 chunk = new Uint8List.view(chunk.buffer, chunk.offsetInBytes + start, length);
113 } 113 }
114 bytes.add(chunk); 114 bytes.add(chunk);
115 } 115 }
116 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func tion, __t13, "CastGeneral", """line 352, column 36 of dart:convert/json.dart: "" ", _toEncodable is __t13, false), _bufferSize, addChunk); 116 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func tion, __t13, "CompositeCast", """line 352, column 36 of dart:convert/json.dart: """, _toEncodable is __t13, false), _bufferSize, addChunk);
117 if (bytes.length == 1) return bytes[0]; 117 if (bytes.length == 1) return bytes[0];
118 int length = 0; 118 int length = 0;
119 for (int i = 0; i < bytes.length; i++) { 119 for (int i = 0; i < bytes.length; i++) {
120 length += bytes[i].length; 120 length += bytes[i].length;
121 } 121 }
122 Uint8List result = new Uint8List(length); 122 Uint8List result = new Uint8List(length);
123 for (int i = 0, offset = 0; i < bytes.length; i++) { 123 for (int i = 0, offset = 0; i < bytes.length; i++) {
124 var byteList = bytes[i]; 124 var byteList = bytes[i];
125 int end = offset + byteList.length; 125 int end = offset + byteList.length;
126 result.setRange(offset, end, byteList); 126 result.setRange(offset, end, byteList);
127 offset = end; 127 offset = end;
128 } 128 }
129 return result; 129 return result;
130 } 130 }
131 ChunkedConversionSink<Object> startChunkedConversion(Sink<List<int>> sink) { 131 ChunkedConversionSink<Object> startChunkedConversion(Sink<List<int>> sink) {
132 ByteConversionSink byteSink; 132 ByteConversionSink byteSink;
133 if (sink is ByteConversionSink) { 133 if (sink is ByteConversionSink) {
134 byteSink = sink; 134 byteSink = sink;
135 } 135 }
136 else { 136 else {
137 byteSink = new ByteConversionSink.from(sink); 137 byteSink = new ByteConversionSink.from(sink);
138 } 138 }
139 return new _JsonUtf8EncoderSink(byteSink, _toEncodable, _indent, _bufferSize); 139 return new _JsonUtf8EncoderSink(byteSink, _toEncodable, _indent, _bufferSize);
140 } 140 }
141 Stream<List<int>> bind(Stream<Object> stream) { 141 Stream<List<int>> bind(Stream<Object> stream) {
142 return ((__x16) => DEVC$RT.cast(__x16, DEVC$RT.type((DDC$async$.Stream<dynamic> _) { 142 return ((__x16) => DEVC$RT.cast(__x16, DEVC$RT.type((DDC$async$.Stream<dynamic> _) {
143 } 143 }
144 ), DEVC$RT.type((DDC$async$.Stream<List<int>> _) { 144 ), DEVC$RT.type((DDC$async$.Stream<List<int>> _) {
145 } 145 }
146 ), "CastDynamic", """line 391, column 12 of dart:convert/json.dart: """, __x16 i s DDC$async$.Stream<List<int>>, false))(super.bind(stream)); 146 ), "CompositeCast", """line 391, column 12 of dart:convert/json.dart: """, __x16 is DDC$async$.Stream<List<int>>, false))(super.bind(stream));
147 } 147 }
148 Converter<Object, dynamic> fuse(Converter<List<int>, dynamic> other) { 148 Converter<Object, dynamic> fuse(Converter<List<int>, dynamic> other) {
149 return super.fuse(other); 149 return super.fuse(other);
150 } 150 }
151 } 151 }
152 class _JsonEncoderSink extends ChunkedConversionSink<Object> {final String _ind ent; 152 class _JsonEncoderSink extends ChunkedConversionSink<Object> {final String _ind ent;
153 final Function _toEncodable; 153 final Function _toEncodable;
154 final StringConversionSink _sink; 154 final StringConversionSink _sink;
155 bool _isDone = false; 155 bool _isDone = false;
156 _JsonEncoderSink(this._sink, this._toEncodable, this._indent); 156 _JsonEncoderSink(this._sink, this._toEncodable, this._indent);
157 void add(Object o) { 157 void add(Object o) {
158 if (_isDone) { 158 if (_isDone) {
159 throw new StateError("Only one call to add allowed"); 159 throw new StateError("Only one call to add allowed");
160 } 160 }
161 _isDone = true; 161 _isDone = true;
162 ClosableStringSink stringSink = _sink.asStringSink(); 162 ClosableStringSink stringSink = _sink.asStringSink();
163 _JsonStringStringifier.printOn(o, stringSink, DEVC$RT.cast(_toEncodable, Functi on, __t9, "CastGeneral", """line 425, column 51 of dart:convert/json.dart: """, _toEncodable is __t9, true), _indent); 163 _JsonStringStringifier.printOn(o, stringSink, DEVC$RT.cast(_toEncodable, Functi on, __t9, "ImplicitCast", """line 425, column 51 of dart:convert/json.dart: """, _toEncodable is __t9, true), _indent);
164 stringSink.close(); 164 stringSink.close();
165 } 165 }
166 void close() { 166 void close() {
167 } 167 }
168 } 168 }
169 class _JsonUtf8EncoderSink extends ChunkedConversionSink<Object> {final ByteCon versionSink _sink; 169 class _JsonUtf8EncoderSink extends ChunkedConversionSink<Object> {final ByteCon versionSink _sink;
170 final List<int> _indent; 170 final List<int> _indent;
171 final Function _toEncodable; 171 final Function _toEncodable;
172 final int _bufferSize; 172 final int _bufferSize;
173 bool _isDone = false; 173 bool _isDone = false;
174 _JsonUtf8EncoderSink(this._sink, this._toEncodable, this._indent, this._bufferS ize); 174 _JsonUtf8EncoderSink(this._sink, this._toEncodable, this._indent, this._bufferS ize);
175 void _addChunk(Uint8List chunk, int start, int end) { 175 void _addChunk(Uint8List chunk, int start, int end) {
176 _sink.addSlice(chunk, start, end, false); 176 _sink.addSlice(chunk, start, end, false);
177 } 177 }
178 void add(Object object) { 178 void add(Object object) {
179 if (_isDone) { 179 if (_isDone) {
180 throw new StateError("Only one call to add allowed"); 180 throw new StateError("Only one call to add allowed");
181 } 181 }
182 _isDone = true; 182 _isDone = true;
183 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func tion, __t13, "CastGeneral", """line 455, column 53 of dart:convert/json.dart: "" ", _toEncodable is __t13, false), _bufferSize, _addChunk); 183 _JsonUtf8Stringifier.stringify(object, _indent, DEVC$RT.cast(_toEncodable, Func tion, __t13, "CompositeCast", """line 455, column 53 of dart:convert/json.dart: """, _toEncodable is __t13, false), _bufferSize, _addChunk);
184 _sink.close(); 184 _sink.close();
185 } 185 }
186 void close() { 186 void close() {
187 if (!_isDone) { 187 if (!_isDone) {
188 _isDone = true; 188 _isDone = true;
189 _sink.close(); 189 _sink.close();
190 } 190 }
191 } 191 }
192 } 192 }
193 class JsonDecoder extends Converter<String, Object> {final _Reviver _reviver; 193 class JsonDecoder extends Converter<String, Object> {final _Reviver _reviver;
(...skipping 13 matching lines...) Expand all
207 static const int CHAR_0 = 0x30; 207 static const int CHAR_0 = 0x30;
208 static const int BACKSLASH = 0x5c; 208 static const int BACKSLASH = 0x5c;
209 static const int CHAR_b = 0x62; 209 static const int CHAR_b = 0x62;
210 static const int CHAR_f = 0x66; 210 static const int CHAR_f = 0x66;
211 static const int CHAR_n = 0x6e; 211 static const int CHAR_n = 0x6e;
212 static const int CHAR_r = 0x72; 212 static const int CHAR_r = 0x72;
213 static const int CHAR_t = 0x74; 213 static const int CHAR_t = 0x74;
214 static const int CHAR_u = 0x75; 214 static const int CHAR_u = 0x75;
215 final List _seen = new List(); 215 final List _seen = new List();
216 final Function _toEncodable; 216 final Function _toEncodable;
217 _JsonStringifier(Object _toEncodable(Object o)) : _toEncodable = ((__x17) => DE VC$RT.cast(__x17, dynamic, Function, "CastGeneral", """line 547, column 24 of da rt:convert/json.dart: """, __x17 is Function, true))((_toEncodable != null) ? _t oEncodable : _defaultToEncodable); 217 _JsonStringifier(Object _toEncodable(Object o)) : _toEncodable = ((__x17) => DE VC$RT.cast(__x17, dynamic, Function, "DynamicCast", """line 547, column 24 of da rt:convert/json.dart: """, __x17 is Function, true))((_toEncodable != null) ? _t oEncodable : _defaultToEncodable);
218 void writeString(String characters); 218 void writeString(String characters);
219 void writeStringSlice(String characters, int start, int end); 219 void writeStringSlice(String characters, int start, int end);
220 void writeCharCode(int charCode); 220 void writeCharCode(int charCode);
221 void writeNumber(num number); 221 void writeNumber(num number);
222 static int hexDigit(int x) => x < 10 ? 48 + x : 87 + x; 222 static int hexDigit(int x) => x < 10 ? 48 + x : 87 + x;
223 void writeStringContent(String s) { 223 void writeStringContent(String s) {
224 int offset = 0; 224 int offset = 0;
225 final int length = s.length; 225 final int length = s.length;
226 for (int i = 0; i < length; i++) { 226 for (int i = 0; i < length; i++) {
227 int charCode = s.codeUnitAt(i); 227 int charCode = s.codeUnitAt(i);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 _removeSeen(object); 283 _removeSeen(object);
284 } 284 }
285 catch (e) { 285 catch (e) {
286 throw new JsonUnsupportedObjectError(object, cause: e); 286 throw new JsonUnsupportedObjectError(object, cause: e);
287 } 287 }
288 } 288 }
289 bool writeJsonValue(object) { 289 bool writeJsonValue(object) {
290 if (object is num) { 290 if (object is num) {
291 if (!object.isFinite) return false; 291 if (!object.isFinite) return false;
292 writeNumber(DEVC$RT.cast(object, dynamic, num, "CastGeneral", """line 673, colu mn 19 of dart:convert/json.dart: """, object is num, true)); 292 writeNumber(DEVC$RT.cast(object, dynamic, num, "DynamicCast", """line 673, colu mn 19 of dart:convert/json.dart: """, object is num, true));
293 return true; 293 return true;
294 } 294 }
295 else if (identical(object, true)) { 295 else if (identical(object, true)) {
296 writeString('true'); 296 writeString('true');
297 return true; 297 return true;
298 } 298 }
299 else if (identical(object, false)) { 299 else if (identical(object, false)) {
300 writeString('false'); 300 writeString('false');
301 return true; 301 return true;
302 } 302 }
303 else if (object == null) { 303 else if (object == null) {
304 writeString('null'); 304 writeString('null');
305 return true; 305 return true;
306 } 306 }
307 else if (object is String) { 307 else if (object is String) {
308 writeString('"'); 308 writeString('"');
309 writeStringContent(DEVC$RT.cast(object, dynamic, String, "CastGeneral", """line 686, column 26 of dart:convert/json.dart: """, object is String, true)); 309 writeStringContent(DEVC$RT.cast(object, dynamic, String, "DynamicCast", """line 686, column 26 of dart:convert/json.dart: """, object is String, true));
310 writeString('"'); 310 writeString('"');
311 return true; 311 return true;
312 } 312 }
313 else if (object is List) { 313 else if (object is List) {
314 _checkCycle(object); 314 _checkCycle(object);
315 writeList(DEVC$RT.cast(object, dynamic, DEVC$RT.type((List<dynamic> _) { 315 writeList(DEVC$RT.cast(object, dynamic, DEVC$RT.type((List<dynamic> _) {
316 } 316 }
317 ), "CastGeneral", """line 691, column 17 of dart:convert/json.dart: """, object is List<dynamic>, true)); 317 ), "DynamicCast", """line 691, column 17 of dart:convert/json.dart: """, object is List<dynamic>, true));
318 _removeSeen(object); 318 _removeSeen(object);
319 return true; 319 return true;
320 } 320 }
321 else if (object is Map) { 321 else if (object is Map) {
322 _checkCycle(object); 322 _checkCycle(object);
323 writeMap(DEVC$RT.cast(object, dynamic, DEVC$RT.type((Map<String, Object> _) { 323 writeMap(DEVC$RT.cast(object, dynamic, DEVC$RT.type((Map<String, Object> _) {
324 } 324 }
325 ), "CastGeneral", """line 696, column 16 of dart:convert/json.dart: """, object is Map<String, Object>, false)); 325 ), "CompositeCast", """line 696, column 16 of dart:convert/json.dart: """, objec t is Map<String, Object>, false));
326 _removeSeen(object); 326 _removeSeen(object);
327 return true; 327 return true;
328 } 328 }
329 else { 329 else {
330 return false; 330 return false;
331 } 331 }
332 } 332 }
333 void writeList(List list) { 333 void writeList(List list) {
334 writeString('['); 334 writeString('[');
335 if (list.length > 0) { 335 if (list.length > 0) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 402 }
403 ); 403 );
404 writeString('\n'); 404 writeString('\n');
405 _indentLevel--; 405 _indentLevel--;
406 writeIndentation(_indentLevel); 406 writeIndentation(_indentLevel);
407 writeString('}'); 407 writeString('}');
408 } 408 }
409 } 409 }
410 } 410 }
411 class _JsonStringStringifier extends _JsonStringifier {final StringSink _sink; 411 class _JsonStringStringifier extends _JsonStringifier {final StringSink _sink;
412 _JsonStringStringifier(this._sink, _toEncodable) : super(DEVC$RT.cast(_toEncoda ble, dynamic, __t7, "CastGeneral", """line 798, column 60 of dart:convert/json.d art: """, _toEncodable is __t7, false)); 412 _JsonStringStringifier(this._sink, _toEncodable) : super(DEVC$RT.cast(_toEncoda ble, dynamic, __t7, "CompositeCast", """line 798, column 60 of dart:convert/json .dart: """, _toEncodable is __t7, false));
413 static String stringify(object, toEncodable(object), String indent) { 413 static String stringify(object, toEncodable(object), String indent) {
414 StringBuffer output = new StringBuffer(); 414 StringBuffer output = new StringBuffer();
415 printOn(object, output, toEncodable, indent); 415 printOn(object, output, toEncodable, indent);
416 return output.toString(); 416 return output.toString();
417 } 417 }
418 static void printOn(object, StringSink output, toEncodable(object), String inde nt) { 418 static void printOn(object, StringSink output, toEncodable(object), String inde nt) {
419 var stringifier; 419 var stringifier;
420 if (indent == null) { 420 if (indent == null) {
421 stringifier = new _JsonStringStringifier(output, toEncodable); 421 stringifier = new _JsonStringStringifier(output, toEncodable);
422 } 422 }
(...skipping 18 matching lines...) Expand all
441 class _JsonStringStringifierPretty extends _JsonStringStringifier with _JsonPre ttyPrintMixin {final String _indent; 441 class _JsonStringStringifierPretty extends _JsonStringStringifier with _JsonPre ttyPrintMixin {final String _indent;
442 _JsonStringStringifierPretty(StringSink sink, Function toEncodable, this._inden t) : super(sink, toEncodable); 442 _JsonStringStringifierPretty(StringSink sink, Function toEncodable, this._inden t) : super(sink, toEncodable);
443 void writeIndentation(int count) { 443 void writeIndentation(int count) {
444 for (int i = 0; i < count; i++) writeString(_indent); 444 for (int i = 0; i < count; i++) writeString(_indent);
445 } 445 }
446 } 446 }
447 class _JsonUtf8Stringifier extends _JsonStringifier {final int bufferSize; 447 class _JsonUtf8Stringifier extends _JsonStringifier {final int bufferSize;
448 final Function addChunk; 448 final Function addChunk;
449 Uint8List buffer; 449 Uint8List buffer;
450 int index = 0; 450 int index = 0;
451 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) : super(DEVC$R T.cast(toEncodable, dynamic, __t7, "CastGeneral", """line 874, column 15 of dart :convert/json.dart: """, toEncodable is __t7, false)), this.bufferSize = bufferS ize, buffer = new Uint8List(bufferSize); 451 _JsonUtf8Stringifier(toEncodable, int bufferSize, this.addChunk) : super(DEVC$R T.cast(toEncodable, dynamic, __t7, "CompositeCast", """line 874, column 15 of da rt:convert/json.dart: """, toEncodable is __t7, false)), this.bufferSize = buffe rSize, buffer = new Uint8List(bufferSize);
452 static void stringify(Object object, List<int> indent, toEncodableFunction(Obje ct o), int bufferSize, void addChunk(Uint8List chunk, int start, int end)) { 452 static void stringify(Object object, List<int> indent, toEncodableFunction(Obje ct o), int bufferSize, void addChunk(Uint8List chunk, int start, int end)) {
453 _JsonUtf8Stringifier stringifier; 453 _JsonUtf8Stringifier stringifier;
454 if (indent != null) { 454 if (indent != null) {
455 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent, buffer Size, addChunk); 455 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent, buffer Size, addChunk);
456 } 456 }
457 else { 457 else {
458 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize, addChunk ); 458 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize, addChunk );
459 } 459 }
460 stringifier.writeObject(object); 460 stringifier.writeObject(object);
461 stringifier.flush(); 461 stringifier.flush();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 void writeByte(int byte) { 526 void writeByte(int byte) {
527 assert (byte <= 0xff); if (index == buffer.length) { 527 assert (byte <= 0xff); if (index == buffer.length) {
528 addChunk(buffer, 0, index); 528 addChunk(buffer, 0, index);
529 buffer = new Uint8List(bufferSize); 529 buffer = new Uint8List(bufferSize);
530 index = 0; 530 index = 0;
531 } 531 }
532 buffer[index++] = byte; 532 buffer[index++] = byte;
533 } 533 }
534 } 534 }
535 class _JsonUtf8StringifierPretty extends _JsonUtf8Stringifier with _JsonPrettyP rintMixin {final List<int> indent; 535 class _JsonUtf8StringifierPretty extends _JsonUtf8Stringifier with _JsonPrettyP rintMixin {final List<int> indent;
536 _JsonUtf8StringifierPretty(toEncodableFunction, this.indent, bufferSize, addChu nk) : super(toEncodableFunction, DEVC$RT.cast(bufferSize, dynamic, int, "CastGen eral", """line 1012, column 36 of dart:convert/json.dart: """, bufferSize is int , true), DEVC$RT.cast(addChunk, dynamic, Function, "CastGeneral", """line 1012, column 48 of dart:convert/json.dart: """, addChunk is Function, true)); 536 _JsonUtf8StringifierPretty(toEncodableFunction, this.indent, bufferSize, addChu nk) : super(toEncodableFunction, DEVC$RT.cast(bufferSize, dynamic, int, "Dynamic Cast", """line 1012, column 36 of dart:convert/json.dart: """, bufferSize is int , true), DEVC$RT.cast(addChunk, dynamic, Function, "DynamicCast", """line 1012, column 48 of dart:convert/json.dart: """, addChunk is Function, true));
537 void writeIndentation(int count) { 537 void writeIndentation(int count) {
538 List<int> indent = this.indent; 538 List<int> indent = this.indent;
539 int indentLength = indent.length; 539 int indentLength = indent.length;
540 if (indentLength == 1) { 540 if (indentLength == 1) {
541 int char = indent[0]; 541 int char = indent[0];
542 while (count > 0) { 542 while (count > 0) {
543 writeByte(char); 543 writeByte(char);
544 count -= 1; 544 count -= 1;
545 } 545 }
546 return;} 546 return;}
(...skipping 10 matching lines...) Expand all
557 } 557 }
558 } 558 }
559 } 559 }
560 } 560 }
561 } 561 }
562 typedef Object __t7(Object __u8); 562 typedef Object __t7(Object __u8);
563 typedef dynamic __t9(dynamic __u10); 563 typedef dynamic __t9(dynamic __u10);
564 typedef dynamic __t13(Object __u14); 564 typedef dynamic __t13(Object __u14);
565 typedef void __t20(String __u21, Object __u22); 565 typedef void __t20(String __u21, Object __u22);
566 typedef dynamic __t23(String __u24, dynamic __u25); 566 typedef dynamic __t23(String __u24, dynamic __u25);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/convert/html_escape.dart ('k') | test/dart_codegen/expect/convert/latin1.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698