OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.serialization_helper; | 5 library dart2js.serialization_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 import 'package:compiler/src/serialization/resolved_ast_serialization.dart'; | 23 import 'package:compiler/src/serialization/resolved_ast_serialization.dart'; |
24 import 'package:compiler/src/serialization/serialization.dart'; | 24 import 'package:compiler/src/serialization/serialization.dart'; |
25 import 'package:compiler/src/serialization/system.dart'; | 25 import 'package:compiler/src/serialization/system.dart'; |
26 import 'package:compiler/src/serialization/task.dart'; | 26 import 'package:compiler/src/serialization/task.dart'; |
27 import 'package:compiler/src/tokens/token.dart'; | 27 import 'package:compiler/src/tokens/token.dart'; |
28 import 'package:compiler/src/universe/call_structure.dart'; | 28 import 'package:compiler/src/universe/call_structure.dart'; |
29 import 'package:compiler/src/universe/world_impact.dart'; | 29 import 'package:compiler/src/universe/world_impact.dart'; |
30 import 'package:compiler/src/universe/use.dart'; | 30 import 'package:compiler/src/universe/use.dart'; |
31 | 31 |
32 import '../memory_compiler.dart'; | 32 import '../memory_compiler.dart'; |
| 33 import 'test_data.dart'; |
33 | 34 |
34 class Arguments { | 35 class Arguments { |
35 final String filename; | 36 final String filename; |
36 final int index; | 37 final int start; |
| 38 final int end; |
37 final bool loadSerializedData; | 39 final bool loadSerializedData; |
38 final bool saveSerializedData; | 40 final bool saveSerializedData; |
39 final String serializedDataFileName; | 41 final String serializedDataFileName; |
40 final bool verbose; | 42 final bool verbose; |
41 | 43 |
42 const Arguments({ | 44 const Arguments({ |
43 this.filename, | 45 this.filename, |
44 this.index, | 46 this.start, |
| 47 this.end, |
45 this.loadSerializedData: false, | 48 this.loadSerializedData: false, |
46 this.saveSerializedData: false, | 49 this.saveSerializedData: false, |
47 this.serializedDataFileName: 'out.data', | 50 this.serializedDataFileName: 'out.data', |
48 this.verbose: false}); | 51 this.verbose: false}); |
49 | 52 |
50 factory Arguments.from(List<String> arguments) { | 53 factory Arguments.from(List<String> arguments) { |
51 String filename; | 54 String filename; |
52 int index; | 55 int start; |
| 56 int end; |
53 for (String arg in arguments) { | 57 for (String arg in arguments) { |
54 if (!arg.startsWith('-')) { | 58 if (!arg.startsWith('-')) { |
55 index = int.parse(arg); | 59 int index = int.parse(arg); |
56 if (index == null) { | 60 if (index == null) { |
57 filename = arg; | 61 filename = arg; |
| 62 } else if (start == null) { |
| 63 start = index; |
| 64 } else { |
| 65 end = index; |
58 } | 66 } |
59 } | 67 } |
60 } | 68 } |
61 bool verbose = arguments.contains('-v'); | 69 bool verbose = arguments.contains('-v'); |
62 bool loadSerializedData = arguments.contains('-l'); | 70 bool loadSerializedData = arguments.contains('-l'); |
63 bool saveSerializedData = arguments.contains('-s'); | 71 bool saveSerializedData = arguments.contains('-s'); |
64 return new Arguments( | 72 return new Arguments( |
65 filename: filename, | 73 filename: filename, |
66 index: index, | 74 start: start, |
| 75 end: end, |
67 verbose: verbose, | 76 verbose: verbose, |
68 loadSerializedData: loadSerializedData, | 77 loadSerializedData: loadSerializedData, |
69 saveSerializedData: saveSerializedData); | 78 saveSerializedData: saveSerializedData); |
70 } | 79 } |
| 80 |
| 81 Future forEachTest(List<Test> tests, Future f(int index, Test test)) async { |
| 82 int first = start ?? 0; |
| 83 int last = end ?? tests.length - 1; |
| 84 for (int index = first; index <= last; index++) { |
| 85 Test test = TESTS[index]; |
| 86 await f(index, test); |
| 87 } |
| 88 } |
71 } | 89 } |
72 | 90 |
73 | 91 |
74 Future<String> serializeDartCore( | 92 Future<String> serializeDartCore( |
75 {Arguments arguments: const Arguments()}) async { | 93 {Arguments arguments: const Arguments()}) async { |
76 print('------------------------------------------------------------------'); | 94 print('------------------------------------------------------------------'); |
77 print('serialize dart:core'); | 95 print('serialize dart:core'); |
78 print('------------------------------------------------------------------'); | 96 print('------------------------------------------------------------------'); |
79 String serializedData; | 97 String serializedData; |
80 if (arguments.loadSerializedData) { | 98 if (arguments.loadSerializedData) { |
(...skipping 13 matching lines...) Expand all Loading... |
94 sink, compiler.libraryLoader.libraries); | 112 sink, compiler.libraryLoader.libraries); |
95 serializedData = sink.text; | 113 serializedData = sink.text; |
96 if (arguments.saveSerializedData) { | 114 if (arguments.saveSerializedData) { |
97 File file = new File(arguments.serializedDataFileName); | 115 File file = new File(arguments.serializedDataFileName); |
98 print('Saving data to $file'); | 116 print('Saving data to $file'); |
99 file.writeAsStringSync(serializedData); | 117 file.writeAsStringSync(serializedData); |
100 } | 118 } |
101 } | 119 } |
102 return serializedData; | 120 return serializedData; |
103 } | 121 } |
OLD | NEW |