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