Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 // TODO(vsm): Merge RulesOptions and TypeOptions | 61 // TODO(vsm): Merge RulesOptions and TypeOptions |
| 62 /// Options used by our RestrictedRules. | 62 /// Options used by our RestrictedRules. |
| 63 class RulesOptions extends TypeOptions { | 63 class RulesOptions extends TypeOptions { |
| 64 /// Whether to allow casts in constant contexts. | 64 /// Whether to allow casts in constant contexts. |
| 65 final bool allowConstCasts; | 65 final bool allowConstCasts; |
| 66 | 66 |
| 67 /// Whether to use covariant generics | 67 /// Whether to use covariant generics |
| 68 final bool covariantGenerics; | 68 final bool covariantGenerics; |
| 69 | 69 |
| 70 /// Whether to infer types downwards from local context | |
| 71 final bool inferDownwards; | |
| 72 static const inferDownwardsDefault = true; | |
| 73 | |
| 70 /// Whether to inject casts between Dart assignable types. | 74 /// Whether to inject casts between Dart assignable types. |
| 71 final bool relaxedCasts; | 75 final bool relaxedCasts; |
| 72 | 76 |
| 73 /// Whether to use static types for code generation. | 77 /// Whether to use static types for code generation. |
| 74 final bool ignoreTypes; | 78 final bool ignoreTypes; |
| 75 | 79 |
| 76 /// Whether to wrap closures for compatibility. | 80 /// Whether to wrap closures for compatibility. |
| 77 final bool wrapClosures; | 81 final bool wrapClosures; |
| 78 | 82 |
| 79 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true, | 83 RulesOptions({this.allowConstCasts: true, this.covariantGenerics: true, |
| 80 this.relaxedCasts: true, this.ignoreTypes: false, | 84 this.inferDownwards: inferDownwardsDefault, this.relaxedCasts: true, |
| 81 this.wrapClosures: true}); | 85 this.ignoreTypes: false, this.wrapClosures: true}); |
| 82 } | 86 } |
| 83 | 87 |
| 84 class JSCodeOptions { | 88 class JSCodeOptions { |
| 85 /// Whether to emit the source map files. | 89 /// Whether to emit the source map files. |
| 86 final bool emitSourceMaps; | 90 final bool emitSourceMaps; |
| 87 | 91 |
| 88 JSCodeOptions({this.emitSourceMaps: true}); | 92 JSCodeOptions({this.emitSourceMaps: true}); |
| 89 } | 93 } |
| 90 | 94 |
| 91 /// General options used by the dev compiler. | 95 /// General options used by the dev compiler. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 final bool useMultiPackage; | 169 final bool useMultiPackage; |
| 166 | 170 |
| 167 /// Package root when resolving 'package:' urls the standard way. | 171 /// Package root when resolving 'package:' urls the standard way. |
| 168 @override | 172 @override |
| 169 final String packageRoot; | 173 final String packageRoot; |
| 170 | 174 |
| 171 /// List of paths used for the multi-package resolver. | 175 /// List of paths used for the multi-package resolver. |
| 172 @override | 176 @override |
| 173 final List<String> packagePaths; | 177 final List<String> packagePaths; |
| 174 | 178 |
| 179 /// Whether to infer types downwards from local context | |
| 180 @override | |
| 181 final bool inferDownwards; | |
| 182 | |
| 175 /// Whether to infer return types and field types from overriden members. | 183 /// Whether to infer return types and field types from overriden members. |
| 176 @override | 184 @override |
| 177 final bool inferFromOverrides; | 185 final bool inferFromOverrides; |
| 178 | 186 |
| 179 /// Whether to infer types for consts and static fields by looking at | 187 /// Whether to infer types for consts and static fields by looking at |
| 180 /// identifiers on the RHS. | 188 /// identifiers on the RHS. |
| 181 @override | 189 @override |
| 182 final bool inferTransitively; | 190 final bool inferTransitively; |
| 183 | 191 |
| 184 /// Restrict inference of fields and top-levels to those that are final and | 192 /// Restrict inference of fields and top-levels to those that are final and |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 208 final String runtimeDir; | 216 final String runtimeDir; |
| 209 | 217 |
| 210 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, | 218 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, |
| 211 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, | 219 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, |
| 212 this.forceCompile: false, this.formatOutput: false, | 220 this.forceCompile: false, this.formatOutput: false, |
| 213 this.cheapTestFormat: false, this.ignoreTypes: false, | 221 this.cheapTestFormat: false, this.ignoreTypes: false, |
| 214 this.wrapClosures: true, this.outputDir, this.outputDart: false, | 222 this.wrapClosures: true, this.outputDir, this.outputDart: false, |
| 215 this.useColors: true, this.covariantGenerics: true, | 223 this.useColors: true, this.covariantGenerics: true, |
| 216 this.relaxedCasts: true, this.useMultiPackage: false, | 224 this.relaxedCasts: true, this.useMultiPackage: false, |
| 217 this.packageRoot: 'packages/', this.packagePaths: const <String>[], | 225 this.packageRoot: 'packages/', this.packagePaths: const <String>[], |
| 226 this.inferDownwards: RulesOptions.inferDownwardsDefault, | |
| 218 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, | 227 this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, |
| 219 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, | 228 this.inferTransitively: ResolverOptions.inferTransitivelyDefault, |
| 220 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, | 229 this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinal FieldsDefault, |
| 221 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, | 230 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, |
| 222 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, | 231 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, |
| 223 this.emitSourceMaps: true, this.entryPointFile: null, | 232 this.emitSourceMaps: true, this.entryPointFile: null, |
| 224 this.serverMode: false, this.host: 'localhost', this.port: 8080, | 233 this.serverMode: false, this.host: 'localhost', this.port: 8080, |
| 225 this.runtimeDir}); | 234 this.runtimeDir}); |
| 226 } | 235 } |
| 227 | 236 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 ignoreTypes: args['ignore-types'], | 272 ignoreTypes: args['ignore-types'], |
| 264 wrapClosures: args['wrap-closures'], | 273 wrapClosures: args['wrap-closures'], |
| 265 outputDart: args['dart-gen'], | 274 outputDart: args['dart-gen'], |
| 266 outputDir: outputDir, | 275 outputDir: outputDir, |
| 267 covariantGenerics: args['covariant-generics'], | 276 covariantGenerics: args['covariant-generics'], |
| 268 relaxedCasts: args['relaxed-casts'], | 277 relaxedCasts: args['relaxed-casts'], |
| 269 useColors: useColors, | 278 useColors: useColors, |
| 270 useMultiPackage: args['use-multi-package'], | 279 useMultiPackage: args['use-multi-package'], |
| 271 packageRoot: args['package-root'], | 280 packageRoot: args['package-root'], |
| 272 packagePaths: args['package-paths'].split(','), | 281 packagePaths: args['package-paths'].split(','), |
| 282 inferDownwards: args['infer-downwards'], | |
| 273 inferFromOverrides: args['infer-from-overrides'], | 283 inferFromOverrides: args['infer-from-overrides'], |
| 274 inferTransitively: args['infer-transitively'], | 284 inferTransitively: args['infer-transitively'], |
| 275 onlyInferConstsAndFinalFields: args['infer-only-finals'], | 285 onlyInferConstsAndFinalFields: args['infer-only-finals'], |
| 276 nonnullableTypes: optionsToList(args['nonnullable'], | 286 nonnullableTypes: optionsToList(args['nonnullable'], |
| 277 defaultValue: TypeOptions.NONNULLABLE_TYPES), | 287 defaultValue: TypeOptions.NONNULLABLE_TYPES), |
| 278 help: args['help'], | 288 help: args['help'], |
| 279 useMockSdk: args['mock-sdk'], | 289 useMockSdk: args['mock-sdk'], |
| 280 dartSdkPath: sdkPath, | 290 dartSdkPath: sdkPath, |
| 281 logLevel: logLevel, | 291 logLevel: logLevel, |
| 282 emitSourceMaps: args['source-maps'], | 292 emitSourceMaps: args['source-maps'], |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 299 help: 'Use covariant generics', defaultsTo: true) | 309 help: 'Use covariant generics', defaultsTo: true) |
| 300 ..addFlag('ignore-types', | 310 ..addFlag('ignore-types', |
| 301 help: 'Ignore types during codegen', defaultsTo: false) | 311 help: 'Ignore types during codegen', defaultsTo: false) |
| 302 ..addFlag('wrap-closures', help: 'wrap closures implicitly', defaultsTo: true) | 312 ..addFlag('wrap-closures', help: 'wrap closures implicitly', defaultsTo: true) |
| 303 ..addFlag('relaxed-casts', | 313 ..addFlag('relaxed-casts', |
| 304 help: 'Cast between Dart assignable types', defaultsTo: true) | 314 help: 'Cast between Dart assignable types', defaultsTo: true) |
| 305 ..addOption('nonnullable', | 315 ..addOption('nonnullable', |
| 306 abbr: 'n', | 316 abbr: 'n', |
| 307 help: 'Comma separated string of non-nullable types', | 317 help: 'Comma separated string of non-nullable types', |
| 308 defaultsTo: null) | 318 defaultsTo: null) |
| 319 ..addFlag('infer-downwards', | |
| 320 help: 'Infer types downwards from local context', defaultsTo: true) | |
|
vsm
2015/03/27 21:20:59
s/true/RulesOptions.inferDownwardsDefault/
Leaf
2015/03/30 23:26:00
Done.
| |
| 309 ..addFlag('infer-from-overrides', | 321 ..addFlag('infer-from-overrides', |
| 310 help: 'Infer unspecified types of fields and return types from\n' | 322 help: 'Infer unspecified types of fields and return types from\n' |
| 311 'definitions in supertypes', | 323 'definitions in supertypes', |
| 312 defaultsTo: ResolverOptions.inferFromOverridesDefault) | 324 defaultsTo: ResolverOptions.inferFromOverridesDefault) |
| 313 ..addFlag('infer-transitively', | 325 ..addFlag('infer-transitively', |
| 314 help: 'Infer consts/fields from definitions in other libraries', | 326 help: 'Infer consts/fields from definitions in other libraries', |
| 315 defaultsTo: ResolverOptions.inferTransitivelyDefault) | 327 defaultsTo: ResolverOptions.inferTransitivelyDefault) |
| 316 ..addFlag('infer-only-finals', | 328 ..addFlag('infer-only-finals', |
| 317 help: 'Do not infer non-const or non-final fields', | 329 help: 'Do not infer non-const or non-final fields', |
| 318 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault) | 330 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 // The pub-cache directory is two levels up, but we verify that the layout | 415 // The pub-cache directory is two levels up, but we verify that the layout |
| 404 // looks correct. | 416 // looks correct. |
| 405 if (path.basename(dir) != 'dev_compiler') return null; | 417 if (path.basename(dir) != 'dev_compiler') return null; |
| 406 dir = path.dirname(dir); | 418 dir = path.dirname(dir); |
| 407 if (path.basename(dir) != 'global_packages') return null; | 419 if (path.basename(dir) != 'global_packages') return null; |
| 408 dir = path.dirname(dir); | 420 dir = path.dirname(dir); |
| 409 return path.join(dir, cacheDir, 'lib', 'runtime'); | 421 return path.join(dir, cacheDir, 'lib', 'runtime'); |
| 410 } | 422 } |
| 411 return null; | 423 return null; |
| 412 } | 424 } |
| OLD | NEW |