OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class MessageTraverser { | 5 class MessageTraverser { |
6 static bool isPrimitive(x) { | 6 static bool isPrimitive(x) { |
7 return (x === null) || (x is String) || (x is num) || (x is bool); | 7 return (x === null) || (x is String) || (x is num) || (x is bool); |
8 } | 8 } |
9 | 9 |
10 MessageTraverser(); | 10 MessageTraverser(); |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 _dispatch(var x) { | 41 _dispatch(var x) { |
42 if (isPrimitive(x)) return visitPrimitive(x); | 42 if (isPrimitive(x)) return visitPrimitive(x); |
43 if (x is List) return visitList(x); | 43 if (x is List) return visitList(x); |
44 if (x is Map) return visitMap(x); | 44 if (x is Map) return visitMap(x); |
45 if (x is SendPortImpl) return visitSendPort(x); | 45 if (x is SendPortImpl) return visitSendPort(x); |
46 if (x is ReceivePortImpl) return visitReceivePort(x); | 46 if (x is ReceivePortImpl) return visitReceivePort(x); |
47 if (x is ReceivePortSingleShotImpl) return visitReceivePortSingleShot(x); | 47 if (x is ReceivePortSingleShotImpl) return visitReceivePortSingleShot(x); |
48 // TODO(floitsch): make this a real exception. (which one)? | 48 // TODO(floitsch): make this a real exception. (which one)? |
49 throw "Message serialization: Illegal value $x passed"; | 49 throw new Exception("Message serialization: Illegal value $x passed"); |
50 } | 50 } |
51 | 51 |
52 abstract visitPrimitive(x); | 52 abstract visitPrimitive(x); |
53 abstract visitList(List x); | 53 abstract visitList(List x); |
54 abstract visitMap(Map x); | 54 abstract visitMap(Map x); |
55 abstract visitSendPort(SendPortImpl x); | 55 abstract visitSendPort(SendPortImpl x); |
56 abstract visitReceivePort(ReceivePortImpl x); | 56 abstract visitReceivePort(ReceivePortImpl x); |
57 abstract visitReceivePortSingleShot(ReceivePortSingleShotImpl x); | 57 abstract visitReceivePortSingleShot(ReceivePortSingleShotImpl x); |
58 | 58 |
59 List _taggedObjects; | 59 List _taggedObjects; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 return a; | 252 return a; |
253 } | 253 } |
254 | 254 |
255 // TODO(floitsch): this should by Map<int, var> or Map<int, Dynamic>. | 255 // TODO(floitsch): this should by Map<int, var> or Map<int, Dynamic>. |
256 Map _deserialized; | 256 Map _deserialized; |
257 | 257 |
258 static bool _isJsArray(x) native; | 258 static bool _isJsArray(x) native; |
259 static _jsArrayIndex(x, int index) native; | 259 static _jsArrayIndex(x, int index) native; |
260 static int _jsArrayLength(x) native; | 260 static int _jsArrayLength(x) native; |
261 } | 261 } |
OLD | NEW |