Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Patch file for the dart:isolate library. | 5 // Patch file for the dart:isolate library. |
| 6 | 6 |
| 7 /******************************************************** | 7 /******************************************************** |
| 8 Inserted from lib/isolate/serialization.dart | 8 Inserted from lib/isolate/serialization.dart |
| 9 ********************************************************/ | 9 ********************************************************/ |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 var result = new List(len); | 134 var result = new List(len); |
| 135 for (int i = 0; i < len; i++) { | 135 for (int i = 0; i < len; i++) { |
| 136 result[i] = _dispatch(list[i]); | 136 result[i] = _dispatch(list[i]); |
| 137 } | 137 } |
| 138 return result; | 138 return result; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 /** Deserializes arrays created with [_Serializer]. */ | 142 /** Deserializes arrays created with [_Serializer]. */ |
| 143 class _Deserializer { | 143 class _Deserializer { |
| 144 Map<int, Dynamic> _deserialized; | 144 Map<int, dynamic> _deserialized; |
| 145 | 145 |
| 146 _Deserializer(); | 146 _Deserializer(); |
| 147 | 147 |
| 148 static bool isPrimitive(x) { | 148 static bool isPrimitive(x) { |
| 149 return (x == null) || (x is String) || (x is num) || (x is bool); | 149 return (x == null) || (x is String) || (x is num) || (x is bool); |
| 150 } | 150 } |
| 151 | 151 |
| 152 deserialize(x) { | 152 deserialize(x) { |
| 153 if (isPrimitive(x)) return x; | 153 if (isPrimitive(x)) return x; |
| 154 // TODO(floitsch): this should be new HashMap<int, var|Dynamic>() | 154 // TODO(floitsch): this should be new HashMap<int, var|dynamic>() |
|
kasperl
2012/10/23 12:24:58
Remove var|.
Anton Muhin
2012/10/23 12:32:54
Done.
| |
| 155 _deserialized = new HashMap(); | 155 _deserialized = new HashMap(); |
| 156 return _deserializeHelper(x); | 156 return _deserializeHelper(x); |
| 157 } | 157 } |
| 158 | 158 |
| 159 _deserializeHelper(x) { | 159 _deserializeHelper(x) { |
| 160 if (isPrimitive(x)) return x; | 160 if (isPrimitive(x)) return x; |
| 161 assert(x is List); | 161 assert(x is List); |
| 162 switch (x[0]) { | 162 switch (x[0]) { |
| 163 case 'ref': return _deserializeRef(x); | 163 case 'ref': return _deserializeRef(x); |
| 164 case 'list': return _deserializeList(x); | 164 case 'list': return _deserializeList(x); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 } | 204 } |
| 205 | 205 |
| 206 abstract deserializeSendPort(List x); | 206 abstract deserializeSendPort(List x); |
| 207 | 207 |
| 208 deserializeObject(List x) { | 208 deserializeObject(List x) { |
| 209 // TODO(floitsch): Use real exception (which one?). | 209 // TODO(floitsch): Use real exception (which one?). |
| 210 throw "Unexpected serialized object"; | 210 throw "Unexpected serialized object"; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| OLD | NEW |