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

Side by Side Diff: lib/runtime/dart/convert.js

Issue 1524843002: JS: Format if statements with no else on a single line (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebased Created 5 years 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 | « lib/runtime/dart/collection.js ('k') | lib/runtime/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 dart_library.library('dart/convert', null, /* Imports */[ 1 dart_library.library('dart/convert', null, /* Imports */[
2 "dart/_runtime", 2 "dart/_runtime",
3 'dart/core', 3 'dart/core',
4 'dart/async', 4 'dart/async',
5 'dart/typed_data', 5 'dart/typed_data',
6 'dart/_internal', 6 'dart/_internal',
7 'dart/collection' 7 'dart/collection'
8 ], /* Lazy imports */[ 8 ], /* Lazy imports */[
9 ], function(exports, dart, core, async, typed_data, _internal, collection) { 9 ], function(exports, dart, core, async, typed_data, _internal, collection) {
10 'use strict'; 10 'use strict';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Encoding() { 44 Encoding() {
45 super.Codec(); 45 super.Codec();
46 } 46 }
47 decodeStream(byteStream) { 47 decodeStream(byteStream) {
48 return byteStream.transform(this.decoder).fold(new core.StringBuffer(), da rt.fn((buffer, string) => ((() => { 48 return byteStream.transform(this.decoder).fold(new core.StringBuffer(), da rt.fn((buffer, string) => ((() => {
49 dart.dsend(buffer, 'write', string); 49 dart.dsend(buffer, 'write', string);
50 return buffer; 50 return buffer;
51 })()))).then(dart.fn(buffer => dart.toString(buffer), core.String, [dart.d ynamic])); 51 })()))).then(dart.fn(buffer => dart.toString(buffer), core.String, [dart.d ynamic]));
52 } 52 }
53 static getByName(name) { 53 static getByName(name) {
54 if (name == null) 54 if (name == null) return null;
55 return null;
56 name = name[dartx.toLowerCase](); 55 name = name[dartx.toLowerCase]();
57 return Encoding._nameToEncoding.get(name); 56 return Encoding._nameToEncoding.get(name);
58 } 57 }
59 } 58 }
60 dart.setSignature(Encoding, { 59 dart.setSignature(Encoding, {
61 constructors: () => ({Encoding: [Encoding, []]}), 60 constructors: () => ({Encoding: [Encoding, []]}),
62 methods: () => ({decodeStream: [async.Future$(core.String), [async.Stream$(c ore.List$(core.int))]]}), 61 methods: () => ({decodeStream: [async.Future$(core.String), [async.Stream$(c ore.List$(core.int))]]}),
63 statics: () => ({getByName: [Encoding, [core.String]]}), 62 statics: () => ({getByName: [Encoding, [core.String]]}),
64 names: ['getByName'] 63 names: ['getByName']
65 }); 64 });
66 const _allowInvalid = Symbol('_allowInvalid'); 65 const _allowInvalid = Symbol('_allowInvalid');
67 class AsciiCodec extends Encoding { 66 class AsciiCodec extends Encoding {
68 AsciiCodec(opts) { 67 AsciiCodec(opts) {
69 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse; 68 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse;
70 this[_allowInvalid] = allowInvalid; 69 this[_allowInvalid] = allowInvalid;
71 super.Encoding(); 70 super.Encoding();
72 } 71 }
73 get name() { 72 get name() {
74 return "us-ascii"; 73 return "us-ascii";
75 } 74 }
76 decode(bytes, opts) { 75 decode(bytes, opts) {
77 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu ll; 76 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu ll;
78 if (allowInvalid == null) 77 if (allowInvalid == null) allowInvalid = this[_allowInvalid];
79 allowInvalid = this[_allowInvalid];
80 if (dart.notNull(allowInvalid)) { 78 if (dart.notNull(allowInvalid)) {
81 return dart.const(new AsciiDecoder({allowInvalid: true})).convert(bytes) ; 79 return dart.const(new AsciiDecoder({allowInvalid: true})).convert(bytes) ;
82 } else { 80 } else {
83 return dart.const(new AsciiDecoder({allowInvalid: false})).convert(bytes ); 81 return dart.const(new AsciiDecoder({allowInvalid: false})).convert(bytes );
84 } 82 }
85 } 83 }
86 get encoder() { 84 get encoder() {
87 return dart.const(new AsciiEncoder()); 85 return dart.const(new AsciiEncoder());
88 } 86 }
89 get decoder() { 87 get decoder() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return Converter; 123 return Converter;
126 }); 124 });
127 let Converter = Converter$(); 125 let Converter = Converter$();
128 const _subsetMask = Symbol('_subsetMask'); 126 const _subsetMask = Symbol('_subsetMask');
129 class _UnicodeSubsetEncoder extends Converter$(core.String, core.List$(core.in t)) { 127 class _UnicodeSubsetEncoder extends Converter$(core.String, core.List$(core.in t)) {
130 _UnicodeSubsetEncoder(subsetMask) { 128 _UnicodeSubsetEncoder(subsetMask) {
131 this[_subsetMask] = subsetMask; 129 this[_subsetMask] = subsetMask;
132 super.Converter(); 130 super.Converter();
133 } 131 }
134 convert(string, start, end) { 132 convert(string, start, end) {
135 if (start === void 0) 133 if (start === void 0) start = 0;
136 start = 0; 134 if (end === void 0) end = null;
137 if (end === void 0)
138 end = null;
139 let stringLength = string[dartx.length]; 135 let stringLength = string[dartx.length];
140 core.RangeError.checkValidRange(start, end, stringLength); 136 core.RangeError.checkValidRange(start, end, stringLength);
141 if (end == null) 137 if (end == null) end = stringLength;
142 end = stringLength;
143 let length = dart.notNull(end) - dart.notNull(start); 138 let length = dart.notNull(end) - dart.notNull(start);
144 let result = typed_data.Uint8List.new(length); 139 let result = typed_data.Uint8List.new(length);
145 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) { 140 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) {
146 let codeUnit = string[dartx.codeUnitAt](dart.notNull(start) + dart.notNu ll(i)); 141 let codeUnit = string[dartx.codeUnitAt](dart.notNull(start) + dart.notNu ll(i));
147 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) { 142 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) {
148 dart.throw(new core.ArgumentError("String contains invalid characters. ")); 143 dart.throw(new core.ArgumentError("String contains invalid characters. "));
149 } 144 }
150 result[dartx.set](i, codeUnit); 145 result[dartx.set](i, codeUnit);
151 } 146 }
152 return dart.as(result, core.List$(core.int)); 147 return dart.as(result, core.List$(core.int));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 }) 223 })
229 }); 224 });
230 const _convertInvalid = Symbol('_convertInvalid'); 225 const _convertInvalid = Symbol('_convertInvalid');
231 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri ng) { 226 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri ng) {
232 _UnicodeSubsetDecoder(allowInvalid, subsetMask) { 227 _UnicodeSubsetDecoder(allowInvalid, subsetMask) {
233 this[_allowInvalid] = allowInvalid; 228 this[_allowInvalid] = allowInvalid;
234 this[_subsetMask] = subsetMask; 229 this[_subsetMask] = subsetMask;
235 super.Converter(); 230 super.Converter();
236 } 231 }
237 convert(bytes, start, end) { 232 convert(bytes, start, end) {
238 if (start === void 0) 233 if (start === void 0) start = 0;
239 start = 0; 234 if (end === void 0) end = null;
240 if (end === void 0)
241 end = null;
242 let byteCount = bytes[dartx.length]; 235 let byteCount = bytes[dartx.length];
243 core.RangeError.checkValidRange(start, end, byteCount); 236 core.RangeError.checkValidRange(start, end, byteCount);
244 if (end == null) 237 if (end == null) end = byteCount;
245 end = byteCount;
246 let length = dart.notNull(end) - dart.notNull(start); 238 let length = dart.notNull(end) - dart.notNull(start);
247 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 239 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
248 let byte = bytes[dartx.get](i); 240 let byte = bytes[dartx.get](i);
249 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) != 0) { 241 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) != 0) {
250 if (!dart.notNull(this[_allowInvalid])) { 242 if (!dart.notNull(this[_allowInvalid])) {
251 dart.throw(new core.FormatException(`Invalid value in input: ${byte} `)); 243 dart.throw(new core.FormatException(`Invalid value in input: ${byte} `));
252 } 244 }
253 return this[_convertInvalid](bytes, start, end); 245 return this[_convertInvalid](bytes, start, end);
254 } 246 }
255 } 247 }
256 return core.String.fromCharCodes(bytes, start, end); 248 return core.String.fromCharCodes(bytes, start, end);
257 } 249 }
258 [_convertInvalid](bytes, start, end) { 250 [_convertInvalid](bytes, start, end) {
259 let buffer = new core.StringBuffer(); 251 let buffer = new core.StringBuffer();
260 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 252 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
261 let value = bytes[dartx.get](i); 253 let value = bytes[dartx.get](i);
262 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) != 0) 254 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) != 0) value = 65533;
263 value = 65533;
264 buffer.writeCharCode(value); 255 buffer.writeCharCode(value);
265 } 256 }
266 return dart.toString(buffer); 257 return dart.toString(buffer);
267 } 258 }
268 bind(stream) { 259 bind(stream) {
269 return super.bind(stream); 260 return super.bind(stream);
270 } 261 }
271 } 262 }
272 dart.setSignature(_UnicodeSubsetDecoder, { 263 dart.setSignature(_UnicodeSubsetDecoder, {
273 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b ool, core.int]]}), 264 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b ool, core.int]]}),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 withCallback: [ByteConversionSink, [dart.functionType(dart.void, [core.Lis t$(core.int)])]], 326 withCallback: [ByteConversionSink, [dart.functionType(dart.void, [core.Lis t$(core.int)])]],
336 from: [ByteConversionSink, [core.Sink$(core.List$(core.int))]] 327 from: [ByteConversionSink, [core.Sink$(core.List$(core.int))]]
337 }) 328 })
338 }); 329 });
339 class ByteConversionSinkBase extends ByteConversionSink { 330 class ByteConversionSinkBase extends ByteConversionSink {
340 ByteConversionSinkBase() { 331 ByteConversionSinkBase() {
341 super.ByteConversionSink(); 332 super.ByteConversionSink();
342 } 333 }
343 addSlice(chunk, start, end, isLast) { 334 addSlice(chunk, start, end, isLast) {
344 this.add(chunk[dartx.sublist](start, end)); 335 this.add(chunk[dartx.sublist](start, end));
345 if (dart.notNull(isLast)) 336 if (dart.notNull(isLast)) this.close();
346 this.close();
347 } 337 }
348 } 338 }
349 dart.setSignature(ByteConversionSinkBase, { 339 dart.setSignature(ByteConversionSinkBase, {
350 methods: () => ({addSlice: [dart.void, [core.List$(core.int), core.int, core .int, core.bool]]}) 340 methods: () => ({addSlice: [dart.void, [core.List$(core.int), core.int, core .int, core.bool]]})
351 }); 341 });
352 const _utf8Sink = Symbol('_utf8Sink'); 342 const _utf8Sink = Symbol('_utf8Sink');
353 class _ErrorHandlingAsciiDecoderSink extends ByteConversionSinkBase { 343 class _ErrorHandlingAsciiDecoderSink extends ByteConversionSinkBase {
354 _ErrorHandlingAsciiDecoderSink(utf8Sink) { 344 _ErrorHandlingAsciiDecoderSink(utf8Sink) {
355 this[_utf8Sink] = utf8Sink; 345 this[_utf8Sink] = utf8Sink;
356 } 346 }
357 close() { 347 close() {
358 this[_utf8Sink].close(); 348 this[_utf8Sink].close();
359 } 349 }
360 add(source) { 350 add(source) {
361 this.addSlice(source, 0, source[dartx.length], false); 351 this.addSlice(source, 0, source[dartx.length], false);
362 } 352 }
363 addSlice(source, start, end, isLast) { 353 addSlice(source, start, end, isLast) {
364 core.RangeError.checkValidRange(start, end, source[dartx.length]); 354 core.RangeError.checkValidRange(start, end, source[dartx.length]);
365 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 355 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
366 if ((dart.notNull(source[dartx.get](i)) & ~dart.notNull(_ASCII_MASK)) != 0) { 356 if ((dart.notNull(source[dartx.get](i)) & ~dart.notNull(_ASCII_MASK)) != 0) {
367 if (dart.notNull(i) > dart.notNull(start)) 357 if (dart.notNull(i) > dart.notNull(start)) this[_utf8Sink].addSlice(so urce, start, i, false);
368 this[_utf8Sink].addSlice(source, start, i, false);
369 this[_utf8Sink].add(dart.const(dart.list([239, 191, 189], core.int))); 358 this[_utf8Sink].add(dart.const(dart.list([239, 191, 189], core.int)));
370 start = dart.notNull(i) + 1; 359 start = dart.notNull(i) + 1;
371 } 360 }
372 } 361 }
373 if (dart.notNull(start) < dart.notNull(end)) { 362 if (dart.notNull(start) < dart.notNull(end)) {
374 this[_utf8Sink].addSlice(source, start, end, isLast); 363 this[_utf8Sink].addSlice(source, start, end, isLast);
375 } else if (dart.notNull(isLast)) { 364 } else if (dart.notNull(isLast)) {
376 this.close(); 365 this.close();
377 } 366 }
378 } 367 }
(...skipping 22 matching lines...) Expand all
401 } 390 }
402 addSlice(source, start, end, isLast) { 391 addSlice(source, start, end, isLast) {
403 let length = source[dartx.length]; 392 let length = source[dartx.length];
404 core.RangeError.checkValidRange(start, end, length); 393 core.RangeError.checkValidRange(start, end, length);
405 if (dart.notNull(start) < dart.notNull(end)) { 394 if (dart.notNull(start) < dart.notNull(end)) {
406 if (start != 0 || end != length) { 395 if (start != 0 || end != length) {
407 source = source[dartx.sublist](start, end); 396 source = source[dartx.sublist](start, end);
408 } 397 }
409 this.add(source); 398 this.add(source);
410 } 399 }
411 if (dart.notNull(isLast)) 400 if (dart.notNull(isLast)) this.close();
412 this.close();
413 } 401 }
414 } 402 }
415 dart.setSignature(_SimpleAsciiDecoderSink, { 403 dart.setSignature(_SimpleAsciiDecoderSink, {
416 constructors: () => ({_SimpleAsciiDecoderSink: [_SimpleAsciiDecoderSink, [co re.Sink]]}), 404 constructors: () => ({_SimpleAsciiDecoderSink: [_SimpleAsciiDecoderSink, [co re.Sink]]}),
417 methods: () => ({ 405 methods: () => ({
418 close: [dart.void, []], 406 close: [dart.void, []],
419 add: [dart.void, [core.List$(core.int)]] 407 add: [dart.void, [core.List$(core.int)]]
420 }) 408 })
421 }); 409 });
422 class _ByteAdapterSink extends ByteConversionSinkBase { 410 class _ByteAdapterSink extends ByteConversionSinkBase {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 class _ConverterStreamEventSink extends core.Object { 532 class _ConverterStreamEventSink extends core.Object {
545 _ConverterStreamEventSink(converter, sink) { 533 _ConverterStreamEventSink(converter, sink) {
546 this[_eventSink] = sink; 534 this[_eventSink] = sink;
547 this[_chunkedSink] = converter.startChunkedConversion(sink); 535 this[_chunkedSink] = converter.startChunkedConversion(sink);
548 } 536 }
549 add(o) { 537 add(o) {
550 dart.as(o, S); 538 dart.as(o, S);
551 return this[_chunkedSink].add(o); 539 return this[_chunkedSink].add(o);
552 } 540 }
553 addError(error, stackTrace) { 541 addError(error, stackTrace) {
554 if (stackTrace === void 0) 542 if (stackTrace === void 0) stackTrace = null;
555 stackTrace = null;
556 this[_eventSink].addError(error, stackTrace); 543 this[_eventSink].addError(error, stackTrace);
557 } 544 }
558 close() { 545 close() {
559 return this[_chunkedSink].close(); 546 return this[_chunkedSink].close();
560 } 547 }
561 } 548 }
562 _ConverterStreamEventSink[dart.implements] = () => [async.EventSink$(S)]; 549 _ConverterStreamEventSink[dart.implements] = () => [async.EventSink$(S)];
563 dart.setSignature(_ConverterStreamEventSink, { 550 dart.setSignature(_ConverterStreamEventSink, {
564 constructors: () => ({_ConverterStreamEventSink: [_ConverterStreamEventSin k$(S, T), [Converter, async.EventSink$(T)]]}), 551 constructors: () => ({_ConverterStreamEventSink: [_ConverterStreamEventSin k$(S, T), [Converter, async.EventSink$(T)]]}),
565 methods: () => ({ 552 methods: () => ({
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 649 }
663 } 650 }
664 dart.defineNamedConstructor(HtmlEscapeMode, '_'); 651 dart.defineNamedConstructor(HtmlEscapeMode, '_');
665 dart.setSignature(HtmlEscapeMode, { 652 dart.setSignature(HtmlEscapeMode, {
666 constructors: () => ({_: [HtmlEscapeMode, [core.String, core.bool, core.bool , core.bool, core.bool]]}) 653 constructors: () => ({_: [HtmlEscapeMode, [core.String, core.bool, core.bool , core.bool, core.bool]]})
667 }); 654 });
668 HtmlEscapeMode.UNKNOWN = dart.const(new HtmlEscapeMode._('unknown', true, true , true, true)); 655 HtmlEscapeMode.UNKNOWN = dart.const(new HtmlEscapeMode._('unknown', true, true , true, true));
669 const _convert = Symbol('_convert'); 656 const _convert = Symbol('_convert');
670 class HtmlEscape extends Converter$(core.String, core.String) { 657 class HtmlEscape extends Converter$(core.String, core.String) {
671 HtmlEscape(mode) { 658 HtmlEscape(mode) {
672 if (mode === void 0) 659 if (mode === void 0) mode = HtmlEscapeMode.UNKNOWN;
673 mode = HtmlEscapeMode.UNKNOWN;
674 this.mode = mode; 660 this.mode = mode;
675 super.Converter(); 661 super.Converter();
676 } 662 }
677 convert(text) { 663 convert(text) {
678 let val = this[_convert](text, 0, text[dartx.length]); 664 let val = this[_convert](text, 0, text[dartx.length]);
679 return val == null ? text : val; 665 return val == null ? text : val;
680 } 666 }
681 [_convert](text, start, end) { 667 [_convert](text, start, end) {
682 let result = null; 668 let result = null;
683 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 669 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
684 let ch = text[dartx.get](i); 670 let ch = text[dartx.get](i);
685 let replace = null; 671 let replace = null;
686 switch (ch) { 672 switch (ch) {
687 case '&': 673 case '&':
688 { 674 {
689 replace = '&amp;'; 675 replace = '&amp;';
690 break; 676 break;
691 } 677 }
692 case ' ': 678 case ' ':
693 { 679 {
694 replace = '&nbsp;'; 680 replace = '&nbsp;';
695 break; 681 break;
696 } 682 }
697 case '"': 683 case '"':
698 { 684 {
699 if (dart.notNull(this.mode.escapeQuot)) 685 if (dart.notNull(this.mode.escapeQuot)) replace = '&quot;';
700 replace = '&quot;';
701 break; 686 break;
702 } 687 }
703 case "'": 688 case "'":
704 { 689 {
705 if (dart.notNull(this.mode.escapeApos)) 690 if (dart.notNull(this.mode.escapeApos)) replace = '&#x27;';
706 replace = '&#x27;';
707 break; 691 break;
708 } 692 }
709 case '<': 693 case '<':
710 { 694 {
711 if (dart.notNull(this.mode.escapeLtGt)) 695 if (dart.notNull(this.mode.escapeLtGt)) replace = '&lt;';
712 replace = '&lt;';
713 break; 696 break;
714 } 697 }
715 case '>': 698 case '>':
716 { 699 {
717 if (dart.notNull(this.mode.escapeLtGt)) 700 if (dart.notNull(this.mode.escapeLtGt)) replace = '&gt;';
718 replace = '&gt;';
719 break; 701 break;
720 } 702 }
721 case '/': 703 case '/':
722 { 704 {
723 if (dart.notNull(this.mode.escapeSlash)) 705 if (dart.notNull(this.mode.escapeSlash)) replace = '&#x2F;';
724 replace = '&#x2F;';
725 break; 706 break;
726 } 707 }
727 } 708 }
728 if (replace != null) { 709 if (replace != null) {
729 if (result == null) 710 if (result == null) result = new core.StringBuffer(text[dartx.substrin g](start, i));
730 result = new core.StringBuffer(text[dartx.substring](start, i));
731 result.write(replace); 711 result.write(replace);
732 } else if (result != null) { 712 } else if (result != null) {
733 result.write(ch); 713 result.write(ch);
734 } 714 }
735 } 715 }
736 return result != null ? dart.toString(result) : null; 716 return result != null ? dart.toString(result) : null;
737 } 717 }
738 startChunkedConversion(sink) { 718 startChunkedConversion(sink) {
739 if (!dart.is(sink, StringConversionSink)) { 719 if (!dart.is(sink, StringConversionSink)) {
740 sink = StringConversionSink.from(sink); 720 sink = StringConversionSink.from(sink);
(...skipping 17 matching lines...) Expand all
758 _HtmlEscapeSink(escape, sink) { 738 _HtmlEscapeSink(escape, sink) {
759 this[_escape] = escape; 739 this[_escape] = escape;
760 this[_sink] = sink; 740 this[_sink] = sink;
761 } 741 }
762 addSlice(chunk, start, end, isLast) { 742 addSlice(chunk, start, end, isLast) {
763 let val = this[_escape][_convert](chunk, start, end); 743 let val = this[_escape][_convert](chunk, start, end);
764 if (val == null) { 744 if (val == null) {
765 this[_sink].addSlice(chunk, start, end, isLast); 745 this[_sink].addSlice(chunk, start, end, isLast);
766 } else { 746 } else {
767 this[_sink].add(val); 747 this[_sink].add(val);
768 if (dart.notNull(isLast)) 748 if (dart.notNull(isLast)) this[_sink].close();
769 this[_sink].close();
770 } 749 }
771 } 750 }
772 close() { 751 close() {
773 return this[_sink].close(); 752 return this[_sink].close();
774 } 753 }
775 } 754 }
776 dart.setSignature(_HtmlEscapeSink, { 755 dart.setSignature(_HtmlEscapeSink, {
777 constructors: () => ({_HtmlEscapeSink: [_HtmlEscapeSink, [HtmlEscape, String ConversionSink]]}), 756 constructors: () => ({_HtmlEscapeSink: [_HtmlEscapeSink, [HtmlEscape, String ConversionSink]]}),
778 methods: () => ({ 757 methods: () => ({
779 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]], 758 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]],
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; 796 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
818 this[_reviver] = reviver; 797 this[_reviver] = reviver;
819 this[_toEncodable$] = toEncodable; 798 this[_toEncodable$] = toEncodable;
820 super.Codec(); 799 super.Codec();
821 } 800 }
822 withReviver(reviver) { 801 withReviver(reviver) {
823 this.JsonCodec({reviver: reviver}); 802 this.JsonCodec({reviver: reviver});
824 } 803 }
825 decode(source, opts) { 804 decode(source, opts) {
826 let reviver = opts && 'reviver' in opts ? opts.reviver : null; 805 let reviver = opts && 'reviver' in opts ? opts.reviver : null;
827 if (reviver == null) 806 if (reviver == null) reviver = this[_reviver];
828 reviver = this[_reviver]; 807 if (reviver == null) return this.decoder.convert(source);
829 if (reviver == null)
830 return this.decoder.convert(source);
831 return new JsonDecoder(reviver).convert(source); 808 return new JsonDecoder(reviver).convert(source);
832 } 809 }
833 encode(value, opts) { 810 encode(value, opts) {
834 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; 811 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
835 if (toEncodable == null) 812 if (toEncodable == null) toEncodable = this[_toEncodable$];
836 toEncodable = this[_toEncodable$]; 813 if (toEncodable == null) return this.encoder.convert(value);
837 if (toEncodable == null)
838 return this.encoder.convert(value);
839 return new JsonEncoder(dart.as(toEncodable, __CastType0)).convert(value); 814 return new JsonEncoder(dart.as(toEncodable, __CastType0)).convert(value);
840 } 815 }
841 get encoder() { 816 get encoder() {
842 if (this[_toEncodable$] == null) 817 if (this[_toEncodable$] == null) return dart.const(new JsonEncoder());
843 return dart.const(new JsonEncoder());
844 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core .Object, [core.Object]))); 818 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core .Object, [core.Object])));
845 } 819 }
846 get decoder() { 820 get decoder() {
847 if (this[_reviver] == null) 821 if (this[_reviver] == null) return dart.const(new JsonDecoder());
848 return dart.const(new JsonDecoder());
849 return new JsonDecoder(this[_reviver]); 822 return new JsonDecoder(this[_reviver]);
850 } 823 }
851 } 824 }
852 dart.defineNamedConstructor(JsonCodec, 'withReviver'); 825 dart.defineNamedConstructor(JsonCodec, 'withReviver');
853 dart.setSignature(JsonCodec, { 826 dart.setSignature(JsonCodec, {
854 constructors: () => ({ 827 constructors: () => ({
855 JsonCodec: [JsonCodec, [], {reviver: dart.functionType(dart.dynamic, [dart .dynamic, dart.dynamic]), toEncodable: dart.functionType(dart.dynamic, [dart.dyn amic])}], 828 JsonCodec: [JsonCodec, [], {reviver: dart.functionType(dart.dynamic, [dart .dynamic, dart.dynamic]), toEncodable: dart.functionType(dart.dynamic, [dart.dyn amic])}],
856 withReviver: [JsonCodec, [dart.functionType(dart.dynamic, [dart.dynamic, d art.dynamic])]] 829 withReviver: [JsonCodec, [dart.functionType(dart.dynamic, [dart.dynamic, d art.dynamic])]]
857 }), 830 }),
858 methods: () => ({ 831 methods: () => ({
859 decode: [dart.dynamic, [core.String], {reviver: dart.functionType(dart.dyn amic, [dart.dynamic, dart.dynamic])}], 832 decode: [dart.dynamic, [core.String], {reviver: dart.functionType(dart.dyn amic, [dart.dynamic, dart.dynamic])}],
860 encode: [core.String, [core.Object], {toEncodable: dart.functionType(dart. dynamic, [dart.dynamic])}] 833 encode: [core.String, [core.Object], {toEncodable: dart.functionType(dart. dynamic, [dart.dynamic])}]
861 }) 834 })
862 }); 835 });
863 const JSON = dart.const(new JsonCodec()); 836 const JSON = dart.const(new JsonCodec());
864 const _Reviver = dart.typedef('_Reviver', () => dart.functionType(dart.dynamic , [dart.dynamic, dart.dynamic])); 837 const _Reviver = dart.typedef('_Reviver', () => dart.functionType(dart.dynamic , [dart.dynamic, dart.dynamic]));
865 const _ToEncodable = dart.typedef('_ToEncodable', () => dart.functionType(dart .dynamic, [dart.dynamic])); 838 const _ToEncodable = dart.typedef('_ToEncodable', () => dart.functionType(dart .dynamic, [dart.dynamic]));
866 class JsonEncoder extends Converter$(core.Object, core.String) { 839 class JsonEncoder extends Converter$(core.Object, core.String) {
867 JsonEncoder(toEncodable) { 840 JsonEncoder(toEncodable) {
868 if (toEncodable === void 0) 841 if (toEncodable === void 0) toEncodable = null;
869 toEncodable = null;
870 this.indent = null; 842 this.indent = null;
871 this[_toEncodable$] = toEncodable; 843 this[_toEncodable$] = toEncodable;
872 super.Converter(); 844 super.Converter();
873 } 845 }
874 withIndent(indent, toEncodable) { 846 withIndent(indent, toEncodable) {
875 if (toEncodable === void 0) 847 if (toEncodable === void 0) toEncodable = null;
876 toEncodable = null;
877 this.indent = indent; 848 this.indent = indent;
878 this[_toEncodable$] = toEncodable; 849 this[_toEncodable$] = toEncodable;
879 super.Converter(); 850 super.Converter();
880 } 851 }
881 convert(object) { 852 convert(object) {
882 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], __CastType2), this.indent); 853 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], __CastType2), this.indent);
883 } 854 }
884 startChunkedConversion(sink) { 855 startChunkedConversion(sink) {
885 if (!dart.is(sink, StringConversionSink)) { 856 if (!dart.is(sink, StringConversionSink)) {
886 sink = StringConversionSink.from(sink); 857 sink = StringConversionSink.from(sink);
(...skipping 22 matching lines...) Expand all
909 convert: [core.String, [core.Object]], 880 convert: [core.String, [core.Object]],
910 startChunkedConversion: [ChunkedConversionSink$(core.Object), [core.Sink$( core.String)]], 881 startChunkedConversion: [ChunkedConversionSink$(core.Object), [core.Sink$( core.String)]],
911 bind: [async.Stream$(core.String), [async.Stream$(core.Object)]], 882 bind: [async.Stream$(core.String), [async.Stream$(core.Object)]],
912 fuse: [Converter$(core.Object, dart.dynamic), [Converter$(core.String, dar t.dynamic)]] 883 fuse: [Converter$(core.Object, dart.dynamic), [Converter$(core.String, dar t.dynamic)]]
913 }) 884 })
914 }); 885 });
915 const _indent = Symbol('_indent'); 886 const _indent = Symbol('_indent');
916 const _bufferSize = Symbol('_bufferSize'); 887 const _bufferSize = Symbol('_bufferSize');
917 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) { 888 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) {
918 JsonUtf8Encoder(indent, toEncodable, bufferSize) { 889 JsonUtf8Encoder(indent, toEncodable, bufferSize) {
919 if (indent === void 0) 890 if (indent === void 0) indent = null;
920 indent = null; 891 if (toEncodable === void 0) toEncodable = null;
921 if (toEncodable === void 0) 892 if (bufferSize === void 0) bufferSize = JsonUtf8Encoder.DEFAULT_BUFFER_SIZ E;
922 toEncodable = null;
923 if (bufferSize === void 0)
924 bufferSize = JsonUtf8Encoder.DEFAULT_BUFFER_SIZE;
925 this[_indent] = JsonUtf8Encoder._utf8Encode(indent); 893 this[_indent] = JsonUtf8Encoder._utf8Encode(indent);
926 this[_toEncodable$] = toEncodable; 894 this[_toEncodable$] = toEncodable;
927 this[_bufferSize] = bufferSize; 895 this[_bufferSize] = bufferSize;
928 super.Converter(); 896 super.Converter();
929 } 897 }
930 static _utf8Encode(string) { 898 static _utf8Encode(string) {
931 if (string == null) 899 if (string == null) return null;
932 return null; 900 if (dart.notNull(string[dartx.isEmpty])) return typed_data.Uint8List.new(0 );
933 if (dart.notNull(string[dartx.isEmpty]))
934 return typed_data.Uint8List.new(0);
935 checkAscii: { 901 checkAscii: {
936 for (let i = 0; dart.notNull(i) < dart.notNull(string[dartx.length]); i = dart.notNull(i) + 1) { 902 for (let i = 0; dart.notNull(i) < dart.notNull(string[dartx.length]); i = dart.notNull(i) + 1) {
937 if (dart.notNull(string[dartx.codeUnitAt](i)) >= 128) 903 if (dart.notNull(string[dartx.codeUnitAt](i)) >= 128) break checkAscii ;
938 break checkAscii;
939 } 904 }
940 return string[dartx.codeUnits]; 905 return string[dartx.codeUnits];
941 } 906 }
942 return UTF8.encode(string); 907 return UTF8.encode(string);
943 } 908 }
944 convert(object) { 909 convert(object) {
945 let bytes = dart.list([], core.List$(core.int)); 910 let bytes = dart.list([], core.List$(core.int));
946 function addChunk(chunk, start, end) { 911 function addChunk(chunk, start, end) {
947 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk.le ngth)) { 912 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk.le ngth)) {
948 let length = dart.notNull(end) - dart.notNull(start); 913 let length = dart.notNull(end) - dart.notNull(start);
949 chunk = typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk.off setInBytes) + dart.notNull(start), length); 914 chunk = typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk.off setInBytes) + dart.notNull(start), length);
950 } 915 }
951 bytes[dartx.add](chunk); 916 bytes[dartx.add](chunk);
952 } 917 }
953 dart.fn(addChunk, dart.void, [typed_data.Uint8List, core.int, core.int]); 918 dart.fn(addChunk, dart.void, [typed_data.Uint8List, core.int, core.int]);
954 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk); 919 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk);
955 if (bytes[dartx.length] == 1) 920 if (bytes[dartx.length] == 1) return bytes[dartx.get](0);
956 return bytes[dartx.get](0);
957 let length = 0; 921 let length = 0;
958 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[dartx.length]); i = d art.notNull(i) + 1) { 922 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[dartx.length]); i = d art.notNull(i) + 1) {
959 length = dart.notNull(length) + dart.notNull(bytes[dartx.get](i)[dartx.l ength]); 923 length = dart.notNull(length) + dart.notNull(bytes[dartx.get](i)[dartx.l ength]);
960 } 924 }
961 let result = typed_data.Uint8List.new(length); 925 let result = typed_data.Uint8List.new(length);
962 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes[dartx.len gth]); i = dart.notNull(i) + 1) { 926 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes[dartx.len gth]); i = dart.notNull(i) + 1) {
963 let byteList = bytes[dartx.get](i); 927 let byteList = bytes[dartx.get](i);
964 let end = dart.notNull(offset) + dart.notNull(byteList[dartx.length]); 928 let end = dart.notNull(offset) + dart.notNull(byteList[dartx.length]);
965 result.setRange(offset, end, byteList); 929 result.setRange(offset, end, byteList);
966 offset = end; 930 offset = end;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 dart.setSignature(_JsonUtf8EncoderSink, { 1017 dart.setSignature(_JsonUtf8EncoderSink, {
1054 constructors: () => ({_JsonUtf8EncoderSink: [_JsonUtf8EncoderSink, [ByteConv ersionSink, core.Function, core.List$(core.int), core.int]]}), 1018 constructors: () => ({_JsonUtf8EncoderSink: [_JsonUtf8EncoderSink, [ByteConv ersionSink, core.Function, core.List$(core.int), core.int]]}),
1055 methods: () => ({ 1019 methods: () => ({
1056 [_addChunk]: [dart.void, [typed_data.Uint8List, core.int, core.int]], 1020 [_addChunk]: [dart.void, [typed_data.Uint8List, core.int, core.int]],
1057 add: [dart.void, [core.Object]], 1021 add: [dart.void, [core.Object]],
1058 close: [dart.void, []] 1022 close: [dart.void, []]
1059 }) 1023 })
1060 }); 1024 });
1061 class JsonDecoder extends Converter$(core.String, core.Object) { 1025 class JsonDecoder extends Converter$(core.String, core.Object) {
1062 JsonDecoder(reviver) { 1026 JsonDecoder(reviver) {
1063 if (reviver === void 0) 1027 if (reviver === void 0) reviver = null;
1064 reviver = null;
1065 this[_reviver] = reviver; 1028 this[_reviver] = reviver;
1066 super.Converter(); 1029 super.Converter();
1067 } 1030 }
1068 convert(input) { 1031 convert(input) {
1069 return _parseJson(input, this[_reviver]); 1032 return _parseJson(input, this[_reviver]);
1070 } 1033 }
1071 startChunkedConversion(sink) { 1034 startChunkedConversion(sink) {
1072 return new _JsonDecoderSink(this[_reviver], sink); 1035 return new _JsonDecoderSink(this[_reviver], sink);
1073 } 1036 }
1074 bind(stream) { 1037 bind(stream) {
1075 return super.bind(stream); 1038 return super.bind(stream);
1076 } 1039 }
1077 } 1040 }
1078 dart.setSignature(JsonDecoder, { 1041 dart.setSignature(JsonDecoder, {
1079 constructors: () => ({JsonDecoder: [JsonDecoder, [], [dart.functionType(dart .dynamic, [dart.dynamic, dart.dynamic])]]}), 1042 constructors: () => ({JsonDecoder: [JsonDecoder, [], [dart.functionType(dart .dynamic, [dart.dynamic, dart.dynamic])]]}),
1080 methods: () => ({ 1043 methods: () => ({
1081 convert: [dart.dynamic, [core.String]], 1044 convert: [dart.dynamic, [core.String]],
1082 startChunkedConversion: [StringConversionSink, [core.Sink$(core.Object)]], 1045 startChunkedConversion: [StringConversionSink, [core.Sink$(core.Object)]],
1083 bind: [async.Stream$(core.Object), [async.Stream$(core.String)]] 1046 bind: [async.Stream$(core.Object), [async.Stream$(core.String)]]
1084 }) 1047 })
1085 }); 1048 });
1086 function _parseJson(source, reviver) { 1049 function _parseJson(source, reviver) {
1087 if (!(typeof source == 'string')) 1050 if (!(typeof source == 'string')) dart.throw(new core.ArgumentError(source)) ;
1088 dart.throw(new core.ArgumentError(source));
1089 let parsed = null; 1051 let parsed = null;
1090 try { 1052 try {
1091 parsed = JSON.parse(source); 1053 parsed = JSON.parse(source);
1092 } catch (e) { 1054 } catch (e) {
1093 dart.throw(new core.FormatException(String(e))); 1055 dart.throw(new core.FormatException(String(e)));
1094 } 1056 }
1095 1057
1096 if (reviver == null) { 1058 if (reviver == null) {
1097 return _convertJsonToDartLazy(parsed); 1059 return _convertJsonToDartLazy(parsed);
1098 } else { 1060 } else {
(...skipping 14 matching lines...) Expand all
1113 this[_toEncodable$] = _toEncodable != null ? _toEncodable : _defaultToEnco dable; 1075 this[_toEncodable$] = _toEncodable != null ? _toEncodable : _defaultToEnco dable;
1114 } 1076 }
1115 static hexDigit(x) { 1077 static hexDigit(x) {
1116 return dart.notNull(x) < 10 ? 48 + dart.notNull(x) : 87 + dart.notNull(x); 1078 return dart.notNull(x) < 10 ? 48 + dart.notNull(x) : 87 + dart.notNull(x);
1117 } 1079 }
1118 writeStringContent(s) { 1080 writeStringContent(s) {
1119 let offset = 0; 1081 let offset = 0;
1120 let length = s[dartx.length]; 1082 let length = s[dartx.length];
1121 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) { 1083 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) {
1122 let charCode = s[dartx.codeUnitAt](i); 1084 let charCode = s[dartx.codeUnitAt](i);
1123 if (dart.notNull(charCode) > dart.notNull(_JsonStringifier.BACKSLASH)) 1085 if (dart.notNull(charCode) > dart.notNull(_JsonStringifier.BACKSLASH)) c ontinue;
1124 continue;
1125 if (dart.notNull(charCode) < 32) { 1086 if (dart.notNull(charCode) < 32) {
1126 if (dart.notNull(i) > dart.notNull(offset)) 1087 if (dart.notNull(i) > dart.notNull(offset)) this.writeStringSlice(s, o ffset, i);
1127 this.writeStringSlice(s, offset, i);
1128 offset = dart.notNull(i) + 1; 1088 offset = dart.notNull(i) + 1;
1129 this.writeCharCode(_JsonStringifier.BACKSLASH); 1089 this.writeCharCode(_JsonStringifier.BACKSLASH);
1130 switch (charCode) { 1090 switch (charCode) {
1131 case _JsonStringifier.BACKSPACE: 1091 case _JsonStringifier.BACKSPACE:
1132 { 1092 {
1133 this.writeCharCode(_JsonStringifier.CHAR_b); 1093 this.writeCharCode(_JsonStringifier.CHAR_b);
1134 break; 1094 break;
1135 } 1095 }
1136 case _JsonStringifier.TAB: 1096 case _JsonStringifier.TAB:
1137 { 1097 {
(...skipping 19 matching lines...) Expand all
1157 { 1117 {
1158 this.writeCharCode(_JsonStringifier.CHAR_u); 1118 this.writeCharCode(_JsonStringifier.CHAR_u);
1159 this.writeCharCode(_JsonStringifier.CHAR_0); 1119 this.writeCharCode(_JsonStringifier.CHAR_0);
1160 this.writeCharCode(_JsonStringifier.CHAR_0); 1120 this.writeCharCode(_JsonStringifier.CHAR_0);
1161 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode ) >> 4 & 15)); 1121 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode ) >> 4 & 15));
1162 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode ) & 15)); 1122 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode ) & 15));
1163 break; 1123 break;
1164 } 1124 }
1165 } 1125 }
1166 } else if (charCode == _JsonStringifier.QUOTE || charCode == _JsonString ifier.BACKSLASH) { 1126 } else if (charCode == _JsonStringifier.QUOTE || charCode == _JsonString ifier.BACKSLASH) {
1167 if (dart.notNull(i) > dart.notNull(offset)) 1127 if (dart.notNull(i) > dart.notNull(offset)) this.writeStringSlice(s, o ffset, i);
1168 this.writeStringSlice(s, offset, i);
1169 offset = dart.notNull(i) + 1; 1128 offset = dart.notNull(i) + 1;
1170 this.writeCharCode(_JsonStringifier.BACKSLASH); 1129 this.writeCharCode(_JsonStringifier.BACKSLASH);
1171 this.writeCharCode(charCode); 1130 this.writeCharCode(charCode);
1172 } 1131 }
1173 } 1132 }
1174 if (offset == 0) { 1133 if (offset == 0) {
1175 this.writeString(s); 1134 this.writeString(s);
1176 } else if (dart.notNull(offset) < dart.notNull(length)) { 1135 } else if (dart.notNull(offset) < dart.notNull(length)) {
1177 this.writeStringSlice(s, offset, length); 1136 this.writeStringSlice(s, offset, length);
1178 } 1137 }
1179 } 1138 }
1180 [_checkCycle](object) { 1139 [_checkCycle](object) {
1181 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen][dartx.length]); i = dart.notNull(i) + 1) { 1140 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen][dartx.length]); i = dart.notNull(i) + 1) {
1182 if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) { 1141 if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) {
1183 dart.throw(new JsonCyclicError(object)); 1142 dart.throw(new JsonCyclicError(object));
1184 } 1143 }
1185 } 1144 }
1186 this[_seen][dartx.add](object); 1145 this[_seen][dartx.add](object);
1187 } 1146 }
1188 [_removeSeen](object) { 1147 [_removeSeen](object) {
1189 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty])); 1148 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty]));
1190 dart.assert(core.identical(this[_seen][dartx.last], object)); 1149 dart.assert(core.identical(this[_seen][dartx.last], object));
1191 this[_seen][dartx.removeLast](); 1150 this[_seen][dartx.removeLast]();
1192 } 1151 }
1193 writeObject(object) { 1152 writeObject(object) {
1194 if (dart.notNull(this.writeJsonValue(object))) 1153 if (dart.notNull(this.writeJsonValue(object))) return;
1195 return;
1196 this[_checkCycle](object); 1154 this[_checkCycle](object);
1197 try { 1155 try {
1198 let customJson = dart.dcall(this[_toEncodable$], object); 1156 let customJson = dart.dcall(this[_toEncodable$], object);
1199 if (!dart.notNull(this.writeJsonValue(customJson))) { 1157 if (!dart.notNull(this.writeJsonValue(customJson))) {
1200 dart.throw(new JsonUnsupportedObjectError(object)); 1158 dart.throw(new JsonUnsupportedObjectError(object));
1201 } 1159 }
1202 this[_removeSeen](object); 1160 this[_removeSeen](object);
1203 } catch (e) { 1161 } catch (e) {
1204 dart.throw(new JsonUnsupportedObjectError(object, {cause: e})); 1162 dart.throw(new JsonUnsupportedObjectError(object, {cause: e}));
1205 } 1163 }
1206 1164
1207 } 1165 }
1208 writeJsonValue(object) { 1166 writeJsonValue(object) {
1209 if (typeof object == 'number') { 1167 if (typeof object == 'number') {
1210 if (!dart.notNull(dart.as(dart.dload(object, 'isFinite'), core.bool))) 1168 if (!dart.notNull(dart.as(dart.dload(object, 'isFinite'), core.bool))) r eturn false;
1211 return false;
1212 this.writeNumber(dart.as(object, core.num)); 1169 this.writeNumber(dart.as(object, core.num));
1213 return true; 1170 return true;
1214 } else if (dart.notNull(core.identical(object, true))) { 1171 } else if (dart.notNull(core.identical(object, true))) {
1215 this.writeString('true'); 1172 this.writeString('true');
1216 return true; 1173 return true;
1217 } else if (dart.notNull(core.identical(object, false))) { 1174 } else if (dart.notNull(core.identical(object, false))) {
1218 this.writeString('false'); 1175 this.writeString('false');
1219 return true; 1176 return true;
1220 } else if (object == null) { 1177 } else if (object == null) {
1221 this.writeString('null'); 1178 this.writeString('null');
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 Latin1Codec(opts) { 1520 Latin1Codec(opts) {
1564 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse; 1521 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse;
1565 this[_allowInvalid] = allowInvalid; 1522 this[_allowInvalid] = allowInvalid;
1566 super.Encoding(); 1523 super.Encoding();
1567 } 1524 }
1568 get name() { 1525 get name() {
1569 return "iso-8859-1"; 1526 return "iso-8859-1";
1570 } 1527 }
1571 decode(bytes, opts) { 1528 decode(bytes, opts) {
1572 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu ll; 1529 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu ll;
1573 if (allowInvalid == null) 1530 if (allowInvalid == null) allowInvalid = this[_allowInvalid];
1574 allowInvalid = this[_allowInvalid];
1575 if (dart.notNull(allowInvalid)) { 1531 if (dart.notNull(allowInvalid)) {
1576 return dart.const(new Latin1Decoder({allowInvalid: true})).convert(bytes ); 1532 return dart.const(new Latin1Decoder({allowInvalid: true})).convert(bytes );
1577 } else { 1533 } else {
1578 return dart.const(new Latin1Decoder({allowInvalid: false})).convert(byte s); 1534 return dart.const(new Latin1Decoder({allowInvalid: false})).convert(byte s);
1579 } 1535 }
1580 } 1536 }
1581 get encoder() { 1537 get encoder() {
1582 return dart.const(new Latin1Encoder()); 1538 return dart.const(new Latin1Encoder());
1583 } 1539 }
1584 get decoder() { 1540 get decoder() {
(...skipping 19 matching lines...) Expand all
1604 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse; 1560 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse;
1605 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK); 1561 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK);
1606 } 1562 }
1607 startChunkedConversion(sink) { 1563 startChunkedConversion(sink) {
1608 let stringSink = null; 1564 let stringSink = null;
1609 if (dart.is(sink, StringConversionSink)) { 1565 if (dart.is(sink, StringConversionSink)) {
1610 stringSink = sink; 1566 stringSink = sink;
1611 } else { 1567 } else {
1612 stringSink = StringConversionSink.from(sink); 1568 stringSink = StringConversionSink.from(sink);
1613 } 1569 }
1614 if (!dart.notNull(this[_allowInvalid])) 1570 if (!dart.notNull(this[_allowInvalid])) return new _Latin1DecoderSink(stri ngSink);
1615 return new _Latin1DecoderSink(stringSink);
1616 return new _Latin1AllowInvalidDecoderSink(stringSink); 1571 return new _Latin1AllowInvalidDecoderSink(stringSink);
1617 } 1572 }
1618 } 1573 }
1619 dart.setSignature(Latin1Decoder, { 1574 dart.setSignature(Latin1Decoder, {
1620 constructors: () => ({Latin1Decoder: [Latin1Decoder, [], {allowInvalid: core .bool}]}), 1575 constructors: () => ({Latin1Decoder: [Latin1Decoder, [], {allowInvalid: core .bool}]}),
1621 methods: () => ({startChunkedConversion: [ByteConversionSink, [core.Sink$(co re.String)]]}) 1576 methods: () => ({startChunkedConversion: [ByteConversionSink, [core.Sink$(co re.String)]]})
1622 }); 1577 });
1623 const _addSliceToSink = Symbol('_addSliceToSink'); 1578 const _addSliceToSink = Symbol('_addSliceToSink');
1624 class _Latin1DecoderSink extends ByteConversionSinkBase { 1579 class _Latin1DecoderSink extends ByteConversionSinkBase {
1625 _Latin1DecoderSink(sink) { 1580 _Latin1DecoderSink(sink) {
1626 this[_sink] = sink; 1581 this[_sink] = sink;
1627 } 1582 }
1628 close() { 1583 close() {
1629 this[_sink].close(); 1584 this[_sink].close();
1630 } 1585 }
1631 add(source) { 1586 add(source) {
1632 this.addSlice(source, 0, source[dartx.length], false); 1587 this.addSlice(source, 0, source[dartx.length], false);
1633 } 1588 }
1634 [_addSliceToSink](source, start, end, isLast) { 1589 [_addSliceToSink](source, start, end, isLast) {
1635 this[_sink].add(core.String.fromCharCodes(source, start, end)); 1590 this[_sink].add(core.String.fromCharCodes(source, start, end));
1636 if (dart.notNull(isLast)) 1591 if (dart.notNull(isLast)) this.close();
1637 this.close();
1638 } 1592 }
1639 addSlice(source, start, end, isLast) { 1593 addSlice(source, start, end, isLast) {
1640 core.RangeError.checkValidRange(start, end, source[dartx.length]); 1594 core.RangeError.checkValidRange(start, end, source[dartx.length]);
1641 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 1595 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
1642 let char = source[dartx.get](i); 1596 let char = source[dartx.get](i);
1643 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) { 1597 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) {
1644 dart.throw(new core.FormatException("Source contains non-Latin-1 chara cters.")); 1598 dart.throw(new core.FormatException("Source contains non-Latin-1 chara cters."));
1645 } 1599 }
1646 } 1600 }
1647 if (dart.notNull(start) < dart.notNull(end)) { 1601 if (dart.notNull(start) < dart.notNull(end)) {
(...skipping 14 matching lines...) Expand all
1662 }); 1616 });
1663 class _Latin1AllowInvalidDecoderSink extends _Latin1DecoderSink { 1617 class _Latin1AllowInvalidDecoderSink extends _Latin1DecoderSink {
1664 _Latin1AllowInvalidDecoderSink(sink) { 1618 _Latin1AllowInvalidDecoderSink(sink) {
1665 super._Latin1DecoderSink(sink); 1619 super._Latin1DecoderSink(sink);
1666 } 1620 }
1667 addSlice(source, start, end, isLast) { 1621 addSlice(source, start, end, isLast) {
1668 core.RangeError.checkValidRange(start, end, source[dartx.length]); 1622 core.RangeError.checkValidRange(start, end, source[dartx.length]);
1669 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 1623 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
1670 let char = source[dartx.get](i); 1624 let char = source[dartx.get](i);
1671 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) { 1625 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) {
1672 if (dart.notNull(i) > dart.notNull(start)) 1626 if (dart.notNull(i) > dart.notNull(start)) this[_addSliceToSink](sourc e, start, i, false);
1673 this[_addSliceToSink](source, start, i, false);
1674 this[_addSliceToSink](dart.const(dart.list([65533], core.int)), 0, 1, false); 1627 this[_addSliceToSink](dart.const(dart.list([65533], core.int)), 0, 1, false);
1675 start = dart.notNull(i) + 1; 1628 start = dart.notNull(i) + 1;
1676 } 1629 }
1677 } 1630 }
1678 if (dart.notNull(start) < dart.notNull(end)) { 1631 if (dart.notNull(start) < dart.notNull(end)) {
1679 this[_addSliceToSink](source, start, end, isLast); 1632 this[_addSliceToSink](source, start, end, isLast);
1680 } 1633 }
1681 if (dart.notNull(isLast)) { 1634 if (dart.notNull(isLast)) {
1682 this.close(); 1635 this.close();
1683 } 1636 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 this[_carry] = null; 1669 this[_carry] = null;
1717 } 1670 }
1718 addSlice(chunk, start, end, isLast) { 1671 addSlice(chunk, start, end, isLast) {
1719 if (this[_carry] != null) { 1672 if (this[_carry] != null) {
1720 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk[dartx.substring] (start, end)); 1673 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk[dartx.substring] (start, end));
1721 start = 0; 1674 start = 0;
1722 end = chunk[dartx.length]; 1675 end = chunk[dartx.length];
1723 this[_carry] = null; 1676 this[_carry] = null;
1724 } 1677 }
1725 this[_carry] = _LineSplitterSink._addSlice(chunk, start, end, isLast, dart .bind(this[_sink], 'add')); 1678 this[_carry] = _LineSplitterSink._addSlice(chunk, start, end, isLast, dart .bind(this[_sink], 'add'));
1726 if (dart.notNull(isLast)) 1679 if (dart.notNull(isLast)) this[_sink].close();
1727 this[_sink].close();
1728 } 1680 }
1729 close() { 1681 close() {
1730 this.addSlice('', 0, 0, true); 1682 this.addSlice('', 0, 0, true);
1731 } 1683 }
1732 static _addSlice(chunk, start, end, isLast, adder) { 1684 static _addSlice(chunk, start, end, isLast, adder) {
1733 let pos = start; 1685 let pos = start;
1734 while (dart.notNull(pos) < dart.notNull(end)) { 1686 while (dart.notNull(pos) < dart.notNull(end)) {
1735 let skip = 0; 1687 let skip = 0;
1736 let char = chunk[dartx.codeUnitAt](pos); 1688 let char = chunk[dartx.codeUnitAt](pos);
1737 if (char == _LineSplitterSink._LF) { 1689 if (char == _LineSplitterSink._LF) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 close() { 1766 close() {
1815 return this[_callback](); 1767 return this[_callback]();
1816 } 1768 }
1817 writeCharCode(charCode) { 1769 writeCharCode(charCode) {
1818 return this[_sink].writeCharCode(charCode); 1770 return this[_sink].writeCharCode(charCode);
1819 } 1771 }
1820 write(o) { 1772 write(o) {
1821 return this[_sink].write(o); 1773 return this[_sink].write(o);
1822 } 1774 }
1823 writeln(o) { 1775 writeln(o) {
1824 if (o === void 0) 1776 if (o === void 0) o = "";
1825 o = "";
1826 return this[_sink].writeln(o); 1777 return this[_sink].writeln(o);
1827 } 1778 }
1828 writeAll(objects, separator) { 1779 writeAll(objects, separator) {
1829 if (separator === void 0) 1780 if (separator === void 0) separator = "";
1830 separator = "";
1831 return this[_sink].writeAll(objects, separator); 1781 return this[_sink].writeAll(objects, separator);
1832 } 1782 }
1833 } 1783 }
1834 _ClosableStringSink[dart.implements] = () => [ClosableStringSink]; 1784 _ClosableStringSink[dart.implements] = () => [ClosableStringSink];
1835 dart.setSignature(_ClosableStringSink, { 1785 dart.setSignature(_ClosableStringSink, {
1836 constructors: () => ({_ClosableStringSink: [_ClosableStringSink, [core.Strin gSink, _StringSinkCloseCallback]]}), 1786 constructors: () => ({_ClosableStringSink: [_ClosableStringSink, [core.Strin gSink, _StringSinkCloseCallback]]}),
1837 methods: () => ({ 1787 methods: () => ({
1838 close: [dart.void, []], 1788 close: [dart.void, []],
1839 writeCharCode: [dart.void, [core.int]], 1789 writeCharCode: [dart.void, [core.int]],
1840 write: [dart.void, [core.Object]], 1790 write: [dart.void, [core.Object]],
1841 writeln: [dart.void, [], [core.Object]], 1791 writeln: [dart.void, [], [core.Object]],
1842 writeAll: [dart.void, [core.Iterable], [core.String]] 1792 writeAll: [dart.void, [core.Iterable], [core.String]]
1843 }) 1793 })
1844 }); 1794 });
1845 const _flush = Symbol('_flush'); 1795 const _flush = Symbol('_flush');
1846 class _StringConversionSinkAsStringSinkAdapter extends core.Object { 1796 class _StringConversionSinkAsStringSinkAdapter extends core.Object {
1847 _StringConversionSinkAsStringSinkAdapter(chunkedSink) { 1797 _StringConversionSinkAsStringSinkAdapter(chunkedSink) {
1848 this[_chunkedSink] = chunkedSink; 1798 this[_chunkedSink] = chunkedSink;
1849 this[_buffer] = new core.StringBuffer(); 1799 this[_buffer] = new core.StringBuffer();
1850 } 1800 }
1851 close() { 1801 close() {
1852 if (dart.notNull(this[_buffer].isNotEmpty)) 1802 if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush]();
1853 this[_flush]();
1854 this[_chunkedSink].close(); 1803 this[_chunkedSink].close();
1855 } 1804 }
1856 writeCharCode(charCode) { 1805 writeCharCode(charCode) {
1857 this[_buffer].writeCharCode(charCode); 1806 this[_buffer].writeCharCode(charCode);
1858 if (dart.notNull(this[_buffer].length) > dart.notNull(_StringConversionSin kAsStringSinkAdapter._MIN_STRING_SIZE)) 1807 if (dart.notNull(this[_buffer].length) > dart.notNull(_StringConversionSin kAsStringSinkAdapter._MIN_STRING_SIZE)) this[_flush]();
1859 this[_flush]();
1860 } 1808 }
1861 write(o) { 1809 write(o) {
1862 if (dart.notNull(this[_buffer].isNotEmpty)) 1810 if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush]();
1863 this[_flush]();
1864 let str = dart.toString(o); 1811 let str = dart.toString(o);
1865 this[_chunkedSink].add(dart.toString(o)); 1812 this[_chunkedSink].add(dart.toString(o));
1866 } 1813 }
1867 writeln(o) { 1814 writeln(o) {
1868 if (o === void 0) 1815 if (o === void 0) o = "";
1869 o = "";
1870 this[_buffer].writeln(o); 1816 this[_buffer].writeln(o);
1871 if (dart.notNull(this[_buffer].length) > dart.notNull(_StringConversionSin kAsStringSinkAdapter._MIN_STRING_SIZE)) 1817 if (dart.notNull(this[_buffer].length) > dart.notNull(_StringConversionSin kAsStringSinkAdapter._MIN_STRING_SIZE)) this[_flush]();
1872 this[_flush]();
1873 } 1818 }
1874 writeAll(objects, separator) { 1819 writeAll(objects, separator) {
1875 if (separator === void 0) 1820 if (separator === void 0) separator = "";
1876 separator = ""; 1821 if (dart.notNull(this[_buffer].isNotEmpty)) this[_flush]();
1877 if (dart.notNull(this[_buffer].isNotEmpty))
1878 this[_flush]();
1879 let iterator = objects[dartx.iterator]; 1822 let iterator = objects[dartx.iterator];
1880 if (!dart.notNull(iterator.moveNext())) 1823 if (!dart.notNull(iterator.moveNext())) return;
1881 return;
1882 if (dart.notNull(separator[dartx.isEmpty])) { 1824 if (dart.notNull(separator[dartx.isEmpty])) {
1883 do { 1825 do {
1884 this[_chunkedSink].add(dart.toString(iterator.current)); 1826 this[_chunkedSink].add(dart.toString(iterator.current));
1885 } while (dart.notNull(iterator.moveNext())); 1827 } while (dart.notNull(iterator.moveNext()));
1886 } else { 1828 } else {
1887 this[_chunkedSink].add(dart.toString(iterator.current)); 1829 this[_chunkedSink].add(dart.toString(iterator.current));
1888 while (dart.notNull(iterator.moveNext())) { 1830 while (dart.notNull(iterator.moveNext())) {
1889 this.write(separator); 1831 this.write(separator);
1890 this[_chunkedSink].add(dart.toString(iterator.current)); 1832 this[_chunkedSink].add(dart.toString(iterator.current));
1891 } 1833 }
(...skipping 25 matching lines...) Expand all
1917 } 1859 }
1918 close() {} 1860 close() {}
1919 addSlice(str, start, end, isLast) { 1861 addSlice(str, start, end, isLast) {
1920 if (start != 0 || end != str[dartx.length]) { 1862 if (start != 0 || end != str[dartx.length]) {
1921 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul l(i) + 1) { 1863 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul l(i) + 1) {
1922 this[_stringSink].writeCharCode(str[dartx.codeUnitAt](i)); 1864 this[_stringSink].writeCharCode(str[dartx.codeUnitAt](i));
1923 } 1865 }
1924 } else { 1866 } else {
1925 this[_stringSink].write(str); 1867 this[_stringSink].write(str);
1926 } 1868 }
1927 if (dart.notNull(isLast)) 1869 if (dart.notNull(isLast)) this.close();
1928 this.close();
1929 } 1870 }
1930 add(str) { 1871 add(str) {
1931 return this[_stringSink].write(str); 1872 return this[_stringSink].write(str);
1932 } 1873 }
1933 asUtf8Sink(allowMalformed) { 1874 asUtf8Sink(allowMalformed) {
1934 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ; 1875 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ;
1935 } 1876 }
1936 asStringSink() { 1877 asStringSink() {
1937 return ClosableStringSink.fromStringSink(this[_stringSink], dart.bind(this , 'close')); 1878 return ClosableStringSink.fromStringSink(this[_stringSink], dart.bind(this , 'close'));
1938 } 1879 }
(...skipping 29 matching lines...) Expand all
1968 } 1909 }
1969 add(str) { 1910 add(str) {
1970 return this[_sink].add(str); 1911 return this[_sink].add(str);
1971 } 1912 }
1972 addSlice(str, start, end, isLast) { 1913 addSlice(str, start, end, isLast) {
1973 if (start == 0 && end == str[dartx.length]) { 1914 if (start == 0 && end == str[dartx.length]) {
1974 this.add(str); 1915 this.add(str);
1975 } else { 1916 } else {
1976 this.add(str[dartx.substring](start, end)); 1917 this.add(str[dartx.substring](start, end));
1977 } 1918 }
1978 if (dart.notNull(isLast)) 1919 if (dart.notNull(isLast)) this.close();
1979 this.close();
1980 } 1920 }
1981 close() { 1921 close() {
1982 return this[_sink].close(); 1922 return this[_sink].close();
1983 } 1923 }
1984 } 1924 }
1985 dart.setSignature(_StringAdapterSink, { 1925 dart.setSignature(_StringAdapterSink, {
1986 constructors: () => ({_StringAdapterSink: [_StringAdapterSink, [core.Sink$(c ore.String)]]}), 1926 constructors: () => ({_StringAdapterSink: [_StringAdapterSink, [core.Sink$(c ore.String)]]}),
1987 methods: () => ({ 1927 methods: () => ({
1988 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]], 1928 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]],
1989 close: [dart.void, []] 1929 close: [dart.void, []]
1990 }) 1930 })
1991 }); 1931 });
1992 const _decoder = Symbol('_decoder'); 1932 const _decoder = Symbol('_decoder');
1993 class _Utf8StringSinkAdapter extends ByteConversionSink { 1933 class _Utf8StringSinkAdapter extends ByteConversionSink {
1994 _Utf8StringSinkAdapter(sink, stringSink, allowMalformed) { 1934 _Utf8StringSinkAdapter(sink, stringSink, allowMalformed) {
1995 this[_sink] = sink; 1935 this[_sink] = sink;
1996 this[_decoder] = new _Utf8Decoder(stringSink, allowMalformed); 1936 this[_decoder] = new _Utf8Decoder(stringSink, allowMalformed);
1997 super.ByteConversionSink(); 1937 super.ByteConversionSink();
1998 } 1938 }
1999 close() { 1939 close() {
2000 this[_decoder].close(); 1940 this[_decoder].close();
2001 if (this[_sink] != null) 1941 if (this[_sink] != null) this[_sink].close();
2002 this[_sink].close();
2003 } 1942 }
2004 add(chunk) { 1943 add(chunk) {
2005 this.addSlice(chunk, 0, chunk[dartx.length], false); 1944 this.addSlice(chunk, 0, chunk[dartx.length], false);
2006 } 1945 }
2007 addSlice(codeUnits, startIndex, endIndex, isLast) { 1946 addSlice(codeUnits, startIndex, endIndex, isLast) {
2008 this[_decoder].convert(codeUnits, startIndex, endIndex); 1947 this[_decoder].convert(codeUnits, startIndex, endIndex);
2009 if (dart.notNull(isLast)) 1948 if (dart.notNull(isLast)) this.close();
2010 this.close();
2011 } 1949 }
2012 } 1950 }
2013 dart.setSignature(_Utf8StringSinkAdapter, { 1951 dart.setSignature(_Utf8StringSinkAdapter, {
2014 constructors: () => ({_Utf8StringSinkAdapter: [_Utf8StringSinkAdapter, [core .Sink, core.StringSink, core.bool]]}), 1952 constructors: () => ({_Utf8StringSinkAdapter: [_Utf8StringSinkAdapter, [core .Sink, core.StringSink, core.bool]]}),
2015 methods: () => ({ 1953 methods: () => ({
2016 close: [dart.void, []], 1954 close: [dart.void, []],
2017 add: [dart.void, [core.List$(core.int)]], 1955 add: [dart.void, [core.List$(core.int)]],
2018 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool ]] 1956 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool ]]
2019 }) 1957 })
2020 }); 1958 });
(...skipping 21 matching lines...) Expand all
2042 this.addSlice(chunk, 0, chunk[dartx.length], false); 1980 this.addSlice(chunk, 0, chunk[dartx.length], false);
2043 } 1981 }
2044 addSlice(chunk, startIndex, endIndex, isLast) { 1982 addSlice(chunk, startIndex, endIndex, isLast) {
2045 this[_decoder].convert(chunk, startIndex, endIndex); 1983 this[_decoder].convert(chunk, startIndex, endIndex);
2046 if (dart.notNull(this[_buffer].isNotEmpty)) { 1984 if (dart.notNull(this[_buffer].isNotEmpty)) {
2047 let accumulated = dart.toString(this[_buffer]); 1985 let accumulated = dart.toString(this[_buffer]);
2048 this[_chunkedSink].addSlice(accumulated, 0, accumulated[dartx.length], i sLast); 1986 this[_chunkedSink].addSlice(accumulated, 0, accumulated[dartx.length], i sLast);
2049 this[_buffer].clear(); 1987 this[_buffer].clear();
2050 return; 1988 return;
2051 } 1989 }
2052 if (dart.notNull(isLast)) 1990 if (dart.notNull(isLast)) this.close();
2053 this.close();
2054 } 1991 }
2055 } 1992 }
2056 dart.defineNamedConstructor(_Utf8ConversionSink, '_'); 1993 dart.defineNamedConstructor(_Utf8ConversionSink, '_');
2057 dart.setSignature(_Utf8ConversionSink, { 1994 dart.setSignature(_Utf8ConversionSink, {
2058 constructors: () => ({ 1995 constructors: () => ({
2059 _Utf8ConversionSink: [_Utf8ConversionSink, [StringConversionSink, core.boo l]], 1996 _Utf8ConversionSink: [_Utf8ConversionSink, [StringConversionSink, core.boo l]],
2060 _: [_Utf8ConversionSink, [StringConversionSink, core.StringBuffer, core.bo ol]] 1997 _: [_Utf8ConversionSink, [StringConversionSink, core.StringBuffer, core.bo ol]]
2061 }), 1998 }),
2062 methods: () => ({ 1999 methods: () => ({
2063 close: [dart.void, []], 2000 close: [dart.void, []],
2064 add: [dart.void, [core.List$(core.int)]], 2001 add: [dart.void, [core.List$(core.int)]],
2065 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool ]] 2002 addSlice: [dart.void, [core.List$(core.int), core.int, core.int, core.bool ]]
2066 }) 2003 })
2067 }); 2004 });
2068 const UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533; 2005 const UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533;
2069 const UNICODE_BOM_CHARACTER_RUNE = 65279; 2006 const UNICODE_BOM_CHARACTER_RUNE = 65279;
2070 const _allowMalformed = Symbol('_allowMalformed'); 2007 const _allowMalformed = Symbol('_allowMalformed');
2071 class Utf8Codec extends Encoding { 2008 class Utf8Codec extends Encoding {
2072 Utf8Codec(opts) { 2009 Utf8Codec(opts) {
2073 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : false; 2010 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : false;
2074 this[_allowMalformed] = allowMalformed; 2011 this[_allowMalformed] = allowMalformed;
2075 super.Encoding(); 2012 super.Encoding();
2076 } 2013 }
2077 get name() { 2014 get name() {
2078 return "utf-8"; 2015 return "utf-8";
2079 } 2016 }
2080 decode(codeUnits, opts) { 2017 decode(codeUnits, opts) {
2081 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : null; 2018 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : null;
2082 if (allowMalformed == null) 2019 if (allowMalformed == null) allowMalformed = this[_allowMalformed];
2083 allowMalformed = this[_allowMalformed];
2084 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits ); 2020 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits );
2085 } 2021 }
2086 get encoder() { 2022 get encoder() {
2087 return new Utf8Encoder(); 2023 return new Utf8Encoder();
2088 } 2024 }
2089 get decoder() { 2025 get decoder() {
2090 return new Utf8Decoder({allowMalformed: this[_allowMalformed]}); 2026 return new Utf8Decoder({allowMalformed: this[_allowMalformed]});
2091 } 2027 }
2092 } 2028 }
2093 dart.setSignature(Utf8Codec, { 2029 dart.setSignature(Utf8Codec, {
2094 constructors: () => ({Utf8Codec: [Utf8Codec, [], {allowMalformed: core.bool} ]}), 2030 constructors: () => ({Utf8Codec: [Utf8Codec, [], {allowMalformed: core.bool} ]}),
2095 methods: () => ({decode: [core.String, [core.List$(core.int)], {allowMalform ed: core.bool}]}) 2031 methods: () => ({decode: [core.String, [core.List$(core.int)], {allowMalform ed: core.bool}]})
2096 }); 2032 });
2097 const UTF8 = dart.const(new Utf8Codec()); 2033 const UTF8 = dart.const(new Utf8Codec());
2098 const _fillBuffer = Symbol('_fillBuffer'); 2034 const _fillBuffer = Symbol('_fillBuffer');
2099 const _writeSurrogate = Symbol('_writeSurrogate'); 2035 const _writeSurrogate = Symbol('_writeSurrogate');
2100 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) { 2036 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) {
2101 Utf8Encoder() { 2037 Utf8Encoder() {
2102 super.Converter(); 2038 super.Converter();
2103 } 2039 }
2104 convert(string, start, end) { 2040 convert(string, start, end) {
2105 if (start === void 0) 2041 if (start === void 0) start = 0;
2106 start = 0; 2042 if (end === void 0) end = null;
2107 if (end === void 0)
2108 end = null;
2109 let stringLength = string[dartx.length]; 2043 let stringLength = string[dartx.length];
2110 core.RangeError.checkValidRange(start, end, stringLength); 2044 core.RangeError.checkValidRange(start, end, stringLength);
2111 if (end == null) 2045 if (end == null) end = stringLength;
2112 end = stringLength;
2113 let length = dart.notNull(end) - dart.notNull(start); 2046 let length = dart.notNull(end) - dart.notNull(start);
2114 if (length == 0) 2047 if (length == 0) return typed_data.Uint8List.new(0);
2115 return typed_data.Uint8List.new(0);
2116 let encoder = new _Utf8Encoder.withBufferSize(dart.notNull(length) * 3); 2048 let encoder = new _Utf8Encoder.withBufferSize(dart.notNull(length) * 3);
2117 let endPosition = encoder[_fillBuffer](string, start, end); 2049 let endPosition = encoder[_fillBuffer](string, start, end);
2118 dart.assert(dart.notNull(endPosition) >= dart.notNull(end) - 1); 2050 dart.assert(dart.notNull(endPosition) >= dart.notNull(end) - 1);
2119 if (endPosition != end) { 2051 if (endPosition != end) {
2120 let lastCodeUnit = string[dartx.codeUnitAt](dart.notNull(end) - 1); 2052 let lastCodeUnit = string[dartx.codeUnitAt](dart.notNull(end) - 1);
2121 dart.assert(_isLeadSurrogate(lastCodeUnit)); 2053 dart.assert(_isLeadSurrogate(lastCodeUnit));
2122 let wasCombined = encoder[_writeSurrogate](lastCodeUnit, 0); 2054 let wasCombined = encoder[_writeSurrogate](lastCodeUnit, 0);
2123 dart.assert(!dart.notNull(wasCombined)); 2055 dart.assert(!dart.notNull(wasCombined));
2124 } 2056 }
2125 return encoder[_buffer][dartx.sublist](0, encoder[_bufferIndex]); 2057 return encoder[_buffer][dartx.sublist](0, encoder[_bufferIndex]);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 } 2132 }
2201 } 2133 }
2202 [_fillBuffer](str, start, end) { 2134 [_fillBuffer](str, start, end) {
2203 if (start != end && dart.notNull(_isLeadSurrogate(str[dartx.codeUnitAt](da rt.notNull(end) - 1)))) { 2135 if (start != end && dart.notNull(_isLeadSurrogate(str[dartx.codeUnitAt](da rt.notNull(end) - 1)))) {
2204 end = dart.notNull(end) - 1; 2136 end = dart.notNull(end) - 1;
2205 } 2137 }
2206 let stringIndex = null; 2138 let stringIndex = null;
2207 for (stringIndex = start; dart.notNull(stringIndex) < dart.notNull(end); s tringIndex = dart.notNull(stringIndex) + 1) { 2139 for (stringIndex = start; dart.notNull(stringIndex) < dart.notNull(end); s tringIndex = dart.notNull(stringIndex) + 1) {
2208 let codeUnit = str[dartx.codeUnitAt](stringIndex); 2140 let codeUnit = str[dartx.codeUnitAt](stringIndex);
2209 if (dart.notNull(codeUnit) <= dart.notNull(_ONE_BYTE_LIMIT)) { 2141 if (dart.notNull(codeUnit) <= dart.notNull(_ONE_BYTE_LIMIT)) {
2210 if (dart.notNull(this[_bufferIndex]) >= dart.notNull(this[_buffer][dar tx.length])) 2142 if (dart.notNull(this[_bufferIndex]) >= dart.notNull(this[_buffer][dar tx.length])) break;
2211 break;
2212 this[_buffer][dartx.set]((() => { 2143 this[_buffer][dartx.set]((() => {
2213 let x = this[_bufferIndex]; 2144 let x = this[_bufferIndex];
2214 this[_bufferIndex] = dart.notNull(x) + 1; 2145 this[_bufferIndex] = dart.notNull(x) + 1;
2215 return x; 2146 return x;
2216 }).bind(this)(), codeUnit); 2147 }).bind(this)(), codeUnit);
2217 } else if (dart.notNull(_isLeadSurrogate(codeUnit))) { 2148 } else if (dart.notNull(_isLeadSurrogate(codeUnit))) {
2218 if (dart.notNull(this[_bufferIndex]) + 3 >= dart.notNull(this[_buffer] [dartx.length])) 2149 if (dart.notNull(this[_bufferIndex]) + 3 >= dart.notNull(this[_buffer] [dartx.length])) break;
2219 break;
2220 let nextCodeUnit = str[dartx.codeUnitAt](dart.notNull(stringIndex) + 1 ); 2150 let nextCodeUnit = str[dartx.codeUnitAt](dart.notNull(stringIndex) + 1 );
2221 let wasCombined = this[_writeSurrogate](codeUnit, nextCodeUnit); 2151 let wasCombined = this[_writeSurrogate](codeUnit, nextCodeUnit);
2222 if (dart.notNull(wasCombined)) { 2152 if (dart.notNull(wasCombined)) {
2223 stringIndex = dart.notNull(stringIndex) + 1; 2153 stringIndex = dart.notNull(stringIndex) + 1;
2224 } 2154 }
2225 } else { 2155 } else {
2226 let rune = codeUnit; 2156 let rune = codeUnit;
2227 if (dart.notNull(rune) <= dart.notNull(_TWO_BYTE_LIMIT)) { 2157 if (dart.notNull(rune) <= dart.notNull(_TWO_BYTE_LIMIT)) {
2228 if (dart.notNull(this[_bufferIndex]) + 1 >= dart.notNull(this[_buffe r][dartx.length])) 2158 if (dart.notNull(this[_bufferIndex]) + 1 >= dart.notNull(this[_buffe r][dartx.length])) break;
2229 break;
2230 this[_buffer][dartx.set]((() => { 2159 this[_buffer][dartx.set]((() => {
2231 let x = this[_bufferIndex]; 2160 let x = this[_bufferIndex];
2232 this[_bufferIndex] = dart.notNull(x) + 1; 2161 this[_bufferIndex] = dart.notNull(x) + 1;
2233 return x; 2162 return x;
2234 }).bind(this)(), 192 | dart.notNull(rune) >> 6); 2163 }).bind(this)(), 192 | dart.notNull(rune) >> 6);
2235 this[_buffer][dartx.set]((() => { 2164 this[_buffer][dartx.set]((() => {
2236 let x = this[_bufferIndex]; 2165 let x = this[_bufferIndex];
2237 this[_bufferIndex] = dart.notNull(x) + 1; 2166 this[_bufferIndex] = dart.notNull(x) + 1;
2238 return x; 2167 return x;
2239 }).bind(this)(), 128 | dart.notNull(rune) & 63); 2168 }).bind(this)(), 128 | dart.notNull(rune) & 63);
2240 } else { 2169 } else {
2241 dart.assert(dart.notNull(rune) <= dart.notNull(_THREE_BYTE_LIMIT)); 2170 dart.assert(dart.notNull(rune) <= dart.notNull(_THREE_BYTE_LIMIT));
2242 if (dart.notNull(this[_bufferIndex]) + 2 >= dart.notNull(this[_buffe r][dartx.length])) 2171 if (dart.notNull(this[_bufferIndex]) + 2 >= dart.notNull(this[_buffe r][dartx.length])) break;
2243 break;
2244 this[_buffer][dartx.set]((() => { 2172 this[_buffer][dartx.set]((() => {
2245 let x = this[_bufferIndex]; 2173 let x = this[_bufferIndex];
2246 this[_bufferIndex] = dart.notNull(x) + 1; 2174 this[_bufferIndex] = dart.notNull(x) + 1;
2247 return x; 2175 return x;
2248 }).bind(this)(), 224 | dart.notNull(rune) >> 12); 2176 }).bind(this)(), 224 | dart.notNull(rune) >> 12);
2249 this[_buffer][dartx.set]((() => { 2177 this[_buffer][dartx.set]((() => {
2250 let x = this[_bufferIndex]; 2178 let x = this[_bufferIndex];
2251 this[_bufferIndex] = dart.notNull(x) + 1; 2179 this[_bufferIndex] = dart.notNull(x) + 1;
2252 return x; 2180 return x;
2253 }).bind(this)(), 128 | dart.notNull(rune) >> 6 & 63); 2181 }).bind(this)(), 128 | dart.notNull(rune) >> 6 & 63);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 let hasBeenCombined = this[_writeSurrogate](str[dartx.codeUnitAt](st art), 0); 2243 let hasBeenCombined = this[_writeSurrogate](str[dartx.codeUnitAt](st art), 0);
2316 dart.assert(!dart.notNull(hasBeenCombined)); 2244 dart.assert(!dart.notNull(hasBeenCombined));
2317 } else { 2245 } else {
2318 this[_carry] = str[dartx.codeUnitAt](start); 2246 this[_carry] = str[dartx.codeUnitAt](start);
2319 } 2247 }
2320 start = dart.notNull(start) + 1; 2248 start = dart.notNull(start) + 1;
2321 } 2249 }
2322 this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice); 2250 this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice);
2323 this[_bufferIndex] = 0; 2251 this[_bufferIndex] = 0;
2324 } while (dart.notNull(start) < dart.notNull(end)); 2252 } while (dart.notNull(start) < dart.notNull(end));
2325 if (dart.notNull(isLast)) 2253 if (dart.notNull(isLast)) this.close();
2326 this.close();
2327 } 2254 }
2328 } 2255 }
2329 dart.setSignature(_Utf8EncoderSink, { 2256 dart.setSignature(_Utf8EncoderSink, {
2330 constructors: () => ({_Utf8EncoderSink: [_Utf8EncoderSink, [ByteConversionSi nk]]}), 2257 constructors: () => ({_Utf8EncoderSink: [_Utf8EncoderSink, [ByteConversionSi nk]]}),
2331 methods: () => ({ 2258 methods: () => ({
2332 close: [dart.void, []], 2259 close: [dart.void, []],
2333 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]] 2260 addSlice: [dart.void, [core.String, core.int, core.int, core.bool]]
2334 }) 2261 })
2335 }); 2262 });
2336 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { 2263 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) {
2337 Utf8Decoder(opts) { 2264 Utf8Decoder(opts) {
2338 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : false; 2265 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme d : false;
2339 this[_allowMalformed] = allowMalformed; 2266 this[_allowMalformed] = allowMalformed;
2340 super.Converter(); 2267 super.Converter();
2341 } 2268 }
2342 convert(codeUnits, start, end) { 2269 convert(codeUnits, start, end) {
2343 if (start === void 0) 2270 if (start === void 0) start = 0;
2344 start = 0; 2271 if (end === void 0) end = null;
2345 if (end === void 0)
2346 end = null;
2347 let length = codeUnits[dartx.length]; 2272 let length = codeUnits[dartx.length];
2348 core.RangeError.checkValidRange(start, end, length); 2273 core.RangeError.checkValidRange(start, end, length);
2349 if (end == null) 2274 if (end == null) end = length;
2350 end = length;
2351 let buffer = new core.StringBuffer(); 2275 let buffer = new core.StringBuffer();
2352 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]); 2276 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]);
2353 decoder.convert(codeUnits, start, end); 2277 decoder.convert(codeUnits, start, end);
2354 decoder.close(); 2278 decoder.close();
2355 return dart.toString(buffer); 2279 return dart.toString(buffer);
2356 } 2280 }
2357 startChunkedConversion(sink) { 2281 startChunkedConversion(sink) {
2358 let stringSink = null; 2282 let stringSink = null;
2359 if (dart.is(sink, StringConversionSink)) { 2283 if (dart.is(sink, StringConversionSink)) {
2360 stringSink = sink; 2284 stringSink = sink;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 let expectedUnits = this[_expectedUnits]; 2363 let expectedUnits = this[_expectedUnits];
2440 let extraUnits = this[_extraUnits]; 2364 let extraUnits = this[_extraUnits];
2441 this[_value] = 0; 2365 this[_value] = 0;
2442 this[_expectedUnits] = 0; 2366 this[_expectedUnits] = 0;
2443 this[_extraUnits] = 0; 2367 this[_extraUnits] = 0;
2444 function scanOneByteCharacters(units, from) { 2368 function scanOneByteCharacters(units, from) {
2445 let to = endIndex; 2369 let to = endIndex;
2446 let mask = _ONE_BYTE_LIMIT; 2370 let mask = _ONE_BYTE_LIMIT;
2447 for (let i = from; dart.notNull(i) < dart.notNull(to); i = dart.notNull( i) + 1) { 2371 for (let i = from; dart.notNull(i) < dart.notNull(to); i = dart.notNull( i) + 1) {
2448 let unit = dart.dindex(units, i); 2372 let unit = dart.dindex(units, i);
2449 if (!dart.equals(dart.dsend(unit, '&', mask), unit)) 2373 if (!dart.equals(dart.dsend(unit, '&', mask), unit)) return dart.notNu ll(i) - dart.notNull(from);
2450 return dart.notNull(i) - dart.notNull(from);
2451 } 2374 }
2452 return dart.notNull(to) - dart.notNull(from); 2375 return dart.notNull(to) - dart.notNull(from);
2453 } 2376 }
2454 dart.fn(scanOneByteCharacters, core.int, [dart.dynamic, core.int]); 2377 dart.fn(scanOneByteCharacters, core.int, [dart.dynamic, core.int]);
2455 const addSingleBytes = (function(from, to) { 2378 const addSingleBytes = (function(from, to) {
2456 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu ll(from) <= dart.notNull(endIndex)); 2379 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu ll(from) <= dart.notNull(endIndex));
2457 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull (to) <= dart.notNull(endIndex)); 2380 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull (to) <= dart.notNull(endIndex));
2458 this[_stringSink].write(core.String.fromCharCodes(codeUnits, from, to)); 2381 this[_stringSink].write(core.String.fromCharCodes(codeUnits, from, to));
2459 }).bind(this); 2382 }).bind(this);
2460 dart.fn(addSingleBytes, dart.void, [core.int, core.int]); 2383 dart.fn(addSingleBytes, dart.void, [core.int, core.int]);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 this[_stringSink].writeCharCode(value); 2422 this[_stringSink].writeCharCode(value);
2500 } 2423 }
2501 this[_isFirstCharacter] = false; 2424 this[_isFirstCharacter] = false;
2502 } 2425 }
2503 while (dart.notNull(i) < dart.notNull(endIndex)) { 2426 while (dart.notNull(i) < dart.notNull(endIndex)) {
2504 let oneBytes = scanOneByteCharacters(codeUnits, i); 2427 let oneBytes = scanOneByteCharacters(codeUnits, i);
2505 if (dart.notNull(oneBytes) > 0) { 2428 if (dart.notNull(oneBytes) > 0) {
2506 this[_isFirstCharacter] = false; 2429 this[_isFirstCharacter] = false;
2507 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes)); 2430 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes));
2508 i = dart.notNull(i) + dart.notNull(oneBytes); 2431 i = dart.notNull(i) + dart.notNull(oneBytes);
2509 if (i == endIndex) 2432 if (i == endIndex) break;
2510 break;
2511 } 2433 }
2512 let unit = codeUnits[dartx.get]((() => { 2434 let unit = codeUnits[dartx.get]((() => {
2513 let x = i; 2435 let x = i;
2514 i = dart.notNull(x) + 1; 2436 i = dart.notNull(x) + 1;
2515 return x; 2437 return x;
2516 })()); 2438 })());
2517 if (dart.notNull(unit) < 0) { 2439 if (dart.notNull(unit) < 0) {
2518 if (!dart.notNull(this[_allowMalformed])) { 2440 if (!dart.notNull(this[_allowMalformed])) {
2519 dart.throw(new core.FormatException(`Negative UTF-8 code unit: - 0x${(-dart.notNull(unit))[dartx.toRadixString](16)}`)); 2441 dart.throw(new core.FormatException(`Negative UTF-8 code unit: - 0x${(-dart.notNull(unit))[dartx.toRadixString](16)}`));
2520 } 2442 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 processed[key] = revived; 2510 processed[key] = revived;
2589 } 2511 }
2590 map[_original] = processed; 2512 map[_original] = processed;
2591 return map; 2513 return map;
2592 } 2514 }
2593 dart.fn(walk); 2515 dart.fn(walk);
2594 return dart.dcall(reviver, null, walk(json)); 2516 return dart.dcall(reviver, null, walk(json));
2595 } 2517 }
2596 dart.fn(_convertJsonToDart, dart.dynamic, [dart.dynamic, dart.functionType(dar t.dynamic, [dart.dynamic, dart.dynamic])]); 2518 dart.fn(_convertJsonToDart, dart.dynamic, [dart.dynamic, dart.functionType(dar t.dynamic, [dart.dynamic, dart.dynamic])]);
2597 function _convertJsonToDartLazy(object) { 2519 function _convertJsonToDartLazy(object) {
2598 if (object == null) 2520 if (object == null) return null;
2599 return null;
2600 if (typeof object != "object") { 2521 if (typeof object != "object") {
2601 return object; 2522 return object;
2602 } 2523 }
2603 if (Object.getPrototypeOf(object) !== Array.prototype) { 2524 if (Object.getPrototypeOf(object) !== Array.prototype) {
2604 return new _JsonMap(object); 2525 return new _JsonMap(object);
2605 } 2526 }
2606 for (let i = 0; dart.notNull(i) < object.length; i = dart.notNull(i) + 1) { 2527 for (let i = 0; dart.notNull(i) < object.length; i = dart.notNull(i) + 1) {
2607 let item = object[i]; 2528 let item = object[i];
2608 object[i] = _convertJsonToDartLazy(item); 2529 object[i] = _convertJsonToDartLazy(item);
2609 } 2530 }
(...skipping 11 matching lines...) Expand all
2621 this[_original] = original; 2542 this[_original] = original;
2622 this[_data] = null; 2543 this[_data] = null;
2623 } 2544 }
2624 get(key) { 2545 get(key) {
2625 if (dart.notNull(this[_isUpgraded])) { 2546 if (dart.notNull(this[_isUpgraded])) {
2626 return this[_upgradedMap].get(key); 2547 return this[_upgradedMap].get(key);
2627 } else if (!(typeof key == 'string')) { 2548 } else if (!(typeof key == 'string')) {
2628 return null; 2549 return null;
2629 } else { 2550 } else {
2630 let result = _JsonMap._getProperty(this[_processed], dart.as(key, core.S tring)); 2551 let result = _JsonMap._getProperty(this[_processed], dart.as(key, core.S tring));
2631 if (dart.notNull(_JsonMap._isUnprocessed(result))) 2552 if (dart.notNull(_JsonMap._isUnprocessed(result))) result = this[_proces s](dart.as(key, core.String));
2632 result = this[_process](dart.as(key, core.String));
2633 return result; 2553 return result;
2634 } 2554 }
2635 } 2555 }
2636 get length() { 2556 get length() {
2637 return dart.notNull(this[_isUpgraded]) ? this[_upgradedMap].length : this[ _computeKeys]()[dartx.length]; 2557 return dart.notNull(this[_isUpgraded]) ? this[_upgradedMap].length : this[ _computeKeys]()[dartx.length];
2638 } 2558 }
2639 get isEmpty() { 2559 get isEmpty() {
2640 return this.length == 0; 2560 return this.length == 0;
2641 } 2561 }
2642 get isNotEmpty() { 2562 get isNotEmpty() {
2643 return dart.notNull(this.length) > 0; 2563 return dart.notNull(this.length) > 0;
2644 } 2564 }
2645 get keys() { 2565 get keys() {
2646 if (dart.notNull(this[_isUpgraded])) 2566 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].keys;
2647 return this[_upgradedMap].keys;
2648 return new _JsonMapKeyIterable(this); 2567 return new _JsonMapKeyIterable(this);
2649 } 2568 }
2650 get values() { 2569 get values() {
2651 if (dart.notNull(this[_isUpgraded])) 2570 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].values;
2652 return this[_upgradedMap].values;
2653 return _internal.MappedIterable.new(this[_computeKeys](), dart.fn((each => this.get(each)).bind(this))); 2571 return _internal.MappedIterable.new(this[_computeKeys](), dart.fn((each => this.get(each)).bind(this)));
2654 } 2572 }
2655 set(key, value) { 2573 set(key, value) {
2656 if (dart.notNull(this[_isUpgraded])) { 2574 if (dart.notNull(this[_isUpgraded])) {
2657 this[_upgradedMap].set(key, value); 2575 this[_upgradedMap].set(key, value);
2658 } else if (dart.notNull(this.containsKey(key))) { 2576 } else if (dart.notNull(this.containsKey(key))) {
2659 let processed = this[_processed]; 2577 let processed = this[_processed];
2660 _JsonMap._setProperty(processed, dart.as(key, core.String), value); 2578 _JsonMap._setProperty(processed, dart.as(key, core.String), value);
2661 let original = this[_original]; 2579 let original = this[_original];
2662 if (!dart.notNull(core.identical(original, processed))) { 2580 if (!dart.notNull(core.identical(original, processed))) {
2663 _JsonMap._setProperty(original, dart.as(key, core.String), null); 2581 _JsonMap._setProperty(original, dart.as(key, core.String), null);
2664 } 2582 }
2665 } else { 2583 } else {
2666 this[_upgrade]().set(key, value); 2584 this[_upgrade]().set(key, value);
2667 } 2585 }
2668 return value; 2586 return value;
2669 } 2587 }
2670 addAll(other) { 2588 addAll(other) {
2671 other.forEach(dart.fn(((key, value) => { 2589 other.forEach(dart.fn(((key, value) => {
2672 this.set(key, value); 2590 this.set(key, value);
2673 }).bind(this))); 2591 }).bind(this)));
2674 } 2592 }
2675 containsValue(value) { 2593 containsValue(value) {
2676 if (dart.notNull(this[_isUpgraded])) 2594 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].containsVal ue(value);
2677 return this[_upgradedMap].containsValue(value);
2678 let keys = this[_computeKeys](); 2595 let keys = this[_computeKeys]();
2679 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) { 2596 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) {
2680 let key = keys[dartx.get](i); 2597 let key = keys[dartx.get](i);
2681 if (dart.equals(this.get(key), value)) 2598 if (dart.equals(this.get(key), value)) return true;
2682 return true;
2683 } 2599 }
2684 return false; 2600 return false;
2685 } 2601 }
2686 containsKey(key) { 2602 containsKey(key) {
2687 if (dart.notNull(this[_isUpgraded])) 2603 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].containsKey (key);
2688 return this[_upgradedMap].containsKey(key); 2604 if (!(typeof key == 'string')) return false;
2689 if (!(typeof key == 'string'))
2690 return false;
2691 return _JsonMap._hasProperty(this[_original], dart.as(key, core.String)); 2605 return _JsonMap._hasProperty(this[_original], dart.as(key, core.String));
2692 } 2606 }
2693 putIfAbsent(key, ifAbsent) { 2607 putIfAbsent(key, ifAbsent) {
2694 if (dart.notNull(this.containsKey(key))) 2608 if (dart.notNull(this.containsKey(key))) return this.get(key);
2695 return this.get(key);
2696 let value = ifAbsent(); 2609 let value = ifAbsent();
2697 this.set(key, value); 2610 this.set(key, value);
2698 return value; 2611 return value;
2699 } 2612 }
2700 remove(key) { 2613 remove(key) {
2701 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key ))) 2614 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key ))) return null;
2702 return null;
2703 return this[_upgrade]().remove(key); 2615 return this[_upgrade]().remove(key);
2704 } 2616 }
2705 clear() { 2617 clear() {
2706 if (dart.notNull(this[_isUpgraded])) { 2618 if (dart.notNull(this[_isUpgraded])) {
2707 this[_upgradedMap].clear(); 2619 this[_upgradedMap].clear();
2708 } else { 2620 } else {
2709 if (this[_data] != null) { 2621 if (this[_data] != null) {
2710 dart.dsend(this[_data], 'clear'); 2622 dart.dsend(this[_data], 'clear');
2711 } 2623 }
2712 this[_original] = this[_processed] = null; 2624 this[_original] = this[_processed] = null;
2713 this[_data] = dart.map(); 2625 this[_data] = dart.map();
2714 } 2626 }
2715 } 2627 }
2716 forEach(f) { 2628 forEach(f) {
2717 if (dart.notNull(this[_isUpgraded])) 2629 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap].forEach(f);
2718 return this[_upgradedMap].forEach(f);
2719 let keys = this[_computeKeys](); 2630 let keys = this[_computeKeys]();
2720 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) { 2631 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) {
2721 let key = keys[dartx.get](i); 2632 let key = keys[dartx.get](i);
2722 let value = _JsonMap._getProperty(this[_processed], key); 2633 let value = _JsonMap._getProperty(this[_processed], key);
2723 if (dart.notNull(_JsonMap._isUnprocessed(value))) { 2634 if (dart.notNull(_JsonMap._isUnprocessed(value))) {
2724 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key)); 2635 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key));
2725 _JsonMap._setProperty(this[_processed], key, value); 2636 _JsonMap._setProperty(this[_processed], key, value);
2726 } 2637 }
2727 dart.dcall(f, key, value); 2638 dart.dcall(f, key, value);
2728 if (!dart.notNull(core.identical(keys, this[_data]))) { 2639 if (!dart.notNull(core.identical(keys, this[_data]))) {
(...skipping 13 matching lines...) Expand all
2742 } 2653 }
2743 [_computeKeys]() { 2654 [_computeKeys]() {
2744 dart.assert(!dart.notNull(this[_isUpgraded])); 2655 dart.assert(!dart.notNull(this[_isUpgraded]));
2745 let keys = dart.as(this[_data], core.List); 2656 let keys = dart.as(this[_data], core.List);
2746 if (keys == null) { 2657 if (keys == null) {
2747 keys = this[_data] = _JsonMap._getPropertyNames(this[_original]); 2658 keys = this[_data] = _JsonMap._getPropertyNames(this[_original]);
2748 } 2659 }
2749 return dart.as(keys, core.List$(core.String)); 2660 return dart.as(keys, core.List$(core.String));
2750 } 2661 }
2751 [_upgrade]() { 2662 [_upgrade]() {
2752 if (dart.notNull(this[_isUpgraded])) 2663 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap];
2753 return this[_upgradedMap];
2754 let result = dart.map(); 2664 let result = dart.map();
2755 let keys = this[_computeKeys](); 2665 let keys = this[_computeKeys]();
2756 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) { 2666 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) {
2757 let key = keys[dartx.get](i); 2667 let key = keys[dartx.get](i);
2758 result.set(key, this.get(key)); 2668 result.set(key, this.get(key));
2759 } 2669 }
2760 if (dart.notNull(keys[dartx.isEmpty])) { 2670 if (dart.notNull(keys[dartx.isEmpty])) {
2761 keys[dartx.add](null); 2671 keys[dartx.add](null);
2762 } else { 2672 } else {
2763 keys[dartx.clear](); 2673 keys[dartx.clear]();
2764 } 2674 }
2765 this[_original] = this[_processed] = null; 2675 this[_original] = this[_processed] = null;
2766 this[_data] = result; 2676 this[_data] = result;
2767 dart.assert(this[_isUpgraded]); 2677 dart.assert(this[_isUpgraded]);
2768 return result; 2678 return result;
2769 } 2679 }
2770 [_process](key) { 2680 [_process](key) {
2771 if (!dart.notNull(_JsonMap._hasProperty(this[_original], key))) 2681 if (!dart.notNull(_JsonMap._hasProperty(this[_original], key))) return nul l;
2772 return null;
2773 let result = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key)); 2682 let result = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key));
2774 return _JsonMap._setProperty(this[_processed], key, result); 2683 return _JsonMap._setProperty(this[_processed], key, result);
2775 } 2684 }
2776 static _hasProperty(object, key) { 2685 static _hasProperty(object, key) {
2777 return Object.prototype.hasOwnProperty.call(object, key); 2686 return Object.prototype.hasOwnProperty.call(object, key);
2778 } 2687 }
2779 static _getProperty(object, key) { 2688 static _getProperty(object, key) {
2780 return object[key]; 2689 return object[key];
2781 } 2690 }
2782 static _setProperty(object, key, value) { 2691 static _setProperty(object, key, value) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 exports.LineSplitter = LineSplitter; 2804 exports.LineSplitter = LineSplitter;
2896 exports.StringConversionSink = StringConversionSink; 2805 exports.StringConversionSink = StringConversionSink;
2897 exports.ClosableStringSink = ClosableStringSink; 2806 exports.ClosableStringSink = ClosableStringSink;
2898 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2807 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2899 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2808 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2900 exports.Utf8Codec = Utf8Codec; 2809 exports.Utf8Codec = Utf8Codec;
2901 exports.UTF8 = UTF8; 2810 exports.UTF8 = UTF8;
2902 exports.Utf8Encoder = Utf8Encoder; 2811 exports.Utf8Encoder = Utf8Encoder;
2903 exports.Utf8Decoder = Utf8Decoder; 2812 exports.Utf8Decoder = Utf8Decoder;
2904 }); 2813 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698