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 part of dart.isolate; | 5 part of dart.isolate; |
6 | 6 |
7 class _IsolateEncoder { | 7 class _IsolateEncoder { |
8 final manglingToken; | 8 final manglingToken; |
9 // TODO(floitsch): switch to identity set. | 9 // TODO(floitsch): switch to identity set. |
10 final Map _encoded = new Map(); | 10 final Map _encoded = new Map(); |
(...skipping 26 matching lines...) Expand all Loading... |
37 _visiting[data] = data; | 37 _visiting[data] = data; |
38 | 38 |
39 var result; | 39 var result; |
40 | 40 |
41 if (data is List) { | 41 if (data is List) { |
42 bool hasBeenDuplicated = false; | 42 bool hasBeenDuplicated = false; |
43 result = data; | 43 result = data; |
44 for (int i = 0; i < data.length; i++) { | 44 for (int i = 0; i < data.length; i++) { |
45 var mangled = encode(data[i]); | 45 var mangled = encode(data[i]); |
46 if (mangled != data[i] && !hasBeenDuplicated) { | 46 if (mangled != data[i] && !hasBeenDuplicated) { |
47 result = new List.fixedLength(data.length); | 47 result = new List(data.length); |
48 for (int j = 0; j < i; j++) { | 48 for (int j = 0; j < i; j++) { |
49 result[j] = data[j]; | 49 result[j] = data[j]; |
50 } | 50 } |
51 hasBeenDuplicated = true; | 51 hasBeenDuplicated = true; |
52 } | 52 } |
53 if (hasBeenDuplicated) { | 53 if (hasBeenDuplicated) { |
54 result[i] = mangled; | 54 result[i] = mangled; |
55 } | 55 } |
56 } | 56 } |
57 result = _escapeIfNecessary(result); | 57 result = _escapeIfNecessary(result); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 261 } |
262 _extractMangled(wrappedMangled) { | 262 _extractMangled(wrappedMangled) { |
263 assert(_isMangled(wrappedMangled)); | 263 assert(_isMangled(wrappedMangled)); |
264 return wrappedMangled[2]; | 264 return wrappedMangled[2]; |
265 } | 265 } |
266 _extractEscaped(data) { | 266 _extractEscaped(data) { |
267 assert(_isEscaped(data)); | 267 assert(_isEscaped(data)); |
268 return data[2]; | 268 return data[2]; |
269 } | 269 } |
270 } | 270 } |
OLD | NEW |