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