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

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

Powered by Google App Engine
This is Rietveld 408576698