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 _Utils { | 5 class _Utils { |
6 static List convertToList(List list) { | 6 static List convertToList(List list) { |
7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. | 7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. |
8 final length = list.length; | 8 final length = list.length; |
9 List result = new List(length); | 9 List result = new List(length); |
10 result.setRange(0, length, list); | 10 result.setRange(0, length, list); |
11 return result; | 11 return result; |
12 } | 12 } |
13 | 13 |
14 static List convertMapToList(Map map) { | 14 static List convertMapToList(Map map) { |
15 List result = []; | 15 List result = []; |
16 map.forEach((k, v) => result.addAll([k, v])); | 16 map.forEach((k, v) => result.addAll([k, v])); |
17 return result; | 17 return result; |
18 } | 18 } |
19 | 19 |
20 static void populateMap(Map result, List list) { | 20 static void populateMap(Map result, List list) { |
21 for (int i = 0; i < list.length; i += 2) { | 21 for (int i = 0; i < list.length; i += 2) { |
22 result[list[i]] = list[i + 1]; | 22 result[list[i]] = list[i + 1]; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 static bool isMap(obj) => obj is Map; | 26 static bool isMap(obj) => obj is Map; |
27 | 27 |
28 static Map createMap() => {}; | 28 static Map createMap() => {}; |
29 | 29 |
30 static makeNotImplementedException(String fileName, int lineNo) { | 30 static makeUnimplementedError(String fileName, int lineNo) { |
31 return new UnsupportedError('[info: $fileName:$lineNo]'); | 31 return new UnsupportedError('[info: $fileName:$lineNo]'); |
32 } | 32 } |
33 | 33 |
34 static window() native "Utils_window"; | 34 static window() native "Utils_window"; |
35 static print(String message) native "Utils_print"; | 35 static print(String message) native "Utils_print"; |
36 static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_
spawnDomFunction"; | 36 static SendPort spawnDomFunctionImpl(Function topLevelFunction) native "Utils_
spawnDomFunction"; |
37 static int _getNewIsolateId() native "Utils_getNewIsolateId"; | 37 static int _getNewIsolateId() native "Utils_getNewIsolateId"; |
38 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup
ported"; | 38 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup
ported"; |
39 } | 39 } |
40 | 40 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool get isEmpty => Maps.isEmpty(this); | 106 bool get isEmpty => Maps.isEmpty(this); |
107 } | 107 } |
108 | 108 |
109 get _printClosure => (s) { | 109 get _printClosure => (s) { |
110 try { | 110 try { |
111 window.console.log(s); | 111 window.console.log(s); |
112 } catch (_) { | 112 } catch (_) { |
113 _Utils.print(s); | 113 _Utils.print(s); |
114 } | 114 } |
115 }; | 115 }; |
OLD | NEW |