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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/isolate_serialization.dart

Issue 2304323002: Cast InternalMap to Map. (Closed)
Patch Set: Make InternalMap directly implement Map instead of casting. Created 4 years, 3 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of dart._isolate_helper; 5 part of dart._isolate_helper;
6 6
7 /// Serialize [message]. 7 /// Serialize [message].
8 _serializeMessage(message) { 8 _serializeMessage(message) {
9 return new _Serializer().serialize(message); 9 return new _Serializer().serialize(message);
10 } 10 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return serialized; 107 return serialized;
108 } 108 }
109 109
110 serializeArrayInPlace(JSArray x) { 110 serializeArrayInPlace(JSArray x) {
111 for (int i = 0; i < x.length; i++) { 111 for (int i = 0; i < x.length; i++) {
112 x[i] = serialize(x[i]); 112 x[i] = serialize(x[i]);
113 } 113 }
114 return x; 114 return x;
115 } 115 }
116 116
117 serializeMap(Map x) { 117 serializeMap(InternalMap x) {
118 Function serializeTearOff = serialize; 118 Function serializeTearOff = serialize;
119 return ['map', 119 return ['map',
120 x.keys.map(serializeTearOff).toList(), 120 x.keys.map(serializeTearOff).toList(),
121 x.values.map(serializeTearOff).toList()]; 121 x.values.map(serializeTearOff).toList()];
122 } 122 }
123 123
124 serializeJSObject(JSObject x) { 124 serializeJSObject(JSObject x) {
125 // Don't serialize objects if their `constructor` property isn't `Object` 125 // Don't serialize objects if their `constructor` property isn't `Object`
126 // or undefined/null. 126 // or undefined/null.
127 // A different constructor is taken as a sign that the object has complex 127 // A different constructor is taken as a sign that the object has complex
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // ['const', <array>]. 269 // ['const', <array>].
270 List deserializeConst(x) { 270 List deserializeConst(x) {
271 assert(x[0] == 'const'); 271 assert(x[0] == 'const');
272 List result = x[1]; 272 List result = x[1];
273 deserializedObjects.add(result); 273 deserializedObjects.add(result);
274 // TODO(floitsch): need to mark list as non-changeable. 274 // TODO(floitsch): need to mark list as non-changeable.
275 return new JSArray.markFixed(deserializeArrayInPlace(result)); 275 return new JSArray.markFixed(deserializeArrayInPlace(result));
276 } 276 }
277 277
278 // ['map', <key-list>, <value-list>]. 278 // ['map', <key-list>, <value-list>].
279 Map deserializeMap(x) { 279 Map deserializeMap(InternalMap x) {
280 assert(x[0] == 'map'); 280 assert(x[0] == 'map');
281 List keys = x[1]; 281 List keys = x[1];
282 List values = x[2]; 282 List values = x[2];
283 Map result = {}; 283 Map result = {};
284 deserializedObjects.add(result); 284 deserializedObjects.add(result);
285 // We need to keep the order of how objects were serialized. 285 // We need to keep the order of how objects were serialized.
286 // First deserialize all keys, and then only deserialize the values. 286 // First deserialize all keys, and then only deserialize the values.
287 keys = keys.map(deserialize).toList(); 287 keys = keys.map(deserialize).toList();
288 288
289 for (int i = 0; i < keys.length; i++) { 289 for (int i = 0; i < keys.length; i++) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 var instanceFromClassId = JS_EMBEDDED_GLOBAL('', INSTANCE_FROM_CLASS_ID); 352 var instanceFromClassId = JS_EMBEDDED_GLOBAL('', INSTANCE_FROM_CLASS_ID);
353 var initializeObject = JS_EMBEDDED_GLOBAL('', INITIALIZE_EMPTY_INSTANCE); 353 var initializeObject = JS_EMBEDDED_GLOBAL('', INITIALIZE_EMPTY_INSTANCE);
354 354
355 var emptyInstance = JS('', '#(#)', instanceFromClassId, classId); 355 var emptyInstance = JS('', '#(#)', instanceFromClassId, classId);
356 deserializedObjects.add(emptyInstance); 356 deserializedObjects.add(emptyInstance);
357 deserializeArrayInPlace(fields); 357 deserializeArrayInPlace(fields);
358 return JS('', '#(#, #, #)', 358 return JS('', '#(#, #, #)',
359 initializeObject, classId, emptyInstance, fields); 359 initializeObject, classId, emptyInstance, fields);
360 } 360 }
361 } 361 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/patch/collection_patch.dart ('k') | pkg/dev_compiler/tool/input_sdk/private/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698