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

Side by Side Diff: lib/src/options.dart

Issue 1038583004: Rationalize coercions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Set of flags and options passed to the compiler 5 /// Set of flags and options passed to the compiler
6 library dev_compiler.src.options; 6 library dev_compiler.src.options;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 /// Whether to use covariant generics 69 /// Whether to use covariant generics
70 final bool covariantGenerics; 70 final bool covariantGenerics;
71 71
72 /// Whether to inject casts between Dart assignable types. 72 /// Whether to inject casts between Dart assignable types.
73 final bool relaxedCasts; 73 final bool relaxedCasts;
74 74
75 /// Whether to use static types for code generation. 75 /// Whether to use static types for code generation.
76 final bool ignoreTypes; 76 final bool ignoreTypes;
77 77
78 /// Whether to wrap closures for compatibility.
79 final bool wrapClosures;
80
78 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true, 81 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true,
79 this.relaxedCasts: true, this.ignoreTypes: false}); 82 this.relaxedCasts: true, this.ignoreTypes: false,
83 this.wrapClosures: true});
80 } 84 }
81 85
82 class JSCodeOptions { 86 class JSCodeOptions {
83 /// Whether to emit the source map files. 87 /// Whether to emit the source map files.
84 final bool emitSourceMaps; 88 final bool emitSourceMaps;
85 89
86 JSCodeOptions({this.emitSourceMaps: true}); 90 JSCodeOptions({this.emitSourceMaps: true});
87 } 91 }
88 92
89 /// General options used by the dev compiler. 93 /// General options used by the dev compiler.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 final bool onlyInferConstsAndFinalFields; 189 final bool onlyInferConstsAndFinalFields;
186 190
187 /// List of non-nullable types. 191 /// List of non-nullable types.
188 @override 192 @override
189 final List<String> nonnullableTypes; 193 final List<String> nonnullableTypes;
190 194
191 /// Whether to use static types for code generation. 195 /// Whether to use static types for code generation.
192 @override 196 @override
193 final bool ignoreTypes; 197 final bool ignoreTypes;
194 198
199 /// Whether to wrap closures for compatibility.
200 @override
201 final bool wrapClosures;
202
195 /// Whether to emit the source map files. 203 /// Whether to emit the source map files.
196 @override 204 @override
197 final bool emitSourceMaps; 205 final bool emitSourceMaps;
198 206
199 /// Location for runtime files, such as `dart_runtime.js`. By default this is 207 /// Location for runtime files, such as `dart_runtime.js`. By default this is
200 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler` 208 /// inferred to be under `lib/runtime/` in the location of the `dev_compiler`
201 /// package (if we can infer where that is located). 209 /// package (if we can infer where that is located).
202 final String runtimeDir; 210 final String runtimeDir;
203 211
204 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, 212 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false,
205 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, 213 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir,
206 this.forceCompile: false, this.formatOutput: false, 214 this.forceCompile: false, this.formatOutput: false,
207 this.cheapTestFormat: false, this.ignoreTypes: false, this.outputDir, 215 this.cheapTestFormat: false, this.ignoreTypes: false,
208 this.outputDart: false, this.useColors: true, 216 this.wrapClosures: true, this.outputDir, this.outputDart: false,
209 this.covariantGenerics: true, this.relaxedCasts: true, 217 this.useColors: true, this.covariantGenerics: true,
210 this.useMultiPackage: false, this.packageRoot: 'packages/', 218 this.relaxedCasts: true, this.useMultiPackage: false,
211 this.packagePaths: const <String>[], 219 this.packageRoot: 'packages/', this.packagePaths: const <String>[],
212 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 220 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
213 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, 221 this.inferTransitively: ResolverOptions.inferTransitivelyDefault,
214 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, 222 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault,
215 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, 223 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
216 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, 224 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
217 this.emitSourceMaps: true, this.entryPointFile: null, 225 this.emitSourceMaps: true, this.entryPointFile: null,
218 this.serverMode: false, this.host: 'localhost', this.port: 8080, 226 this.serverMode: false, this.host: 'localhost', this.port: 8080,
219 this.runtimeDir}); 227 this.runtimeDir});
220 } 228 }
221 229
(...skipping 26 matching lines...) Expand all
248 256
249 return new CompilerOptions( 257 return new CompilerOptions(
250 allowConstCasts: args['allow-const-casts'], 258 allowConstCasts: args['allow-const-casts'],
251 checkSdk: args['sdk-check'], 259 checkSdk: args['sdk-check'],
252 dumpInfo: dumpInfo, 260 dumpInfo: dumpInfo,
253 dumpInfoFile: args['dump-info-file'], 261 dumpInfoFile: args['dump-info-file'],
254 dumpSrcDir: args['dump-src-to'], 262 dumpSrcDir: args['dump-src-to'],
255 forceCompile: args['force-compile'] || serverMode, 263 forceCompile: args['force-compile'] || serverMode,
256 formatOutput: args['dart-gen-fmt'], 264 formatOutput: args['dart-gen-fmt'],
257 ignoreTypes: args['ignore-types'], 265 ignoreTypes: args['ignore-types'],
266 wrapClosures: args['wrap-closures'],
258 outputDart: args['dart-gen'], 267 outputDart: args['dart-gen'],
259 outputDir: outputDir, 268 outputDir: outputDir,
260 covariantGenerics: args['covariant-generics'], 269 covariantGenerics: args['covariant-generics'],
261 relaxedCasts: args['relaxed-casts'], 270 relaxedCasts: args['relaxed-casts'],
262 useColors: useColors, 271 useColors: useColors,
263 useMultiPackage: args['use-multi-package'], 272 useMultiPackage: args['use-multi-package'],
264 packageRoot: args['package-root'], 273 packageRoot: args['package-root'],
265 packagePaths: args['package-paths'].split(','), 274 packagePaths: args['package-paths'].split(','),
266 inferFromOverrides: args['infer-from-overrides'], 275 inferFromOverrides: args['infer-from-overrides'],
267 inferTransitively: args['infer-transitively'], 276 inferTransitively: args['infer-transitively'],
(...skipping 17 matching lines...) Expand all
285 ..addFlag('allow-const-casts', 294 ..addFlag('allow-const-casts',
286 help: 'Allow casts in const contexts', defaultsTo: true) 295 help: 'Allow casts in const contexts', defaultsTo: true)
287 ..addFlag('sdk-check', 296 ..addFlag('sdk-check',
288 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false) 297 abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
289 ..addFlag('mock-sdk', 298 ..addFlag('mock-sdk',
290 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false) 299 abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false)
291 ..addFlag('covariant-generics', 300 ..addFlag('covariant-generics',
292 help: 'Use covariant generics', defaultsTo: true) 301 help: 'Use covariant generics', defaultsTo: true)
293 ..addFlag('ignore-types', 302 ..addFlag('ignore-types',
294 help: 'Ignore types during codegen', defaultsTo: false) 303 help: 'Ignore types during codegen', defaultsTo: false)
304 ..addFlag('wrap-closures', help: 'wrap closures implicitly', defaultsTo: true)
295 ..addFlag('relaxed-casts', 305 ..addFlag('relaxed-casts',
296 help: 'Cast between Dart assignable types', defaultsTo: true) 306 help: 'Cast between Dart assignable types', defaultsTo: true)
297 ..addOption('nonnullable', 307 ..addOption('nonnullable',
298 abbr: 'n', 308 abbr: 'n',
299 help: 'Comma separated string of non-nullable types', 309 help: 'Comma separated string of non-nullable types',
300 defaultsTo: null) 310 defaultsTo: null)
301 ..addFlag('infer-from-overrides', 311 ..addFlag('infer-from-overrides',
302 help: 'Infer unspecified types of fields and return types from\n' 312 help: 'Infer unspecified types of fields and return types from\n'
303 'definitions in supertypes', 313 'definitions in supertypes',
304 defaultsTo: ResolverOptions.inferFromOverridesDefault) 314 defaultsTo: ResolverOptions.inferFromOverridesDefault)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // The pub-cache directory is two levels up, but we verify that the layout 405 // The pub-cache directory is two levels up, but we verify that the layout
396 // looks correct. 406 // looks correct.
397 if (path.basename(dir) != 'dev_compiler') return null; 407 if (path.basename(dir) != 'dev_compiler') return null;
398 dir = path.dirname(dir); 408 dir = path.dirname(dir);
399 if (path.basename(dir) != 'global_packages') return null; 409 if (path.basename(dir) != 'global_packages') return null;
400 dir = path.dirname(dir); 410 dir = path.dirname(dir);
401 return path.join(dir, cacheDir, 'lib', 'runtime'); 411 return path.join(dir, cacheDir, 'lib', 'runtime');
402 } 412 }
403 return null; 413 return null;
404 } 414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698