Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: tests/compiler/dart2js/serialization/helper.dart

Issue 1994613004: Handle use of constant constructors with default values. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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';
11 import 'package:compiler/src/common/names.dart'; 11 import 'package:compiler/src/common/names.dart';
12 import 'package:compiler/src/compiler.dart'; 12 import 'package:compiler/src/compiler.dart';
13 13
14 import '../memory_compiler.dart'; 14 import '../memory_compiler.dart';
15 import 'test_data.dart'; 15 import 'test_data.dart';
16 16
17 const String DEFAULT_DATA_FILE_NAME = 'out.data';
18
17 class Arguments { 19 class Arguments {
18 final String filename; 20 final String filename;
19 final int start; 21 final int start;
20 final int end; 22 final int end;
21 final bool loadSerializedData; 23 final bool loadSerializedData;
22 final bool saveSerializedData; 24 final bool saveSerializedData;
23 final String serializedDataFileName; 25 final String serializedDataFileName;
24 final bool verbose; 26 final bool verbose;
25 27
26 const Arguments({ 28 const Arguments({
27 this.filename, 29 this.filename,
28 this.start, 30 this.start,
29 this.end, 31 this.end,
30 this.loadSerializedData: false, 32 this.loadSerializedData: false,
31 this.saveSerializedData: false, 33 this.saveSerializedData: false,
32 this.serializedDataFileName: 'out.data', 34 this.serializedDataFileName: DEFAULT_DATA_FILE_NAME,
33 this.verbose: false}); 35 this.verbose: false});
34 36
35 factory Arguments.from(List<String> arguments) { 37 factory Arguments.from(List<String> arguments) {
36 String filename; 38 String filename;
37 int start; 39 int start;
38 int end; 40 int end;
39 for (String arg in arguments) { 41 for (String arg in arguments) {
40 if (!arg.startsWith('-')) { 42 if (!arg.startsWith('-')) {
41 int index = int.parse(arg); 43 int index = int.parse(arg, onError: (_) => null);
42 if (index == null) { 44 if (index == null) {
43 filename = arg; 45 filename = arg;
44 } else if (start == null) { 46 } else if (start == null) {
45 start = index; 47 start = index;
46 } else { 48 } else {
47 end = index; 49 end = index;
48 } 50 }
49 } 51 }
50 } 52 }
51 bool verbose = arguments.contains('-v'); 53 bool verbose = arguments.contains('-v');
52 bool loadSerializedData = arguments.contains('-l'); 54 bool loadSerializedData = arguments.contains('-l');
53 bool saveSerializedData = arguments.contains('-s'); 55 bool saveSerializedData = arguments.contains('-s');
56 if (arguments.contains('--auto')) {
57 File file = new File(DEFAULT_DATA_FILE_NAME);
58 if (file.existsSync()) {
59 loadSerializedData = true;
60 } else {
61 saveSerializedData = true;
62 }
63 }
54 return new Arguments( 64 return new Arguments(
55 filename: filename, 65 filename: filename,
56 start: start, 66 start: start,
57 end: end, 67 end: end,
58 verbose: verbose, 68 verbose: verbose,
59 loadSerializedData: loadSerializedData, 69 loadSerializedData: loadSerializedData,
60 saveSerializedData: saveSerializedData); 70 saveSerializedData: saveSerializedData);
61 } 71 }
62 72
63 Future forEachTest(List<Test> tests, Future f(int index, Test test)) async { 73 Future forEachTest(List<Test> tests, Future f(int index, Test test)) async {
(...skipping 30 matching lines...) Expand all
94 sink, compiler.libraryLoader.libraries); 104 sink, compiler.libraryLoader.libraries);
95 serializedData = sink.text; 105 serializedData = sink.text;
96 if (arguments.saveSerializedData) { 106 if (arguments.saveSerializedData) {
97 File file = new File(arguments.serializedDataFileName); 107 File file = new File(arguments.serializedDataFileName);
98 print('Saving data to $file'); 108 print('Saving data to $file');
99 file.writeAsStringSync(serializedData); 109 file.writeAsStringSync(serializedData);
100 } 110 }
101 } 111 }
102 return serializedData; 112 return serializedData;
103 } 113 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization/equivalence_test.dart ('k') | tests/compiler/dart2js/serialization/test_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698