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

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

Issue 963343002: implement private members, fixes #74 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 var convert; 1 var convert;
2 (function(convert) { 2 (function(convert) {
3 'use strict'; 3 'use strict';
4 let _processed = Symbol('_processed');
5 let _original = Symbol('_original');
6 let _data = Symbol('_data');
7 let _isUpgraded = Symbol('_isUpgraded');
8 let _upgradedMap = Symbol('_upgradedMap');
9 let _process = Symbol('_process');
10 let _computeKeys = Symbol('_computeKeys');
11 let _upgrade = Symbol('_upgrade');
12 let _hasProperty = Symbol('_hasProperty');
13 let _getProperty = Symbol('_getProperty');
14 let _setProperty = Symbol('_setProperty');
15 let _getPropertyNames = Symbol('_getPropertyNames');
16 let _isUnprocessed = Symbol('_isUnprocessed');
17 let _newJavaScriptObject = Symbol('_newJavaScriptObject');
18 let _parent = Symbol('_parent');
19 let _reviver = Symbol('_reviver');
20 let _sink = Symbol('_sink');
21 let _stringSink = Symbol('_stringSink');
22 let _allowInvalid = Symbol('_allowInvalid');
23 let _subsetMask = Symbol('_subsetMask');
24 let _convertInvalid = Symbol('_convertInvalid');
25 let _utf8Sink = Symbol('_utf8Sink');
26 let _buffer = Symbol('_buffer');
27 let _callback = Symbol('_callback');
28 let _bufferIndex = Symbol('_bufferIndex');
29 let _roundToPowerOf2 = Symbol('_roundToPowerOf2');
30 let _accumulated = Symbol('_accumulated');
31 let _eventSink = Symbol('_eventSink');
32 let _chunkedSink = Symbol('_chunkedSink');
33 let _first = Symbol('_first');
34 let _second = Symbol('_second');
35 let _codec = Symbol('_codec');
36 let _name = Symbol('_name');
37 let _convert = Symbol('_convert');
38 let _escape = Symbol('_escape');
39 let _toEncodable = Symbol('_toEncodable');
40 let _indent = Symbol('_indent');
41 let _bufferSize = Symbol('_bufferSize');
42 let _utf8Encode = Symbol('_utf8Encode');
43 let _isDone = Symbol('_isDone');
44 let _addChunk = Symbol('_addChunk');
45 let _seen = Symbol('_seen');
46 let _checkCycle = Symbol('_checkCycle');
47 let _removeSeen = Symbol('_removeSeen');
48 let _indentLevel = Symbol('_indentLevel');
49 let _addSliceToSink = Symbol('_addSliceToSink');
50 let _carry = Symbol('_carry');
51 let _addSlice = Symbol('_addSlice');
52 let _flush = Symbol('_flush');
53 let _decoder = Symbol('_decoder');
54 let _Utf8ConversionSink$_ = Symbol('_Utf8ConversionSink$_');
55 let _allowMalformed = Symbol('_allowMalformed');
56 let _Utf8Encoder$withBufferSize = Symbol('_Utf8Encoder$withBufferSize');
57 let _createBuffer = Symbol('_createBuffer');
58 let _writeSurrogate = Symbol('_writeSurrogate');
59 let _fillBuffer = Symbol('_fillBuffer');
60 let _isFirstCharacter = Symbol('_isFirstCharacter');
61 let _value = Symbol('_value');
62 let _expectedUnits = Symbol('_expectedUnits');
63 let _extraUnits = Symbol('_extraUnits');
4 // Function _convertJsonToDart: (dynamic, (dynamic, dynamic) → dynamic) → dyna mic 64 // Function _convertJsonToDart: (dynamic, (dynamic, dynamic) → dynamic) → dyna mic
5 function _convertJsonToDart(json, reviver) { 65 function _convertJsonToDart(json, reviver) {
6 dart.assert(reviver !== null); 66 dart.assert(reviver !== null);
7 // Function walk: (dynamic) → dynamic 67 // Function walk: (dynamic) → dynamic
8 function walk(e) { 68 function walk(e) {
9 if (dart.notNull(e == null) || dart.notNull(typeof e != "object")) { 69 if (dart.notNull(e == null) || dart.notNull(typeof e != "object")) {
10 return e; 70 return e;
11 } 71 }
12 if (Object.getPrototypeOf(e) === Array.prototype) { 72 if (Object.getPrototypeOf(e) === Array.prototype) {
13 for (let i = 0; i < e.length; i++) { 73 for (let i = 0; i < e.length; i++) {
14 let item = e[i]; 74 let item = e[i];
15 e[i] = reviver(i, walk(item)); 75 e[i] = reviver(i, walk(item));
16 } 76 }
17 return e; 77 return e;
18 } 78 }
19 let map = new _JsonMap(e); 79 let map = new _JsonMap(e);
20 let processed = map._processed; 80 let processed = map[_processed];
21 let keys = map._computeKeys(); 81 let keys = map._computeKeys();
22 for (let i = 0; i < keys.length; i++) { 82 for (let i = 0; i < keys.length; i++) {
23 let key = keys.get(i); 83 let key = keys.get(i);
24 let revived = reviver(key, walk(e[key])); 84 let revived = reviver(key, walk(e[key]));
25 processed[key] = revived; 85 processed[key] = revived;
26 } 86 }
27 map._original = processed; 87 map[_original] = processed;
28 return map; 88 return map;
29 } 89 }
30 return reviver(null, walk(json)); 90 return reviver(null, walk(json));
31 } 91 }
32 // Function _convertJsonToDartLazy: (dynamic) → dynamic 92 // Function _convertJsonToDartLazy: (dynamic) → dynamic
33 function _convertJsonToDartLazy(object) { 93 function _convertJsonToDartLazy(object) {
34 if (object === null) 94 if (object === null)
35 return null; 95 return null;
36 if (typeof object != "object") { 96 if (typeof object != "object") {
37 return object; 97 return object;
38 } 98 }
39 if (Object.getPrototypeOf(object) !== Array.prototype) { 99 if (Object.getPrototypeOf(object) !== Array.prototype) {
40 return new _JsonMap(object); 100 return new _JsonMap(object);
41 } 101 }
42 for (let i = 0; i < object.length; i++) { 102 for (let i = 0; i < object.length; i++) {
43 let item = object[i]; 103 let item = object[i];
44 object[i] = _convertJsonToDartLazy(item); 104 object[i] = _convertJsonToDartLazy(item);
45 } 105 }
46 return object; 106 return object;
47 } 107 }
48 class _JsonMap extends dart.Object { 108 class _JsonMap extends dart.Object {
49 _JsonMap(_original) { 109 _JsonMap($_original) {
50 this._processed = _newJavaScriptObject(); 110 this[_processed] = _newJavaScriptObject();
51 this._original = _original; 111 this[_original] = $_original;
52 this._data = null; 112 this[_data] = null;
53 } 113 }
54 get(key) { 114 get(key) {
55 if (this._isUpgraded) { 115 if (this[_isUpgraded]) {
56 return this._upgradedMap.get(key); 116 return this[_upgradedMap].get(key);
57 } else if (!(typeof key == string)) { 117 } else if (!(typeof key == string)) {
58 return null; 118 return null;
59 } else { 119 } else {
60 let result = _getProperty(this._processed, dart.as(key, core.String)); 120 let result = _getProperty(this[_processed], dart.as(key, core.String));
61 if (_isUnprocessed(result)) 121 if (_isUnprocessed(result))
62 result = this._process(dart.as(key, core.String)); 122 result = this[_process](dart.as(key, core.String));
63 return result; 123 return result;
64 } 124 }
65 } 125 }
66 get length() { 126 get length() {
67 return this._isUpgraded ? this._upgradedMap.length : this._computeKeys().l ength; 127 return this[_isUpgraded] ? this[_upgradedMap].length : this[_computeKeys]( ).length;
68 } 128 }
69 get isEmpty() { 129 get isEmpty() {
70 return this.length === 0; 130 return this.length === 0;
71 } 131 }
72 get isNotEmpty() { 132 get isNotEmpty() {
73 return this.length > 0; 133 return this.length > 0;
74 } 134 }
75 get keys() { 135 get keys() {
76 if (this._isUpgraded) 136 if (this[_isUpgraded])
77 return this._upgradedMap.keys; 137 return this[_upgradedMap].keys;
78 return new _JsonMapKeyIterable(this); 138 return new _JsonMapKeyIterable(this);
79 } 139 }
80 get values() { 140 get values() {
81 if (this._isUpgraded) 141 if (this[_isUpgraded])
82 return this._upgradedMap.values; 142 return this[_upgradedMap].values;
83 return new _internal.MappedIterable(this._computeKeys(), ((each) => this.g et(each)).bind(this)); 143 return new _internal.MappedIterable(this[_computeKeys](), ((each) => this. get(each)).bind(this));
84 } 144 }
85 set(key, value) { 145 set(key, value) {
86 if (this._isUpgraded) { 146 if (this[_isUpgraded]) {
87 this._upgradedMap.set(key, value); 147 this[_upgradedMap].set(key, value);
88 } else if (this.containsKey(key)) { 148 } else if (this.containsKey(key)) {
89 let processed = this._processed; 149 let processed = this[_processed];
90 _setProperty(processed, dart.as(key, core.String), value); 150 _setProperty(processed, dart.as(key, core.String), value);
91 let original = this._original; 151 let original = this[_original];
92 if (!dart.notNull(core.identical(original, processed))) { 152 if (!dart.notNull(core.identical(original, processed))) {
93 _setProperty(original, dart.as(key, core.String), null); 153 _setProperty(original, dart.as(key, core.String), null);
94 } 154 }
95 } else { 155 } else {
96 this._upgrade().set(key, value); 156 this[_upgrade]().set(key, value);
97 } 157 }
98 } 158 }
99 addAll(other) { 159 addAll(other) {
100 other.forEach(((key, value) => { 160 other.forEach(((key, value) => {
101 this.set(key, value); 161 this.set(key, value);
102 }).bind(this)); 162 }).bind(this));
103 } 163 }
104 containsValue(value) { 164 containsValue(value) {
105 if (this._isUpgraded) 165 if (this[_isUpgraded])
106 return this._upgradedMap.containsValue(value); 166 return this[_upgradedMap].containsValue(value);
107 let keys = this._computeKeys(); 167 let keys = this[_computeKeys]();
108 for (let i = 0; i < keys.length; i++) { 168 for (let i = 0; i < keys.length; i++) {
109 let key = keys.get(i); 169 let key = keys.get(i);
110 if (dart.equals(this.get(key), value)) 170 if (dart.equals(this.get(key), value))
111 return true; 171 return true;
112 } 172 }
113 return false; 173 return false;
114 } 174 }
115 containsKey(key) { 175 containsKey(key) {
116 if (this._isUpgraded) 176 if (this[_isUpgraded])
117 return this._upgradedMap.containsKey(key); 177 return this[_upgradedMap].containsKey(key);
118 if (!(typeof key == string)) 178 if (!(typeof key == string))
119 return false; 179 return false;
120 return _hasProperty(this._original, dart.as(key, core.String)); 180 return _hasProperty(this[_original], dart.as(key, core.String));
121 } 181 }
122 putIfAbsent(key, ifAbsent) { 182 putIfAbsent(key, ifAbsent) {
123 if (this.containsKey(key)) 183 if (this.containsKey(key))
124 return this.get(key); 184 return this.get(key);
125 let value = ifAbsent(); 185 let value = ifAbsent();
126 this.set(key, value); 186 this.set(key, value);
127 return value; 187 return value;
128 } 188 }
129 remove(key) { 189 remove(key) {
130 if (dart.notNull(!dart.notNull(this._isUpgraded)) && dart.notNull(!dart.no tNull(this.containsKey(key)))) 190 if (dart.notNull(!dart.notNull(this[_isUpgraded])) && dart.notNull(!dart.n otNull(this.containsKey(key))))
131 return null; 191 return null;
132 return this._upgrade().remove(key); 192 return this[_upgrade]().remove(key);
133 } 193 }
134 clear() { 194 clear() {
135 if (this._isUpgraded) { 195 if (this[_isUpgraded]) {
136 this._upgradedMap.clear(); 196 this[_upgradedMap].clear();
137 } else { 197 } else {
138 if (this._data !== null) { 198 if (this[_data] !== null) {
139 dart.dinvoke(this._data, 'clear'); 199 dart.dinvoke(this[_data], 'clear');
140 } 200 }
141 this._original = this._processed = null; 201 this[_original] = this[_processed] = null;
142 this._data = dart.map(); 202 this[_data] = dart.map();
143 } 203 }
144 } 204 }
145 forEach(f) { 205 forEach(f) {
146 if (this._isUpgraded) 206 if (this[_isUpgraded])
147 return this._upgradedMap.forEach(f); 207 return this[_upgradedMap].forEach(f);
148 let keys = this._computeKeys(); 208 let keys = this[_computeKeys]();
149 for (let i = 0; i < keys.length; i++) { 209 for (let i = 0; i < keys.length; i++) {
150 let key = keys.get(i); 210 let key = keys.get(i);
151 let value = _getProperty(this._processed, key); 211 let value = _getProperty(this[_processed], key);
152 if (_isUnprocessed(value)) { 212 if (_isUnprocessed(value)) {
153 value = _convertJsonToDartLazy(_getProperty(this._original, key)); 213 value = _convertJsonToDartLazy(_getProperty(this[_original], key));
154 _setProperty(this._processed, key, value); 214 _setProperty(this[_processed], key, value);
155 } 215 }
156 f(key, value); 216 f(key, value);
157 if (!dart.notNull(core.identical(keys, this._data))) { 217 if (!dart.notNull(core.identical(keys, this[_data]))) {
158 throw new core.ConcurrentModificationError(this); 218 throw new core.ConcurrentModificationError(this);
159 } 219 }
160 } 220 }
161 } 221 }
162 toString() { 222 toString() {
163 return collection.Maps.mapToString(this); 223 return collection.Maps.mapToString(this);
164 } 224 }
165 get _isUpgraded() { 225 get [_isUpgraded]() {
166 return this._processed === null; 226 return this[_processed] === null;
167 } 227 }
168 get _upgradedMap() { 228 get [_upgradedMap]() {
169 dart.assert(this._isUpgraded); 229 dart.assert(this[_isUpgraded]);
170 return dart.as(this._data, core.Map); 230 return dart.as(this[_data], core.Map);
171 } 231 }
172 _computeKeys() { 232 [_computeKeys]() {
173 dart.assert(!dart.notNull(this._isUpgraded)); 233 dart.assert(!dart.notNull(this[_isUpgraded]));
174 let keys = dart.as(this._data, core.List); 234 let keys = dart.as(this[_data], core.List);
175 if (keys === null) { 235 if (keys === null) {
176 keys = this._data = _getPropertyNames(this._original); 236 keys = this[_data] = _getPropertyNames(this[_original]);
177 } 237 }
178 return dart.as(keys, core.List$(core.String)); 238 return dart.as(keys, core.List$(core.String));
179 } 239 }
180 _upgrade() { 240 [_upgrade]() {
181 if (this._isUpgraded) 241 if (this[_isUpgraded])
182 return this._upgradedMap; 242 return this[_upgradedMap];
183 let result = dart.map(); 243 let result = dart.map();
184 let keys = this._computeKeys(); 244 let keys = this[_computeKeys]();
185 for (let i = 0; i < keys.length; i++) { 245 for (let i = 0; i < keys.length; i++) {
186 let key = keys.get(i); 246 let key = keys.get(i);
187 result.set(key, this.get(key)); 247 result.set(key, this.get(key));
188 } 248 }
189 if (keys.isEmpty) { 249 if (keys.isEmpty) {
190 keys.add(null); 250 keys.add(null);
191 } else { 251 } else {
192 keys.clear(); 252 keys.clear();
193 } 253 }
194 this._original = this._processed = null; 254 this[_original] = this[_processed] = null;
195 this._data = result; 255 this[_data] = result;
196 dart.assert(this._isUpgraded); 256 dart.assert(this[_isUpgraded]);
197 return result; 257 return result;
198 } 258 }
199 _process(key) { 259 [_process](key) {
200 if (!dart.notNull(_hasProperty(this._original, key))) 260 if (!dart.notNull(_hasProperty(this[_original], key)))
201 return null; 261 return null;
202 let result = _convertJsonToDartLazy(_getProperty(this._original, key)); 262 let result = _convertJsonToDartLazy(_getProperty(this[_original], key));
203 return _setProperty(this._processed, key, result); 263 return _setProperty(this[_processed], key, result);
204 } 264 }
205 static _hasProperty(object, key) { 265 static [_hasProperty](object, key) {
206 return Object.prototype.hasOwnProperty.call(object, key); 266 return Object.prototype.hasOwnProperty.call(object, key);
207 } 267 }
208 static _getProperty(object, key) { 268 static [_getProperty](object, key) {
209 return object[key]; 269 return object[key];
210 } 270 }
211 static _setProperty(object, key, value) { 271 static [_setProperty](object, key, value) {
212 return object[key] = value; 272 return object[key] = value;
213 } 273 }
214 static _getPropertyNames(object) { 274 static [_getPropertyNames](object) {
215 return dart.as(Object.keys(object), core.List); 275 return dart.as(Object.keys(object), core.List);
216 } 276 }
217 static _isUnprocessed(object) { 277 static [_isUnprocessed](object) {
218 return typeof object == "undefined"; 278 return typeof object == "undefined";
219 } 279 }
220 static _newJavaScriptObject() { 280 static [_newJavaScriptObject]() {
221 return Object.create(null); 281 return Object.create(null);
222 } 282 }
223 } 283 }
224 class _JsonMapKeyIterable extends _internal.ListIterable { 284 class _JsonMapKeyIterable extends _internal.ListIterable {
225 _JsonMapKeyIterable(_parent) { 285 _JsonMapKeyIterable($_parent) {
226 this._parent = _parent; 286 this[_parent] = $_parent;
227 super.ListIterable(); 287 super.ListIterable();
228 } 288 }
229 get length() { 289 get length() {
230 return this._parent.length; 290 return this[_parent].length;
231 } 291 }
232 elementAt(index) { 292 elementAt(index) {
233 return dart.as(this._parent._isUpgraded ? this._parent.keys.elementAt(inde x) : this._parent._computeKeys().get(index), core.String); 293 return dart.as(this[_parent][_isUpgraded] ? this[_parent].keys.elementAt(i ndex) : this[_parent]._computeKeys().get(index), core.String);
234 } 294 }
235 get iterator() { 295 get iterator() {
236 return dart.as(this._parent._isUpgraded ? this._parent.keys.iterator : thi s._parent._computeKeys().iterator, core.Iterator); 296 return dart.as(this[_parent][_isUpgraded] ? this[_parent].keys.iterator : this[_parent]._computeKeys().iterator, core.Iterator);
237 } 297 }
238 contains(key) { 298 contains(key) {
239 return this._parent.containsKey(key); 299 return this[_parent].containsKey(key);
240 } 300 }
241 } 301 }
242 class _JsonDecoderSink extends _StringSinkConversionSink { 302 class _JsonDecoderSink extends _StringSinkConversionSink {
243 _JsonDecoderSink(_reviver, _sink) { 303 _JsonDecoderSink($_reviver, $_sink) {
244 this._reviver = _reviver; 304 this[_reviver] = $_reviver;
245 this._sink = _sink; 305 this[_sink] = $_sink;
246 super._StringSinkConversionSink(new core.StringBuffer()); 306 super._StringSinkConversionSink(new core.StringBuffer());
247 } 307 }
248 close() { 308 close() {
249 super.close(); 309 super.close();
250 let buffer = dart.as(this._stringSink, core.StringBuffer); 310 let buffer = dart.as(this[_stringSink], core.StringBuffer);
251 let accumulated = buffer.toString(); 311 let accumulated = buffer.toString();
252 buffer.clear(); 312 buffer.clear();
253 let decoded = _parseJson(accumulated, this._reviver); 313 let decoded = _parseJson(accumulated, this[_reviver]);
254 this._sink.add(decoded); 314 this[_sink].add(decoded);
255 this._sink.close(); 315 this[_sink].close();
256 } 316 }
257 } 317 }
258 let ASCII = new AsciiCodec(); 318 let ASCII = new AsciiCodec();
259 let _ASCII_MASK = 127; 319 let _ASCII_MASK = 127;
260 class AsciiCodec extends Encoding { 320 class AsciiCodec extends Encoding {
261 AsciiCodec(opt$) { 321 AsciiCodec(opt$) {
262 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d; 322 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d;
263 this._allowInvalid = allowInvalid; 323 this[_allowInvalid] = allowInvalid;
264 super.Encoding(); 324 super.Encoding();
265 } 325 }
266 get name() { 326 get name() {
267 return "us-ascii"; 327 return "us-ascii";
268 } 328 }
269 decode(bytes, opt$) { 329 decode(bytes, opt$) {
270 let allowInvalid = opt$.allowInvalid === void 0 ? null : opt$.allowInvalid ; 330 let allowInvalid = opt$.allowInvalid === void 0 ? null : opt$.allowInvalid ;
271 if (allowInvalid === null) 331 if (allowInvalid === null)
272 allowInvalid = this._allowInvalid; 332 allowInvalid = this[_allowInvalid];
273 if (allowInvalid) { 333 if (allowInvalid) {
274 return new AsciiDecoder({allowInvalid: true}).convert(bytes); 334 return new AsciiDecoder({allowInvalid: true}).convert(bytes);
275 } else { 335 } else {
276 return new AsciiDecoder({allowInvalid: false}).convert(bytes); 336 return new AsciiDecoder({allowInvalid: false}).convert(bytes);
277 } 337 }
278 } 338 }
279 get encoder() { 339 get encoder() {
280 return new AsciiEncoder(); 340 return new AsciiEncoder();
281 } 341 }
282 get decoder() { 342 get decoder() {
283 return this._allowInvalid ? new AsciiDecoder({allowInvalid: true}) : new A sciiDecoder({allowInvalid: false}); 343 return this[_allowInvalid] ? new AsciiDecoder({allowInvalid: true}) : new AsciiDecoder({allowInvalid: false});
284 } 344 }
285 } 345 }
286 class _UnicodeSubsetEncoder extends Converter$(core.String, core.List$(core.in t)) { 346 class _UnicodeSubsetEncoder extends Converter$(core.String, core.List$(core.in t)) {
287 _UnicodeSubsetEncoder(_subsetMask) { 347 _UnicodeSubsetEncoder($_subsetMask) {
288 this._subsetMask = _subsetMask; 348 this[_subsetMask] = $_subsetMask;
289 super.Converter(); 349 super.Converter();
290 } 350 }
291 convert(string, start, end) { 351 convert(string, start, end) {
292 if (start === void 0) 352 if (start === void 0)
293 start = 0; 353 start = 0;
294 if (end === void 0) 354 if (end === void 0)
295 end = null; 355 end = null;
296 let stringLength = string.length; 356 let stringLength = string.length;
297 core.RangeError.checkValidRange(start, end, stringLength); 357 core.RangeError.checkValidRange(start, end, stringLength);
298 if (end === null) 358 if (end === null)
299 end = stringLength; 359 end = stringLength;
300 let length = end - start; 360 let length = end - start;
301 let result = new typed_data.Uint8List(length); 361 let result = new typed_data.Uint8List(length);
302 for (let i = 0; i < length; i++) { 362 for (let i = 0; i < length; i++) {
303 let codeUnit = string.codeUnitAt(start + i); 363 let codeUnit = string.codeUnitAt(start + i);
304 if ((codeUnit & ~this._subsetMask) !== 0) { 364 if ((codeUnit & ~this[_subsetMask]) !== 0) {
305 throw new core.ArgumentError("String contains invalid characters."); 365 throw new core.ArgumentError("String contains invalid characters.");
306 } 366 }
307 result.set(i, codeUnit); 367 result.set(i, codeUnit);
308 } 368 }
309 return dart.as(result, core.List$(core.int)); 369 return dart.as(result, core.List$(core.int));
310 } 370 }
311 startChunkedConversion(sink) { 371 startChunkedConversion(sink) {
312 if (!dart.is(sink, ByteConversionSink)) { 372 if (!dart.is(sink, ByteConversionSink)) {
313 sink = new ByteConversionSink.from(sink); 373 sink = new ByteConversionSink.from(sink);
314 } 374 }
315 return new _UnicodeSubsetEncoderSink(this._subsetMask, dart.as(sink, ByteC onversionSink)); 375 return new _UnicodeSubsetEncoderSink(this[_subsetMask], dart.as(sink, Byte ConversionSink));
316 } 376 }
317 bind(stream) { 377 bind(stream) {
318 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int))); 378 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int)));
319 } 379 }
320 } 380 }
321 class AsciiEncoder extends _UnicodeSubsetEncoder { 381 class AsciiEncoder extends _UnicodeSubsetEncoder {
322 AsciiEncoder() { 382 AsciiEncoder() {
323 super._UnicodeSubsetEncoder(_ASCII_MASK); 383 super._UnicodeSubsetEncoder(_ASCII_MASK);
324 } 384 }
325 } 385 }
326 class _UnicodeSubsetEncoderSink extends StringConversionSinkBase { 386 class _UnicodeSubsetEncoderSink extends StringConversionSinkBase {
327 _UnicodeSubsetEncoderSink(_subsetMask, _sink) { 387 _UnicodeSubsetEncoderSink($_subsetMask, $_sink) {
328 this._subsetMask = _subsetMask; 388 this[_subsetMask] = $_subsetMask;
329 this._sink = _sink; 389 this[_sink] = $_sink;
330 super.StringConversionSinkBase(); 390 super.StringConversionSinkBase();
331 } 391 }
332 close() { 392 close() {
333 this._sink.close(); 393 this[_sink].close();
334 } 394 }
335 addSlice(source, start, end, isLast) { 395 addSlice(source, start, end, isLast) {
336 core.RangeError.checkValidRange(start, end, source.length); 396 core.RangeError.checkValidRange(start, end, source.length);
337 for (let i = start; i < end; i++) { 397 for (let i = start; i < end; i++) {
338 let codeUnit = source.codeUnitAt(i); 398 let codeUnit = source.codeUnitAt(i);
339 if ((codeUnit & ~this._subsetMask) !== 0) { 399 if ((codeUnit & ~this[_subsetMask]) !== 0) {
340 throw new core.ArgumentError(`Source contains invalid character with c ode point: ${codeUnit}.`); 400 throw new core.ArgumentError(`Source contains invalid character with c ode point: ${codeUnit}.`);
341 } 401 }
342 } 402 }
343 this._sink.add(source.codeUnits.sublist(start, end)); 403 this[_sink].add(source.codeUnits.sublist(start, end));
344 if (isLast) { 404 if (isLast) {
345 this.close(); 405 this.close();
346 } 406 }
347 } 407 }
348 } 408 }
349 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri ng) { 409 class _UnicodeSubsetDecoder extends Converter$(core.List$(core.int), core.Stri ng) {
350 _UnicodeSubsetDecoder(_allowInvalid, _subsetMask) { 410 _UnicodeSubsetDecoder($_allowInvalid, $_subsetMask) {
351 this._allowInvalid = _allowInvalid; 411 this[_allowInvalid] = $_allowInvalid;
352 this._subsetMask = _subsetMask; 412 this[_subsetMask] = $_subsetMask;
353 super.Converter(); 413 super.Converter();
354 } 414 }
355 convert(bytes, start, end) { 415 convert(bytes, start, end) {
356 if (start === void 0) 416 if (start === void 0)
357 start = 0; 417 start = 0;
358 if (end === void 0) 418 if (end === void 0)
359 end = null; 419 end = null;
360 let byteCount = bytes.length; 420 let byteCount = bytes.length;
361 core.RangeError.checkValidRange(start, end, byteCount); 421 core.RangeError.checkValidRange(start, end, byteCount);
362 if (end === null) 422 if (end === null)
363 end = byteCount; 423 end = byteCount;
364 let length = end - start; 424 let length = end - start;
365 for (let i = start; i < end; i++) { 425 for (let i = start; i < end; i++) {
366 let byte = bytes.get(i); 426 let byte = bytes.get(i);
367 if ((byte & ~this._subsetMask) !== 0) { 427 if ((byte & ~this[_subsetMask]) !== 0) {
368 if (!dart.notNull(this._allowInvalid)) { 428 if (!dart.notNull(this[_allowInvalid])) {
369 throw new core.FormatException(`Invalid value in input: ${byte}`); 429 throw new core.FormatException(`Invalid value in input: ${byte}`);
370 } 430 }
371 return this._convertInvalid(bytes, start, end); 431 return this[_convertInvalid](bytes, start, end);
372 } 432 }
373 } 433 }
374 return new core.String.fromCharCodes(bytes, start, end); 434 return new core.String.fromCharCodes(bytes, start, end);
375 } 435 }
376 _convertInvalid(bytes, start, end) { 436 [_convertInvalid](bytes, start, end) {
377 let buffer = new core.StringBuffer(); 437 let buffer = new core.StringBuffer();
378 for (let i = start; i < end; i++) { 438 for (let i = start; i < end; i++) {
379 let value = bytes.get(i); 439 let value = bytes.get(i);
380 if ((value & ~this._subsetMask) !== 0) 440 if ((value & ~this[_subsetMask]) !== 0)
381 value = 65533; 441 value = 65533;
382 buffer.writeCharCode(value); 442 buffer.writeCharCode(value);
383 } 443 }
384 return buffer.toString(); 444 return buffer.toString();
385 } 445 }
386 bind(stream) { 446 bind(stream) {
387 return dart.as(super.bind(stream), async.Stream$(core.String)); 447 return dart.as(super.bind(stream), async.Stream$(core.String));
388 } 448 }
389 } 449 }
390 class AsciiDecoder extends _UnicodeSubsetDecoder { 450 class AsciiDecoder extends _UnicodeSubsetDecoder {
391 AsciiDecoder(opt$) { 451 AsciiDecoder(opt$) {
392 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d; 452 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d;
393 super._UnicodeSubsetDecoder(allowInvalid, _ASCII_MASK); 453 super._UnicodeSubsetDecoder(allowInvalid, _ASCII_MASK);
394 } 454 }
395 startChunkedConversion(sink) { 455 startChunkedConversion(sink) {
396 let stringSink = null; 456 let stringSink = null;
397 if (dart.is(sink, StringConversionSink)) { 457 if (dart.is(sink, StringConversionSink)) {
398 stringSink = sink; 458 stringSink = sink;
399 } else { 459 } else {
400 stringSink = new StringConversionSink.from(sink); 460 stringSink = new StringConversionSink.from(sink);
401 } 461 }
402 if (this._allowInvalid) { 462 if (this[_allowInvalid]) {
403 return new _ErrorHandlingAsciiDecoderSink(stringSink.asUtf8Sink(false)); 463 return new _ErrorHandlingAsciiDecoderSink(stringSink.asUtf8Sink(false));
404 } else { 464 } else {
405 return new _SimpleAsciiDecoderSink(stringSink); 465 return new _SimpleAsciiDecoderSink(stringSink);
406 } 466 }
407 } 467 }
408 } 468 }
409 class _ErrorHandlingAsciiDecoderSink extends ByteConversionSinkBase { 469 class _ErrorHandlingAsciiDecoderSink extends ByteConversionSinkBase {
410 _ErrorHandlingAsciiDecoderSink(_utf8Sink) { 470 _ErrorHandlingAsciiDecoderSink($_utf8Sink) {
411 this._utf8Sink = _utf8Sink; 471 this[_utf8Sink] = $_utf8Sink;
412 super.ByteConversionSinkBase(); 472 super.ByteConversionSinkBase();
413 } 473 }
414 close() { 474 close() {
415 this._utf8Sink.close(); 475 this[_utf8Sink].close();
416 } 476 }
417 add(source) { 477 add(source) {
418 this.addSlice(source, 0, source.length, false); 478 this.addSlice(source, 0, source.length, false);
419 } 479 }
420 addSlice(source, start, end, isLast) { 480 addSlice(source, start, end, isLast) {
421 core.RangeError.checkValidRange(start, end, source.length); 481 core.RangeError.checkValidRange(start, end, source.length);
422 for (let i = start; i < end; i++) { 482 for (let i = start; i < end; i++) {
423 if ((source.get(i) & ~_ASCII_MASK) !== 0) { 483 if ((source.get(i) & ~_ASCII_MASK) !== 0) {
424 if (i > start) 484 if (i > start)
425 this._utf8Sink.addSlice(source, start, i, false); 485 this[_utf8Sink].addSlice(source, start, i, false);
426 this._utf8Sink.add(/* Unimplemented const */new List.from([239, 191, 1 89])); 486 this[_utf8Sink].add(/* Unimplemented const */new List.from([239, 191, 189]));
427 start = i + 1; 487 start = i + 1;
428 } 488 }
429 } 489 }
430 if (start < end) { 490 if (start < end) {
431 this._utf8Sink.addSlice(source, start, end, isLast); 491 this[_utf8Sink].addSlice(source, start, end, isLast);
432 } else if (isLast) { 492 } else if (isLast) {
433 this.close(); 493 this.close();
434 } 494 }
435 } 495 }
436 } 496 }
437 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase { 497 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase {
438 _SimpleAsciiDecoderSink(_sink) { 498 _SimpleAsciiDecoderSink($_sink) {
439 this._sink = _sink; 499 this[_sink] = $_sink;
440 super.ByteConversionSinkBase(); 500 super.ByteConversionSinkBase();
441 } 501 }
442 close() { 502 close() {
443 this._sink.close(); 503 this[_sink].close();
444 } 504 }
445 add(source) { 505 add(source) {
446 for (let i = 0; i < source.length; i++) { 506 for (let i = 0; i < source.length; i++) {
447 if ((source.get(i) & ~_ASCII_MASK) !== 0) { 507 if ((source.get(i) & ~_ASCII_MASK) !== 0) {
448 throw new core.FormatException("Source contains non-ASCII bytes."); 508 throw new core.FormatException("Source contains non-ASCII bytes.");
449 } 509 }
450 } 510 }
451 this._sink.add(new core.String.fromCharCodes(source)); 511 this[_sink].add(new core.String.fromCharCodes(source));
452 } 512 }
453 addSlice(source, start, end, isLast) { 513 addSlice(source, start, end, isLast) {
454 let length = source.length; 514 let length = source.length;
455 core.RangeError.checkValidRange(start, end, length); 515 core.RangeError.checkValidRange(start, end, length);
456 if (start < end) { 516 if (start < end) {
457 if (dart.notNull(start !== 0) || dart.notNull(end !== length)) { 517 if (dart.notNull(start !== 0) || dart.notNull(end !== length)) {
458 source = source.sublist(start, end); 518 source = source.sublist(start, end);
459 } 519 }
460 this.add(source); 520 this.add(source);
461 } 521 }
(...skipping 15 matching lines...) Expand all
477 dart.defineNamedConstructor(ByteConversionSink, 'withCallback'); 537 dart.defineNamedConstructor(ByteConversionSink, 'withCallback');
478 dart.defineNamedConstructor(ByteConversionSink, 'from'); 538 dart.defineNamedConstructor(ByteConversionSink, 'from');
479 class ByteConversionSinkBase extends ByteConversionSink { 539 class ByteConversionSinkBase extends ByteConversionSink {
480 addSlice(chunk, start, end, isLast) { 540 addSlice(chunk, start, end, isLast) {
481 this.add(chunk.sublist(start, end)); 541 this.add(chunk.sublist(start, end));
482 if (isLast) 542 if (isLast)
483 this.close(); 543 this.close();
484 } 544 }
485 } 545 }
486 class _ByteAdapterSink extends ByteConversionSinkBase { 546 class _ByteAdapterSink extends ByteConversionSinkBase {
487 _ByteAdapterSink(_sink) { 547 _ByteAdapterSink($_sink) {
488 this._sink = _sink; 548 this[_sink] = $_sink;
489 super.ByteConversionSinkBase(); 549 super.ByteConversionSinkBase();
490 } 550 }
491 add(chunk) { 551 add(chunk) {
492 return this._sink.add(chunk); 552 return this[_sink].add(chunk);
493 } 553 }
494 close() { 554 close() {
495 return this._sink.close(); 555 return this[_sink].close();
496 } 556 }
497 } 557 }
498 class _ByteCallbackSink extends ByteConversionSinkBase { 558 class _ByteCallbackSink extends ByteConversionSinkBase {
499 _ByteCallbackSink(callback) { 559 _ByteCallbackSink(callback) {
500 this._buffer = new typed_data.Uint8List(dart.as(_INITIAL_BUFFER_SIZE, core .int)); 560 this[_buffer] = new typed_data.Uint8List(dart.as(_INITIAL_BUFFER_SIZE, cor e.int));
501 this._callback = callback; 561 this[_callback] = callback;
502 this._bufferIndex = 0; 562 this[_bufferIndex] = 0;
503 super.ByteConversionSinkBase(); 563 super.ByteConversionSinkBase();
504 } 564 }
505 add(chunk) { 565 add(chunk) {
506 let freeCount = this._buffer.length - this._bufferIndex; 566 let freeCount = this[_buffer].length - this[_bufferIndex];
507 if (chunk.length > freeCount) { 567 if (chunk.length > freeCount) {
508 let oldLength = this._buffer.length; 568 let oldLength = this[_buffer].length;
509 let newLength = _roundToPowerOf2(chunk.length + oldLength) * 2; 569 let newLength = _roundToPowerOf2(chunk.length + oldLength) * 2;
510 let grown = new typed_data.Uint8List(newLength); 570 let grown = new typed_data.Uint8List(newLength);
511 grown.setRange(0, this._buffer.length, this._buffer); 571 grown.setRange(0, this[_buffer].length, this[_buffer]);
512 this._buffer = grown; 572 this[_buffer] = grown;
513 } 573 }
514 this._buffer.setRange(this._bufferIndex, this._bufferIndex + chunk.length, chunk); 574 this[_buffer].setRange(this[_bufferIndex], this[_bufferIndex] + chunk.leng th, chunk);
515 this._bufferIndex = chunk.length; 575 this[_bufferIndex] = chunk.length;
516 } 576 }
517 static _roundToPowerOf2(v) { 577 static [_roundToPowerOf2](v) {
518 dart.assert(v > 0); 578 dart.assert(v > 0);
519 v--; 579 v--;
520 v = v >> 1; 580 v = v >> 1;
521 v = v >> 2; 581 v = v >> 2;
522 v = v >> 4; 582 v = v >> 4;
523 v = v >> 8; 583 v = v >> 8;
524 v = v >> 16; 584 v = v >> 16;
525 v++; 585 v++;
526 return v; 586 return v;
527 } 587 }
528 close() { 588 close() {
529 this._callback(this._buffer.sublist(0, this._bufferIndex)); 589 this[_callback](this[_buffer].sublist(0, this[_bufferIndex]));
530 } 590 }
531 } 591 }
532 _ByteCallbackSink._INITIAL_BUFFER_SIZE = 1024; 592 _ByteCallbackSink._INITIAL_BUFFER_SIZE = 1024;
533 let ChunkedConversionSink$ = dart.generic(function(T) { 593 let ChunkedConversionSink$ = dart.generic(function(T) {
534 class ChunkedConversionSink extends dart.Object { 594 class ChunkedConversionSink extends dart.Object {
535 ChunkedConversionSink() { 595 ChunkedConversionSink() {
536 } 596 }
537 ChunkedConversionSink$withCallback(callback) { 597 ChunkedConversionSink$withCallback(callback) {
538 return new _SimpleCallbackSink(callback); 598 return new _SimpleCallbackSink(callback);
539 } 599 }
540 } 600 }
541 dart.defineNamedConstructor(ChunkedConversionSink, 'withCallback'); 601 dart.defineNamedConstructor(ChunkedConversionSink, 'withCallback');
542 return ChunkedConversionSink; 602 return ChunkedConversionSink;
543 }); 603 });
544 let ChunkedConversionSink = ChunkedConversionSink$(dynamic); 604 let ChunkedConversionSink = ChunkedConversionSink$(dynamic);
545 let _SimpleCallbackSink$ = dart.generic(function(T) { 605 let _SimpleCallbackSink$ = dart.generic(function(T) {
546 class _SimpleCallbackSink extends ChunkedConversionSink$(T) { 606 class _SimpleCallbackSink extends ChunkedConversionSink$(T) {
547 _SimpleCallbackSink(_callback) { 607 _SimpleCallbackSink($_callback) {
548 this._accumulated = new List.from([]); 608 this[_accumulated] = new List.from([]);
549 this._callback = _callback; 609 this[_callback] = $_callback;
550 super.ChunkedConversionSink(); 610 super.ChunkedConversionSink();
551 } 611 }
552 add(chunk) { 612 add(chunk) {
553 this._accumulated.add(chunk); 613 this[_accumulated].add(chunk);
554 } 614 }
555 close() { 615 close() {
556 this._callback(this._accumulated); 616 this[_callback](this[_accumulated]);
557 } 617 }
558 } 618 }
559 return _SimpleCallbackSink; 619 return _SimpleCallbackSink;
560 }); 620 });
561 let _SimpleCallbackSink = _SimpleCallbackSink$(dynamic); 621 let _SimpleCallbackSink = _SimpleCallbackSink$(dynamic);
562 let _EventSinkAdapter$ = dart.generic(function(T) { 622 let _EventSinkAdapter$ = dart.generic(function(T) {
563 class _EventSinkAdapter extends dart.Object { 623 class _EventSinkAdapter extends dart.Object {
564 _EventSinkAdapter(_sink) { 624 _EventSinkAdapter($_sink) {
565 this._sink = _sink; 625 this[_sink] = $_sink;
566 } 626 }
567 add(data) { 627 add(data) {
568 return this._sink.add(data); 628 return this[_sink].add(data);
569 } 629 }
570 close() { 630 close() {
571 return this._sink.close(); 631 return this[_sink].close();
572 } 632 }
573 } 633 }
574 return _EventSinkAdapter; 634 return _EventSinkAdapter;
575 }); 635 });
576 let _EventSinkAdapter = _EventSinkAdapter$(dynamic); 636 let _EventSinkAdapter = _EventSinkAdapter$(dynamic);
577 let _ConverterStreamEventSink$ = dart.generic(function(S, T) { 637 let _ConverterStreamEventSink$ = dart.generic(function(S, T) {
578 class _ConverterStreamEventSink extends dart.Object { 638 class _ConverterStreamEventSink extends dart.Object {
579 _ConverterStreamEventSink(converter, sink) { 639 _ConverterStreamEventSink(converter, sink) {
580 this._eventSink = sink; 640 this[_eventSink] = sink;
581 this._chunkedSink = converter.startChunkedConversion(sink); 641 this[_chunkedSink] = converter.startChunkedConversion(sink);
582 } 642 }
583 add(o) { 643 add(o) {
584 return this._chunkedSink.add(o); 644 return this[_chunkedSink].add(o);
585 } 645 }
586 addError(error, stackTrace) { 646 addError(error, stackTrace) {
587 if (stackTrace === void 0) 647 if (stackTrace === void 0)
588 stackTrace = null; 648 stackTrace = null;
589 this._eventSink.addError(error, stackTrace); 649 this[_eventSink].addError(error, stackTrace);
590 } 650 }
591 close() { 651 close() {
592 return this._chunkedSink.close(); 652 return this[_chunkedSink].close();
593 } 653 }
594 } 654 }
595 return _ConverterStreamEventSink; 655 return _ConverterStreamEventSink;
596 }); 656 });
597 let _ConverterStreamEventSink = _ConverterStreamEventSink$(dynamic, dynamic); 657 let _ConverterStreamEventSink = _ConverterStreamEventSink$(dynamic, dynamic);
598 let Codec$ = dart.generic(function(S, T) { 658 let Codec$ = dart.generic(function(S, T) {
599 class Codec extends dart.Object { 659 class Codec extends dart.Object {
600 Codec() { 660 Codec() {
601 } 661 }
602 encode(input) { 662 encode(input) {
603 return this.encoder.convert(input); 663 return this.encoder.convert(input);
604 } 664 }
605 decode(encoded) { 665 decode(encoded) {
606 return this.decoder.convert(encoded); 666 return this.decoder.convert(encoded);
607 } 667 }
608 fuse(other) { 668 fuse(other) {
609 return new _FusedCodec(this, other); 669 return new _FusedCodec(this, other);
610 } 670 }
611 get inverted() { 671 get inverted() {
612 return new _InvertedCodec(this); 672 return new _InvertedCodec(this);
613 } 673 }
614 } 674 }
615 return Codec; 675 return Codec;
616 }); 676 });
617 let Codec = Codec$(dynamic, dynamic); 677 let Codec = Codec$(dynamic, dynamic);
618 let _FusedCodec$ = dart.generic(function(S, M, T) { 678 let _FusedCodec$ = dart.generic(function(S, M, T) {
619 class _FusedCodec extends Codec$(S, T) { 679 class _FusedCodec extends Codec$(S, T) {
620 get encoder() { 680 get encoder() {
621 return dart.as(this._first.encoder.fuse(this._second.encoder), Converter $(S, T)); 681 return dart.as(this[_first].encoder.fuse(this[_second].encoder), Convert er$(S, T));
622 } 682 }
623 get decoder() { 683 get decoder() {
624 return dart.as(this._second.decoder.fuse(this._first.decoder), Converter $(T, S)); 684 return dart.as(this[_second].decoder.fuse(this[_first].decoder), Convert er$(T, S));
625 } 685 }
626 _FusedCodec(_first, _second) { 686 _FusedCodec($_first, $_second) {
627 this._first = _first; 687 this[_first] = $_first;
628 this._second = _second; 688 this[_second] = $_second;
629 super.Codec(); 689 super.Codec();
630 } 690 }
631 } 691 }
632 return _FusedCodec; 692 return _FusedCodec;
633 }); 693 });
634 let _FusedCodec = _FusedCodec$(dynamic, dynamic, dynamic); 694 let _FusedCodec = _FusedCodec$(dynamic, dynamic, dynamic);
635 let _InvertedCodec$ = dart.generic(function(T, S) { 695 let _InvertedCodec$ = dart.generic(function(T, S) {
636 class _InvertedCodec extends Codec$(T, S) { 696 class _InvertedCodec extends Codec$(T, S) {
637 _InvertedCodec(codec) { 697 _InvertedCodec(codec) {
638 this._codec = codec; 698 this[_codec] = codec;
639 super.Codec(); 699 super.Codec();
640 } 700 }
641 get encoder() { 701 get encoder() {
642 return this._codec.decoder; 702 return this[_codec].decoder;
643 } 703 }
644 get decoder() { 704 get decoder() {
645 return this._codec.encoder; 705 return this[_codec].encoder;
646 } 706 }
647 get inverted() { 707 get inverted() {
648 return this._codec; 708 return this[_codec];
649 } 709 }
650 } 710 }
651 return _InvertedCodec; 711 return _InvertedCodec;
652 }); 712 });
653 let _InvertedCodec = _InvertedCodec$(dynamic, dynamic); 713 let _InvertedCodec = _InvertedCodec$(dynamic, dynamic);
654 let Converter$ = dart.generic(function(S, T) { 714 let Converter$ = dart.generic(function(S, T) {
655 class Converter extends dart.Object { 715 class Converter extends dart.Object {
656 Converter() { 716 Converter() {
657 } 717 }
658 fuse(other) { 718 fuse(other) {
659 return new _FusedConverter(this, other); 719 return new _FusedConverter(this, other);
660 } 720 }
661 startChunkedConversion(sink) { 721 startChunkedConversion(sink) {
662 throw new core.UnsupportedError(`This converter does not support chunked conversions: ${this}`); 722 throw new core.UnsupportedError(`This converter does not support chunked conversions: ${this}`);
663 } 723 }
664 bind(source) { 724 bind(source) {
665 return new async.Stream.eventTransformed(source, ((sink) => new _Convert erStreamEventSink(this, sink)).bind(this)); 725 return new async.Stream.eventTransformed(source, ((sink) => new _Convert erStreamEventSink(this, sink)).bind(this));
666 } 726 }
667 } 727 }
668 return Converter; 728 return Converter;
669 }); 729 });
670 let Converter = Converter$(dynamic, dynamic); 730 let Converter = Converter$(dynamic, dynamic);
671 let _FusedConverter$ = dart.generic(function(S, M, T) { 731 let _FusedConverter$ = dart.generic(function(S, M, T) {
672 class _FusedConverter extends Converter$(S, T) { 732 class _FusedConverter extends Converter$(S, T) {
673 _FusedConverter(_first, _second) { 733 _FusedConverter($_first, $_second) {
674 this._first = _first; 734 this[_first] = $_first;
675 this._second = _second; 735 this[_second] = $_second;
676 super.Converter(); 736 super.Converter();
677 } 737 }
678 convert(input) { 738 convert(input) {
679 return dart.as(this._second.convert(this._first.convert(input)), T); 739 return dart.as(this[_second].convert(this[_first].convert(input)), T);
680 } 740 }
681 startChunkedConversion(sink) { 741 startChunkedConversion(sink) {
682 return this._first.startChunkedConversion(this._second.startChunkedConve rsion(sink)); 742 return this[_first].startChunkedConversion(this[_second].startChunkedCon version(sink));
683 } 743 }
684 } 744 }
685 return _FusedConverter; 745 return _FusedConverter;
686 }); 746 });
687 let _FusedConverter = _FusedConverter$(dynamic, dynamic, dynamic); 747 let _FusedConverter = _FusedConverter$(dynamic, dynamic, dynamic);
688 class Encoding extends Codec$(core.String, core.List$(core.int)) { 748 class Encoding extends Codec$(core.String, core.List$(core.int)) {
689 Encoding() { 749 Encoding() {
690 super.Codec(); 750 super.Codec();
691 } 751 }
692 decodeStream(byteStream) { 752 decodeStream(byteStream) {
693 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)); 753 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));
694 } 754 }
695 static getByName(name) { 755 static getByName(name) {
696 if (name === null) 756 if (name === null)
697 return null; 757 return null;
698 name = name.toLowerCase(); 758 name = name.toLowerCase();
699 return _nameToEncoding.get(name); 759 return _nameToEncoding.get(name);
700 } 760 }
701 } 761 }
702 dart.defineLazyProperties(Encoding, { 762 dart.defineLazyProperties(Encoding, {
703 get _nameToEncoding() { 763 get _nameToEncoding() {
704 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}); 764 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});
705 }, 765 },
706 set _nameToEncoding() {} 766 set _nameToEncoding() {}
707 }); 767 });
708 let HTML_ESCAPE = new HtmlEscape(); 768 let HTML_ESCAPE = new HtmlEscape();
709 class HtmlEscapeMode extends dart.Object { 769 class HtmlEscapeMode extends dart.Object {
710 HtmlEscapeMode$_(_name, escapeLtGt, escapeQuot, escapeApos, escapeSlash) { 770 HtmlEscapeMode$_($_name, escapeLtGt, escapeQuot, escapeApos, escapeSlash) {
711 this._name = _name; 771 this[_name] = $_name;
712 this.escapeLtGt = escapeLtGt; 772 this.escapeLtGt = escapeLtGt;
713 this.escapeQuot = escapeQuot; 773 this.escapeQuot = escapeQuot;
714 this.escapeApos = escapeApos; 774 this.escapeApos = escapeApos;
715 this.escapeSlash = escapeSlash; 775 this.escapeSlash = escapeSlash;
716 } 776 }
717 toString() { 777 toString() {
718 return this._name; 778 return this[_name];
719 } 779 }
720 } 780 }
721 dart.defineNamedConstructor(HtmlEscapeMode, '_'); 781 dart.defineNamedConstructor(HtmlEscapeMode, '_');
722 HtmlEscapeMode.UNKNOWN = new HtmlEscapeMode._('unknown', true, true, true, tru e); 782 HtmlEscapeMode.UNKNOWN = new HtmlEscapeMode._('unknown', true, true, true, tru e);
723 HtmlEscapeMode.ATTRIBUTE = new HtmlEscapeMode._('attribute', false, true, fals e, false); 783 HtmlEscapeMode.ATTRIBUTE = new HtmlEscapeMode._('attribute', false, true, fals e, false);
724 HtmlEscapeMode.ELEMENT = new HtmlEscapeMode._('element', true, false, false, t rue); 784 HtmlEscapeMode.ELEMENT = new HtmlEscapeMode._('element', true, false, false, t rue);
725 class HtmlEscape extends Converter$(core.String, core.String) { 785 class HtmlEscape extends Converter$(core.String, core.String) {
726 HtmlEscape(mode) { 786 HtmlEscape(mode) {
727 if (mode === void 0) 787 if (mode === void 0)
728 mode = HtmlEscapeMode.UNKNOWN; 788 mode = HtmlEscapeMode.UNKNOWN;
729 this.mode = mode; 789 this.mode = mode;
730 super.Converter(); 790 super.Converter();
731 } 791 }
732 convert(text) { 792 convert(text) {
733 let val = this._convert(text, 0, text.length); 793 let val = this[_convert](text, 0, text.length);
734 return val === null ? text : val; 794 return val === null ? text : val;
735 } 795 }
736 _convert(text, start, end) { 796 [_convert](text, start, end) {
737 let result = null; 797 let result = null;
738 for (let i = start; i < end; i++) { 798 for (let i = start; i < end; i++) {
739 let ch = text.get(i); 799 let ch = text.get(i);
740 let replace = null; 800 let replace = null;
741 switch (ch) { 801 switch (ch) {
742 case '&': 802 case '&':
743 replace = '&amp;'; 803 replace = '&amp;';
744 break; 804 break;
745 case ' ': 805 case ' ':
746 replace = '&nbsp;'; 806 replace = '&nbsp;';
(...skipping 30 matching lines...) Expand all
777 return dart.as(result !== null ? result.toString() : null, core.String); 837 return dart.as(result !== null ? result.toString() : null, core.String);
778 } 838 }
779 startChunkedConversion(sink) { 839 startChunkedConversion(sink) {
780 if (!dart.is(sink, StringConversionSink)) { 840 if (!dart.is(sink, StringConversionSink)) {
781 sink = new StringConversionSink.from(sink); 841 sink = new StringConversionSink.from(sink);
782 } 842 }
783 return new _HtmlEscapeSink(this, dart.as(sink, StringConversionSink)); 843 return new _HtmlEscapeSink(this, dart.as(sink, StringConversionSink));
784 } 844 }
785 } 845 }
786 class _HtmlEscapeSink extends StringConversionSinkBase { 846 class _HtmlEscapeSink extends StringConversionSinkBase {
787 _HtmlEscapeSink(_escape, _sink) { 847 _HtmlEscapeSink($_escape, $_sink) {
788 this._escape = _escape; 848 this[_escape] = $_escape;
789 this._sink = _sink; 849 this[_sink] = $_sink;
790 super.StringConversionSinkBase(); 850 super.StringConversionSinkBase();
791 } 851 }
792 addSlice(chunk, start, end, isLast) { 852 addSlice(chunk, start, end, isLast) {
793 let val = this._escape._convert(chunk, start, end); 853 let val = this[_escape]._convert(chunk, start, end);
794 if (val === null) { 854 if (val === null) {
795 this._sink.addSlice(chunk, start, end, isLast); 855 this[_sink].addSlice(chunk, start, end, isLast);
796 } else { 856 } else {
797 this._sink.add(val); 857 this[_sink].add(val);
798 if (isLast) 858 if (isLast)
799 this._sink.close(); 859 this[_sink].close();
800 } 860 }
801 } 861 }
802 close() { 862 close() {
803 return this._sink.close(); 863 return this[_sink].close();
804 } 864 }
805 } 865 }
806 class JsonUnsupportedObjectError extends core.Error { 866 class JsonUnsupportedObjectError extends core.Error {
807 JsonUnsupportedObjectError(unsupportedObject, opt$) { 867 JsonUnsupportedObjectError(unsupportedObject, opt$) {
808 let cause = opt$.cause === void 0 ? null : opt$.cause; 868 let cause = opt$.cause === void 0 ? null : opt$.cause;
809 this.unsupportedObject = unsupportedObject; 869 this.unsupportedObject = unsupportedObject;
810 this.cause = cause; 870 this.cause = cause;
811 super.Error(); 871 super.Error();
812 } 872 }
813 toString() { 873 toString() {
(...skipping 10 matching lines...) Expand all
824 } 884 }
825 toString() { 885 toString() {
826 return "Cyclic error in JSON stringify"; 886 return "Cyclic error in JSON stringify";
827 } 887 }
828 } 888 }
829 let JSON = new JsonCodec(); 889 let JSON = new JsonCodec();
830 class JsonCodec extends Codec$(core.Object, core.String) { 890 class JsonCodec extends Codec$(core.Object, core.String) {
831 JsonCodec(opt$) { 891 JsonCodec(opt$) {
832 let reviver = opt$.reviver === void 0 ? null : opt$.reviver; 892 let reviver = opt$.reviver === void 0 ? null : opt$.reviver;
833 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable; 893 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable;
834 this._reviver = reviver; 894 this[_reviver] = reviver;
835 this._toEncodable = toEncodable; 895 this[_toEncodable] = toEncodable;
836 super.Codec(); 896 super.Codec();
837 } 897 }
838 JsonCodec$withReviver(reviver) { 898 JsonCodec$withReviver(reviver) {
839 this.JsonCodec({reviver: reviver}); 899 this.JsonCodec({reviver: reviver});
840 } 900 }
841 decode(source, opt$) { 901 decode(source, opt$) {
842 let reviver = opt$.reviver === void 0 ? null : opt$.reviver; 902 let reviver = opt$.reviver === void 0 ? null : opt$.reviver;
843 if (reviver === null) 903 if (reviver === null)
844 reviver = this._reviver; 904 reviver = this[_reviver];
845 if (reviver === null) 905 if (reviver === null)
846 return this.decoder.convert(source); 906 return this.decoder.convert(source);
847 return new JsonDecoder(reviver).convert(source); 907 return new JsonDecoder(reviver).convert(source);
848 } 908 }
849 encode(value, opt$) { 909 encode(value, opt$) {
850 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable; 910 let toEncodable = opt$.toEncodable === void 0 ? null : opt$.toEncodable;
851 if (toEncodable === null) 911 if (toEncodable === null)
852 toEncodable = this._toEncodable; 912 toEncodable = this[_toEncodable];
853 if (toEncodable === null) 913 if (toEncodable === null)
854 return this.encoder.convert(value); 914 return this.encoder.convert(value);
855 return new JsonEncoder(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))).convert(value); 915 return new JsonEncoder(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))).convert(value);
856 } 916 }
857 get encoder() { 917 get encoder() {
858 if (this._toEncodable === null) 918 if (this[_toEncodable] === null)
859 return new JsonEncoder(); 919 return new JsonEncoder();
860 return new JsonEncoder(dart.as(this._toEncodable, dart.throw_("Unimplement ed type (Object) → Object"))); 920 return new JsonEncoder(dart.as(this[_toEncodable], dart.throw_("Unimplemen ted type (Object) → Object")));
861 } 921 }
862 get decoder() { 922 get decoder() {
863 if (this._reviver === null) 923 if (this[_reviver] === null)
864 return new JsonDecoder(); 924 return new JsonDecoder();
865 return new JsonDecoder(this._reviver); 925 return new JsonDecoder(this[_reviver]);
866 } 926 }
867 } 927 }
868 dart.defineNamedConstructor(JsonCodec, 'withReviver'); 928 dart.defineNamedConstructor(JsonCodec, 'withReviver');
869 class JsonEncoder extends Converter$(core.Object, core.String) { 929 class JsonEncoder extends Converter$(core.Object, core.String) {
870 JsonEncoder(toEncodable) { 930 JsonEncoder(toEncodable) {
871 if (toEncodable === void 0) 931 if (toEncodable === void 0)
872 toEncodable = null; 932 toEncodable = null;
873 this.indent = null; 933 this.indent = null;
874 this._toEncodable = toEncodable; 934 this[_toEncodable] = toEncodable;
875 super.Converter(); 935 super.Converter();
876 } 936 }
877 JsonEncoder$withIndent(indent, toEncodable) { 937 JsonEncoder$withIndent(indent, toEncodable) {
878 if (toEncodable === void 0) 938 if (toEncodable === void 0)
879 toEncodable = null; 939 toEncodable = null;
880 this.indent = indent; 940 this.indent = indent;
881 this._toEncodable = toEncodable; 941 this[_toEncodable] = toEncodable;
882 super.Converter(); 942 super.Converter();
883 } 943 }
884 convert(object) { 944 convert(object) {
885 return _JsonStringStringifier.stringify(object, dart.as(this._toEncodable, dart.throw_("Unimplemented type (dynamic) → dynamic")), this.indent); 945 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable] , dart.throw_("Unimplemented type (dynamic) → dynamic")), this.indent);
886 } 946 }
887 startChunkedConversion(sink) { 947 startChunkedConversion(sink) {
888 if (!dart.is(sink, StringConversionSink)) { 948 if (!dart.is(sink, StringConversionSink)) {
889 sink = new StringConversionSink.from(sink); 949 sink = new StringConversionSink.from(sink);
890 } else if (dart.is(sink, _Utf8EncoderSink)) { 950 } else if (dart.is(sink, _Utf8EncoderSink)) {
891 return new _JsonUtf8EncoderSink(sink._sink, this._toEncodable, JsonUtf8E ncoder._utf8Encode(this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); 951 return new _JsonUtf8EncoderSink(sink[_sink], this[_toEncodable], JsonUtf 8Encoder._utf8Encode(this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE);
892 } 952 }
893 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this._toE ncodable, this.indent); 953 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this[_toE ncodable], this.indent);
894 } 954 }
895 bind(stream) { 955 bind(stream) {
896 return dart.as(super.bind(stream), async.Stream$(core.String)); 956 return dart.as(super.bind(stream), async.Stream$(core.String));
897 } 957 }
898 fuse(other) { 958 fuse(other) {
899 if (dart.is(other, Utf8Encoder)) { 959 if (dart.is(other, Utf8Encoder)) {
900 return new JsonUtf8Encoder(this.indent, dart.as(this._toEncodable, dart. throw_("Unimplemented type (Object) → dynamic"))); 960 return new JsonUtf8Encoder(this.indent, dart.as(this[_toEncodable], dart .throw_("Unimplemented type (Object) → dynamic")));
901 } 961 }
902 return super.fuse(other); 962 return super.fuse(other);
903 } 963 }
904 } 964 }
905 dart.defineNamedConstructor(JsonEncoder, 'withIndent'); 965 dart.defineNamedConstructor(JsonEncoder, 'withIndent');
906 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) { 966 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) {
907 JsonUtf8Encoder(indent, toEncodable, bufferSize) { 967 JsonUtf8Encoder(indent, toEncodable, bufferSize) {
908 if (indent === void 0) 968 if (indent === void 0)
909 indent = null; 969 indent = null;
910 if (toEncodable === void 0) 970 if (toEncodable === void 0)
911 toEncodable = null; 971 toEncodable = null;
912 if (bufferSize === void 0) 972 if (bufferSize === void 0)
913 bufferSize = DEFAULT_BUFFER_SIZE; 973 bufferSize = DEFAULT_BUFFER_SIZE;
914 this._indent = _utf8Encode(indent); 974 this[_indent] = _utf8Encode(indent);
915 this._toEncodable = toEncodable; 975 this[_toEncodable] = toEncodable;
916 this._bufferSize = bufferSize; 976 this[_bufferSize] = bufferSize;
917 super.Converter(); 977 super.Converter();
918 } 978 }
919 static _utf8Encode(string) { 979 static [_utf8Encode](string) {
920 if (string === null) 980 if (string === null)
921 return null; 981 return null;
922 if (string.isEmpty) 982 if (string.isEmpty)
923 return new typed_data.Uint8List(0); 983 return new typed_data.Uint8List(0);
924 checkAscii: { 984 checkAscii: {
925 for (let i = 0; i < string.length; i++) { 985 for (let i = 0; i < string.length; i++) {
926 if (string.codeUnitAt(i) >= 128) 986 if (string.codeUnitAt(i) >= 128)
927 break checkAscii; 987 break checkAscii;
928 } 988 }
929 return string.codeUnits; 989 return string.codeUnits;
930 } 990 }
931 return UTF8.encode(string); 991 return UTF8.encode(string);
932 } 992 }
933 convert(object) { 993 convert(object) {
934 let bytes = dart.as(new List.from([]), core.List$(core.List$(core.int))); 994 let bytes = dart.as(new List.from([]), core.List$(core.List$(core.int)));
935 // Function addChunk: (Uint8List, int, int) → void 995 // Function addChunk: (Uint8List, int, int) → void
936 function addChunk(chunk, start, end) { 996 function addChunk(chunk, start, end) {
937 if (dart.notNull(start > 0) || dart.notNull(end < chunk.length)) { 997 if (dart.notNull(start > 0) || dart.notNull(end < chunk.length)) {
938 let length = end - start; 998 let length = end - start;
939 chunk = new typed_data.Uint8List.view(chunk.buffer, chunk.offsetInByte s + start, length); 999 chunk = new typed_data.Uint8List.view(chunk.buffer, chunk.offsetInByte s + start, length);
940 } 1000 }
941 bytes.add(chunk); 1001 bytes.add(chunk);
942 } 1002 }
943 _JsonUtf8Stringifier.stringify(object, this._indent, dart.as(this._toEncod able, dart.throw_("Unimplemented type (Object) → dynamic")), this._bufferSize, a ddChunk); 1003 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize] , addChunk);
944 if (bytes.length === 1) 1004 if (bytes.length === 1)
945 return bytes.get(0); 1005 return bytes.get(0);
946 let length = 0; 1006 let length = 0;
947 for (let i = 0; i < bytes.length; i++) { 1007 for (let i = 0; i < bytes.length; i++) {
948 length = bytes.get(i).length; 1008 length = bytes.get(i).length;
949 } 1009 }
950 let result = new typed_data.Uint8List(length); 1010 let result = new typed_data.Uint8List(length);
951 for (let i = 0, offset = 0; i < bytes.length; i++) { 1011 for (let i = 0, offset = 0; i < bytes.length; i++) {
952 let byteList = bytes.get(i); 1012 let byteList = bytes.get(i);
953 let end = offset + byteList.length; 1013 let end = offset + byteList.length;
954 result.setRange(offset, end, byteList); 1014 result.setRange(offset, end, byteList);
955 offset = end; 1015 offset = end;
956 } 1016 }
957 return result; 1017 return result;
958 } 1018 }
959 startChunkedConversion(sink) { 1019 startChunkedConversion(sink) {
960 let byteSink = null; 1020 let byteSink = null;
961 if (dart.is(sink, ByteConversionSink)) { 1021 if (dart.is(sink, ByteConversionSink)) {
962 byteSink = sink; 1022 byteSink = sink;
963 } else { 1023 } else {
964 byteSink = new ByteConversionSink.from(sink); 1024 byteSink = new ByteConversionSink.from(sink);
965 } 1025 }
966 return new _JsonUtf8EncoderSink(byteSink, this._toEncodable, this._indent, this._bufferSize); 1026 return new _JsonUtf8EncoderSink(byteSink, this[_toEncodable], this[_indent ], this[_bufferSize]);
967 } 1027 }
968 bind(stream) { 1028 bind(stream) {
969 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int))); 1029 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int)));
970 } 1030 }
971 fuse(other) { 1031 fuse(other) {
972 return super.fuse(other); 1032 return super.fuse(other);
973 } 1033 }
974 } 1034 }
975 JsonUtf8Encoder.DEFAULT_BUFFER_SIZE = 256; 1035 JsonUtf8Encoder.DEFAULT_BUFFER_SIZE = 256;
976 class _JsonEncoderSink extends ChunkedConversionSink$(core.Object) { 1036 class _JsonEncoderSink extends ChunkedConversionSink$(core.Object) {
977 _JsonEncoderSink(_sink, _toEncodable, _indent) { 1037 _JsonEncoderSink($_sink, $_toEncodable, $_indent) {
978 this._sink = _sink; 1038 this[_sink] = $_sink;
979 this._toEncodable = _toEncodable; 1039 this[_toEncodable] = $_toEncodable;
980 this._indent = _indent; 1040 this[_indent] = $_indent;
981 this._isDone = false; 1041 this[_isDone] = false;
982 super.ChunkedConversionSink(); 1042 super.ChunkedConversionSink();
983 } 1043 }
984 add(o) { 1044 add(o) {
985 if (this._isDone) { 1045 if (this[_isDone]) {
986 throw new core.StateError("Only one call to add allowed"); 1046 throw new core.StateError("Only one call to add allowed");
987 } 1047 }
988 this._isDone = true; 1048 this[_isDone] = true;
989 let stringSink = this._sink.asStringSink(); 1049 let stringSink = this[_sink].asStringSink();
990 _JsonStringStringifier.printOn(o, stringSink, dart.as(this._toEncodable, d art.throw_("Unimplemented type (dynamic) → dynamic")), this._indent); 1050 _JsonStringStringifier.printOn(o, stringSink, dart.as(this[_toEncodable], dart.throw_("Unimplemented type (dynamic) → dynamic")), this[_indent]);
991 stringSink.close(); 1051 stringSink.close();
992 } 1052 }
993 close() {} 1053 close() {}
994 } 1054 }
995 class _JsonUtf8EncoderSink extends ChunkedConversionSink$(core.Object) { 1055 class _JsonUtf8EncoderSink extends ChunkedConversionSink$(core.Object) {
996 _JsonUtf8EncoderSink(_sink, _toEncodable, _indent, _bufferSize) { 1056 _JsonUtf8EncoderSink($_sink, $_toEncodable, $_indent, $_bufferSize) {
997 this._sink = _sink; 1057 this[_sink] = $_sink;
998 this._toEncodable = _toEncodable; 1058 this[_toEncodable] = $_toEncodable;
999 this._indent = _indent; 1059 this[_indent] = $_indent;
1000 this._bufferSize = _bufferSize; 1060 this[_bufferSize] = $_bufferSize;
1001 this._isDone = false; 1061 this[_isDone] = false;
1002 super.ChunkedConversionSink(); 1062 super.ChunkedConversionSink();
1003 } 1063 }
1004 _addChunk(chunk, start, end) { 1064 [_addChunk](chunk, start, end) {
1005 this._sink.addSlice(chunk, start, end, false); 1065 this[_sink].addSlice(chunk, start, end, false);
1006 } 1066 }
1007 add(object) { 1067 add(object) {
1008 if (this._isDone) { 1068 if (this[_isDone]) {
1009 throw new core.StateError("Only one call to add allowed"); 1069 throw new core.StateError("Only one call to add allowed");
1010 } 1070 }
1011 this._isDone = true; 1071 this[_isDone] = true;
1012 _JsonUtf8Stringifier.stringify(object, this._indent, dart.as(this._toEncod able, dart.throw_("Unimplemented type (Object) → dynamic")), this._bufferSize, t his._addChunk); 1072 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize] , this[_addChunk]);
1013 this._sink.close(); 1073 this[_sink].close();
1014 } 1074 }
1015 close() { 1075 close() {
1016 if (!dart.notNull(this._isDone)) { 1076 if (!dart.notNull(this[_isDone])) {
1017 this._isDone = true; 1077 this[_isDone] = true;
1018 this._sink.close(); 1078 this[_sink].close();
1019 } 1079 }
1020 } 1080 }
1021 } 1081 }
1022 class JsonDecoder extends Converter$(core.String, core.Object) { 1082 class JsonDecoder extends Converter$(core.String, core.Object) {
1023 JsonDecoder(reviver) { 1083 JsonDecoder(reviver) {
1024 if (reviver === void 0) 1084 if (reviver === void 0)
1025 reviver = null; 1085 reviver = null;
1026 this._reviver = reviver; 1086 this[_reviver] = reviver;
1027 super.Converter(); 1087 super.Converter();
1028 } 1088 }
1029 convert(input) { 1089 convert(input) {
1030 return _parseJson(input, this._reviver); 1090 return _parseJson(input, this[_reviver]);
1031 } 1091 }
1032 startChunkedConversion(sink) { 1092 startChunkedConversion(sink) {
1033 return new _JsonDecoderSink(this._reviver, sink); 1093 return new _JsonDecoderSink(this[_reviver], sink);
1034 } 1094 }
1035 bind(stream) { 1095 bind(stream) {
1036 return dart.as(super.bind(stream), async.Stream$(core.Object)); 1096 return dart.as(super.bind(stream), async.Stream$(core.Object));
1037 } 1097 }
1038 } 1098 }
1039 // Function _parseJson: (String, (dynamic, dynamic) → dynamic) → dynamic 1099 // Function _parseJson: (String, (dynamic, dynamic) → dynamic) → dynamic
1040 function _parseJson(source, reviver) { 1100 function _parseJson(source, reviver) {
1041 if (!(typeof source == string)) 1101 if (!(typeof source == string))
1042 throw new core.ArgumentError(source); 1102 throw new core.ArgumentError(source);
1043 let parsed = null; 1103 let parsed = null;
1044 try { 1104 try {
1045 parsed = JSON.parse(source); 1105 parsed = JSON.parse(source);
1046 } catch (e) { 1106 } catch (e) {
1047 throw new core.FormatException(String(e)); 1107 throw new core.FormatException(String(e));
1048 } 1108 }
1049 1109
1050 if (reviver === null) { 1110 if (reviver === null) {
1051 return _convertJsonToDartLazy(parsed); 1111 return _convertJsonToDartLazy(parsed);
1052 } else { 1112 } else {
1053 return _convertJsonToDart(parsed, reviver); 1113 return _convertJsonToDart(parsed, reviver);
1054 } 1114 }
1055 } 1115 }
1056 // Function _defaultToEncodable: (dynamic) → Object 1116 // Function _defaultToEncodable: (dynamic) → Object
1057 function _defaultToEncodable(object) { 1117 function _defaultToEncodable(object) {
1058 return dart.dinvoke(object, 'toJson'); 1118 return dart.dinvoke(object, 'toJson');
1059 } 1119 }
1060 class _JsonStringifier extends dart.Object { 1120 class _JsonStringifier extends dart.Object {
1061 _JsonStringifier(_toEncodable) { 1121 _JsonStringifier(_toEncodable) {
1062 this._seen = new core.List(); 1122 this[_seen] = new core.List();
1063 this._toEncodable = dart.as(_toEncodable !== null ? _toEncodable : _defaul tToEncodable, core.Function); 1123 this[_toEncodable] = dart.as(_toEncodable !== null ? _toEncodable : _defau ltToEncodable, core.Function);
1064 } 1124 }
1065 static hexDigit(x) { 1125 static hexDigit(x) {
1066 return x < 10 ? 48 + x : 87 + x; 1126 return x < 10 ? 48 + x : 87 + x;
1067 } 1127 }
1068 writeStringContent(s) { 1128 writeStringContent(s) {
1069 let offset = 0; 1129 let offset = 0;
1070 let length = s.length; 1130 let length = s.length;
1071 for (let i = 0; i < length; i++) { 1131 for (let i = 0; i < length; i++) {
1072 let charCode = s.codeUnitAt(i); 1132 let charCode = s.codeUnitAt(i);
1073 if (charCode > BACKSLASH) 1133 if (charCode > BACKSLASH)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 this.writeCharCode(BACKSLASH); 1168 this.writeCharCode(BACKSLASH);
1109 this.writeCharCode(charCode); 1169 this.writeCharCode(charCode);
1110 } 1170 }
1111 } 1171 }
1112 if (offset === 0) { 1172 if (offset === 0) {
1113 this.writeString(s); 1173 this.writeString(s);
1114 } else if (offset < length) { 1174 } else if (offset < length) {
1115 this.writeStringSlice(s, offset, length); 1175 this.writeStringSlice(s, offset, length);
1116 } 1176 }
1117 } 1177 }
1118 _checkCycle(object) { 1178 [_checkCycle](object) {
1119 for (let i = 0; i < this._seen.length; i++) { 1179 for (let i = 0; i < this[_seen].length; i++) {
1120 if (core.identical(object, this._seen.get(i))) { 1180 if (core.identical(object, this[_seen].get(i))) {
1121 throw new JsonCyclicError(object); 1181 throw new JsonCyclicError(object);
1122 } 1182 }
1123 } 1183 }
1124 this._seen.add(object); 1184 this[_seen].add(object);
1125 } 1185 }
1126 _removeSeen(object) { 1186 [_removeSeen](object) {
1127 dart.assert(!dart.notNull(this._seen.isEmpty)); 1187 dart.assert(!dart.notNull(this[_seen].isEmpty));
1128 dart.assert(core.identical(this._seen.last, object)); 1188 dart.assert(core.identical(this[_seen].last, object));
1129 this._seen.removeLast(); 1189 this[_seen].removeLast();
1130 } 1190 }
1131 writeObject(object) { 1191 writeObject(object) {
1132 if (this.writeJsonValue(object)) 1192 if (this.writeJsonValue(object))
1133 return; 1193 return;
1134 this._checkCycle(object); 1194 this[_checkCycle](object);
1135 try { 1195 try {
1136 let customJson = dart.dinvokef(this._toEncodable, object); 1196 let customJson = dart.dinvokef(this[_toEncodable], object);
1137 if (!dart.notNull(this.writeJsonValue(customJson))) { 1197 if (!dart.notNull(this.writeJsonValue(customJson))) {
1138 throw new JsonUnsupportedObjectError(object); 1198 throw new JsonUnsupportedObjectError(object);
1139 } 1199 }
1140 this._removeSeen(object); 1200 this[_removeSeen](object);
1141 } catch (e) { 1201 } catch (e) {
1142 throw new JsonUnsupportedObjectError(object, {cause: e}); 1202 throw new JsonUnsupportedObjectError(object, {cause: e});
1143 } 1203 }
1144 1204
1145 } 1205 }
1146 writeJsonValue(object) { 1206 writeJsonValue(object) {
1147 if (dart.is(object, core.num)) { 1207 if (dart.is(object, core.num)) {
1148 if (dart.throw_("Unimplemented PrefixExpression: !object.isFinite")) 1208 if (dart.throw_("Unimplemented PrefixExpression: !object.isFinite"))
1149 return false; 1209 return false;
1150 this.writeNumber(dart.as(object, core.num)); 1210 this.writeNumber(dart.as(object, core.num));
1151 return true; 1211 return true;
1152 } else if (core.identical(object, true)) { 1212 } else if (core.identical(object, true)) {
1153 this.writeString('true'); 1213 this.writeString('true');
1154 return true; 1214 return true;
1155 } else if (core.identical(object, false)) { 1215 } else if (core.identical(object, false)) {
1156 this.writeString('false'); 1216 this.writeString('false');
1157 return true; 1217 return true;
1158 } else if (object === null) { 1218 } else if (object === null) {
1159 this.writeString('null'); 1219 this.writeString('null');
1160 return true; 1220 return true;
1161 } else if (typeof object == string) { 1221 } else if (typeof object == string) {
1162 this.writeString('"'); 1222 this.writeString('"');
1163 this.writeStringContent(dart.as(object, core.String)); 1223 this.writeStringContent(dart.as(object, core.String));
1164 this.writeString('"'); 1224 this.writeString('"');
1165 return true; 1225 return true;
1166 } else if (dart.is(object, core.List)) { 1226 } else if (dart.is(object, core.List)) {
1167 this._checkCycle(object); 1227 this[_checkCycle](object);
1168 this.writeList(dart.as(object, core.List)); 1228 this.writeList(dart.as(object, core.List));
1169 this._removeSeen(object); 1229 this[_removeSeen](object);
1170 return true; 1230 return true;
1171 } else if (dart.is(object, core.Map)) { 1231 } else if (dart.is(object, core.Map)) {
1172 this._checkCycle(object); 1232 this[_checkCycle](object);
1173 this.writeMap(dart.as(object, core.Map$(core.String, core.Object))); 1233 this.writeMap(dart.as(object, core.Map$(core.String, core.Object)));
1174 this._removeSeen(object); 1234 this[_removeSeen](object);
1175 return true; 1235 return true;
1176 } else { 1236 } else {
1177 return false; 1237 return false;
1178 } 1238 }
1179 } 1239 }
1180 writeList(list) { 1240 writeList(list) {
1181 this.writeString('['); 1241 this.writeString('[');
1182 if (list.length > 0) { 1242 if (list.length > 0) {
1183 this.writeObject(list.get(0)); 1243 this.writeObject(list.get(0));
1184 for (let i = 1; i < list.length; i++) { 1244 for (let i = 1; i < list.length; i++) {
(...skipping 25 matching lines...) Expand all
1210 _JsonStringifier.CHAR_0 = 48; 1270 _JsonStringifier.CHAR_0 = 48;
1211 _JsonStringifier.BACKSLASH = 92; 1271 _JsonStringifier.BACKSLASH = 92;
1212 _JsonStringifier.CHAR_b = 98; 1272 _JsonStringifier.CHAR_b = 98;
1213 _JsonStringifier.CHAR_f = 102; 1273 _JsonStringifier.CHAR_f = 102;
1214 _JsonStringifier.CHAR_n = 110; 1274 _JsonStringifier.CHAR_n = 110;
1215 _JsonStringifier.CHAR_r = 114; 1275 _JsonStringifier.CHAR_r = 114;
1216 _JsonStringifier.CHAR_t = 116; 1276 _JsonStringifier.CHAR_t = 116;
1217 _JsonStringifier.CHAR_u = 117; 1277 _JsonStringifier.CHAR_u = 117;
1218 class _JsonPrettyPrintMixin extends dart.Object { 1278 class _JsonPrettyPrintMixin extends dart.Object {
1219 _JsonPrettyPrintMixin() { 1279 _JsonPrettyPrintMixin() {
1220 this._indentLevel = 0; 1280 this[_indentLevel] = 0;
1221 } 1281 }
1222 writeList(list) { 1282 writeList(list) {
1223 if (list.isEmpty) { 1283 if (list.isEmpty) {
1224 this.writeString('[]'); 1284 this.writeString('[]');
1225 } else { 1285 } else {
1226 this.writeString('[\n'); 1286 this.writeString('[\n');
1227 this._indentLevel++; 1287 this[_indentLevel]++;
1228 this.writeIndentation(this._indentLevel); 1288 this.writeIndentation(this[_indentLevel]);
1229 this.writeObject(list.get(0)); 1289 this.writeObject(list.get(0));
1230 for (let i = 1; i < list.length; i++) { 1290 for (let i = 1; i < list.length; i++) {
1231 this.writeString(',\n'); 1291 this.writeString(',\n');
1232 this.writeIndentation(this._indentLevel); 1292 this.writeIndentation(this[_indentLevel]);
1233 this.writeObject(list.get(i)); 1293 this.writeObject(list.get(i));
1234 } 1294 }
1235 this.writeString('\n'); 1295 this.writeString('\n');
1236 this._indentLevel--; 1296 this[_indentLevel]--;
1237 this.writeIndentation(this._indentLevel); 1297 this.writeIndentation(this[_indentLevel]);
1238 this.writeString(']'); 1298 this.writeString(']');
1239 } 1299 }
1240 } 1300 }
1241 writeMap(map) { 1301 writeMap(map) {
1242 if (map.isEmpty) { 1302 if (map.isEmpty) {
1243 this.writeString('{}'); 1303 this.writeString('{}');
1244 } else { 1304 } else {
1245 this.writeString('{\n'); 1305 this.writeString('{\n');
1246 this._indentLevel++; 1306 this[_indentLevel]++;
1247 let first = true; 1307 let first = true;
1248 map.forEach(dart.as(((key, value) => { 1308 map.forEach(dart.as(((key, value) => {
1249 if (!dart.notNull(first)) { 1309 if (!dart.notNull(first)) {
1250 this.writeString(",\n"); 1310 this.writeString(",\n");
1251 } 1311 }
1252 this.writeIndentation(this._indentLevel); 1312 this.writeIndentation(this[_indentLevel]);
1253 this.writeString('"'); 1313 this.writeString('"');
1254 this.writeStringContent(key); 1314 this.writeStringContent(key);
1255 this.writeString('": '); 1315 this.writeString('": ');
1256 this.writeObject(value); 1316 this.writeObject(value);
1257 first = false; 1317 first = false;
1258 }).bind(this), dart.throw_("Unimplemented type (dynamic, dynamic) → void "))); 1318 }).bind(this), dart.throw_("Unimplemented type (dynamic, dynamic) → void ")));
1259 this.writeString('\n'); 1319 this.writeString('\n');
1260 this._indentLevel--; 1320 this[_indentLevel]--;
1261 this.writeIndentation(this._indentLevel); 1321 this.writeIndentation(this[_indentLevel]);
1262 this.writeString('}'); 1322 this.writeString('}');
1263 } 1323 }
1264 } 1324 }
1265 } 1325 }
1266 class _JsonStringStringifier extends _JsonStringifier { 1326 class _JsonStringStringifier extends _JsonStringifier {
1267 _JsonStringStringifier(_sink, _toEncodable) { 1327 _JsonStringStringifier($_sink, _toEncodable) {
1268 this._sink = _sink; 1328 this[_sink] = $_sink;
1269 super._JsonStringifier(dart.as(_toEncodable, dart.throw_("Unimplemented ty pe (Object) → Object"))); 1329 super._JsonStringifier(dart.as(_toEncodable, dart.throw_("Unimplemented ty pe (Object) → Object")));
1270 } 1330 }
1271 static stringify(object, toEncodable, indent) { 1331 static stringify(object, toEncodable, indent) {
1272 let output = new core.StringBuffer(); 1332 let output = new core.StringBuffer();
1273 printOn(object, output, toEncodable, indent); 1333 printOn(object, output, toEncodable, indent);
1274 return output.toString(); 1334 return output.toString();
1275 } 1335 }
1276 static printOn(object, output, toEncodable, indent) { 1336 static printOn(object, output, toEncodable, indent) {
1277 let stringifier = null; 1337 let stringifier = null;
1278 if (indent === null) { 1338 if (indent === null) {
1279 stringifier = new _JsonStringStringifier(output, toEncodable); 1339 stringifier = new _JsonStringStringifier(output, toEncodable);
1280 } else { 1340 } else {
1281 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt); 1341 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt);
1282 } 1342 }
1283 dart.dinvoke(stringifier, 'writeObject', object); 1343 dart.dinvoke(stringifier, 'writeObject', object);
1284 } 1344 }
1285 writeNumber(number) { 1345 writeNumber(number) {
1286 this._sink.write(number.toString()); 1346 this[_sink].write(number.toString());
1287 } 1347 }
1288 writeString(string) { 1348 writeString(string) {
1289 this._sink.write(string); 1349 this[_sink].write(string);
1290 } 1350 }
1291 writeStringSlice(string, start, end) { 1351 writeStringSlice(string, start, end) {
1292 this._sink.write(string.substring(start, end)); 1352 this[_sink].write(string.substring(start, end));
1293 } 1353 }
1294 writeCharCode(charCode) { 1354 writeCharCode(charCode) {
1295 this._sink.writeCharCode(charCode); 1355 this[_sink].writeCharCode(charCode);
1296 } 1356 }
1297 } 1357 }
1298 class _JsonStringStringifierPretty extends dart.mixin(_JsonStringStringifier, _JsonPrettyPrintMixin) { 1358 class _JsonStringStringifierPretty extends dart.mixin(_JsonStringStringifier, _JsonPrettyPrintMixin) {
1299 _JsonStringStringifierPretty(sink, toEncodable, _indent) { 1359 _JsonStringStringifierPretty(sink, toEncodable, $_indent) {
1300 this._indent = _indent; 1360 this[_indent] = $_indent;
1301 super._JsonStringStringifier(sink, toEncodable); 1361 super._JsonStringStringifier(sink, toEncodable);
1302 } 1362 }
1303 writeIndentation(count) { 1363 writeIndentation(count) {
1304 for (let i = 0; i < count; i++) 1364 for (let i = 0; i < count; i++)
1305 this.writeString(this._indent); 1365 this.writeString(this[_indent]);
1306 } 1366 }
1307 } 1367 }
1308 class _JsonUtf8Stringifier extends _JsonStringifier { 1368 class _JsonUtf8Stringifier extends _JsonStringifier {
1309 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) { 1369 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) {
1310 this.addChunk = addChunk; 1370 this.addChunk = addChunk;
1311 this.bufferSize = bufferSize; 1371 this.bufferSize = bufferSize;
1312 this.buffer = new typed_data.Uint8List(bufferSize); 1372 this.buffer = new typed_data.Uint8List(bufferSize);
1313 this.index = 0; 1373 this.index = 0;
1314 super._JsonStringifier(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))); 1374 super._JsonStringifier(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object")));
1315 } 1375 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 } 1488 }
1429 } 1489 }
1430 } 1490 }
1431 } 1491 }
1432 } 1492 }
1433 let LATIN1 = new Latin1Codec(); 1493 let LATIN1 = new Latin1Codec();
1434 let _LATIN1_MASK = 255; 1494 let _LATIN1_MASK = 255;
1435 class Latin1Codec extends Encoding { 1495 class Latin1Codec extends Encoding {
1436 Latin1Codec(opt$) { 1496 Latin1Codec(opt$) {
1437 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d; 1497 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d;
1438 this._allowInvalid = allowInvalid; 1498 this[_allowInvalid] = allowInvalid;
1439 super.Encoding(); 1499 super.Encoding();
1440 } 1500 }
1441 get name() { 1501 get name() {
1442 return "iso-8859-1"; 1502 return "iso-8859-1";
1443 } 1503 }
1444 decode(bytes, opt$) { 1504 decode(bytes, opt$) {
1445 let allowInvalid = opt$.allowInvalid === void 0 ? null : opt$.allowInvalid ; 1505 let allowInvalid = opt$.allowInvalid === void 0 ? null : opt$.allowInvalid ;
1446 if (allowInvalid === null) 1506 if (allowInvalid === null)
1447 allowInvalid = this._allowInvalid; 1507 allowInvalid = this[_allowInvalid];
1448 if (allowInvalid) { 1508 if (allowInvalid) {
1449 return new Latin1Decoder({allowInvalid: true}).convert(bytes); 1509 return new Latin1Decoder({allowInvalid: true}).convert(bytes);
1450 } else { 1510 } else {
1451 return new Latin1Decoder({allowInvalid: false}).convert(bytes); 1511 return new Latin1Decoder({allowInvalid: false}).convert(bytes);
1452 } 1512 }
1453 } 1513 }
1454 get encoder() { 1514 get encoder() {
1455 return new Latin1Encoder(); 1515 return new Latin1Encoder();
1456 } 1516 }
1457 get decoder() { 1517 get decoder() {
1458 return this._allowInvalid ? new Latin1Decoder({allowInvalid: true}) : new Latin1Decoder({allowInvalid: false}); 1518 return this[_allowInvalid] ? new Latin1Decoder({allowInvalid: true}) : new Latin1Decoder({allowInvalid: false});
1459 } 1519 }
1460 } 1520 }
1461 class Latin1Encoder extends _UnicodeSubsetEncoder { 1521 class Latin1Encoder extends _UnicodeSubsetEncoder {
1462 Latin1Encoder() { 1522 Latin1Encoder() {
1463 super._UnicodeSubsetEncoder(_LATIN1_MASK); 1523 super._UnicodeSubsetEncoder(_LATIN1_MASK);
1464 } 1524 }
1465 } 1525 }
1466 class Latin1Decoder extends _UnicodeSubsetDecoder { 1526 class Latin1Decoder extends _UnicodeSubsetDecoder {
1467 Latin1Decoder(opt$) { 1527 Latin1Decoder(opt$) {
1468 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d; 1528 let allowInvalid = opt$.allowInvalid === void 0 ? false : opt$.allowInvali d;
1469 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK); 1529 super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK);
1470 } 1530 }
1471 startChunkedConversion(sink) { 1531 startChunkedConversion(sink) {
1472 let stringSink = null; 1532 let stringSink = null;
1473 if (dart.is(sink, StringConversionSink)) { 1533 if (dart.is(sink, StringConversionSink)) {
1474 stringSink = sink; 1534 stringSink = sink;
1475 } else { 1535 } else {
1476 stringSink = new StringConversionSink.from(sink); 1536 stringSink = new StringConversionSink.from(sink);
1477 } 1537 }
1478 if (!dart.notNull(this._allowInvalid)) 1538 if (!dart.notNull(this[_allowInvalid]))
1479 return new _Latin1DecoderSink(stringSink); 1539 return new _Latin1DecoderSink(stringSink);
1480 return new _Latin1AllowInvalidDecoderSink(stringSink); 1540 return new _Latin1AllowInvalidDecoderSink(stringSink);
1481 } 1541 }
1482 } 1542 }
1483 class _Latin1DecoderSink extends ByteConversionSinkBase { 1543 class _Latin1DecoderSink extends ByteConversionSinkBase {
1484 _Latin1DecoderSink(_sink) { 1544 _Latin1DecoderSink($_sink) {
1485 this._sink = _sink; 1545 this[_sink] = $_sink;
1486 super.ByteConversionSinkBase(); 1546 super.ByteConversionSinkBase();
1487 } 1547 }
1488 close() { 1548 close() {
1489 this._sink.close(); 1549 this[_sink].close();
1490 } 1550 }
1491 add(source) { 1551 add(source) {
1492 this.addSlice(source, 0, source.length, false); 1552 this.addSlice(source, 0, source.length, false);
1493 } 1553 }
1494 _addSliceToSink(source, start, end, isLast) { 1554 [_addSliceToSink](source, start, end, isLast) {
1495 this._sink.add(new core.String.fromCharCodes(source, start, end)); 1555 this[_sink].add(new core.String.fromCharCodes(source, start, end));
1496 if (isLast) 1556 if (isLast)
1497 this.close(); 1557 this.close();
1498 } 1558 }
1499 addSlice(source, start, end, isLast) { 1559 addSlice(source, start, end, isLast) {
1500 core.RangeError.checkValidRange(start, end, source.length); 1560 core.RangeError.checkValidRange(start, end, source.length);
1501 for (let i = start; i < end; i++) { 1561 for (let i = start; i < end; i++) {
1502 let char = source.get(i); 1562 let char = source.get(i);
1503 if (dart.notNull(char > _LATIN1_MASK) || dart.notNull(char < 0)) { 1563 if (dart.notNull(char > _LATIN1_MASK) || dart.notNull(char < 0)) {
1504 throw new core.FormatException("Source contains non-Latin-1 characters ."); 1564 throw new core.FormatException("Source contains non-Latin-1 characters .");
1505 } 1565 }
1506 } 1566 }
1507 if (start < end) { 1567 if (start < end) {
1508 this._addSliceToSink(source, start, end, isLast); 1568 this[_addSliceToSink](source, start, end, isLast);
1509 } 1569 }
1510 if (isLast) { 1570 if (isLast) {
1511 this.close(); 1571 this.close();
1512 } 1572 }
1513 } 1573 }
1514 } 1574 }
1515 class _Latin1AllowInvalidDecoderSink extends _Latin1DecoderSink { 1575 class _Latin1AllowInvalidDecoderSink extends _Latin1DecoderSink {
1516 _Latin1AllowInvalidDecoderSink(sink) { 1576 _Latin1AllowInvalidDecoderSink(sink) {
1517 super._Latin1DecoderSink(sink); 1577 super._Latin1DecoderSink(sink);
1518 } 1578 }
1519 addSlice(source, start, end, isLast) { 1579 addSlice(source, start, end, isLast) {
1520 core.RangeError.checkValidRange(start, end, source.length); 1580 core.RangeError.checkValidRange(start, end, source.length);
1521 for (let i = start; i < end; i++) { 1581 for (let i = start; i < end; i++) {
1522 let char = source.get(i); 1582 let char = source.get(i);
1523 if (dart.notNull(char > _LATIN1_MASK) || dart.notNull(char < 0)) { 1583 if (dart.notNull(char > _LATIN1_MASK) || dart.notNull(char < 0)) {
1524 if (i > start) 1584 if (i > start)
1525 this._addSliceToSink(source, start, i, false); 1585 this[_addSliceToSink](source, start, i, false);
1526 this._addSliceToSink(dart.as(/* Unimplemented const */new List.from([6 5533]), core.List$(core.int)), 0, 1, false); 1586 this[_addSliceToSink](dart.as(/* Unimplemented const */new List.from([ 65533]), core.List$(core.int)), 0, 1, false);
1527 start = i + 1; 1587 start = i + 1;
1528 } 1588 }
1529 } 1589 }
1530 if (start < end) { 1590 if (start < end) {
1531 this._addSliceToSink(source, start, end, isLast); 1591 this[_addSliceToSink](source, start, end, isLast);
1532 } 1592 }
1533 if (isLast) { 1593 if (isLast) {
1534 this.close(); 1594 this.close();
1535 } 1595 }
1536 } 1596 }
1537 } 1597 }
1538 class LineSplitter extends Converter$(core.String, core.List$(core.String)) { 1598 class LineSplitter extends Converter$(core.String, core.List$(core.String)) {
1539 LineSplitter() { 1599 LineSplitter() {
1540 super.Converter(); 1600 super.Converter();
1541 } 1601 }
1542 convert(data) { 1602 convert(data) {
1543 let lines = new core.List(); 1603 let lines = new core.List();
1544 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add); 1604 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add);
1545 return lines; 1605 return lines;
1546 } 1606 }
1547 startChunkedConversion(sink) { 1607 startChunkedConversion(sink) {
1548 if (!dart.is(sink, StringConversionSink)) { 1608 if (!dart.is(sink, StringConversionSink)) {
1549 sink = new StringConversionSink.from(sink); 1609 sink = new StringConversionSink.from(sink);
1550 } 1610 }
1551 return new _LineSplitterSink(dart.as(sink, StringConversionSink)); 1611 return new _LineSplitterSink(dart.as(sink, StringConversionSink));
1552 } 1612 }
1553 } 1613 }
1554 class _LineSplitterSink extends StringConversionSinkBase { 1614 class _LineSplitterSink extends StringConversionSinkBase {
1555 _LineSplitterSink(_sink) { 1615 _LineSplitterSink($_sink) {
1556 this._sink = _sink; 1616 this[_sink] = $_sink;
1557 this._carry = null; 1617 this[_carry] = null;
1558 super.StringConversionSinkBase(); 1618 super.StringConversionSinkBase();
1559 } 1619 }
1560 addSlice(chunk, start, end, isLast) { 1620 addSlice(chunk, start, end, isLast) {
1561 if (this._carry !== null) { 1621 if (this[_carry] !== null) {
1562 chunk = core.String['+'](this._carry, chunk.substring(start, end)); 1622 chunk = core.String['+'](this[_carry], chunk.substring(start, end));
1563 start = 0; 1623 start = 0;
1564 end = chunk.length; 1624 end = chunk.length;
1565 this._carry = null; 1625 this[_carry] = null;
1566 } 1626 }
1567 this._carry = _addSlice(chunk, start, end, isLast, this._sink.add); 1627 this[_carry] = _addSlice(chunk, start, end, isLast, this[_sink].add);
1568 if (isLast) 1628 if (isLast)
1569 this._sink.close(); 1629 this[_sink].close();
1570 } 1630 }
1571 close() { 1631 close() {
1572 this.addSlice('', 0, 0, true); 1632 this.addSlice('', 0, 0, true);
1573 } 1633 }
1574 static _addSlice(chunk, start, end, isLast, adder) { 1634 static [_addSlice](chunk, start, end, isLast, adder) {
1575 let pos = start; 1635 let pos = start;
1576 while (pos < end) { 1636 while (pos < end) {
1577 let skip = 0; 1637 let skip = 0;
1578 let char = chunk.codeUnitAt(pos); 1638 let char = chunk.codeUnitAt(pos);
1579 if (char === _LF) { 1639 if (char === _LF) {
1580 skip = 1; 1640 skip = 1;
1581 } else if (char === _CR) { 1641 } else if (char === _CR) {
1582 skip = 1; 1642 skip = 1;
1583 if (pos + 1 < end) { 1643 if (pos + 1 < end) {
1584 if (chunk.codeUnitAt(pos + 1) === _LF) { 1644 if (chunk.codeUnitAt(pos + 1) === _LF) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 dart.defineNamedConstructor(StringConversionSink, 'withCallback'); 1685 dart.defineNamedConstructor(StringConversionSink, 'withCallback');
1626 dart.defineNamedConstructor(StringConversionSink, 'from'); 1686 dart.defineNamedConstructor(StringConversionSink, 'from');
1627 dart.defineNamedConstructor(StringConversionSink, 'fromStringSink'); 1687 dart.defineNamedConstructor(StringConversionSink, 'fromStringSink');
1628 class ClosableStringSink extends core.StringSink { 1688 class ClosableStringSink extends core.StringSink {
1629 ClosableStringSink$fromStringSink(sink, onClose) { 1689 ClosableStringSink$fromStringSink(sink, onClose) {
1630 return new _ClosableStringSink(sink, onClose); 1690 return new _ClosableStringSink(sink, onClose);
1631 } 1691 }
1632 } 1692 }
1633 dart.defineNamedConstructor(ClosableStringSink, 'fromStringSink'); 1693 dart.defineNamedConstructor(ClosableStringSink, 'fromStringSink');
1634 class _ClosableStringSink extends dart.Object { 1694 class _ClosableStringSink extends dart.Object {
1635 _ClosableStringSink(_sink, _callback) { 1695 _ClosableStringSink($_sink, $_callback) {
1636 this._sink = _sink; 1696 this[_sink] = $_sink;
1637 this._callback = _callback; 1697 this[_callback] = $_callback;
1638 } 1698 }
1639 close() { 1699 close() {
1640 return this._callback(); 1700 return this[_callback]();
1641 } 1701 }
1642 writeCharCode(charCode) { 1702 writeCharCode(charCode) {
1643 return this._sink.writeCharCode(charCode); 1703 return this[_sink].writeCharCode(charCode);
1644 } 1704 }
1645 write(o) { 1705 write(o) {
1646 return this._sink.write(o); 1706 return this[_sink].write(o);
1647 } 1707 }
1648 writeln(o) { 1708 writeln(o) {
1649 if (o === void 0) 1709 if (o === void 0)
1650 o = ""; 1710 o = "";
1651 return this._sink.writeln(o); 1711 return this[_sink].writeln(o);
1652 } 1712 }
1653 writeAll(objects, separator) { 1713 writeAll(objects, separator) {
1654 if (separator === void 0) 1714 if (separator === void 0)
1655 separator = ""; 1715 separator = "";
1656 return this._sink.writeAll(objects, separator); 1716 return this[_sink].writeAll(objects, separator);
1657 } 1717 }
1658 } 1718 }
1659 class _StringConversionSinkAsStringSinkAdapter extends dart.Object { 1719 class _StringConversionSinkAsStringSinkAdapter extends dart.Object {
1660 _StringConversionSinkAsStringSinkAdapter(_chunkedSink) { 1720 _StringConversionSinkAsStringSinkAdapter($_chunkedSink) {
1661 this._chunkedSink = _chunkedSink; 1721 this[_chunkedSink] = $_chunkedSink;
1662 this._buffer = new core.StringBuffer(); 1722 this[_buffer] = new core.StringBuffer();
1663 } 1723 }
1664 close() { 1724 close() {
1665 if (this._buffer.isNotEmpty) 1725 if (this[_buffer].isNotEmpty)
1666 this._flush(); 1726 this[_flush]();
1667 this._chunkedSink.close(); 1727 this[_chunkedSink].close();
1668 } 1728 }
1669 writeCharCode(charCode) { 1729 writeCharCode(charCode) {
1670 this._buffer.writeCharCode(charCode); 1730 this[_buffer].writeCharCode(charCode);
1671 if (this._buffer.length['>'](_MIN_STRING_SIZE)) 1731 if (this[_buffer].length['>'](_MIN_STRING_SIZE))
1672 this._flush(); 1732 this[_flush]();
1673 } 1733 }
1674 write(o) { 1734 write(o) {
1675 if (this._buffer.isNotEmpty) 1735 if (this[_buffer].isNotEmpty)
1676 this._flush(); 1736 this[_flush]();
1677 let str = o.toString(); 1737 let str = o.toString();
1678 this._chunkedSink.add(o.toString()); 1738 this[_chunkedSink].add(o.toString());
1679 } 1739 }
1680 writeln(o) { 1740 writeln(o) {
1681 if (o === void 0) 1741 if (o === void 0)
1682 o = ""; 1742 o = "";
1683 this._buffer.writeln(o); 1743 this[_buffer].writeln(o);
1684 if (this._buffer.length['>'](_MIN_STRING_SIZE)) 1744 if (this[_buffer].length['>'](_MIN_STRING_SIZE))
1685 this._flush(); 1745 this[_flush]();
1686 } 1746 }
1687 writeAll(objects, separator) { 1747 writeAll(objects, separator) {
1688 if (separator === void 0) 1748 if (separator === void 0)
1689 separator = ""; 1749 separator = "";
1690 if (this._buffer.isNotEmpty) 1750 if (this[_buffer].isNotEmpty)
1691 this._flush(); 1751 this[_flush]();
1692 let iterator = objects.iterator; 1752 let iterator = objects.iterator;
1693 if (!dart.notNull(iterator.moveNext())) 1753 if (!dart.notNull(iterator.moveNext()))
1694 return; 1754 return;
1695 if (separator.isEmpty) { 1755 if (separator.isEmpty) {
1696 do { 1756 do {
1697 this._chunkedSink.add(dart.as(dart.dinvoke(iterator.current, 'toString '), core.String)); 1757 this[_chunkedSink].add(dart.as(dart.dinvoke(iterator.current, 'toStrin g'), core.String));
1698 } while (iterator.moveNext()); 1758 } while (iterator.moveNext());
1699 } else { 1759 } else {
1700 this._chunkedSink.add(dart.as(dart.dinvoke(iterator.current, 'toString') , core.String)); 1760 this[_chunkedSink].add(dart.as(dart.dinvoke(iterator.current, 'toString' ), core.String));
1701 while (iterator.moveNext()) { 1761 while (iterator.moveNext()) {
1702 this.write(separator); 1762 this.write(separator);
1703 this._chunkedSink.add(dart.as(dart.dinvoke(iterator.current, 'toString '), core.String)); 1763 this[_chunkedSink].add(dart.as(dart.dinvoke(iterator.current, 'toStrin g'), core.String));
1704 } 1764 }
1705 } 1765 }
1706 } 1766 }
1707 _flush() { 1767 [_flush]() {
1708 let accumulated = this._buffer.toString(); 1768 let accumulated = this[_buffer].toString();
1709 this._buffer.clear(); 1769 this[_buffer].clear();
1710 this._chunkedSink.add(accumulated); 1770 this[_chunkedSink].add(accumulated);
1711 } 1771 }
1712 } 1772 }
1713 _StringConversionSinkAsStringSinkAdapter._MIN_STRING_SIZE = 16; 1773 _StringConversionSinkAsStringSinkAdapter._MIN_STRING_SIZE = 16;
1714 class StringConversionSinkBase extends StringConversionSinkMixin { 1774 class StringConversionSinkBase extends StringConversionSinkMixin {
1715 } 1775 }
1716 class StringConversionSinkMixin extends dart.Object { 1776 class StringConversionSinkMixin extends dart.Object {
1717 add(str) { 1777 add(str) {
1718 return this.addSlice(str, 0, str.length, false); 1778 return this.addSlice(str, 0, str.length, false);
1719 } 1779 }
1720 asUtf8Sink(allowMalformed) { 1780 asUtf8Sink(allowMalformed) {
1721 return new _Utf8ConversionSink(this, allowMalformed); 1781 return new _Utf8ConversionSink(this, allowMalformed);
1722 } 1782 }
1723 asStringSink() { 1783 asStringSink() {
1724 return new _StringConversionSinkAsStringSinkAdapter(this); 1784 return new _StringConversionSinkAsStringSinkAdapter(this);
1725 } 1785 }
1726 } 1786 }
1727 class _StringSinkConversionSink extends StringConversionSinkBase { 1787 class _StringSinkConversionSink extends StringConversionSinkBase {
1728 _StringSinkConversionSink(_stringSink) { 1788 _StringSinkConversionSink($_stringSink) {
1729 this._stringSink = _stringSink; 1789 this[_stringSink] = $_stringSink;
1730 super.StringConversionSinkBase(); 1790 super.StringConversionSinkBase();
1731 } 1791 }
1732 close() {} 1792 close() {}
1733 addSlice(str, start, end, isLast) { 1793 addSlice(str, start, end, isLast) {
1734 if (dart.notNull(start !== 0) || dart.notNull(end !== str.length)) { 1794 if (dart.notNull(start !== 0) || dart.notNull(end !== str.length)) {
1735 for (let i = start; i < end; i++) { 1795 for (let i = start; i < end; i++) {
1736 this._stringSink.writeCharCode(str.codeUnitAt(i)); 1796 this[_stringSink].writeCharCode(str.codeUnitAt(i));
1737 } 1797 }
1738 } else { 1798 } else {
1739 this._stringSink.write(str); 1799 this[_stringSink].write(str);
1740 } 1800 }
1741 if (isLast) 1801 if (isLast)
1742 this.close(); 1802 this.close();
1743 } 1803 }
1744 add(str) { 1804 add(str) {
1745 return this._stringSink.write(str); 1805 return this[_stringSink].write(str);
1746 } 1806 }
1747 asUtf8Sink(allowMalformed) { 1807 asUtf8Sink(allowMalformed) {
1748 return new _Utf8StringSinkAdapter(this, this._stringSink, allowMalformed); 1808 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ;
1749 } 1809 }
1750 asStringSink() { 1810 asStringSink() {
1751 return new ClosableStringSink.fromStringSink(this._stringSink, this.close) ; 1811 return new ClosableStringSink.fromStringSink(this[_stringSink], this.close );
1752 } 1812 }
1753 } 1813 }
1754 class _StringCallbackSink extends _StringSinkConversionSink { 1814 class _StringCallbackSink extends _StringSinkConversionSink {
1755 _StringCallbackSink(_callback) { 1815 _StringCallbackSink($_callback) {
1756 this._callback = _callback; 1816 this[_callback] = $_callback;
1757 super._StringSinkConversionSink(new core.StringBuffer()); 1817 super._StringSinkConversionSink(new core.StringBuffer());
1758 } 1818 }
1759 close() { 1819 close() {
1760 let buffer = dart.as(this._stringSink, core.StringBuffer); 1820 let buffer = dart.as(this[_stringSink], core.StringBuffer);
1761 let accumulated = buffer.toString(); 1821 let accumulated = buffer.toString();
1762 buffer.clear(); 1822 buffer.clear();
1763 this._callback(accumulated); 1823 this[_callback](accumulated);
1764 } 1824 }
1765 asUtf8Sink(allowMalformed) { 1825 asUtf8Sink(allowMalformed) {
1766 return new _Utf8StringSinkAdapter(this, this._stringSink, allowMalformed); 1826 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ;
1767 } 1827 }
1768 } 1828 }
1769 class _StringAdapterSink extends StringConversionSinkBase { 1829 class _StringAdapterSink extends StringConversionSinkBase {
1770 _StringAdapterSink(_sink) { 1830 _StringAdapterSink($_sink) {
1771 this._sink = _sink; 1831 this[_sink] = $_sink;
1772 super.StringConversionSinkBase(); 1832 super.StringConversionSinkBase();
1773 } 1833 }
1774 add(str) { 1834 add(str) {
1775 return this._sink.add(str); 1835 return this[_sink].add(str);
1776 } 1836 }
1777 addSlice(str, start, end, isLast) { 1837 addSlice(str, start, end, isLast) {
1778 if (dart.notNull(start === 0) && dart.notNull(end === str.length)) { 1838 if (dart.notNull(start === 0) && dart.notNull(end === str.length)) {
1779 this.add(str); 1839 this.add(str);
1780 } else { 1840 } else {
1781 this.add(str.substring(start, end)); 1841 this.add(str.substring(start, end));
1782 } 1842 }
1783 if (isLast) 1843 if (isLast)
1784 this.close(); 1844 this.close();
1785 } 1845 }
1786 close() { 1846 close() {
1787 return this._sink.close(); 1847 return this[_sink].close();
1788 } 1848 }
1789 } 1849 }
1790 class _Utf8StringSinkAdapter extends ByteConversionSink { 1850 class _Utf8StringSinkAdapter extends ByteConversionSink {
1791 _Utf8StringSinkAdapter(_sink, stringSink, allowMalformed) { 1851 _Utf8StringSinkAdapter($_sink, stringSink, allowMalformed) {
1792 this._sink = _sink; 1852 this[_sink] = $_sink;
1793 this._decoder = new _Utf8Decoder(stringSink, allowMalformed); 1853 this[_decoder] = new _Utf8Decoder(stringSink, allowMalformed);
1794 super.ByteConversionSink(); 1854 super.ByteConversionSink();
1795 } 1855 }
1796 close() { 1856 close() {
1797 this._decoder.close(); 1857 this[_decoder].close();
1798 if (this._sink !== null) 1858 if (this[_sink] !== null)
1799 this._sink.close(); 1859 this[_sink].close();
1800 } 1860 }
1801 add(chunk) { 1861 add(chunk) {
1802 this.addSlice(chunk, 0, chunk.length, false); 1862 this.addSlice(chunk, 0, chunk.length, false);
1803 } 1863 }
1804 addSlice(codeUnits, startIndex, endIndex, isLast) { 1864 addSlice(codeUnits, startIndex, endIndex, isLast) {
1805 this._decoder.convert(codeUnits, startIndex, endIndex); 1865 this[_decoder].convert(codeUnits, startIndex, endIndex);
1806 if (isLast) 1866 if (isLast)
1807 this.close(); 1867 this.close();
1808 } 1868 }
1809 } 1869 }
1810 class _Utf8ConversionSink extends ByteConversionSink { 1870 class _Utf8ConversionSink extends ByteConversionSink {
1811 _Utf8ConversionSink(sink, allowMalformed) { 1871 _Utf8ConversionSink(sink, allowMalformed) {
1812 this._Utf8ConversionSink$_(sink, new core.StringBuffer(), allowMalformed); 1872 this[_Utf8ConversionSink$_](sink, new core.StringBuffer(), allowMalformed) ;
1813 } 1873 }
1814 _Utf8ConversionSink$_(_chunkedSink, stringBuffer, allowMalformed) { 1874 _Utf8ConversionSink$_($_chunkedSink, stringBuffer, allowMalformed) {
1815 this._chunkedSink = _chunkedSink; 1875 this[_chunkedSink] = $_chunkedSink;
1816 this._decoder = new _Utf8Decoder(stringBuffer, allowMalformed); 1876 this[_decoder] = new _Utf8Decoder(stringBuffer, allowMalformed);
1817 this._buffer = stringBuffer; 1877 this[_buffer] = stringBuffer;
1818 super.ByteConversionSink(); 1878 super.ByteConversionSink();
1819 } 1879 }
1820 close() { 1880 close() {
1821 this._decoder.close(); 1881 this[_decoder].close();
1822 if (this._buffer.isNotEmpty) { 1882 if (this[_buffer].isNotEmpty) {
1823 let accumulated = this._buffer.toString(); 1883 let accumulated = this[_buffer].toString();
1824 this._buffer.clear(); 1884 this[_buffer].clear();
1825 this._chunkedSink.addSlice(accumulated, 0, accumulated.length, true); 1885 this[_chunkedSink].addSlice(accumulated, 0, accumulated.length, true);
1826 } else { 1886 } else {
1827 this._chunkedSink.close(); 1887 this[_chunkedSink].close();
1828 } 1888 }
1829 } 1889 }
1830 add(chunk) { 1890 add(chunk) {
1831 this.addSlice(chunk, 0, chunk.length, false); 1891 this.addSlice(chunk, 0, chunk.length, false);
1832 } 1892 }
1833 addSlice(chunk, startIndex, endIndex, isLast) { 1893 addSlice(chunk, startIndex, endIndex, isLast) {
1834 this._decoder.convert(chunk, startIndex, endIndex); 1894 this[_decoder].convert(chunk, startIndex, endIndex);
1835 if (this._buffer.isNotEmpty) { 1895 if (this[_buffer].isNotEmpty) {
1836 let accumulated = this._buffer.toString(); 1896 let accumulated = this[_buffer].toString();
1837 this._chunkedSink.addSlice(accumulated, 0, accumulated.length, isLast); 1897 this[_chunkedSink].addSlice(accumulated, 0, accumulated.length, isLast);
1838 this._buffer.clear(); 1898 this[_buffer].clear();
1839 return; 1899 return;
1840 } 1900 }
1841 if (isLast) 1901 if (isLast)
1842 this.close(); 1902 this.close();
1843 } 1903 }
1844 } 1904 }
1845 dart.defineNamedConstructor(_Utf8ConversionSink, '_'); 1905 dart.defineNamedConstructor(_Utf8ConversionSink, '_');
1846 let UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533; 1906 let UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533;
1847 let UNICODE_BOM_CHARACTER_RUNE = 65279; 1907 let UNICODE_BOM_CHARACTER_RUNE = 65279;
1848 let UTF8 = new Utf8Codec(); 1908 let UTF8 = new Utf8Codec();
1849 class Utf8Codec extends Encoding { 1909 class Utf8Codec extends Encoding {
1850 Utf8Codec(opt$) { 1910 Utf8Codec(opt$) {
1851 let allowMalformed = opt$.allowMalformed === void 0 ? false : opt$.allowMa lformed; 1911 let allowMalformed = opt$.allowMalformed === void 0 ? false : opt$.allowMa lformed;
1852 this._allowMalformed = allowMalformed; 1912 this[_allowMalformed] = allowMalformed;
1853 super.Encoding(); 1913 super.Encoding();
1854 } 1914 }
1855 get name() { 1915 get name() {
1856 return "utf-8"; 1916 return "utf-8";
1857 } 1917 }
1858 decode(codeUnits, opt$) { 1918 decode(codeUnits, opt$) {
1859 let allowMalformed = opt$.allowMalformed === void 0 ? null : opt$.allowMal formed; 1919 let allowMalformed = opt$.allowMalformed === void 0 ? null : opt$.allowMal formed;
1860 if (allowMalformed === null) 1920 if (allowMalformed === null)
1861 allowMalformed = this._allowMalformed; 1921 allowMalformed = this[_allowMalformed];
1862 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits ); 1922 return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits );
1863 } 1923 }
1864 get encoder() { 1924 get encoder() {
1865 return new Utf8Encoder(); 1925 return new Utf8Encoder();
1866 } 1926 }
1867 get decoder() { 1927 get decoder() {
1868 return new Utf8Decoder({allowMalformed: this._allowMalformed}); 1928 return new Utf8Decoder({allowMalformed: this[_allowMalformed]});
1869 } 1929 }
1870 } 1930 }
1871 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) { 1931 class Utf8Encoder extends Converter$(core.String, core.List$(core.int)) {
1872 Utf8Encoder() { 1932 Utf8Encoder() {
1873 super.Converter(); 1933 super.Converter();
1874 } 1934 }
1875 convert(string, start, end) { 1935 convert(string, start, end) {
1876 if (start === void 0) 1936 if (start === void 0)
1877 start = 0; 1937 start = 0;
1878 if (end === void 0) 1938 if (end === void 0)
1879 end = null; 1939 end = null;
1880 let stringLength = string.length; 1940 let stringLength = string.length;
1881 core.RangeError.checkValidRange(start, end, stringLength); 1941 core.RangeError.checkValidRange(start, end, stringLength);
1882 if (end === null) 1942 if (end === null)
1883 end = stringLength; 1943 end = stringLength;
1884 let length = end - start; 1944 let length = end - start;
1885 if (length === 0) 1945 if (length === 0)
1886 return new typed_data.Uint8List(0); 1946 return new typed_data.Uint8List(0);
1887 let encoder = new _Utf8Encoder.withBufferSize(length * 3); 1947 let encoder = new _Utf8Encoder.withBufferSize(length * 3);
1888 let endPosition = encoder._fillBuffer(string, start, end); 1948 let endPosition = encoder._fillBuffer(string, start, end);
1889 dart.assert(endPosition >= end - 1); 1949 dart.assert(endPosition >= end - 1);
1890 if (endPosition !== end) { 1950 if (endPosition !== end) {
1891 let lastCodeUnit = string.codeUnitAt(end - 1); 1951 let lastCodeUnit = string.codeUnitAt(end - 1);
1892 dart.assert(_isLeadSurrogate(lastCodeUnit)); 1952 dart.assert(_isLeadSurrogate(lastCodeUnit));
1893 let wasCombined = encoder._writeSurrogate(lastCodeUnit, 0); 1953 let wasCombined = encoder._writeSurrogate(lastCodeUnit, 0);
1894 dart.assert(!dart.notNull(wasCombined)); 1954 dart.assert(!dart.notNull(wasCombined));
1895 } 1955 }
1896 return encoder._buffer.sublist(0, encoder._bufferIndex); 1956 return encoder[_buffer].sublist(0, encoder[_bufferIndex]);
1897 } 1957 }
1898 startChunkedConversion(sink) { 1958 startChunkedConversion(sink) {
1899 if (!dart.is(sink, ByteConversionSink)) { 1959 if (!dart.is(sink, ByteConversionSink)) {
1900 sink = new ByteConversionSink.from(sink); 1960 sink = new ByteConversionSink.from(sink);
1901 } 1961 }
1902 return new _Utf8EncoderSink(dart.as(sink, ByteConversionSink)); 1962 return new _Utf8EncoderSink(dart.as(sink, ByteConversionSink));
1903 } 1963 }
1904 bind(stream) { 1964 bind(stream) {
1905 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int))); 1965 return dart.as(super.bind(stream), async.Stream$(core.List$(core.int)));
1906 } 1966 }
1907 } 1967 }
1908 class _Utf8Encoder extends dart.Object { 1968 class _Utf8Encoder extends dart.Object {
1909 _Utf8Encoder() { 1969 _Utf8Encoder() {
1910 this._Utf8Encoder$withBufferSize(dart.as(_DEFAULT_BYTE_BUFFER_SIZE, core.i nt)); 1970 this[_Utf8Encoder$withBufferSize](dart.as(_DEFAULT_BYTE_BUFFER_SIZE, core. int));
1911 } 1971 }
1912 _Utf8Encoder$withBufferSize(bufferSize) { 1972 _Utf8Encoder$withBufferSize(bufferSize) {
1913 this._buffer = _createBuffer(bufferSize); 1973 this[_buffer] = _createBuffer(bufferSize);
1914 this._carry = 0; 1974 this[_carry] = 0;
1915 this._bufferIndex = 0; 1975 this[_bufferIndex] = 0;
1916 } 1976 }
1917 static _createBuffer(size) { 1977 static [_createBuffer](size) {
1918 return new typed_data.Uint8List(size); 1978 return new typed_data.Uint8List(size);
1919 } 1979 }
1920 _writeSurrogate(leadingSurrogate, nextCodeUnit) { 1980 [_writeSurrogate](leadingSurrogate, nextCodeUnit) {
1921 if (_isTailSurrogate(nextCodeUnit)) { 1981 if (_isTailSurrogate(nextCodeUnit)) {
1922 let rune = _combineSurrogatePair(leadingSurrogate, nextCodeUnit); 1982 let rune = _combineSurrogatePair(leadingSurrogate, nextCodeUnit);
1923 dart.assert(rune > _THREE_BYTE_LIMIT); 1983 dart.assert(rune > _THREE_BYTE_LIMIT);
1924 dart.assert(rune <= _FOUR_BYTE_LIMIT); 1984 dart.assert(rune <= _FOUR_BYTE_LIMIT);
1925 this._buffer.set(this._bufferIndex++, 240 | rune >> 18); 1985 this[_buffer].set(this[_bufferIndex]++, 240 | rune >> 18);
1926 this._buffer.set(this._bufferIndex++, 128 | rune >> 12 & 63); 1986 this[_buffer].set(this[_bufferIndex]++, 128 | rune >> 12 & 63);
1927 this._buffer.set(this._bufferIndex++, 128 | rune >> 6 & 63); 1987 this[_buffer].set(this[_bufferIndex]++, 128 | rune >> 6 & 63);
1928 this._buffer.set(this._bufferIndex++, 128 | rune & 63); 1988 this[_buffer].set(this[_bufferIndex]++, 128 | rune & 63);
1929 return true; 1989 return true;
1930 } else { 1990 } else {
1931 this._buffer.set(this._bufferIndex++, 224 | leadingSurrogate >> 12); 1991 this[_buffer].set(this[_bufferIndex]++, 224 | leadingSurrogate >> 12);
1932 this._buffer.set(this._bufferIndex++, 128 | leadingSurrogate >> 6 & 63); 1992 this[_buffer].set(this[_bufferIndex]++, 128 | leadingSurrogate >> 6 & 63 );
1933 this._buffer.set(this._bufferIndex++, 128 | leadingSurrogate & 63); 1993 this[_buffer].set(this[_bufferIndex]++, 128 | leadingSurrogate & 63);
1934 return false; 1994 return false;
1935 } 1995 }
1936 } 1996 }
1937 _fillBuffer(str, start, end) { 1997 [_fillBuffer](str, start, end) {
1938 if (dart.notNull(start !== end) && dart.notNull(_isLeadSurrogate(str.codeU nitAt(end - 1)))) { 1998 if (dart.notNull(start !== end) && dart.notNull(_isLeadSurrogate(str.codeU nitAt(end - 1)))) {
1939 end--; 1999 end--;
1940 } 2000 }
1941 let stringIndex = null; 2001 let stringIndex = null;
1942 for (stringIndex = start; stringIndex < end; stringIndex++) { 2002 for (stringIndex = start; stringIndex < end; stringIndex++) {
1943 let codeUnit = str.codeUnitAt(stringIndex); 2003 let codeUnit = str.codeUnitAt(stringIndex);
1944 if (codeUnit <= _ONE_BYTE_LIMIT) { 2004 if (codeUnit <= _ONE_BYTE_LIMIT) {
1945 if (this._bufferIndex >= this._buffer.length) 2005 if (this[_bufferIndex] >= this[_buffer].length)
1946 break; 2006 break;
1947 this._buffer.set(this._bufferIndex++, codeUnit); 2007 this[_buffer].set(this[_bufferIndex]++, codeUnit);
1948 } else if (_isLeadSurrogate(codeUnit)) { 2008 } else if (_isLeadSurrogate(codeUnit)) {
1949 if (this._bufferIndex + 3 >= this._buffer.length) 2009 if (this[_bufferIndex] + 3 >= this[_buffer].length)
1950 break; 2010 break;
1951 let nextCodeUnit = str.codeUnitAt(stringIndex + 1); 2011 let nextCodeUnit = str.codeUnitAt(stringIndex + 1);
1952 let wasCombined = this._writeSurrogate(codeUnit, nextCodeUnit); 2012 let wasCombined = this[_writeSurrogate](codeUnit, nextCodeUnit);
1953 if (wasCombined) 2013 if (wasCombined)
1954 stringIndex++; 2014 stringIndex++;
1955 } else { 2015 } else {
1956 let rune = codeUnit; 2016 let rune = codeUnit;
1957 if (rune <= _TWO_BYTE_LIMIT) { 2017 if (rune <= _TWO_BYTE_LIMIT) {
1958 if (this._bufferIndex + 1 >= this._buffer.length) 2018 if (this[_bufferIndex] + 1 >= this[_buffer].length)
1959 break; 2019 break;
1960 this._buffer.set(this._bufferIndex++, 192 | rune >> 6); 2020 this[_buffer].set(this[_bufferIndex]++, 192 | rune >> 6);
1961 this._buffer.set(this._bufferIndex++, 128 | rune & 63); 2021 this[_buffer].set(this[_bufferIndex]++, 128 | rune & 63);
1962 } else { 2022 } else {
1963 dart.assert(rune <= _THREE_BYTE_LIMIT); 2023 dart.assert(rune <= _THREE_BYTE_LIMIT);
1964 if (this._bufferIndex + 2 >= this._buffer.length) 2024 if (this[_bufferIndex] + 2 >= this[_buffer].length)
1965 break; 2025 break;
1966 this._buffer.set(this._bufferIndex++, 224 | rune >> 12); 2026 this[_buffer].set(this[_bufferIndex]++, 224 | rune >> 12);
1967 this._buffer.set(this._bufferIndex++, 128 | rune >> 6 & 63); 2027 this[_buffer].set(this[_bufferIndex]++, 128 | rune >> 6 & 63);
1968 this._buffer.set(this._bufferIndex++, 128 | rune & 63); 2028 this[_buffer].set(this[_bufferIndex]++, 128 | rune & 63);
1969 } 2029 }
1970 } 2030 }
1971 } 2031 }
1972 return stringIndex; 2032 return stringIndex;
1973 } 2033 }
1974 } 2034 }
1975 dart.defineNamedConstructor(_Utf8Encoder, 'withBufferSize'); 2035 dart.defineNamedConstructor(_Utf8Encoder, 'withBufferSize');
1976 _Utf8Encoder._DEFAULT_BYTE_BUFFER_SIZE = 1024; 2036 _Utf8Encoder._DEFAULT_BYTE_BUFFER_SIZE = 1024;
1977 class _Utf8EncoderSink extends dart.mixin(_Utf8Encoder, StringConversionSinkMi xin) { 2037 class _Utf8EncoderSink extends dart.mixin(_Utf8Encoder, StringConversionSinkMi xin) {
1978 _Utf8EncoderSink(_sink) { 2038 _Utf8EncoderSink($_sink) {
1979 this._sink = _sink; 2039 this[_sink] = $_sink;
1980 super._Utf8Encoder(); 2040 super._Utf8Encoder();
1981 } 2041 }
1982 close() { 2042 close() {
1983 if (this._carry !== 0) { 2043 if (this[_carry] !== 0) {
1984 this.addSlice("", 0, 0, true); 2044 this.addSlice("", 0, 0, true);
1985 return; 2045 return;
1986 } 2046 }
1987 this._sink.close(); 2047 this[_sink].close();
1988 } 2048 }
1989 addSlice(str, start, end, isLast) { 2049 addSlice(str, start, end, isLast) {
1990 this._bufferIndex = 0; 2050 this[_bufferIndex] = 0;
1991 if (dart.notNull(start === end) && dart.notNull(!dart.notNull(isLast))) { 2051 if (dart.notNull(start === end) && dart.notNull(!dart.notNull(isLast))) {
1992 return; 2052 return;
1993 } 2053 }
1994 if (this._carry !== 0) { 2054 if (this[_carry] !== 0) {
1995 let nextCodeUnit = 0; 2055 let nextCodeUnit = 0;
1996 if (start !== end) { 2056 if (start !== end) {
1997 nextCodeUnit = str.codeUnitAt(start); 2057 nextCodeUnit = str.codeUnitAt(start);
1998 } else { 2058 } else {
1999 dart.assert(isLast); 2059 dart.assert(isLast);
2000 } 2060 }
2001 let wasCombined = this._writeSurrogate(this._carry, nextCodeUnit); 2061 let wasCombined = this[_writeSurrogate](this[_carry], nextCodeUnit);
2002 dart.assert(dart.notNull(!dart.notNull(wasCombined)) || dart.notNull(sta rt !== end)); 2062 dart.assert(dart.notNull(!dart.notNull(wasCombined)) || dart.notNull(sta rt !== end));
2003 if (wasCombined) 2063 if (wasCombined)
2004 start++; 2064 start++;
2005 this._carry = 0; 2065 this[_carry] = 0;
2006 } 2066 }
2007 do { 2067 do {
2008 start = this._fillBuffer(str, start, end); 2068 start = this[_fillBuffer](str, start, end);
2009 let isLastSlice = dart.notNull(isLast) && dart.notNull(start === end); 2069 let isLastSlice = dart.notNull(isLast) && dart.notNull(start === end);
2010 if (dart.notNull(start === end - 1) && dart.notNull(_isLeadSurrogate(str .codeUnitAt(start)))) { 2070 if (dart.notNull(start === end - 1) && dart.notNull(_isLeadSurrogate(str .codeUnitAt(start)))) {
2011 if (dart.notNull(isLast) && dart.notNull(this._bufferIndex < this._buf fer.length - 3)) { 2071 if (dart.notNull(isLast) && dart.notNull(this[_bufferIndex] < this[_bu ffer].length - 3)) {
2012 let hasBeenCombined = this._writeSurrogate(str.codeUnitAt(start), 0) ; 2072 let hasBeenCombined = this[_writeSurrogate](str.codeUnitAt(start), 0 );
2013 dart.assert(!dart.notNull(hasBeenCombined)); 2073 dart.assert(!dart.notNull(hasBeenCombined));
2014 } else { 2074 } else {
2015 this._carry = str.codeUnitAt(start); 2075 this[_carry] = str.codeUnitAt(start);
2016 } 2076 }
2017 start++; 2077 start++;
2018 } 2078 }
2019 this._sink.addSlice(this._buffer, 0, this._bufferIndex, isLastSlice); 2079 this[_sink].addSlice(this[_buffer], 0, this[_bufferIndex], isLastSlice);
2020 this._bufferIndex = 0; 2080 this[_bufferIndex] = 0;
2021 } while (start < end); 2081 } while (start < end);
2022 if (isLast) 2082 if (isLast)
2023 this.close(); 2083 this.close();
2024 } 2084 }
2025 } 2085 }
2026 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) { 2086 class Utf8Decoder extends Converter$(core.List$(core.int), core.String) {
2027 Utf8Decoder(opt$) { 2087 Utf8Decoder(opt$) {
2028 let allowMalformed = opt$.allowMalformed === void 0 ? false : opt$.allowMa lformed; 2088 let allowMalformed = opt$.allowMalformed === void 0 ? false : opt$.allowMa lformed;
2029 this._allowMalformed = allowMalformed; 2089 this[_allowMalformed] = allowMalformed;
2030 super.Converter(); 2090 super.Converter();
2031 } 2091 }
2032 convert(codeUnits, start, end) { 2092 convert(codeUnits, start, end) {
2033 if (start === void 0) 2093 if (start === void 0)
2034 start = 0; 2094 start = 0;
2035 if (end === void 0) 2095 if (end === void 0)
2036 end = null; 2096 end = null;
2037 let length = codeUnits.length; 2097 let length = codeUnits.length;
2038 core.RangeError.checkValidRange(start, end, length); 2098 core.RangeError.checkValidRange(start, end, length);
2039 if (end === null) 2099 if (end === null)
2040 end = length; 2100 end = length;
2041 let buffer = new core.StringBuffer(); 2101 let buffer = new core.StringBuffer();
2042 let decoder = new _Utf8Decoder(buffer, this._allowMalformed); 2102 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]);
2043 decoder.convert(codeUnits, start, end); 2103 decoder.convert(codeUnits, start, end);
2044 decoder.close(); 2104 decoder.close();
2045 return buffer.toString(); 2105 return buffer.toString();
2046 } 2106 }
2047 startChunkedConversion(sink) { 2107 startChunkedConversion(sink) {
2048 let stringSink = null; 2108 let stringSink = null;
2049 if (dart.is(sink, StringConversionSink)) { 2109 if (dart.is(sink, StringConversionSink)) {
2050 stringSink = sink; 2110 stringSink = sink;
2051 } else { 2111 } else {
2052 stringSink = new StringConversionSink.from(sink); 2112 stringSink = new StringConversionSink.from(sink);
2053 } 2113 }
2054 return stringSink.asUtf8Sink(this._allowMalformed); 2114 return stringSink.asUtf8Sink(this[_allowMalformed]);
2055 } 2115 }
2056 bind(stream) { 2116 bind(stream) {
2057 return dart.as(super.bind(stream), async.Stream$(core.String)); 2117 return dart.as(super.bind(stream), async.Stream$(core.String));
2058 } 2118 }
2059 fuse(next) { 2119 fuse(next) {
2060 return super.fuse(next); 2120 return super.fuse(next);
2061 } 2121 }
2062 } 2122 }
2063 let _ONE_BYTE_LIMIT = 127; 2123 let _ONE_BYTE_LIMIT = 127;
2064 let _TWO_BYTE_LIMIT = 2047; 2124 let _TWO_BYTE_LIMIT = 2047;
(...skipping 14 matching lines...) Expand all
2079 } 2139 }
2080 // Function _isTailSurrogate: (int) → bool 2140 // Function _isTailSurrogate: (int) → bool
2081 function _isTailSurrogate(codeUnit) { 2141 function _isTailSurrogate(codeUnit) {
2082 return (codeUnit & _SURROGATE_TAG_MASK) === _TAIL_SURROGATE_MIN; 2142 return (codeUnit & _SURROGATE_TAG_MASK) === _TAIL_SURROGATE_MIN;
2083 } 2143 }
2084 // Function _combineSurrogatePair: (int, int) → int 2144 // Function _combineSurrogatePair: (int, int) → int
2085 function _combineSurrogatePair(lead, tail) { 2145 function _combineSurrogatePair(lead, tail) {
2086 return 65536 + ((lead & _SURROGATE_VALUE_MASK) << 10) | tail & _SURROGATE_VA LUE_MASK; 2146 return 65536 + ((lead & _SURROGATE_VALUE_MASK) << 10) | tail & _SURROGATE_VA LUE_MASK;
2087 } 2147 }
2088 class _Utf8Decoder extends dart.Object { 2148 class _Utf8Decoder extends dart.Object {
2089 _Utf8Decoder(_stringSink, _allowMalformed) { 2149 _Utf8Decoder($_stringSink, $_allowMalformed) {
2090 this._stringSink = _stringSink; 2150 this[_stringSink] = $_stringSink;
2091 this._allowMalformed = _allowMalformed; 2151 this[_allowMalformed] = $_allowMalformed;
2092 this._isFirstCharacter = true; 2152 this[_isFirstCharacter] = true;
2093 this._value = 0; 2153 this[_value] = 0;
2094 this._expectedUnits = 0; 2154 this[_expectedUnits] = 0;
2095 this._extraUnits = 0; 2155 this[_extraUnits] = 0;
2096 } 2156 }
2097 get hasPartialInput() { 2157 get hasPartialInput() {
2098 return this._expectedUnits > 0; 2158 return this[_expectedUnits] > 0;
2099 } 2159 }
2100 close() { 2160 close() {
2101 this.flush(); 2161 this.flush();
2102 } 2162 }
2103 flush() { 2163 flush() {
2104 if (this.hasPartialInput) { 2164 if (this.hasPartialInput) {
2105 if (!dart.notNull(this._allowMalformed)) { 2165 if (!dart.notNull(this[_allowMalformed])) {
2106 throw new core.FormatException("Unfinished UTF-8 octet sequence"); 2166 throw new core.FormatException("Unfinished UTF-8 octet sequence");
2107 } 2167 }
2108 this._stringSink.writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE); 2168 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE);
2109 this._value = 0; 2169 this[_value] = 0;
2110 this._expectedUnits = 0; 2170 this[_expectedUnits] = 0;
2111 this._extraUnits = 0; 2171 this[_extraUnits] = 0;
2112 } 2172 }
2113 } 2173 }
2114 convert(codeUnits, startIndex, endIndex) { 2174 convert(codeUnits, startIndex, endIndex) {
2115 let value = this._value; 2175 let value = this[_value];
2116 let expectedUnits = this._expectedUnits; 2176 let expectedUnits = this[_expectedUnits];
2117 let extraUnits = this._extraUnits; 2177 let extraUnits = this[_extraUnits];
2118 this._value = 0; 2178 this[_value] = 0;
2119 this._expectedUnits = 0; 2179 this[_expectedUnits] = 0;
2120 this._extraUnits = 0; 2180 this[_extraUnits] = 0;
2121 // Function scanOneByteCharacters: (dynamic, int) → int 2181 // Function scanOneByteCharacters: (dynamic, int) → int
2122 function scanOneByteCharacters(units, from) { 2182 function scanOneByteCharacters(units, from) {
2123 let to = endIndex; 2183 let to = endIndex;
2124 let mask = _ONE_BYTE_LIMIT; 2184 let mask = _ONE_BYTE_LIMIT;
2125 for (let i = from; i < to; i++) { 2185 for (let i = from; i < to; i++) {
2126 let unit = dart.dindex(units, i); 2186 let unit = dart.dindex(units, i);
2127 if (!dart.equals(dart.dbinary(unit, '&', mask), unit)) 2187 if (!dart.equals(dart.dbinary(unit, '&', mask), unit))
2128 return i - from; 2188 return i - from;
2129 } 2189 }
2130 return to - from; 2190 return to - from;
2131 } 2191 }
2132 // Function addSingleBytes: (int, int) → void 2192 // Function addSingleBytes: (int, int) → void
2133 function addSingleBytes(from, to) { 2193 function addSingleBytes(from, to) {
2134 dart.assert(dart.notNull(from >= startIndex) && dart.notNull(from <= end Index)); 2194 dart.assert(dart.notNull(from >= startIndex) && dart.notNull(from <= end Index));
2135 dart.assert(dart.notNull(to >= startIndex) && dart.notNull(to <= endInde x)); 2195 dart.assert(dart.notNull(to >= startIndex) && dart.notNull(to <= endInde x));
2136 this._stringSink.write(new core.String.fromCharCodes(codeUnits, from, to )); 2196 this[_stringSink].write(new core.String.fromCharCodes(codeUnits, from, t o));
2137 } 2197 }
2138 let i = startIndex; 2198 let i = startIndex;
2139 loop: 2199 loop:
2140 while (true) { 2200 while (true) {
2141 multibyte: 2201 multibyte:
2142 if (expectedUnits > 0) { 2202 if (expectedUnits > 0) {
2143 do { 2203 do {
2144 if (i === endIndex) { 2204 if (i === endIndex) {
2145 break loop; 2205 break loop;
2146 } 2206 }
2147 let unit = codeUnits.get(i); 2207 let unit = codeUnits.get(i);
2148 if ((unit & 192) !== 128) { 2208 if ((unit & 192) !== 128) {
2149 expectedUnits = 0; 2209 expectedUnits = 0;
2150 if (!dart.notNull(this._allowMalformed)) { 2210 if (!dart.notNull(this[_allowMalformed])) {
2151 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit. toRadixString(16)}`); 2211 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit. toRadixString(16)}`);
2152 } 2212 }
2153 this._isFirstCharacter = false; 2213 this[_isFirstCharacter] = false;
2154 this._stringSink.writeCharCode(UNICODE_REPLACEMENT_CHARACTER_R UNE); 2214 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_ RUNE);
2155 break multibyte; 2215 break multibyte;
2156 } else { 2216 } else {
2157 value = value << 6 | unit & 63; 2217 value = value << 6 | unit & 63;
2158 expectedUnits--; 2218 expectedUnits--;
2159 i++; 2219 i++;
2160 } 2220 }
2161 } while (expectedUnits > 0); 2221 } while (expectedUnits > 0);
2162 if (value <= _LIMITS.get(extraUnits - 1)) { 2222 if (value <= _LIMITS.get(extraUnits - 1)) {
2163 if (!dart.notNull(this._allowMalformed)) { 2223 if (!dart.notNull(this[_allowMalformed])) {
2164 throw new core.FormatException(`Overlong encoding of 0x${value .toRadixString(16)}`); 2224 throw new core.FormatException(`Overlong encoding of 0x${value .toRadixString(16)}`);
2165 } 2225 }
2166 expectedUnits = extraUnits = 0; 2226 expectedUnits = extraUnits = 0;
2167 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2227 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2168 } 2228 }
2169 if (value > _FOUR_BYTE_LIMIT) { 2229 if (value > _FOUR_BYTE_LIMIT) {
2170 if (!dart.notNull(this._allowMalformed)) { 2230 if (!dart.notNull(this[_allowMalformed])) {
2171 throw new core.FormatException("Character outside valid Unicod e range: " + `0x${value.toRadixString(16)}`); 2231 throw new core.FormatException("Character outside valid Unicod e range: " + `0x${value.toRadixString(16)}`);
2172 } 2232 }
2173 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2233 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2174 } 2234 }
2175 if (dart.notNull(!dart.notNull(this._isFirstCharacter)) || dart.no tNull(value !== UNICODE_BOM_CHARACTER_RUNE)) { 2235 if (dart.notNull(!dart.notNull(this[_isFirstCharacter])) || dart.n otNull(value !== UNICODE_BOM_CHARACTER_RUNE)) {
2176 this._stringSink.writeCharCode(value); 2236 this[_stringSink].writeCharCode(value);
2177 } 2237 }
2178 this._isFirstCharacter = false; 2238 this[_isFirstCharacter] = false;
2179 } 2239 }
2180 while (i < endIndex) { 2240 while (i < endIndex) {
2181 let oneBytes = scanOneByteCharacters(codeUnits, i); 2241 let oneBytes = scanOneByteCharacters(codeUnits, i);
2182 if (oneBytes > 0) { 2242 if (oneBytes > 0) {
2183 this._isFirstCharacter = false; 2243 this[_isFirstCharacter] = false;
2184 addSingleBytes(i, i + oneBytes); 2244 addSingleBytes(i, i + oneBytes);
2185 i = oneBytes; 2245 i = oneBytes;
2186 if (i === endIndex) 2246 if (i === endIndex)
2187 break; 2247 break;
2188 } 2248 }
2189 let unit = codeUnits.get(i++); 2249 let unit = codeUnits.get(i++);
2190 if (unit < 0) { 2250 if (unit < 0) {
2191 if (!dart.notNull(this._allowMalformed)) { 2251 if (!dart.notNull(this[_allowMalformed])) {
2192 throw new core.FormatException(`Negative UTF-8 code unit: -0x${( -unit).toRadixString(16)}`); 2252 throw new core.FormatException(`Negative UTF-8 code unit: -0x${( -unit).toRadixString(16)}`);
2193 } 2253 }
2194 this._stringSink.writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE) ; 2254 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE );
2195 } else { 2255 } else {
2196 dart.assert(unit > _ONE_BYTE_LIMIT); 2256 dart.assert(unit > _ONE_BYTE_LIMIT);
2197 if ((unit & 224) === 192) { 2257 if ((unit & 224) === 192) {
2198 value = unit & 31; 2258 value = unit & 31;
2199 expectedUnits = extraUnits = 1; 2259 expectedUnits = extraUnits = 1;
2200 continue loop; 2260 continue loop;
2201 } 2261 }
2202 if ((unit & 240) === 224) { 2262 if ((unit & 240) === 224) {
2203 value = unit & 15; 2263 value = unit & 15;
2204 expectedUnits = extraUnits = 2; 2264 expectedUnits = extraUnits = 2;
2205 continue loop; 2265 continue loop;
2206 } 2266 }
2207 if (dart.notNull((unit & 248) === 240) && dart.notNull(unit < 245) ) { 2267 if (dart.notNull((unit & 248) === 240) && dart.notNull(unit < 245) ) {
2208 value = unit & 7; 2268 value = unit & 7;
2209 expectedUnits = extraUnits = 3; 2269 expectedUnits = extraUnits = 3;
2210 continue loop; 2270 continue loop;
2211 } 2271 }
2212 if (!dart.notNull(this._allowMalformed)) { 2272 if (!dart.notNull(this[_allowMalformed])) {
2213 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.toRa dixString(16)}`); 2273 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit.toRa dixString(16)}`);
2214 } 2274 }
2215 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2275 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2216 expectedUnits = extraUnits = 0; 2276 expectedUnits = extraUnits = 0;
2217 this._isFirstCharacter = false; 2277 this[_isFirstCharacter] = false;
2218 this._stringSink.writeCharCode(value); 2278 this[_stringSink].writeCharCode(value);
2219 } 2279 }
2220 } 2280 }
2221 break loop; 2281 break loop;
2222 } 2282 }
2223 if (expectedUnits > 0) { 2283 if (expectedUnits > 0) {
2224 this._value = value; 2284 this[_value] = value;
2225 this._expectedUnits = expectedUnits; 2285 this[_expectedUnits] = expectedUnits;
2226 this._extraUnits = extraUnits; 2286 this[_extraUnits] = extraUnits;
2227 } 2287 }
2228 } 2288 }
2229 } 2289 }
2230 _Utf8Decoder._LIMITS = /* Unimplemented const */new List.from([_ONE_BYTE_LIMIT , _TWO_BYTE_LIMIT, _THREE_BYTE_LIMIT, _FOUR_BYTE_LIMIT]); 2290 _Utf8Decoder._LIMITS = /* Unimplemented const */new List.from([_ONE_BYTE_LIMIT , _TWO_BYTE_LIMIT, _THREE_BYTE_LIMIT, _FOUR_BYTE_LIMIT]);
2231 // Exports: 2291 // Exports:
2232 convert.ASCII = ASCII; 2292 convert.ASCII = ASCII;
2233 convert.AsciiCodec = AsciiCodec; 2293 convert.AsciiCodec = AsciiCodec;
2234 convert.AsciiEncoder = AsciiEncoder; 2294 convert.AsciiEncoder = AsciiEncoder;
2235 convert.AsciiDecoder = AsciiDecoder; 2295 convert.AsciiDecoder = AsciiDecoder;
2236 convert.ByteConversionSink = ByteConversionSink; 2296 convert.ByteConversionSink = ByteConversionSink;
(...skipping 24 matching lines...) Expand all
2261 convert.ClosableStringSink = ClosableStringSink; 2321 convert.ClosableStringSink = ClosableStringSink;
2262 convert.StringConversionSinkBase = StringConversionSinkBase; 2322 convert.StringConversionSinkBase = StringConversionSinkBase;
2263 convert.StringConversionSinkMixin = StringConversionSinkMixin; 2323 convert.StringConversionSinkMixin = StringConversionSinkMixin;
2264 convert.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2324 convert.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2265 convert.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2325 convert.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2266 convert.UTF8 = UTF8; 2326 convert.UTF8 = UTF8;
2267 convert.Utf8Codec = Utf8Codec; 2327 convert.Utf8Codec = Utf8Codec;
2268 convert.Utf8Encoder = Utf8Encoder; 2328 convert.Utf8Encoder = Utf8Encoder;
2269 convert.Utf8Decoder = Utf8Decoder; 2329 convert.Utf8Decoder = Utf8Decoder;
2270 })(convert || (convert = {})); 2330 })(convert || (convert = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698