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

Side by Side Diff: test/generated_sdk/lib/convert/convert.dart

Issue 1112403004: SDK fixes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Formatting fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * 6 *
7 * Encoders and decoders for converting between different data representations, 7 * Encoders and decoders for converting between different data representations,
8 * including JSON and UTF-8. 8 * including JSON and UTF-8.
9 * 9 *
10 * In addition to converters for common data representations, this library 10 * In addition to converters for common data representations, this library
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // We keep track of the map entries that we have already 160 // We keep track of the map entries that we have already
161 // processed by adding them to a separate JavaScript object. 161 // processed by adding them to a separate JavaScript object.
162 var _processed = _newJavaScriptObject(); 162 var _processed = _newJavaScriptObject();
163 163
164 // If the data slot isn't null, it represents either the list 164 // If the data slot isn't null, it represents either the list
165 // of keys (for non-upgraded JSON maps) or the upgraded map. 165 // of keys (for non-upgraded JSON maps) or the upgraded map.
166 var _data = null; 166 var _data = null;
167 167
168 _JsonMap(this._original); 168 _JsonMap(this._original);
169 169
170 operator[](key) { 170 operator[](Object key) {
171 if (_isUpgraded) { 171 if (_isUpgraded) {
172 return _upgradedMap[key]; 172 return _upgradedMap[key];
173 } else if (key is !String) { 173 } else if (key is !String) {
174 return null; 174 return null;
175 } else { 175 } else {
176 var result = _getProperty(_processed, key); 176 var result = _getProperty(_processed, key);
177 if (_isUnprocessed(result)) result = _process(key); 177 if (_isUnprocessed(result)) result = _process(key);
178 return result; 178 return result;
179 } 179 }
180 } 180 }
(...skipping 29 matching lines...) Expand all
210 _upgrade()[key] = value; 210 _upgrade()[key] = value;
211 } 211 }
212 } 212 }
213 213
214 void addAll(Map other) { 214 void addAll(Map other) {
215 other.forEach((key, value) { 215 other.forEach((key, value) {
216 this[key] = value; 216 this[key] = value;
217 }); 217 });
218 } 218 }
219 219
220 bool containsValue(value) { 220 bool containsValue(Object value) {
221 if (_isUpgraded) return _upgradedMap.containsValue(value); 221 if (_isUpgraded) return _upgradedMap.containsValue(value);
222 List<String> keys = _computeKeys(); 222 List<String> keys = _computeKeys();
223 for (int i = 0; i < keys.length; i++) { 223 for (int i = 0; i < keys.length; i++) {
224 String key = keys[i]; 224 String key = keys[i];
225 if (this[key] == value) return true; 225 if (this[key] == value) return true;
226 } 226 }
227 return false; 227 return false;
228 } 228 }
229 229
230 bool containsKey(key) { 230 bool containsKey(Object key) {
231 if (_isUpgraded) return _upgradedMap.containsKey(key); 231 if (_isUpgraded) return _upgradedMap.containsKey(key);
232 if (key is !String) return false; 232 if (key is !String) return false;
233 return _hasProperty(_original, key); 233 return _hasProperty(_original, key);
234 } 234 }
235 235
236 putIfAbsent(key, ifAbsent()) { 236 putIfAbsent(key, ifAbsent()) {
237 if (containsKey(key)) return this[key]; 237 if (containsKey(key)) return this[key];
238 var value = ifAbsent(); 238 var value = ifAbsent();
239 this[key] = value; 239 this[key] = value;
240 return value; 240 return value;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void close() { 405 void close() {
406 super.close(); 406 super.close();
407 StringBuffer buffer = _stringSink; 407 StringBuffer buffer = _stringSink;
408 String accumulated = buffer.toString(); 408 String accumulated = buffer.toString();
409 buffer.clear(); 409 buffer.clear();
410 Object decoded = _parseJson(accumulated, _reviver); 410 Object decoded = _parseJson(accumulated, _reviver);
411 _sink.add(decoded); 411 _sink.add(decoded);
412 _sink.close(); 412 _sink.close();
413 } 413 }
414 } 414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698