| 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 import "dart:collection" show HashMap; | 5 import "dart:collection" show HashMap; |
| 6 | 6 |
| 7 patch class ReceivePort { | 7 patch class ReceivePort { |
| 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 9 | 9 |
| 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 // Call into the VM to close the VM maintained mappings. | 132 // Call into the VM to close the VM maintained mappings. |
| 133 _closeInternal() native "RawReceivePortImpl_closeInternal"; | 133 _closeInternal() native "RawReceivePortImpl_closeInternal"; |
| 134 | 134 |
| 135 void set handler(Function value) { | 135 void set handler(Function value) { |
| 136 _handlerMap[this._get_id()] = value; | 136 _handlerMap[this._get_id()] = value; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // TODO(iposva): Ideally keep this map in the VM. | 139 // TODO(iposva): Ideally keep this map in the VM. |
| 140 // id to handler mapping. | 140 // id to handler mapping. |
| 141 static final Map _handlerMap = new HashMap(); | 141 static _initHandlerMap() { |
| 142 // TODO(18511): Workaround bad CheckSmi hoisting. |
| 143 var tempMap = new HashMap(); |
| 144 // Collect feedback that not all keys are Smis. |
| 145 tempMap["."] = 1; |
| 146 tempMap["."] = 2; |
| 147 |
| 148 return new HashMap(); |
| 149 } |
| 150 static final Map _handlerMap = _initHandlerMap(); |
| 142 } | 151 } |
| 143 | 152 |
| 144 | 153 |
| 145 class _SendPortImpl implements SendPort { | 154 class _SendPortImpl implements SendPort { |
| 146 /*--- public interface ---*/ | 155 /*--- public interface ---*/ |
| 147 void send(var message) { | 156 void send(var message) { |
| 148 _sendInternal(message); | 157 _sendInternal(message); |
| 149 } | 158 } |
| 150 | 159 |
| 151 bool operator==(var other) { | 160 bool operator==(var other) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 268 } |
| 260 | 269 |
| 261 static final RawReceivePort _self = _mainPort; | 270 static final RawReceivePort _self = _mainPort; |
| 262 static RawReceivePort get _mainPort native "Isolate_mainPort"; | 271 static RawReceivePort get _mainPort native "Isolate_mainPort"; |
| 263 | 272 |
| 264 static SendPort _spawnFunction(Function topLevelFunction) | 273 static SendPort _spawnFunction(Function topLevelFunction) |
| 265 native "Isolate_spawnFunction"; | 274 native "Isolate_spawnFunction"; |
| 266 | 275 |
| 267 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; | 276 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; |
| 268 } | 277 } |
| OLD | NEW |