| 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 // Defines message visitors, serialization, and deserialization. | 5 // Defines message visitors, serialization, and deserialization. |
| 6 | 6 |
| 7 /** Serialize [message] (or simulate serialization). */ | 7 /** Serialize [message] (or simulate serialization). */ |
| 8 _serializeMessage(message) { | 8 _serializeMessage(message) { |
| 9 if (_globalState.needSerialization) { | 9 if (_globalState.needSerialization) { |
| 10 return new _JsSerializer().traverse(message); | 10 return new _JsSerializer().traverse(message); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 class _JsSerializer extends _Serializer { | 26 class _JsSerializer extends _Serializer { |
| 27 | 27 |
| 28 _JsSerializer() : super() { _visited = new _JsVisitedMap(); } | 28 _JsSerializer() : super() { _visited = new _JsVisitedMap(); } |
| 29 | 29 |
| 30 visitSendPort(SendPort x) { | 30 visitSendPort(SendPort x) { |
| 31 if (x is _NativeJsSendPort) return visitNativeJsSendPort(x); | 31 if (x is _NativeJsSendPort) return visitNativeJsSendPort(x); |
| 32 if (x is _WorkerSendPort) return visitWorkerSendPort(x); | 32 if (x is _WorkerSendPort) return visitWorkerSendPort(x); |
| 33 if (x is _BufferingSendPort) return visitBufferingSendPort(x); | 33 if (x is _BufferingSendPort) return visitBufferingSendPort(x); |
| 34 throw "Illegal underlying port $p"; | 34 throw "Illegal underlying port $x"; |
| 35 } | 35 } |
| 36 | 36 |
| 37 visitNativeJsSendPort(_NativeJsSendPort port) { | 37 visitNativeJsSendPort(_NativeJsSendPort port) { |
| 38 return ['sendport', _globalState.currentManagerId, | 38 return ['sendport', _globalState.currentManagerId, |
| 39 port._isolateId, port._receivePort._id]; | 39 port._isolateId, port._receivePort._id]; |
| 40 } | 40 } |
| 41 | 41 |
| 42 visitWorkerSendPort(_WorkerSendPort port) { | 42 visitWorkerSendPort(_WorkerSendPort port) { |
| 43 return ['sendport', port._workerId, port._isolateId, port._receivePortId]; | 43 return ['sendport', port._workerId, port._isolateId, port._receivePortId]; |
| 44 } | 44 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 return new _JsCopier().traverse(x); | 155 return new _JsCopier().traverse(x); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // only visible for testing purposes | 158 // only visible for testing purposes |
| 159 static serialize(x) { | 159 static serialize(x) { |
| 160 _Serializer serializer = new _JsSerializer(); | 160 _Serializer serializer = new _JsSerializer(); |
| 161 _Deserializer deserializer = new _JsDeserializer(); | 161 _Deserializer deserializer = new _JsDeserializer(); |
| 162 return deserializer.deserialize(serializer.traverse(x)); | 162 return deserializer.deserialize(serializer.traverse(x)); |
| 163 } | 163 } |
| 164 } | 164 } |
| OLD | NEW |