| OLD | NEW |
| 1 var convert; | 1 var convert; |
| 2 (function(exports) { | 2 (function(exports) { |
| 3 'use strict'; | 3 'use strict'; |
| 4 let ASCII = new AsciiCodec(); | 4 let ASCII = new AsciiCodec(); |
| 5 let _ASCII_MASK = 127; | 5 let _ASCII_MASK = 127; |
| 6 let _allowInvalid = Symbol('_allowInvalid'); | 6 let _allowInvalid = Symbol('_allowInvalid'); |
| 7 let _nameToEncoding = Symbol('_nameToEncoding'); | 7 let _nameToEncoding = Symbol('_nameToEncoding'); |
| 8 let Codec$ = dart.generic(function(S, T) { | 8 let Codec$ = dart.generic(function(S, T) { |
| 9 class Codec extends core.Object { | 9 class Codec extends core.Object { |
| 10 Codec() { | 10 Codec() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 }); | 26 }); |
| 27 let Codec = Codec$(dart.dynamic, dart.dynamic); | 27 let Codec = Codec$(dart.dynamic, dart.dynamic); |
| 28 class Encoding extends Codec$(core.String, core.List$(core.int)) { | 28 class Encoding extends Codec$(core.String, core.List$(core.int)) { |
| 29 Encoding() { | 29 Encoding() { |
| 30 super.Codec(); | 30 super.Codec(); |
| 31 } | 31 } |
| 32 decodeStream(byteStream) { | 32 decodeStream(byteStream) { |
| 33 return dart.as(byteStream.transform(dart.as(this.decoder, async.StreamTran
sformer$(core.List$(core.int), dynamic))).fold(new core.StringBuffer(), (buffer,
string) => dart.dinvoke(buffer, 'write', string), buffer).then((buffer) => dart
.dinvoke(buffer, 'toString')), async.Future$(core.String)); | 33 return dart.as(byteStream.transform(dart.as(this.decoder, async.StreamTran
sformer$(core.List$(core.int), dynamic))).fold(new core.StringBuffer(), (buffer,
string) => dart.dinvoke(buffer, 'write', string), buffer).then((buffer) => dart
.dinvoke(buffer, 'toString')), async.Future$(core.String)); |
| 34 } | 34 } |
| 35 static getByName(name) { | 35 static getByName(name) { |
| 36 if (name === null) | 36 if (name == null) |
| 37 return null; | 37 return null; |
| 38 name = name.toLowerCase(); | 38 name = name.toLowerCase(); |
| 39 return Encoding[_nameToEncoding].get(name); | 39 return Encoding[_nameToEncoding].get(name); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 dart.defineLazyProperties(Encoding, { | 42 dart.defineLazyProperties(Encoding, { |
| 43 get _nameToEncoding() { | 43 get _nameToEncoding() { |
| 44 return dart.map({"iso_8859-1:1987": LATIN1, "iso-ir-100": LATIN1, "iso_885
9-1": LATIN1, "iso-8859-1": LATIN1, latin1: LATIN1, l1: LATIN1, ibm819: LATIN1,
cp819: LATIN1, csisolatin1: LATIN1, "iso-ir-6": ASCII, "ansi_x3.4-1968": ASCII,
"ansi_x3.4-1986": ASCII, "iso_646.irv:1991": ASCII, "iso646-us": ASCII, "us-asci
i": ASCII, us: ASCII, ibm367: ASCII, cp367: ASCII, csascii: ASCII, ascii: ASCII,
csutf8: UTF8, "utf-8": UTF8}); | 44 return dart.map({"iso_8859-1:1987": LATIN1, "iso-ir-100": LATIN1, "iso_885
9-1": LATIN1, "iso-8859-1": LATIN1, latin1: LATIN1, l1: LATIN1, ibm819: LATIN1,
cp819: LATIN1, csisolatin1: LATIN1, "iso-ir-6": ASCII, "ansi_x3.4-1968": ASCII,
"ansi_x3.4-1986": ASCII, "iso_646.irv:1991": ASCII, "iso646-us": ASCII, "us-asci
i": ASCII, us: ASCII, ibm367: ASCII, cp367: ASCII, csascii: ASCII, ascii: ASCII,
csutf8: UTF8, "utf-8": UTF8}); |
| 45 }, | 45 }, |
| 46 set _nameToEncoding(_) {} | 46 set _nameToEncoding(_) {} |
| 47 }); | 47 }); |
| 48 class AsciiCodec extends Encoding { | 48 class AsciiCodec extends Encoding { |
| 49 AsciiCodec(opts) { | 49 AsciiCodec(opts) { |
| 50 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | 50 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; |
| 51 this[_allowInvalid] = allowInvalid; | 51 this[_allowInvalid] = allowInvalid; |
| 52 super.Encoding(); | 52 super.Encoding(); |
| 53 } | 53 } |
| 54 get name() { | 54 get name() { |
| 55 return "us-ascii"; | 55 return "us-ascii"; |
| 56 } | 56 } |
| 57 decode(bytes, opts) { | 57 decode(bytes, opts) { |
| 58 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; | 58 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; |
| 59 if (allowInvalid === null) | 59 if (allowInvalid == null) |
| 60 allowInvalid = this[_allowInvalid]; | 60 allowInvalid = this[_allowInvalid]; |
| 61 if (allowInvalid) { | 61 if (allowInvalid) { |
| 62 return new AsciiDecoder({allowInvalid: true}).convert(bytes); | 62 return new AsciiDecoder({allowInvalid: true}).convert(bytes); |
| 63 } else { | 63 } else { |
| 64 return new AsciiDecoder({allowInvalid: false}).convert(bytes); | 64 return new AsciiDecoder({allowInvalid: false}).convert(bytes); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 get encoder() { | 67 get encoder() { |
| 68 return new AsciiEncoder(); | 68 return new AsciiEncoder(); |
| 69 } | 69 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 this[_subsetMask] = subsetMask; | 94 this[_subsetMask] = subsetMask; |
| 95 super.Converter(); | 95 super.Converter(); |
| 96 } | 96 } |
| 97 convert(string, start, end) { | 97 convert(string, start, end) { |
| 98 if (start === void 0) | 98 if (start === void 0) |
| 99 start = 0; | 99 start = 0; |
| 100 if (end === void 0) | 100 if (end === void 0) |
| 101 end = null; | 101 end = null; |
| 102 let stringLength = string.length; | 102 let stringLength = string.length; |
| 103 core.RangeError.checkValidRange(start, end, stringLength); | 103 core.RangeError.checkValidRange(start, end, stringLength); |
| 104 if (end === null) | 104 if (end == null) |
| 105 end = stringLength; | 105 end = stringLength; |
| 106 let length = dart.notNull(end) - dart.notNull(start); | 106 let length = dart.notNull(end) - dart.notNull(start); |
| 107 let result = new typed_data.Uint8List(length); | 107 let result = new typed_data.Uint8List(length); |
| 108 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i
) + 1) { | 108 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i
) + 1) { |
| 109 let codeUnit = string.codeUnitAt(dart.notNull(start) + dart.notNull(i)); | 109 let codeUnit = string.codeUnitAt(dart.notNull(start) + dart.notNull(i)); |
| 110 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) !== 0) { | 110 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) { |
| 111 throw new core.ArgumentError("String contains invalid characters."); | 111 throw new core.ArgumentError("String contains invalid characters."); |
| 112 } | 112 } |
| 113 result.set(i, codeUnit); | 113 result.set(i, codeUnit); |
| 114 } | 114 } |
| 115 return dart.as(result, core.List$(core.int)); | 115 return dart.as(result, core.List$(core.int)); |
| 116 } | 116 } |
| 117 startChunkedConversion(sink) { | 117 startChunkedConversion(sink) { |
| 118 if (!dart.is(sink, ByteConversionSink)) { | 118 if (!dart.is(sink, ByteConversionSink)) { |
| 119 sink = new ByteConversionSink.from(sink); | 119 sink = new ByteConversionSink.from(sink); |
| 120 } | 120 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 149 this[_sink] = sink$; | 149 this[_sink] = sink$; |
| 150 super.StringConversionSinkBase(); | 150 super.StringConversionSinkBase(); |
| 151 } | 151 } |
| 152 close() { | 152 close() { |
| 153 this[_sink].close(); | 153 this[_sink].close(); |
| 154 } | 154 } |
| 155 addSlice(source, start, end, isLast) { | 155 addSlice(source, start, end, isLast) { |
| 156 core.RangeError.checkValidRange(start, end, source.length); | 156 core.RangeError.checkValidRange(start, end, source.length); |
| 157 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 157 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 158 let codeUnit = source.codeUnitAt(i); | 158 let codeUnit = source.codeUnitAt(i); |
| 159 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) !== 0) { | 159 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) { |
| 160 throw new core.ArgumentError(`Source contains invalid character with c
ode point: ${codeUnit}.`); | 160 throw new core.ArgumentError(`Source contains invalid character with c
ode point: ${codeUnit}.`); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 this[_sink].add(source.codeUnits.sublist(start, end)); | 163 this[_sink].add(source.codeUnits.sublist(start, end)); |
| 164 if (isLast) { | 164 if (isLast) { |
| 165 this.close(); | 165 this.close(); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 let _convertInvalid = Symbol('_convertInvalid'); | 169 let _convertInvalid = Symbol('_convertInvalid'); |
| 170 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri
ng) { | 170 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri
ng) { |
| 171 _UnicodeSubsetDecoder(allowInvalid$, subsetMask) { | 171 _UnicodeSubsetDecoder(allowInvalid$, subsetMask) { |
| 172 this[_allowInvalid] = allowInvalid$; | 172 this[_allowInvalid] = allowInvalid$; |
| 173 this[_subsetMask] = subsetMask; | 173 this[_subsetMask] = subsetMask; |
| 174 super.Converter(); | 174 super.Converter(); |
| 175 } | 175 } |
| 176 convert(bytes, start, end) { | 176 convert(bytes, start, end) { |
| 177 if (start === void 0) | 177 if (start === void 0) |
| 178 start = 0; | 178 start = 0; |
| 179 if (end === void 0) | 179 if (end === void 0) |
| 180 end = null; | 180 end = null; |
| 181 let byteCount = bytes.length; | 181 let byteCount = bytes.length; |
| 182 core.RangeError.checkValidRange(start, end, byteCount); | 182 core.RangeError.checkValidRange(start, end, byteCount); |
| 183 if (end === null) | 183 if (end == null) |
| 184 end = byteCount; | 184 end = byteCount; |
| 185 let length = dart.notNull(end) - dart.notNull(start); | 185 let length = dart.notNull(end) - dart.notNull(start); |
| 186 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 186 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 187 let byte = bytes.get(i); | 187 let byte = bytes.get(i); |
| 188 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) !== 0) { | 188 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) != 0) { |
| 189 if (!dart.notNull(this[_allowInvalid])) { | 189 if (!dart.notNull(this[_allowInvalid])) { |
| 190 throw new core.FormatException(`Invalid value in input: ${byte}`); | 190 throw new core.FormatException(`Invalid value in input: ${byte}`); |
| 191 } | 191 } |
| 192 return this[_convertInvalid](bytes, start, end); | 192 return this[_convertInvalid](bytes, start, end); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 return new core.String.fromCharCodes(bytes, start, end); | 195 return new core.String.fromCharCodes(bytes, start, end); |
| 196 } | 196 } |
| 197 [_convertInvalid](bytes, start, end) { | 197 [_convertInvalid](bytes, start, end) { |
| 198 let buffer = new core.StringBuffer(); | 198 let buffer = new core.StringBuffer(); |
| 199 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 199 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 200 let value = bytes.get(i); | 200 let value = bytes.get(i); |
| 201 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) !== 0) | 201 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) != 0) |
| 202 value = 65533; | 202 value = 65533; |
| 203 buffer.writeCharCode(value); | 203 buffer.writeCharCode(value); |
| 204 } | 204 } |
| 205 return buffer.toString(); | 205 return buffer.toString(); |
| 206 } | 206 } |
| 207 bind(stream) { | 207 bind(stream) { |
| 208 return dart.as(super.bind(stream), async.Stream$(core.String)); | 208 return dart.as(super.bind(stream), async.Stream$(core.String)); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 class AsciiDecoder extends _UnicodeSubsetDecoder { | 211 class AsciiDecoder extends _UnicodeSubsetDecoder { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 close() { | 268 close() { |
| 269 this[_utf8Sink].close(); | 269 this[_utf8Sink].close(); |
| 270 } | 270 } |
| 271 add(source) { | 271 add(source) { |
| 272 this.addSlice(source, 0, source.length, false); | 272 this.addSlice(source, 0, source.length, false); |
| 273 } | 273 } |
| 274 addSlice(source, start, end, isLast) { | 274 addSlice(source, start, end, isLast) { |
| 275 core.RangeError.checkValidRange(start, end, source.length); | 275 core.RangeError.checkValidRange(start, end, source.length); |
| 276 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 276 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 277 if ((dart.notNull(source.get(i)) & ~dart.notNull(_ASCII_MASK)) !== 0) { | 277 if ((dart.notNull(source.get(i)) & ~dart.notNull(_ASCII_MASK)) != 0) { |
| 278 if (dart.notNull(i) > dart.notNull(start)) | 278 if (dart.notNull(i) > dart.notNull(start)) |
| 279 this[_utf8Sink].addSlice(source, start, i, false); | 279 this[_utf8Sink].addSlice(source, start, i, false); |
| 280 this[_utf8Sink].add(/* Unimplemented const */new core.List$(core.int).
from([239, 191, 189])); | 280 this[_utf8Sink].add(/* Unimplemented const */new core.List$(core.int).
from([239, 191, 189])); |
| 281 start = dart.notNull(i) + 1; | 281 start = dart.notNull(i) + 1; |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 if (dart.notNull(start) < dart.notNull(end)) { | 284 if (dart.notNull(start) < dart.notNull(end)) { |
| 285 this[_utf8Sink].addSlice(source, start, end, isLast); | 285 this[_utf8Sink].addSlice(source, start, end, isLast); |
| 286 } else if (isLast) { | 286 } else if (isLast) { |
| 287 this.close(); | 287 this.close(); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase { | 291 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase { |
| 292 _SimpleAsciiDecoderSink(sink$) { | 292 _SimpleAsciiDecoderSink(sink$) { |
| 293 this[_sink] = sink$; | 293 this[_sink] = sink$; |
| 294 super.ByteConversionSinkBase(); | 294 super.ByteConversionSinkBase(); |
| 295 } | 295 } |
| 296 close() { | 296 close() { |
| 297 this[_sink].close(); | 297 this[_sink].close(); |
| 298 } | 298 } |
| 299 add(source) { | 299 add(source) { |
| 300 for (let i = 0; dart.notNull(i) < dart.notNull(source.length); i = dart.no
tNull(i) + 1) { | 300 for (let i = 0; dart.notNull(i) < dart.notNull(source.length); i = dart.no
tNull(i) + 1) { |
| 301 if ((dart.notNull(source.get(i)) & ~dart.notNull(_ASCII_MASK)) !== 0) { | 301 if ((dart.notNull(source.get(i)) & ~dart.notNull(_ASCII_MASK)) != 0) { |
| 302 throw new core.FormatException("Source contains non-ASCII bytes."); | 302 throw new core.FormatException("Source contains non-ASCII bytes."); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 this[_sink].add(new core.String.fromCharCodes(source)); | 305 this[_sink].add(new core.String.fromCharCodes(source)); |
| 306 } | 306 } |
| 307 addSlice(source, start, end, isLast) { | 307 addSlice(source, start, end, isLast) { |
| 308 let length = source.length; | 308 let length = source.length; |
| 309 core.RangeError.checkValidRange(start, end, length); | 309 core.RangeError.checkValidRange(start, end, length); |
| 310 if (dart.notNull(start) < dart.notNull(end)) { | 310 if (dart.notNull(start) < dart.notNull(end)) { |
| 311 if (start !== 0 || end !== length) { | 311 if (start != 0 || end != length) { |
| 312 source = source.sublist(start, end); | 312 source = source.sublist(start, end); |
| 313 } | 313 } |
| 314 this.add(source); | 314 this.add(source); |
| 315 } | 315 } |
| 316 if (isLast) | 316 if (isLast) |
| 317 this.close(); | 317 this.close(); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 class _ByteAdapterSink extends ByteConversionSinkBase { | 320 class _ByteAdapterSink extends ByteConversionSinkBase { |
| 321 _ByteAdapterSink(sink$) { | 321 _ByteAdapterSink(sink$) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 let _convert = Symbol('_convert'); | 503 let _convert = Symbol('_convert'); |
| 504 class HtmlEscape extends Converter$(core.String, core.String) { | 504 class HtmlEscape extends Converter$(core.String, core.String) { |
| 505 HtmlEscape(mode) { | 505 HtmlEscape(mode) { |
| 506 if (mode === void 0) | 506 if (mode === void 0) |
| 507 mode = HtmlEscapeMode.UNKNOWN; | 507 mode = HtmlEscapeMode.UNKNOWN; |
| 508 this.mode = mode; | 508 this.mode = mode; |
| 509 super.Converter(); | 509 super.Converter(); |
| 510 } | 510 } |
| 511 convert(text) { | 511 convert(text) { |
| 512 let val = this[_convert](text, 0, text.length); | 512 let val = this[_convert](text, 0, text.length); |
| 513 return val === null ? text : val; | 513 return val == null ? text : val; |
| 514 } | 514 } |
| 515 [_convert](text, start, end) { | 515 [_convert](text, start, end) { |
| 516 let result = null; | 516 let result = null; |
| 517 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 517 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 518 let ch = text.get(i); | 518 let ch = text.get(i); |
| 519 let replace = null; | 519 let replace = null; |
| 520 switch (ch) { | 520 switch (ch) { |
| 521 case '&': | 521 case '&': |
| 522 { | 522 { |
| 523 replace = '&'; | 523 replace = '&'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 552 replace = '>'; | 552 replace = '>'; |
| 553 break; | 553 break; |
| 554 } | 554 } |
| 555 case '/': | 555 case '/': |
| 556 { | 556 { |
| 557 if (this.mode.escapeSlash) | 557 if (this.mode.escapeSlash) |
| 558 replace = '/'; | 558 replace = '/'; |
| 559 break; | 559 break; |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 if (replace !== null) { | 562 if (replace != null) { |
| 563 if (result === null) | 563 if (result == null) |
| 564 result = new core.StringBuffer(text.substring(start, i)); | 564 result = new core.StringBuffer(text.substring(start, i)); |
| 565 result.write(replace); | 565 result.write(replace); |
| 566 } else if (result !== null) { | 566 } else if (result != null) { |
| 567 result.write(ch); | 567 result.write(ch); |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 return result !== null ? result.toString() : null; | 570 return result != null ? result.toString() : null; |
| 571 } | 571 } |
| 572 startChunkedConversion(sink) { | 572 startChunkedConversion(sink) { |
| 573 if (!dart.is(sink, StringConversionSink)) { | 573 if (!dart.is(sink, StringConversionSink)) { |
| 574 sink = new StringConversionSink.from(sink); | 574 sink = new StringConversionSink.from(sink); |
| 575 } | 575 } |
| 576 return new _HtmlEscapeSink(this, dart.as(sink, StringConversionSink)); | 576 return new _HtmlEscapeSink(this, dart.as(sink, StringConversionSink)); |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 let _escape = Symbol('_escape'); | 579 let _escape = Symbol('_escape'); |
| 580 class _HtmlEscapeSink extends StringConversionSinkBase { | 580 class _HtmlEscapeSink extends StringConversionSinkBase { |
| 581 _HtmlEscapeSink(escape, sink$) { | 581 _HtmlEscapeSink(escape, sink$) { |
| 582 this[_escape] = escape; | 582 this[_escape] = escape; |
| 583 this[_sink] = sink$; | 583 this[_sink] = sink$; |
| 584 super.StringConversionSinkBase(); | 584 super.StringConversionSinkBase(); |
| 585 } | 585 } |
| 586 addSlice(chunk, start, end, isLast) { | 586 addSlice(chunk, start, end, isLast) { |
| 587 let val = this[_escape]._convert(chunk, start, end); | 587 let val = this[_escape]._convert(chunk, start, end); |
| 588 if (val === null) { | 588 if (val == null) { |
| 589 this[_sink].addSlice(chunk, start, end, isLast); | 589 this[_sink].addSlice(chunk, start, end, isLast); |
| 590 } else { | 590 } else { |
| 591 this[_sink].add(val); | 591 this[_sink].add(val); |
| 592 if (isLast) | 592 if (isLast) |
| 593 this[_sink].close(); | 593 this[_sink].close(); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 close() { | 596 close() { |
| 597 return this[_sink].close(); | 597 return this[_sink].close(); |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 class JsonUnsupportedObjectError extends core.Error { | 600 class JsonUnsupportedObjectError extends core.Error { |
| 601 JsonUnsupportedObjectError(unsupportedObject, opts) { | 601 JsonUnsupportedObjectError(unsupportedObject, opts) { |
| 602 let cause = opts && 'cause' in opts ? opts.cause : null; | 602 let cause = opts && 'cause' in opts ? opts.cause : null; |
| 603 this.unsupportedObject = unsupportedObject; | 603 this.unsupportedObject = unsupportedObject; |
| 604 this.cause = cause; | 604 this.cause = cause; |
| 605 super.Error(); | 605 super.Error(); |
| 606 } | 606 } |
| 607 toString() { | 607 toString() { |
| 608 if (this.cause !== null) { | 608 if (this.cause != null) { |
| 609 return "Converting object to an encodable object failed."; | 609 return "Converting object to an encodable object failed."; |
| 610 } else { | 610 } else { |
| 611 return "Converting object did not return an encodable object."; | 611 return "Converting object did not return an encodable object."; |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 class JsonCyclicError extends JsonUnsupportedObjectError { | 615 class JsonCyclicError extends JsonUnsupportedObjectError { |
| 616 JsonCyclicError(object) { | 616 JsonCyclicError(object) { |
| 617 super.JsonUnsupportedObjectError(object); | 617 super.JsonUnsupportedObjectError(object); |
| 618 } | 618 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 629 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; | 629 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; |
| 630 this[_reviver] = reviver; | 630 this[_reviver] = reviver; |
| 631 this[_toEncodable$] = toEncodable; | 631 this[_toEncodable$] = toEncodable; |
| 632 super.Codec(); | 632 super.Codec(); |
| 633 } | 633 } |
| 634 withReviver(reviver) { | 634 withReviver(reviver) { |
| 635 this.JsonCodec({reviver: reviver}); | 635 this.JsonCodec({reviver: reviver}); |
| 636 } | 636 } |
| 637 decode(source, opts) { | 637 decode(source, opts) { |
| 638 let reviver = opts && 'reviver' in opts ? opts.reviver : null; | 638 let reviver = opts && 'reviver' in opts ? opts.reviver : null; |
| 639 if (reviver === null) | 639 if (reviver == null) |
| 640 reviver = this[_reviver]; | 640 reviver = this[_reviver]; |
| 641 if (reviver === null) | 641 if (reviver == null) |
| 642 return this.decoder.convert(source); | 642 return this.decoder.convert(source); |
| 643 return new JsonDecoder(reviver).convert(source); | 643 return new JsonDecoder(reviver).convert(source); |
| 644 } | 644 } |
| 645 encode(value, opts) { | 645 encode(value, opts) { |
| 646 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; | 646 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; |
| 647 if (toEncodable === null) | 647 if (toEncodable == null) |
| 648 toEncodable = this[_toEncodable$]; | 648 toEncodable = this[_toEncodable$]; |
| 649 if (toEncodable === null) | 649 if (toEncodable == null) |
| 650 return this.encoder.convert(value); | 650 return this.encoder.convert(value); |
| 651 return new JsonEncoder(dart.closureWrap(toEncodable, "(Object) → Object"))
.convert(value); | 651 return new JsonEncoder(dart.closureWrap(toEncodable, "(Object) → Object"))
.convert(value); |
| 652 } | 652 } |
| 653 get encoder() { | 653 get encoder() { |
| 654 if (this[_toEncodable$] === null) | 654 if (this[_toEncodable$] == null) |
| 655 return new JsonEncoder(); | 655 return new JsonEncoder(); |
| 656 return new JsonEncoder(dart.closureWrap(this[_toEncodable$], "(Object) → O
bject")); | 656 return new JsonEncoder(dart.closureWrap(this[_toEncodable$], "(Object) → O
bject")); |
| 657 } | 657 } |
| 658 get decoder() { | 658 get decoder() { |
| 659 if (this[_reviver] === null) | 659 if (this[_reviver] == null) |
| 660 return new JsonDecoder(); | 660 return new JsonDecoder(); |
| 661 return new JsonDecoder(this[_reviver]); | 661 return new JsonDecoder(this[_reviver]); |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 dart.defineNamedConstructor(JsonCodec, 'withReviver'); | 664 dart.defineNamedConstructor(JsonCodec, 'withReviver'); |
| 665 class JsonEncoder extends Converter$(core.Object, core.String) { | 665 class JsonEncoder extends Converter$(core.Object, core.String) { |
| 666 JsonEncoder(toEncodable) { | 666 JsonEncoder(toEncodable) { |
| 667 if (toEncodable === void 0) | 667 if (toEncodable === void 0) |
| 668 toEncodable = null; | 668 toEncodable = null; |
| 669 this.indent = null; | 669 this.indent = null; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 if (toEncodable === void 0) | 709 if (toEncodable === void 0) |
| 710 toEncodable = null; | 710 toEncodable = null; |
| 711 if (bufferSize === void 0) | 711 if (bufferSize === void 0) |
| 712 bufferSize = JsonUtf8Encoder.DEFAULT_BUFFER_SIZE; | 712 bufferSize = JsonUtf8Encoder.DEFAULT_BUFFER_SIZE; |
| 713 this[_indent] = JsonUtf8Encoder[_utf8Encode](indent); | 713 this[_indent] = JsonUtf8Encoder[_utf8Encode](indent); |
| 714 this[_toEncodable$] = toEncodable; | 714 this[_toEncodable$] = toEncodable; |
| 715 this[_bufferSize] = bufferSize; | 715 this[_bufferSize] = bufferSize; |
| 716 super.Converter(); | 716 super.Converter(); |
| 717 } | 717 } |
| 718 static [_utf8Encode](string) { | 718 static [_utf8Encode](string) { |
| 719 if (string === null) | 719 if (string == null) |
| 720 return null; | 720 return null; |
| 721 if (string.isEmpty) | 721 if (string.isEmpty) |
| 722 return new typed_data.Uint8List(0); | 722 return new typed_data.Uint8List(0); |
| 723 checkAscii: { | 723 checkAscii: { |
| 724 for (let i = 0; dart.notNull(i) < dart.notNull(string.length); i = dart.
notNull(i) + 1) { | 724 for (let i = 0; dart.notNull(i) < dart.notNull(string.length); i = dart.
notNull(i) + 1) { |
| 725 if (dart.notNull(string.codeUnitAt(i)) >= 128) | 725 if (dart.notNull(string.codeUnitAt(i)) >= 128) |
| 726 break checkAscii; | 726 break checkAscii; |
| 727 } | 727 } |
| 728 return string.codeUnits; | 728 return string.codeUnits; |
| 729 } | 729 } |
| 730 return UTF8.encode(string); | 730 return UTF8.encode(string); |
| 731 } | 731 } |
| 732 convert(object) { | 732 convert(object) { |
| 733 let bytes = dart.as(new core.List.from([]), core.List$(core.List$(core.int
))); | 733 let bytes = dart.as(new core.List.from([]), core.List$(core.List$(core.int
))); |
| 734 // Function addChunk: (Uint8List, int, int) → void | 734 // Function addChunk: (Uint8List, int, int) → void |
| 735 function addChunk(chunk, start, end) { | 735 function addChunk(chunk, start, end) { |
| 736 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk.le
ngth)) { | 736 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk.le
ngth)) { |
| 737 let length = dart.notNull(end) - dart.notNull(start); | 737 let length = dart.notNull(end) - dart.notNull(start); |
| 738 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk
.offsetInBytes) + dart.notNull(start), length); | 738 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk
.offsetInBytes) + dart.notNull(start), length); |
| 739 } | 739 } |
| 740 bytes.add(chunk); | 740 bytes.add(chunk); |
| 741 } | 741 } |
| 742 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco
dable$], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize
], addChunk); | 742 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco
dable$], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize
], addChunk); |
| 743 if (bytes.length === 1) | 743 if (bytes.length == 1) |
| 744 return bytes.get(0); | 744 return bytes.get(0); |
| 745 let length = 0; | 745 let length = 0; |
| 746 for (let i = 0; dart.notNull(i) < dart.notNull(bytes.length); i = dart.not
Null(i) + 1) { | 746 for (let i = 0; dart.notNull(i) < dart.notNull(bytes.length); i = dart.not
Null(i) + 1) { |
| 747 length = bytes.get(i).length; | 747 length = bytes.get(i).length; |
| 748 } | 748 } |
| 749 let result = new typed_data.Uint8List(length); | 749 let result = new typed_data.Uint8List(length); |
| 750 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes.length);
i = dart.notNull(i) + 1) { | 750 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes.length);
i = dart.notNull(i) + 1) { |
| 751 let byteList = bytes.get(i); | 751 let byteList = bytes.get(i); |
| 752 let end = dart.notNull(offset) + dart.notNull(byteList.length); | 752 let end = dart.notNull(offset) + dart.notNull(byteList.length); |
| 753 result.setRange(offset, end, byteList); | 753 result.setRange(offset, end, byteList); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 function _parseJson(source, reviver) { | 841 function _parseJson(source, reviver) { |
| 842 if (!(typeof source == 'string')) | 842 if (!(typeof source == 'string')) |
| 843 throw new core.ArgumentError(source); | 843 throw new core.ArgumentError(source); |
| 844 let parsed = null; | 844 let parsed = null; |
| 845 try { | 845 try { |
| 846 parsed = JSON.parse(source); | 846 parsed = JSON.parse(source); |
| 847 } catch (e) { | 847 } catch (e) { |
| 848 throw new core.FormatException(String(e)); | 848 throw new core.FormatException(String(e)); |
| 849 } | 849 } |
| 850 | 850 |
| 851 if (reviver === null) { | 851 if (reviver == null) { |
| 852 return _convertJsonToDartLazy(parsed); | 852 return _convertJsonToDartLazy(parsed); |
| 853 } else { | 853 } else { |
| 854 return _convertJsonToDart(parsed, reviver); | 854 return _convertJsonToDart(parsed, reviver); |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 // Function _defaultToEncodable: (dynamic) → Object | 857 // Function _defaultToEncodable: (dynamic) → Object |
| 858 function _defaultToEncodable(object) { | 858 function _defaultToEncodable(object) { |
| 859 return dart.dinvoke(object, 'toJson'); | 859 return dart.dinvoke(object, 'toJson'); |
| 860 } | 860 } |
| 861 let _seen = Symbol('_seen'); | 861 let _seen = Symbol('_seen'); |
| 862 let _checkCycle = Symbol('_checkCycle'); | 862 let _checkCycle = Symbol('_checkCycle'); |
| 863 let _removeSeen = Symbol('_removeSeen'); | 863 let _removeSeen = Symbol('_removeSeen'); |
| 864 class _JsonStringifier extends core.Object { | 864 class _JsonStringifier extends core.Object { |
| 865 _JsonStringifier(_toEncodable) { | 865 _JsonStringifier(_toEncodable) { |
| 866 this[_seen] = new core.List(); | 866 this[_seen] = new core.List(); |
| 867 this[_toEncodable$] = dart.as(_toEncodable !== null ? _toEncodable : _defa
ultToEncodable, core.Function); | 867 this[_toEncodable$] = dart.as(_toEncodable != null ? _toEncodable : _defau
ltToEncodable, core.Function); |
| 868 } | 868 } |
| 869 static hexDigit(x) { | 869 static hexDigit(x) { |
| 870 return dart.notNull(x) < 10 ? 48 + dart.notNull(x) : 87 + dart.notNull(x); | 870 return dart.notNull(x) < 10 ? 48 + dart.notNull(x) : 87 + dart.notNull(x); |
| 871 } | 871 } |
| 872 writeStringContent(s) { | 872 writeStringContent(s) { |
| 873 let offset = 0; | 873 let offset = 0; |
| 874 let length = s.length; | 874 let length = s.length; |
| 875 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i
) + 1) { | 875 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i
) + 1) { |
| 876 let charCode = s.codeUnitAt(i); | 876 let charCode = s.codeUnitAt(i); |
| 877 if (dart.notNull(charCode) > dart.notNull(_JsonStringifier.BACKSLASH)) | 877 if (dart.notNull(charCode) > dart.notNull(_JsonStringifier.BACKSLASH)) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 default: | 910 default: |
| 911 { | 911 { |
| 912 this.writeCharCode(_JsonStringifier.CHAR_u); | 912 this.writeCharCode(_JsonStringifier.CHAR_u); |
| 913 this.writeCharCode(_JsonStringifier.CHAR_0); | 913 this.writeCharCode(_JsonStringifier.CHAR_0); |
| 914 this.writeCharCode(_JsonStringifier.CHAR_0); | 914 this.writeCharCode(_JsonStringifier.CHAR_0); |
| 915 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode
) >> 4 & 15)); | 915 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode
) >> 4 & 15)); |
| 916 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode
) & 15)); | 916 this.writeCharCode(_JsonStringifier.hexDigit(dart.notNull(charCode
) & 15)); |
| 917 break; | 917 break; |
| 918 } | 918 } |
| 919 } | 919 } |
| 920 } else if (charCode === _JsonStringifier.QUOTE || charCode === _JsonStri
ngifier.BACKSLASH) { | 920 } else if (charCode == _JsonStringifier.QUOTE || charCode == _JsonString
ifier.BACKSLASH) { |
| 921 if (dart.notNull(i) > dart.notNull(offset)) | 921 if (dart.notNull(i) > dart.notNull(offset)) |
| 922 this.writeStringSlice(s, offset, i); | 922 this.writeStringSlice(s, offset, i); |
| 923 offset = dart.notNull(i) + 1; | 923 offset = dart.notNull(i) + 1; |
| 924 this.writeCharCode(_JsonStringifier.BACKSLASH); | 924 this.writeCharCode(_JsonStringifier.BACKSLASH); |
| 925 this.writeCharCode(charCode); | 925 this.writeCharCode(charCode); |
| 926 } | 926 } |
| 927 } | 927 } |
| 928 if (offset === 0) { | 928 if (offset == 0) { |
| 929 this.writeString(s); | 929 this.writeString(s); |
| 930 } else if (dart.notNull(offset) < dart.notNull(length)) { | 930 } else if (dart.notNull(offset) < dart.notNull(length)) { |
| 931 this.writeStringSlice(s, offset, length); | 931 this.writeStringSlice(s, offset, length); |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 [_checkCycle](object) { | 934 [_checkCycle](object) { |
| 935 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen].length); i = da
rt.notNull(i) + 1) { | 935 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen].length); i = da
rt.notNull(i) + 1) { |
| 936 if (core.identical(object, this[_seen].get(i))) { | 936 if (core.identical(object, this[_seen].get(i))) { |
| 937 throw new JsonCyclicError(object); | 937 throw new JsonCyclicError(object); |
| 938 } | 938 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 964 if (dart.dunary('!', dart.dload(object, 'isFinite'))) | 964 if (dart.dunary('!', dart.dload(object, 'isFinite'))) |
| 965 return false; | 965 return false; |
| 966 this.writeNumber(dart.as(object, core.num)); | 966 this.writeNumber(dart.as(object, core.num)); |
| 967 return true; | 967 return true; |
| 968 } else if (core.identical(object, true)) { | 968 } else if (core.identical(object, true)) { |
| 969 this.writeString('true'); | 969 this.writeString('true'); |
| 970 return true; | 970 return true; |
| 971 } else if (core.identical(object, false)) { | 971 } else if (core.identical(object, false)) { |
| 972 this.writeString('false'); | 972 this.writeString('false'); |
| 973 return true; | 973 return true; |
| 974 } else if (object === null) { | 974 } else if (object == null) { |
| 975 this.writeString('null'); | 975 this.writeString('null'); |
| 976 return true; | 976 return true; |
| 977 } else if (typeof object == 'string') { | 977 } else if (typeof object == 'string') { |
| 978 this.writeString('"'); | 978 this.writeString('"'); |
| 979 this.writeStringContent(dart.as(object, core.String)); | 979 this.writeStringContent(dart.as(object, core.String)); |
| 980 this.writeString('"'); | 980 this.writeString('"'); |
| 981 return true; | 981 return true; |
| 982 } else if (dart.is(object, core.List)) { | 982 } else if (dart.is(object, core.List)) { |
| 983 this[_checkCycle](object); | 983 this[_checkCycle](object); |
| 984 this.writeList(dart.as(object, core.List)); | 984 this.writeList(dart.as(object, core.List)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 this[_sink] = sink$; | 1085 this[_sink] = sink$; |
| 1086 super._JsonStringifier(dart.as(_toEncodable, dart.throw_("Unimplemented ty
pe (Object) → Object"))); | 1086 super._JsonStringifier(dart.as(_toEncodable, dart.throw_("Unimplemented ty
pe (Object) → Object"))); |
| 1087 } | 1087 } |
| 1088 static stringify(object, toEncodable, indent) { | 1088 static stringify(object, toEncodable, indent) { |
| 1089 let output = new core.StringBuffer(); | 1089 let output = new core.StringBuffer(); |
| 1090 _JsonStringStringifier.printOn(object, output, toEncodable, indent); | 1090 _JsonStringStringifier.printOn(object, output, toEncodable, indent); |
| 1091 return output.toString(); | 1091 return output.toString(); |
| 1092 } | 1092 } |
| 1093 static printOn(object, output, toEncodable, indent) { | 1093 static printOn(object, output, toEncodable, indent) { |
| 1094 let stringifier = null; | 1094 let stringifier = null; |
| 1095 if (indent === null) { | 1095 if (indent == null) { |
| 1096 stringifier = new _JsonStringStringifier(output, toEncodable); | 1096 stringifier = new _JsonStringStringifier(output, toEncodable); |
| 1097 } else { | 1097 } else { |
| 1098 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde
nt); | 1098 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde
nt); |
| 1099 } | 1099 } |
| 1100 dart.dinvoke(stringifier, 'writeObject', object); | 1100 dart.dinvoke(stringifier, 'writeObject', object); |
| 1101 } | 1101 } |
| 1102 writeNumber(number) { | 1102 writeNumber(number) { |
| 1103 this[_sink].write(number.toString()); | 1103 this[_sink].write(number.toString()); |
| 1104 } | 1104 } |
| 1105 writeString(string) { | 1105 writeString(string) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1125 class _JsonUtf8Stringifier extends _JsonStringifier { | 1125 class _JsonUtf8Stringifier extends _JsonStringifier { |
| 1126 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) { | 1126 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) { |
| 1127 this.addChunk = addChunk; | 1127 this.addChunk = addChunk; |
| 1128 this.bufferSize = bufferSize; | 1128 this.bufferSize = bufferSize; |
| 1129 this.buffer = new typed_data.Uint8List(bufferSize); | 1129 this.buffer = new typed_data.Uint8List(bufferSize); |
| 1130 this.index = 0; | 1130 this.index = 0; |
| 1131 super._JsonStringifier(dart.as(toEncodable, dart.throw_("Unimplemented typ
e (Object) → Object"))); | 1131 super._JsonStringifier(dart.as(toEncodable, dart.throw_("Unimplemented typ
e (Object) → Object"))); |
| 1132 } | 1132 } |
| 1133 static stringify(object, indent, toEncodableFunction, bufferSize, addChunk)
{ | 1133 static stringify(object, indent, toEncodableFunction, bufferSize, addChunk)
{ |
| 1134 let stringifier = null; | 1134 let stringifier = null; |
| 1135 if (indent !== null) { | 1135 if (indent != null) { |
| 1136 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent
, bufferSize, addChunk); | 1136 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent
, bufferSize, addChunk); |
| 1137 } else { | 1137 } else { |
| 1138 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize,
addChunk); | 1138 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize,
addChunk); |
| 1139 } | 1139 } |
| 1140 stringifier.writeObject(object); | 1140 stringifier.writeObject(object); |
| 1141 stringifier.flush(); | 1141 stringifier.flush(); |
| 1142 } | 1142 } |
| 1143 flush() { | 1143 flush() { |
| 1144 if (dart.notNull(this.index) > 0) { | 1144 if (dart.notNull(this.index) > 0) { |
| 1145 dart.dinvokef(this.addChunk, this.buffer, 0, this.index); | 1145 dart.dinvokef(this.addChunk, this.buffer, 0, this.index); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1159 } | 1159 } |
| 1160 writeString(string) { | 1160 writeString(string) { |
| 1161 this.writeStringSlice(string, 0, string.length); | 1161 this.writeStringSlice(string, 0, string.length); |
| 1162 } | 1162 } |
| 1163 writeStringSlice(string, start, end) { | 1163 writeStringSlice(string, start, end) { |
| 1164 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | 1164 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { |
| 1165 let char = string.codeUnitAt(i); | 1165 let char = string.codeUnitAt(i); |
| 1166 if (dart.notNull(char) <= 127) { | 1166 if (dart.notNull(char) <= 127) { |
| 1167 this.writeByte(char); | 1167 this.writeByte(char); |
| 1168 } else { | 1168 } else { |
| 1169 if ((dart.notNull(char) & 64512) === 55296 && dart.notNull(i) + 1 < da
rt.notNull(end)) { | 1169 if ((dart.notNull(char) & 64512) == 55296 && dart.notNull(i) + 1 < dar
t.notNull(end)) { |
| 1170 let nextChar = string.codeUnitAt(dart.notNull(i) + 1); | 1170 let nextChar = string.codeUnitAt(dart.notNull(i) + 1); |
| 1171 if ((dart.notNull(nextChar) & 64512) === 56320) { | 1171 if ((dart.notNull(nextChar) & 64512) == 56320) { |
| 1172 char = 65536 + ((dart.notNull(char) & 1023) << 10) + (dart.notNull
(nextChar) & 1023); | 1172 char = 65536 + ((dart.notNull(char) & 1023) << 10) + (dart.notNull
(nextChar) & 1023); |
| 1173 this.writeFourByteCharCode(char); | 1173 this.writeFourByteCharCode(char); |
| 1174 i = dart.notNull(i) + 1; | 1174 i = dart.notNull(i) + 1; |
| 1175 continue; | 1175 continue; |
| 1176 } | 1176 } |
| 1177 } | 1177 } |
| 1178 this.writeMultiByteCharCode(char); | 1178 this.writeMultiByteCharCode(char); |
| 1179 } | 1179 } |
| 1180 } | 1180 } |
| 1181 } | 1181 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1202 } | 1202 } |
| 1203 writeFourByteCharCode(charCode) { | 1203 writeFourByteCharCode(charCode) { |
| 1204 dart.assert(dart.notNull(charCode) <= 1114111); | 1204 dart.assert(dart.notNull(charCode) <= 1114111); |
| 1205 this.writeByte(240 | dart.notNull(charCode) >> 18); | 1205 this.writeByte(240 | dart.notNull(charCode) >> 18); |
| 1206 this.writeByte(128 | dart.notNull(charCode) >> 12 & 63); | 1206 this.writeByte(128 | dart.notNull(charCode) >> 12 & 63); |
| 1207 this.writeByte(128 | dart.notNull(charCode) >> 6 & 63); | 1207 this.writeByte(128 | dart.notNull(charCode) >> 6 & 63); |
| 1208 this.writeByte(128 | dart.notNull(charCode) & 63); | 1208 this.writeByte(128 | dart.notNull(charCode) & 63); |
| 1209 } | 1209 } |
| 1210 writeByte(byte) { | 1210 writeByte(byte) { |
| 1211 dart.assert(dart.notNull(byte) <= 255); | 1211 dart.assert(dart.notNull(byte) <= 255); |
| 1212 if (this.index === this.buffer.length) { | 1212 if (this.index == this.buffer.length) { |
| 1213 dart.dinvokef(this.addChunk, this.buffer, 0, this.index); | 1213 dart.dinvokef(this.addChunk, this.buffer, 0, this.index); |
| 1214 this.buffer = new typed_data.Uint8List(this.bufferSize); | 1214 this.buffer = new typed_data.Uint8List(this.bufferSize); |
| 1215 this.index = 0; | 1215 this.index = 0; |
| 1216 } | 1216 } |
| 1217 this.buffer.set(((x$) => this.index = dart.notNull(x$) + 1, x$).bind(this)
(this.index), byte); | 1217 this.buffer.set(((x$) => this.index = dart.notNull(x$) + 1, x$).bind(this)
(this.index), byte); |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| 1220 class _JsonUtf8StringifierPretty extends dart.mixin(_JsonUtf8Stringifier, _Jso
nPrettyPrintMixin) { | 1220 class _JsonUtf8StringifierPretty extends dart.mixin(_JsonUtf8Stringifier, _Jso
nPrettyPrintMixin) { |
| 1221 _JsonUtf8StringifierPretty(toEncodableFunction, indent, bufferSize, addChunk
) { | 1221 _JsonUtf8StringifierPretty(toEncodableFunction, indent, bufferSize, addChunk
) { |
| 1222 this.indent = indent; | 1222 this.indent = indent; |
| 1223 super._JsonUtf8Stringifier(toEncodableFunction, dart.as(bufferSize, core.i
nt), dart.as(addChunk, core.Function)); | 1223 super._JsonUtf8Stringifier(toEncodableFunction, dart.as(bufferSize, core.i
nt), dart.as(addChunk, core.Function)); |
| 1224 } | 1224 } |
| 1225 writeIndentation(count) { | 1225 writeIndentation(count) { |
| 1226 let indent = this.indent; | 1226 let indent = this.indent; |
| 1227 let indentLength = indent.length; | 1227 let indentLength = indent.length; |
| 1228 if (indentLength === 1) { | 1228 if (indentLength == 1) { |
| 1229 let char = indent.get(0); | 1229 let char = indent.get(0); |
| 1230 while (dart.notNull(count) > 0) { | 1230 while (dart.notNull(count) > 0) { |
| 1231 this.writeByte(char); | 1231 this.writeByte(char); |
| 1232 count = 1; | 1232 count = 1; |
| 1233 } | 1233 } |
| 1234 return; | 1234 return; |
| 1235 } | 1235 } |
| 1236 while (dart.notNull(count) > 0) { | 1236 while (dart.notNull(count) > 0) { |
| 1237 count = dart.notNull(count) - 1; | 1237 count = dart.notNull(count) - 1; |
| 1238 let end = dart.notNull(this.index) + dart.notNull(indentLength); | 1238 let end = dart.notNull(this.index) + dart.notNull(indentLength); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1253 Latin1Codec(opts) { | 1253 Latin1Codec(opts) { |
| 1254 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; | 1254 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa
lse; |
| 1255 this[_allowInvalid] = allowInvalid; | 1255 this[_allowInvalid] = allowInvalid; |
| 1256 super.Encoding(); | 1256 super.Encoding(); |
| 1257 } | 1257 } |
| 1258 get name() { | 1258 get name() { |
| 1259 return "iso-8859-1"; | 1259 return "iso-8859-1"; |
| 1260 } | 1260 } |
| 1261 decode(bytes, opts) { | 1261 decode(bytes, opts) { |
| 1262 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; | 1262 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : nu
ll; |
| 1263 if (allowInvalid === null) | 1263 if (allowInvalid == null) |
| 1264 allowInvalid = this[_allowInvalid]; | 1264 allowInvalid = this[_allowInvalid]; |
| 1265 if (allowInvalid) { | 1265 if (allowInvalid) { |
| 1266 return new Latin1Decoder({allowInvalid: true}).convert(bytes); | 1266 return new Latin1Decoder({allowInvalid: true}).convert(bytes); |
| 1267 } else { | 1267 } else { |
| 1268 return new Latin1Decoder({allowInvalid: false}).convert(bytes); | 1268 return new Latin1Decoder({allowInvalid: false}).convert(bytes); |
| 1269 } | 1269 } |
| 1270 } | 1270 } |
| 1271 get encoder() { | 1271 get encoder() { |
| 1272 return new Latin1Encoder(); | 1272 return new Latin1Encoder(); |
| 1273 } | 1273 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 let _addSlice = Symbol('_addSlice'); | 1373 let _addSlice = Symbol('_addSlice'); |
| 1374 let _LF = Symbol('_LF'); | 1374 let _LF = Symbol('_LF'); |
| 1375 let _CR = Symbol('_CR'); | 1375 let _CR = Symbol('_CR'); |
| 1376 class _LineSplitterSink extends StringConversionSinkBase { | 1376 class _LineSplitterSink extends StringConversionSinkBase { |
| 1377 _LineSplitterSink(sink$) { | 1377 _LineSplitterSink(sink$) { |
| 1378 this[_sink] = sink$; | 1378 this[_sink] = sink$; |
| 1379 this[_carry] = null; | 1379 this[_carry] = null; |
| 1380 super.StringConversionSinkBase(); | 1380 super.StringConversionSinkBase(); |
| 1381 } | 1381 } |
| 1382 addSlice(chunk, start, end, isLast) { | 1382 addSlice(chunk, start, end, isLast) { |
| 1383 if (this[_carry] !== null) { | 1383 if (this[_carry] != null) { |
| 1384 chunk = core.String['+'](this[_carry], chunk.substring(start, end)); | 1384 chunk = core.String['+'](this[_carry], chunk.substring(start, end)); |
| 1385 start = 0; | 1385 start = 0; |
| 1386 end = chunk.length; | 1386 end = chunk.length; |
| 1387 this[_carry] = null; | 1387 this[_carry] = null; |
| 1388 } | 1388 } |
| 1389 this[_carry] = _LineSplitterSink[_addSlice](chunk, start, end, isLast, thi
s[_sink].add); | 1389 this[_carry] = _LineSplitterSink[_addSlice](chunk, start, end, isLast, thi
s[_sink].add); |
| 1390 if (isLast) | 1390 if (isLast) |
| 1391 this[_sink].close(); | 1391 this[_sink].close(); |
| 1392 } | 1392 } |
| 1393 close() { | 1393 close() { |
| 1394 this.addSlice('', 0, 0, true); | 1394 this.addSlice('', 0, 0, true); |
| 1395 } | 1395 } |
| 1396 static [_addSlice](chunk, start, end, isLast, adder) { | 1396 static [_addSlice](chunk, start, end, isLast, adder) { |
| 1397 let pos = start; | 1397 let pos = start; |
| 1398 while (dart.notNull(pos) < dart.notNull(end)) { | 1398 while (dart.notNull(pos) < dart.notNull(end)) { |
| 1399 let skip = 0; | 1399 let skip = 0; |
| 1400 let char = chunk.codeUnitAt(pos); | 1400 let char = chunk.codeUnitAt(pos); |
| 1401 if (char === _LineSplitterSink[_LF]) { | 1401 if (char == _LineSplitterSink[_LF]) { |
| 1402 skip = 1; | 1402 skip = 1; |
| 1403 } else if (char === _LineSplitterSink[_CR]) { | 1403 } else if (char == _LineSplitterSink[_CR]) { |
| 1404 skip = 1; | 1404 skip = 1; |
| 1405 if (dart.notNull(pos) + 1 < dart.notNull(end)) { | 1405 if (dart.notNull(pos) + 1 < dart.notNull(end)) { |
| 1406 if (chunk.codeUnitAt(dart.notNull(pos) + 1) === _LineSplitterSink[_L
F]) { | 1406 if (chunk.codeUnitAt(dart.notNull(pos) + 1) == _LineSplitterSink[_LF
]) { |
| 1407 skip = 2; | 1407 skip = 2; |
| 1408 } | 1408 } |
| 1409 } else if (!dart.notNull(isLast)) { | 1409 } else if (!dart.notNull(isLast)) { |
| 1410 return chunk.substring(start, end); | 1410 return chunk.substring(start, end); |
| 1411 } | 1411 } |
| 1412 } | 1412 } |
| 1413 if (dart.notNull(skip) > 0) { | 1413 if (dart.notNull(skip) > 0) { |
| 1414 adder(chunk.substring(start, pos)); | 1414 adder(chunk.substring(start, pos)); |
| 1415 start = pos = dart.notNull(pos) + dart.notNull(skip); | 1415 start = pos = dart.notNull(pos) + dart.notNull(skip); |
| 1416 } else { | 1416 } else { |
| 1417 pos = dart.notNull(pos) + 1; | 1417 pos = dart.notNull(pos) + 1; |
| 1418 } | 1418 } |
| 1419 } | 1419 } |
| 1420 if (pos !== start) { | 1420 if (pos != start) { |
| 1421 let carry = chunk.substring(start, pos); | 1421 let carry = chunk.substring(start, pos); |
| 1422 if (isLast) { | 1422 if (isLast) { |
| 1423 adder(carry); | 1423 adder(carry); |
| 1424 } else { | 1424 } else { |
| 1425 return carry; | 1425 return carry; |
| 1426 } | 1426 } |
| 1427 } | 1427 } |
| 1428 return null; | 1428 return null; |
| 1429 } | 1429 } |
| 1430 } | 1430 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 } | 1536 } |
| 1537 _StringConversionSinkAsStringSinkAdapter._MIN_STRING_SIZE = 16; | 1537 _StringConversionSinkAsStringSinkAdapter._MIN_STRING_SIZE = 16; |
| 1538 let _stringSink = Symbol('_stringSink'); | 1538 let _stringSink = Symbol('_stringSink'); |
| 1539 class _StringSinkConversionSink extends StringConversionSinkBase { | 1539 class _StringSinkConversionSink extends StringConversionSinkBase { |
| 1540 _StringSinkConversionSink(stringSink$) { | 1540 _StringSinkConversionSink(stringSink$) { |
| 1541 this[_stringSink] = stringSink$; | 1541 this[_stringSink] = stringSink$; |
| 1542 super.StringConversionSinkBase(); | 1542 super.StringConversionSinkBase(); |
| 1543 } | 1543 } |
| 1544 close() {} | 1544 close() {} |
| 1545 addSlice(str, start, end, isLast) { | 1545 addSlice(str, start, end, isLast) { |
| 1546 if (start !== 0 || end !== str.length) { | 1546 if (start != 0 || end != str.length) { |
| 1547 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul
l(i) + 1) { | 1547 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul
l(i) + 1) { |
| 1548 this[_stringSink].writeCharCode(str.codeUnitAt(i)); | 1548 this[_stringSink].writeCharCode(str.codeUnitAt(i)); |
| 1549 } | 1549 } |
| 1550 } else { | 1550 } else { |
| 1551 this[_stringSink].write(str); | 1551 this[_stringSink].write(str); |
| 1552 } | 1552 } |
| 1553 if (isLast) | 1553 if (isLast) |
| 1554 this.close(); | 1554 this.close(); |
| 1555 } | 1555 } |
| 1556 add(str) { | 1556 add(str) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1580 } | 1580 } |
| 1581 class _StringAdapterSink extends StringConversionSinkBase { | 1581 class _StringAdapterSink extends StringConversionSinkBase { |
| 1582 _StringAdapterSink(sink$) { | 1582 _StringAdapterSink(sink$) { |
| 1583 this[_sink] = sink$; | 1583 this[_sink] = sink$; |
| 1584 super.StringConversionSinkBase(); | 1584 super.StringConversionSinkBase(); |
| 1585 } | 1585 } |
| 1586 add(str) { | 1586 add(str) { |
| 1587 return this[_sink].add(str); | 1587 return this[_sink].add(str); |
| 1588 } | 1588 } |
| 1589 addSlice(str, start, end, isLast) { | 1589 addSlice(str, start, end, isLast) { |
| 1590 if (start === 0 && end === str.length) { | 1590 if (start == 0 && end == str.length) { |
| 1591 this.add(str); | 1591 this.add(str); |
| 1592 } else { | 1592 } else { |
| 1593 this.add(str.substring(start, end)); | 1593 this.add(str.substring(start, end)); |
| 1594 } | 1594 } |
| 1595 if (isLast) | 1595 if (isLast) |
| 1596 this.close(); | 1596 this.close(); |
| 1597 } | 1597 } |
| 1598 close() { | 1598 close() { |
| 1599 return this[_sink].close(); | 1599 return this[_sink].close(); |
| 1600 } | 1600 } |
| 1601 } | 1601 } |
| 1602 let _decoder = Symbol('_decoder'); | 1602 let _decoder = Symbol('_decoder'); |
| 1603 class _Utf8StringSinkAdapter extends ByteConversionSink { | 1603 class _Utf8StringSinkAdapter extends ByteConversionSink { |
| 1604 _Utf8StringSinkAdapter(sink$, stringSink, allowMalformed) { | 1604 _Utf8StringSinkAdapter(sink$, stringSink, allowMalformed) { |
| 1605 this[_sink] = sink$; | 1605 this[_sink] = sink$; |
| 1606 this[_decoder] = new _Utf8Decoder(stringSink, allowMalformed); | 1606 this[_decoder] = new _Utf8Decoder(stringSink, allowMalformed); |
| 1607 super.ByteConversionSink(); | 1607 super.ByteConversionSink(); |
| 1608 } | 1608 } |
| 1609 close() { | 1609 close() { |
| 1610 this[_decoder].close(); | 1610 this[_decoder].close(); |
| 1611 if (this[_sink] !== null) | 1611 if (this[_sink] != null) |
| 1612 this[_sink].close(); | 1612 this[_sink].close(); |
| 1613 } | 1613 } |
| 1614 add(chunk) { | 1614 add(chunk) { |
| 1615 this.addSlice(chunk, 0, chunk.length, false); | 1615 this.addSlice(chunk, 0, chunk.length, false); |
| 1616 } | 1616 } |
| 1617 addSlice(codeUnits, startIndex, endIndex, isLast) { | 1617 addSlice(codeUnits, startIndex, endIndex, isLast) { |
| 1618 this[_decoder].convert(codeUnits, startIndex, endIndex); | 1618 this[_decoder].convert(codeUnits, startIndex, endIndex); |
| 1619 if (isLast) | 1619 if (isLast) |
| 1620 this.close(); | 1620 this.close(); |
| 1621 } | 1621 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 Utf8Codec(opts) { | 1664 Utf8Codec(opts) { |
| 1665 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; | 1665 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; |
| 1666 this[_allowMalformed] = allowMalformed; | 1666 this[_allowMalformed] = allowMalformed; |
| 1667 super.Encoding(); | 1667 super.Encoding(); |
| 1668 } | 1668 } |
| 1669 get name() { | 1669 get name() { |
| 1670 return "utf-8"; | 1670 return "utf-8"; |
| 1671 } | 1671 } |
| 1672 decode(codeUnits, opts) { | 1672 decode(codeUnits, opts) { |
| 1673 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : null; | 1673 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : null; |
| 1674 if (allowMalformed === null) | 1674 if (allowMalformed == null) |
| 1675 allowMalformed = this[_allowMalformed]; | 1675 allowMalformed = this[_allowMalformed]; |
| 1676 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits
); | 1676 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits
); |
| 1677 } | 1677 } |
| 1678 get encoder() { | 1678 get encoder() { |
| 1679 return new Utf8Encoder(); | 1679 return new Utf8Encoder(); |
| 1680 } | 1680 } |
| 1681 get decoder() { | 1681 get decoder() { |
| 1682 return new Utf8Decoder({allowMalformed: this[_allowMalformed]}); | 1682 return new Utf8Decoder({allowMalformed: this[_allowMalformed]}); |
| 1683 } | 1683 } |
| 1684 } | 1684 } |
| 1685 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) { | 1685 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) { |
| 1686 Utf8Encoder() { | 1686 Utf8Encoder() { |
| 1687 super.Converter(); | 1687 super.Converter(); |
| 1688 } | 1688 } |
| 1689 convert(string, start, end) { | 1689 convert(string, start, end) { |
| 1690 if (start === void 0) | 1690 if (start === void 0) |
| 1691 start = 0; | 1691 start = 0; |
| 1692 if (end === void 0) | 1692 if (end === void 0) |
| 1693 end = null; | 1693 end = null; |
| 1694 let stringLength = string.length; | 1694 let stringLength = string.length; |
| 1695 core.RangeError.checkValidRange(start, end, stringLength); | 1695 core.RangeError.checkValidRange(start, end, stringLength); |
| 1696 if (end === null) | 1696 if (end == null) |
| 1697 end = stringLength; | 1697 end = stringLength; |
| 1698 let length = dart.notNull(end) - dart.notNull(start); | 1698 let length = dart.notNull(end) - dart.notNull(start); |
| 1699 if (length === 0) | 1699 if (length == 0) |
| 1700 return new typed_data.Uint8List(0); | 1700 return new typed_data.Uint8List(0); |
| 1701 let encoder = new _Utf8Encoder.withBufferSize(dart.notNull(length) * 3); | 1701 let encoder = new _Utf8Encoder.withBufferSize(dart.notNull(length) * 3); |
| 1702 let endPosition = encoder._fillBuffer(string, start, end); | 1702 let endPosition = encoder._fillBuffer(string, start, end); |
| 1703 dart.assert(dart.notNull(endPosition) >= dart.notNull(end) - 1); | 1703 dart.assert(dart.notNull(endPosition) >= dart.notNull(end) - 1); |
| 1704 if (endPosition !== end) { | 1704 if (endPosition != end) { |
| 1705 let lastCodeUnit = string.codeUnitAt(dart.notNull(end) - 1); | 1705 let lastCodeUnit = string.codeUnitAt(dart.notNull(end) - 1); |
| 1706 dart.assert(_isLeadSurrogate(lastCodeUnit)); | 1706 dart.assert(_isLeadSurrogate(lastCodeUnit)); |
| 1707 let wasCombined = encoder._writeSurrogate(lastCodeUnit, 0); | 1707 let wasCombined = encoder._writeSurrogate(lastCodeUnit, 0); |
| 1708 dart.assert(!dart.notNull(wasCombined)); | 1708 dart.assert(!dart.notNull(wasCombined)); |
| 1709 } | 1709 } |
| 1710 return encoder[_buffer].sublist(0, encoder[_bufferIndex]); | 1710 return encoder[_buffer].sublist(0, encoder[_bufferIndex]); |
| 1711 } | 1711 } |
| 1712 startChunkedConversion(sink) { | 1712 startChunkedConversion(sink) { |
| 1713 if (!dart.is(sink, ByteConversionSink)) { | 1713 if (!dart.is(sink, ByteConversionSink)) { |
| 1714 sink = new ByteConversionSink.from(sink); | 1714 sink = new ByteConversionSink.from(sink); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(rune) & 63); | 1746 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(rune) & 63); |
| 1747 return true; | 1747 return true; |
| 1748 } else { | 1748 } else { |
| 1749 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 224 | dart.notNull(leadingSurrogate) >> 12); | 1749 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 224 | dart.notNull(leadingSurrogate) >> 12); |
| 1750 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(leadingSurrogate) >> 6 & 63
); | 1750 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(leadingSurrogate) >> 6 & 63
); |
| 1751 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(leadingSurrogate) & 63); | 1751 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1, x$
).bind(this)(this[_bufferIndex]), 128 | dart.notNull(leadingSurrogate) & 63); |
| 1752 return false; | 1752 return false; |
| 1753 } | 1753 } |
| 1754 } | 1754 } |
| 1755 [_fillBuffer](str, start, end) { | 1755 [_fillBuffer](str, start, end) { |
| 1756 if (start !== end && dart.notNull(_isLeadSurrogate(str.codeUnitAt(dart.not
Null(end) - 1)))) { | 1756 if (start != end && dart.notNull(_isLeadSurrogate(str.codeUnitAt(dart.notN
ull(end) - 1)))) { |
| 1757 end = dart.notNull(end) - 1; | 1757 end = dart.notNull(end) - 1; |
| 1758 } | 1758 } |
| 1759 let stringIndex = null; | 1759 let stringIndex = null; |
| 1760 for (stringIndex = start; dart.notNull(stringIndex) < dart.notNull(end); s
tringIndex = dart.notNull(stringIndex) + 1) { | 1760 for (stringIndex = start; dart.notNull(stringIndex) < dart.notNull(end); s
tringIndex = dart.notNull(stringIndex) + 1) { |
| 1761 let codeUnit = str.codeUnitAt(stringIndex); | 1761 let codeUnit = str.codeUnitAt(stringIndex); |
| 1762 if (dart.notNull(codeUnit) <= dart.notNull(_ONE_BYTE_LIMIT)) { | 1762 if (dart.notNull(codeUnit) <= dart.notNull(_ONE_BYTE_LIMIT)) { |
| 1763 if (dart.notNull(this[_bufferIndex]) >= dart.notNull(this[_buffer].len
gth)) | 1763 if (dart.notNull(this[_bufferIndex]) >= dart.notNull(this[_buffer].len
gth)) |
| 1764 break; | 1764 break; |
| 1765 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1,
x$).bind(this)(this[_bufferIndex]), codeUnit); | 1765 this[_buffer].set(((x$) => this[_bufferIndex] = dart.notNull(x$) + 1,
x$).bind(this)(this[_bufferIndex]), codeUnit); |
| 1766 } else if (_isLeadSurrogate(codeUnit)) { | 1766 } else if (_isLeadSurrogate(codeUnit)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1791 } | 1791 } |
| 1792 } | 1792 } |
| 1793 dart.defineNamedConstructor(_Utf8Encoder, 'withBufferSize'); | 1793 dart.defineNamedConstructor(_Utf8Encoder, 'withBufferSize'); |
| 1794 _Utf8Encoder._DEFAULT_BYTE_BUFFER_SIZE = 1024; | 1794 _Utf8Encoder._DEFAULT_BYTE_BUFFER_SIZE = 1024; |
| 1795 class _Utf8EncoderSink extends dart.mixin(_Utf8Encoder, StringConversionSinkMi
xin) { | 1795 class _Utf8EncoderSink extends dart.mixin(_Utf8Encoder, StringConversionSinkMi
xin) { |
| 1796 _Utf8EncoderSink(sink$) { | 1796 _Utf8EncoderSink(sink$) { |
| 1797 this[_sink] = sink$; | 1797 this[_sink] = sink$; |
| 1798 super._Utf8Encoder(); | 1798 super._Utf8Encoder(); |
| 1799 } | 1799 } |
| 1800 close() { | 1800 close() { |
| 1801 if (this[_carry] !== 0) { | 1801 if (this[_carry] != 0) { |
| 1802 this.addSlice("", 0, 0, true); | 1802 this.addSlice("", 0, 0, true); |
| 1803 return; | 1803 return; |
| 1804 } | 1804 } |
| 1805 this[_sink].close(); | 1805 this[_sink].close(); |
| 1806 } | 1806 } |
| 1807 addSlice(str, start, end, isLast) { | 1807 addSlice(str, start, end, isLast) { |
| 1808 this[_bufferIndex] = 0; | 1808 this[_bufferIndex] = 0; |
| 1809 if (start === end && !dart.notNull(isLast)) { | 1809 if (start == end && !dart.notNull(isLast)) { |
| 1810 return; | 1810 return; |
| 1811 } | 1811 } |
| 1812 if (this[_carry] !== 0) { | 1812 if (this[_carry] != 0) { |
| 1813 let nextCodeUnit = 0; | 1813 let nextCodeUnit = 0; |
| 1814 if (start !== end) { | 1814 if (start != end) { |
| 1815 nextCodeUnit = str.codeUnitAt(start); | 1815 nextCodeUnit = str.codeUnitAt(start); |
| 1816 } else { | 1816 } else { |
| 1817 dart.assert(isLast); | 1817 dart.assert(isLast); |
| 1818 } | 1818 } |
| 1819 let wasCombined = this[_writeSurrogate](this[_carry], nextCodeUnit); | 1819 let wasCombined = this[_writeSurrogate](this[_carry], nextCodeUnit); |
| 1820 dart.assert(!dart.notNull(wasCombined) || start !== end); | 1820 dart.assert(!dart.notNull(wasCombined) || start != end); |
| 1821 if (wasCombined) | 1821 if (wasCombined) |
| 1822 start = dart.notNull(start) + 1; | 1822 start = dart.notNull(start) + 1; |
| 1823 this[_carry] = 0; | 1823 this[_carry] = 0; |
| 1824 } | 1824 } |
| 1825 do { | 1825 do { |
| 1826 start = this[_fillBuffer](str, start, end); | 1826 start = this[_fillBuffer](str, start, end); |
| 1827 let isLastSlice = dart.notNull(isLast) && start === end; | 1827 let isLastSlice = dart.notNull(isLast) && start == end; |
| 1828 if (start === dart.notNull(end) - 1 && dart.notNull(_isLeadSurrogate(str
.codeUnitAt(start)))) { | 1828 if (start == dart.notNull(end) - 1 && dart.notNull(_isLeadSurrogate(str.
codeUnitAt(start)))) { |
| 1829 if (dart.notNull(isLast) && dart.notNull(this[_bufferIndex]) < dart.no
tNull(this[_buffer].length) - 3) { | 1829 if (dart.notNull(isLast) && dart.notNull(this[_bufferIndex]) < dart.no
tNull(this[_buffer].length) - 3) { |
| 1830 let hasBeenCombined = this[_writeSurrogate](str.codeUnitAt(start), 0
); | 1830 let hasBeenCombined = this[_writeSurrogate](str.codeUnitAt(start), 0
); |
| 1831 dart.assert(!dart.notNull(hasBeenCombined)); | 1831 dart.assert(!dart.notNull(hasBeenCombined)); |
| 1832 } else { | 1832 } else { |
| 1833 this[_carry] = str.codeUnitAt(start); | 1833 this[_carry] = str.codeUnitAt(start); |
| 1834 } | 1834 } |
| 1835 start = dart.notNull(start) + 1; | 1835 start = dart.notNull(start) + 1; |
| 1836 } | 1836 } |
| 1837 this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice); | 1837 this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice); |
| 1838 this[_bufferIndex] = 0; | 1838 this[_bufferIndex] = 0; |
| 1839 } while (dart.notNull(start) < dart.notNull(end)); | 1839 } while (dart.notNull(start) < dart.notNull(end)); |
| 1840 if (isLast) | 1840 if (isLast) |
| 1841 this.close(); | 1841 this.close(); |
| 1842 } | 1842 } |
| 1843 } | 1843 } |
| 1844 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { | 1844 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { |
| 1845 Utf8Decoder(opts) { | 1845 Utf8Decoder(opts) { |
| 1846 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; | 1846 let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalforme
d : false; |
| 1847 this[_allowMalformed] = allowMalformed; | 1847 this[_allowMalformed] = allowMalformed; |
| 1848 super.Converter(); | 1848 super.Converter(); |
| 1849 } | 1849 } |
| 1850 convert(codeUnits, start, end) { | 1850 convert(codeUnits, start, end) { |
| 1851 if (start === void 0) | 1851 if (start === void 0) |
| 1852 start = 0; | 1852 start = 0; |
| 1853 if (end === void 0) | 1853 if (end === void 0) |
| 1854 end = null; | 1854 end = null; |
| 1855 let length = codeUnits.length; | 1855 let length = codeUnits.length; |
| 1856 core.RangeError.checkValidRange(start, end, length); | 1856 core.RangeError.checkValidRange(start, end, length); |
| 1857 if (end === null) | 1857 if (end == null) |
| 1858 end = length; | 1858 end = length; |
| 1859 let buffer = new core.StringBuffer(); | 1859 let buffer = new core.StringBuffer(); |
| 1860 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]); | 1860 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]); |
| 1861 decoder.convert(codeUnits, start, end); | 1861 decoder.convert(codeUnits, start, end); |
| 1862 decoder.close(); | 1862 decoder.close(); |
| 1863 return buffer.toString(); | 1863 return buffer.toString(); |
| 1864 } | 1864 } |
| 1865 startChunkedConversion(sink) { | 1865 startChunkedConversion(sink) { |
| 1866 let stringSink = null; | 1866 let stringSink = null; |
| 1867 if (dart.is(sink, StringConversionSink)) { | 1867 if (dart.is(sink, StringConversionSink)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1882 let _TWO_BYTE_LIMIT = 2047; | 1882 let _TWO_BYTE_LIMIT = 2047; |
| 1883 let _THREE_BYTE_LIMIT = 65535; | 1883 let _THREE_BYTE_LIMIT = 65535; |
| 1884 let _FOUR_BYTE_LIMIT = 1114111; | 1884 let _FOUR_BYTE_LIMIT = 1114111; |
| 1885 let _SURROGATE_MASK = 63488; | 1885 let _SURROGATE_MASK = 63488; |
| 1886 let _SURROGATE_TAG_MASK = 64512; | 1886 let _SURROGATE_TAG_MASK = 64512; |
| 1887 let _SURROGATE_VALUE_MASK = 1023; | 1887 let _SURROGATE_VALUE_MASK = 1023; |
| 1888 let _LEAD_SURROGATE_MIN = 55296; | 1888 let _LEAD_SURROGATE_MIN = 55296; |
| 1889 let _TAIL_SURROGATE_MIN = 56320; | 1889 let _TAIL_SURROGATE_MIN = 56320; |
| 1890 // Function _isSurrogate: (int) → bool | 1890 // Function _isSurrogate: (int) → bool |
| 1891 function _isSurrogate(codeUnit) { | 1891 function _isSurrogate(codeUnit) { |
| 1892 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_MASK)) === _LEAD_SU
RROGATE_MIN; | 1892 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_MASK)) == _LEAD_SUR
ROGATE_MIN; |
| 1893 } | 1893 } |
| 1894 // Function _isLeadSurrogate: (int) → bool | 1894 // Function _isLeadSurrogate: (int) → bool |
| 1895 function _isLeadSurrogate(codeUnit) { | 1895 function _isLeadSurrogate(codeUnit) { |
| 1896 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_TAG_MASK)) === _LEA
D_SURROGATE_MIN; | 1896 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_TAG_MASK)) == _LEAD
_SURROGATE_MIN; |
| 1897 } | 1897 } |
| 1898 // Function _isTailSurrogate: (int) → bool | 1898 // Function _isTailSurrogate: (int) → bool |
| 1899 function _isTailSurrogate(codeUnit) { | 1899 function _isTailSurrogate(codeUnit) { |
| 1900 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_TAG_MASK)) === _TAI
L_SURROGATE_MIN; | 1900 return (dart.notNull(codeUnit) & dart.notNull(_SURROGATE_TAG_MASK)) == _TAIL
_SURROGATE_MIN; |
| 1901 } | 1901 } |
| 1902 // Function _combineSurrogatePair: (int, int) → int | 1902 // Function _combineSurrogatePair: (int, int) → int |
| 1903 function _combineSurrogatePair(lead, tail) { | 1903 function _combineSurrogatePair(lead, tail) { |
| 1904 return 65536 + ((dart.notNull(lead) & dart.notNull(_SURROGATE_VALUE_MASK)) <
< 10) | dart.notNull(tail) & dart.notNull(_SURROGATE_VALUE_MASK); | 1904 return 65536 + ((dart.notNull(lead) & dart.notNull(_SURROGATE_VALUE_MASK)) <
< 10) | dart.notNull(tail) & dart.notNull(_SURROGATE_VALUE_MASK); |
| 1905 } | 1905 } |
| 1906 let _isFirstCharacter = Symbol('_isFirstCharacter'); | 1906 let _isFirstCharacter = Symbol('_isFirstCharacter'); |
| 1907 let _value = Symbol('_value'); | 1907 let _value = Symbol('_value'); |
| 1908 let _expectedUnits = Symbol('_expectedUnits'); | 1908 let _expectedUnits = Symbol('_expectedUnits'); |
| 1909 let _extraUnits = Symbol('_extraUnits'); | 1909 let _extraUnits = Symbol('_extraUnits'); |
| 1910 let _LIMITS = Symbol('_LIMITS'); | 1910 let _LIMITS = Symbol('_LIMITS'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu
ll(from) <= dart.notNull(endIndex)); | 1957 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu
ll(from) <= dart.notNull(endIndex)); |
| 1958 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull
(to) <= dart.notNull(endIndex)); | 1958 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull
(to) <= dart.notNull(endIndex)); |
| 1959 this[_stringSink].write(new core.String.fromCharCodes(codeUnits, from, t
o)); | 1959 this[_stringSink].write(new core.String.fromCharCodes(codeUnits, from, t
o)); |
| 1960 } | 1960 } |
| 1961 let i = startIndex; | 1961 let i = startIndex; |
| 1962 loop: | 1962 loop: |
| 1963 while (true) { | 1963 while (true) { |
| 1964 multibyte: | 1964 multibyte: |
| 1965 if (dart.notNull(expectedUnits) > 0) { | 1965 if (dart.notNull(expectedUnits) > 0) { |
| 1966 do { | 1966 do { |
| 1967 if (i === endIndex) { | 1967 if (i == endIndex) { |
| 1968 break loop; | 1968 break loop; |
| 1969 } | 1969 } |
| 1970 let unit = codeUnits.get(i); | 1970 let unit = codeUnits.get(i); |
| 1971 if ((dart.notNull(unit) & 192) !== 128) { | 1971 if ((dart.notNull(unit) & 192) != 128) { |
| 1972 expectedUnits = 0; | 1972 expectedUnits = 0; |
| 1973 if (!dart.notNull(this[_allowMalformed])) { | 1973 if (!dart.notNull(this[_allowMalformed])) { |
| 1974 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.
toRadixString(16)}`); | 1974 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.
toRadixString(16)}`); |
| 1975 } | 1975 } |
| 1976 this[_isFirstCharacter] = false; | 1976 this[_isFirstCharacter] = false; |
| 1977 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_
RUNE); | 1977 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_
RUNE); |
| 1978 break multibyte; | 1978 break multibyte; |
| 1979 } else { | 1979 } else { |
| 1980 value = dart.notNull(value) << 6 | dart.notNull(unit) & 63; | 1980 value = dart.notNull(value) << 6 | dart.notNull(unit) & 63; |
| 1981 expectedUnits = dart.notNull(expectedUnits) - 1; | 1981 expectedUnits = dart.notNull(expectedUnits) - 1; |
| 1982 i = dart.notNull(i) + 1; | 1982 i = dart.notNull(i) + 1; |
| 1983 } | 1983 } |
| 1984 } while (dart.notNull(expectedUnits) > 0); | 1984 } while (dart.notNull(expectedUnits) > 0); |
| 1985 if (dart.notNull(value) <= dart.notNull(_Utf8Decoder[_LIMITS].get(
dart.notNull(extraUnits) - 1))) { | 1985 if (dart.notNull(value) <= dart.notNull(_Utf8Decoder[_LIMITS].get(
dart.notNull(extraUnits) - 1))) { |
| 1986 if (!dart.notNull(this[_allowMalformed])) { | 1986 if (!dart.notNull(this[_allowMalformed])) { |
| 1987 throw new core.FormatException(`Overlong encoding of 0x${value
.toRadixString(16)}`); | 1987 throw new core.FormatException(`Overlong encoding of 0x${value
.toRadixString(16)}`); |
| 1988 } | 1988 } |
| 1989 expectedUnits = extraUnits = 0; | 1989 expectedUnits = extraUnits = 0; |
| 1990 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; | 1990 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; |
| 1991 } | 1991 } |
| 1992 if (dart.notNull(value) > dart.notNull(_FOUR_BYTE_LIMIT)) { | 1992 if (dart.notNull(value) > dart.notNull(_FOUR_BYTE_LIMIT)) { |
| 1993 if (!dart.notNull(this[_allowMalformed])) { | 1993 if (!dart.notNull(this[_allowMalformed])) { |
| 1994 throw new core.FormatException("Character outside valid Unicod
e range: " + `0x${value.toRadixString(16)}`); | 1994 throw new core.FormatException("Character outside valid Unicod
e range: " + `0x${value.toRadixString(16)}`); |
| 1995 } | 1995 } |
| 1996 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; | 1996 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; |
| 1997 } | 1997 } |
| 1998 if (!dart.notNull(this[_isFirstCharacter]) || value !== UNICODE_BO
M_CHARACTER_RUNE) { | 1998 if (!dart.notNull(this[_isFirstCharacter]) || value != UNICODE_BOM
_CHARACTER_RUNE) { |
| 1999 this[_stringSink].writeCharCode(value); | 1999 this[_stringSink].writeCharCode(value); |
| 2000 } | 2000 } |
| 2001 this[_isFirstCharacter] = false; | 2001 this[_isFirstCharacter] = false; |
| 2002 } | 2002 } |
| 2003 while (dart.notNull(i) < dart.notNull(endIndex)) { | 2003 while (dart.notNull(i) < dart.notNull(endIndex)) { |
| 2004 let oneBytes = scanOneByteCharacters(codeUnits, i); | 2004 let oneBytes = scanOneByteCharacters(codeUnits, i); |
| 2005 if (dart.notNull(oneBytes) > 0) { | 2005 if (dart.notNull(oneBytes) > 0) { |
| 2006 this[_isFirstCharacter] = false; | 2006 this[_isFirstCharacter] = false; |
| 2007 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes)); | 2007 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes)); |
| 2008 i = oneBytes; | 2008 i = oneBytes; |
| 2009 if (i === endIndex) | 2009 if (i == endIndex) |
| 2010 break; | 2010 break; |
| 2011 } | 2011 } |
| 2012 let unit = codeUnits.get(((x$) => i = dart.notNull(x$) + 1, x$)(i)); | 2012 let unit = codeUnits.get(((x$) => i = dart.notNull(x$) + 1, x$)(i)); |
| 2013 if (dart.notNull(unit) < 0) { | 2013 if (dart.notNull(unit) < 0) { |
| 2014 if (!dart.notNull(this[_allowMalformed])) { | 2014 if (!dart.notNull(this[_allowMalformed])) { |
| 2015 throw new core.FormatException(`Negative UTF-8 code unit: -0x${(
-dart.notNull(unit)).toRadixString(16)}`); | 2015 throw new core.FormatException(`Negative UTF-8 code unit: -0x${(
-dart.notNull(unit)).toRadixString(16)}`); |
| 2016 } | 2016 } |
| 2017 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE
); | 2017 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE
); |
| 2018 } else { | 2018 } else { |
| 2019 dart.assert(dart.notNull(unit) > dart.notNull(_ONE_BYTE_LIMIT)); | 2019 dart.assert(dart.notNull(unit) > dart.notNull(_ONE_BYTE_LIMIT)); |
| 2020 if ((dart.notNull(unit) & 224) === 192) { | 2020 if ((dart.notNull(unit) & 224) == 192) { |
| 2021 value = dart.notNull(unit) & 31; | 2021 value = dart.notNull(unit) & 31; |
| 2022 expectedUnits = extraUnits = 1; | 2022 expectedUnits = extraUnits = 1; |
| 2023 continue loop; | 2023 continue loop; |
| 2024 } | 2024 } |
| 2025 if ((dart.notNull(unit) & 240) === 224) { | 2025 if ((dart.notNull(unit) & 240) == 224) { |
| 2026 value = dart.notNull(unit) & 15; | 2026 value = dart.notNull(unit) & 15; |
| 2027 expectedUnits = extraUnits = 2; | 2027 expectedUnits = extraUnits = 2; |
| 2028 continue loop; | 2028 continue loop; |
| 2029 } | 2029 } |
| 2030 if ((dart.notNull(unit) & 248) === 240 && dart.notNull(unit) < 245
) { | 2030 if ((dart.notNull(unit) & 248) == 240 && dart.notNull(unit) < 245)
{ |
| 2031 value = dart.notNull(unit) & 7; | 2031 value = dart.notNull(unit) & 7; |
| 2032 expectedUnits = extraUnits = 3; | 2032 expectedUnits = extraUnits = 3; |
| 2033 continue loop; | 2033 continue loop; |
| 2034 } | 2034 } |
| 2035 if (!dart.notNull(this[_allowMalformed])) { | 2035 if (!dart.notNull(this[_allowMalformed])) { |
| 2036 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.toRa
dixString(16)}`); | 2036 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.toRa
dixString(16)}`); |
| 2037 } | 2037 } |
| 2038 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; | 2038 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; |
| 2039 expectedUnits = extraUnits = 0; | 2039 expectedUnits = extraUnits = 0; |
| 2040 this[_isFirstCharacter] = false; | 2040 this[_isFirstCharacter] = false; |
| 2041 this[_stringSink].writeCharCode(value); | 2041 this[_stringSink].writeCharCode(value); |
| 2042 } | 2042 } |
| 2043 } | 2043 } |
| 2044 break loop; | 2044 break loop; |
| 2045 } | 2045 } |
| 2046 if (dart.notNull(expectedUnits) > 0) { | 2046 if (dart.notNull(expectedUnits) > 0) { |
| 2047 this[_value] = value; | 2047 this[_value] = value; |
| 2048 this[_expectedUnits] = expectedUnits; | 2048 this[_expectedUnits] = expectedUnits; |
| 2049 this[_extraUnits] = extraUnits; | 2049 this[_extraUnits] = extraUnits; |
| 2050 } | 2050 } |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 _Utf8Decoder._LIMITS = /* Unimplemented const */new core.List$(core.int).from(
[_ONE_BYTE_LIMIT, _TWO_BYTE_LIMIT, _THREE_BYTE_LIMIT, _FOUR_BYTE_LIMIT]); | 2053 _Utf8Decoder._LIMITS = /* Unimplemented const */new core.List$(core.int).from(
[_ONE_BYTE_LIMIT, _TWO_BYTE_LIMIT, _THREE_BYTE_LIMIT, _FOUR_BYTE_LIMIT]); |
| 2054 let _processed = Symbol('_processed'); | 2054 let _processed = Symbol('_processed'); |
| 2055 let _original = Symbol('_original'); | 2055 let _original = Symbol('_original'); |
| 2056 // Function _convertJsonToDart: (dynamic, (dynamic, dynamic) → dynamic) → dyna
mic | 2056 // Function _convertJsonToDart: (dynamic, (dynamic, dynamic) → dynamic) → dyna
mic |
| 2057 function _convertJsonToDart(json, reviver) { | 2057 function _convertJsonToDart(json, reviver) { |
| 2058 dart.assert(reviver !== null); | 2058 dart.assert(reviver != null); |
| 2059 // Function walk: (dynamic) → dynamic | 2059 // Function walk: (dynamic) → dynamic |
| 2060 function walk(e) { | 2060 function walk(e) { |
| 2061 if (e == null || typeof e != "object") { | 2061 if (e == null || typeof e != "object") { |
| 2062 return e; | 2062 return e; |
| 2063 } | 2063 } |
| 2064 if (Object.getPrototypeOf(e) === Array.prototype) { | 2064 if (Object.getPrototypeOf(e) === Array.prototype) { |
| 2065 for (let i = 0; dart.notNull(i) < e.length; i = dart.notNull(i) + 1) { | 2065 for (let i = 0; dart.notNull(i) < e.length; i = dart.notNull(i) + 1) { |
| 2066 let item = e[i]; | 2066 let item = e[i]; |
| 2067 e[i] = dart.dinvokef(reviver, i, walk(item)); | 2067 e[i] = dart.dinvokef(reviver, i, walk(item)); |
| 2068 } | 2068 } |
| 2069 return e; | 2069 return e; |
| 2070 } | 2070 } |
| 2071 let map = new _JsonMap(e); | 2071 let map = new _JsonMap(e); |
| 2072 let processed = map[_processed]; | 2072 let processed = map[_processed]; |
| 2073 let keys = map._computeKeys(); | 2073 let keys = map._computeKeys(); |
| 2074 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { | 2074 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { |
| 2075 let key = keys.get(i); | 2075 let key = keys.get(i); |
| 2076 let revived = dart.dinvokef(reviver, key, walk(e[key])); | 2076 let revived = dart.dinvokef(reviver, key, walk(e[key])); |
| 2077 processed[key] = revived; | 2077 processed[key] = revived; |
| 2078 } | 2078 } |
| 2079 map[_original] = processed; | 2079 map[_original] = processed; |
| 2080 return map; | 2080 return map; |
| 2081 } | 2081 } |
| 2082 return dart.dinvokef(reviver, null, walk(json)); | 2082 return dart.dinvokef(reviver, null, walk(json)); |
| 2083 } | 2083 } |
| 2084 // Function _convertJsonToDartLazy: (dynamic) → dynamic | 2084 // Function _convertJsonToDartLazy: (dynamic) → dynamic |
| 2085 function _convertJsonToDartLazy(object) { | 2085 function _convertJsonToDartLazy(object) { |
| 2086 if (object === null) | 2086 if (object == null) |
| 2087 return null; | 2087 return null; |
| 2088 if (typeof object != "object") { | 2088 if (typeof object != "object") { |
| 2089 return object; | 2089 return object; |
| 2090 } | 2090 } |
| 2091 if (Object.getPrototypeOf(object) !== Array.prototype) { | 2091 if (Object.getPrototypeOf(object) !== Array.prototype) { |
| 2092 return new _JsonMap(object); | 2092 return new _JsonMap(object); |
| 2093 } | 2093 } |
| 2094 for (let i = 0; dart.notNull(i) < object.length; i = dart.notNull(i) + 1) { | 2094 for (let i = 0; dart.notNull(i) < object.length; i = dart.notNull(i) + 1) { |
| 2095 let item = object[i]; | 2095 let item = object[i]; |
| 2096 object[i] = _convertJsonToDartLazy(item); | 2096 object[i] = _convertJsonToDartLazy(item); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2124 let result = _JsonMap[_getProperty](this[_processed], dart.as(key, core.
String)); | 2124 let result = _JsonMap[_getProperty](this[_processed], dart.as(key, core.
String)); |
| 2125 if (_JsonMap[_isUnprocessed](result)) | 2125 if (_JsonMap[_isUnprocessed](result)) |
| 2126 result = this[_process](dart.as(key, core.String)); | 2126 result = this[_process](dart.as(key, core.String)); |
| 2127 return result; | 2127 return result; |
| 2128 } | 2128 } |
| 2129 } | 2129 } |
| 2130 get length() { | 2130 get length() { |
| 2131 return this[_isUpgraded] ? this[_upgradedMap].length : this[_computeKeys](
).length; | 2131 return this[_isUpgraded] ? this[_upgradedMap].length : this[_computeKeys](
).length; |
| 2132 } | 2132 } |
| 2133 get isEmpty() { | 2133 get isEmpty() { |
| 2134 return this.length === 0; | 2134 return this.length == 0; |
| 2135 } | 2135 } |
| 2136 get isNotEmpty() { | 2136 get isNotEmpty() { |
| 2137 return dart.notNull(this.length) > 0; | 2137 return dart.notNull(this.length) > 0; |
| 2138 } | 2138 } |
| 2139 get keys() { | 2139 get keys() { |
| 2140 if (this[_isUpgraded]) | 2140 if (this[_isUpgraded]) |
| 2141 return this[_upgradedMap].keys; | 2141 return this[_upgradedMap].keys; |
| 2142 return new _JsonMapKeyIterable(this); | 2142 return new _JsonMapKeyIterable(this); |
| 2143 } | 2143 } |
| 2144 get values() { | 2144 get values() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 } | 2192 } |
| 2193 remove(key) { | 2193 remove(key) { |
| 2194 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key
))) | 2194 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key
))) |
| 2195 return null; | 2195 return null; |
| 2196 return this[_upgrade]().remove(key); | 2196 return this[_upgrade]().remove(key); |
| 2197 } | 2197 } |
| 2198 clear() { | 2198 clear() { |
| 2199 if (this[_isUpgraded]) { | 2199 if (this[_isUpgraded]) { |
| 2200 this[_upgradedMap].clear(); | 2200 this[_upgradedMap].clear(); |
| 2201 } else { | 2201 } else { |
| 2202 if (this[_data] !== null) { | 2202 if (this[_data] != null) { |
| 2203 dart.dinvoke(this[_data], 'clear'); | 2203 dart.dinvoke(this[_data], 'clear'); |
| 2204 } | 2204 } |
| 2205 this[_original] = this[_processed] = null; | 2205 this[_original] = this[_processed] = null; |
| 2206 this[_data] = dart.map(); | 2206 this[_data] = dart.map(); |
| 2207 } | 2207 } |
| 2208 } | 2208 } |
| 2209 forEach(f) { | 2209 forEach(f) { |
| 2210 if (this[_isUpgraded]) | 2210 if (this[_isUpgraded]) |
| 2211 return this[_upgradedMap].forEach(f); | 2211 return this[_upgradedMap].forEach(f); |
| 2212 let keys = this[_computeKeys](); | 2212 let keys = this[_computeKeys](); |
| 2213 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { | 2213 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { |
| 2214 let key = keys.get(i); | 2214 let key = keys.get(i); |
| 2215 let value = _JsonMap[_getProperty](this[_processed], key); | 2215 let value = _JsonMap[_getProperty](this[_processed], key); |
| 2216 if (_JsonMap[_isUnprocessed](value)) { | 2216 if (_JsonMap[_isUnprocessed](value)) { |
| 2217 value = _convertJsonToDartLazy(_JsonMap[_getProperty](this[_original],
key)); | 2217 value = _convertJsonToDartLazy(_JsonMap[_getProperty](this[_original],
key)); |
| 2218 _JsonMap[_setProperty](this[_processed], key, value); | 2218 _JsonMap[_setProperty](this[_processed], key, value); |
| 2219 } | 2219 } |
| 2220 dart.dinvokef(f, key, value); | 2220 dart.dinvokef(f, key, value); |
| 2221 if (!dart.notNull(core.identical(keys, this[_data]))) { | 2221 if (!dart.notNull(core.identical(keys, this[_data]))) { |
| 2222 throw new core.ConcurrentModificationError(this); | 2222 throw new core.ConcurrentModificationError(this); |
| 2223 } | 2223 } |
| 2224 } | 2224 } |
| 2225 } | 2225 } |
| 2226 toString() { | 2226 toString() { |
| 2227 return collection.Maps.mapToString(this); | 2227 return collection.Maps.mapToString(this); |
| 2228 } | 2228 } |
| 2229 get [_isUpgraded]() { | 2229 get [_isUpgraded]() { |
| 2230 return this[_processed] === null; | 2230 return this[_processed] == null; |
| 2231 } | 2231 } |
| 2232 get [_upgradedMap]() { | 2232 get [_upgradedMap]() { |
| 2233 dart.assert(this[_isUpgraded]); | 2233 dart.assert(this[_isUpgraded]); |
| 2234 return dart.as(this[_data], core.Map); | 2234 return dart.as(this[_data], core.Map); |
| 2235 } | 2235 } |
| 2236 [_computeKeys]() { | 2236 [_computeKeys]() { |
| 2237 dart.assert(!dart.notNull(this[_isUpgraded])); | 2237 dart.assert(!dart.notNull(this[_isUpgraded])); |
| 2238 let keys = dart.as(this[_data], core.List); | 2238 let keys = dart.as(this[_data], core.List); |
| 2239 if (keys === null) { | 2239 if (keys == null) { |
| 2240 keys = this[_data] = _JsonMap[_getPropertyNames](this[_original]); | 2240 keys = this[_data] = _JsonMap[_getPropertyNames](this[_original]); |
| 2241 } | 2241 } |
| 2242 return dart.as(keys, core.List$(core.String)); | 2242 return dart.as(keys, core.List$(core.String)); |
| 2243 } | 2243 } |
| 2244 [_upgrade]() { | 2244 [_upgrade]() { |
| 2245 if (this[_isUpgraded]) | 2245 if (this[_isUpgraded]) |
| 2246 return this[_upgradedMap]; | 2246 return this[_upgradedMap]; |
| 2247 let result = dart.map(); | 2247 let result = dart.map(); |
| 2248 let keys = this[_computeKeys](); | 2248 let keys = this[_computeKeys](); |
| 2249 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { | 2249 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 exports.LineSplitter = LineSplitter; | 2353 exports.LineSplitter = LineSplitter; |
| 2354 exports.StringConversionSink = StringConversionSink; | 2354 exports.StringConversionSink = StringConversionSink; |
| 2355 exports.ClosableStringSink = ClosableStringSink; | 2355 exports.ClosableStringSink = ClosableStringSink; |
| 2356 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN
E; | 2356 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN
E; |
| 2357 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; | 2357 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; |
| 2358 exports.UTF8 = UTF8; | 2358 exports.UTF8 = UTF8; |
| 2359 exports.Utf8Codec = Utf8Codec; | 2359 exports.Utf8Codec = Utf8Codec; |
| 2360 exports.Utf8Encoder = Utf8Encoder; | 2360 exports.Utf8Encoder = Utf8Encoder; |
| 2361 exports.Utf8Decoder = Utf8Decoder; | 2361 exports.Utf8Decoder = Utf8Decoder; |
| 2362 })(convert || (convert = {})); | 2362 })(convert || (convert = {})); |
| OLD | NEW |