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

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

Issue 1038213003: Downward inference (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Rebase Created 5 years, 8 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
« no previous file with comments | « lib/src/info.dart ('k') | lib/src/testing.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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',
321 defaultsTo: RulesOptions.inferDownwardsDefault)
309 ..addFlag('infer-from-overrides', 322 ..addFlag('infer-from-overrides',
310 help: 'Infer unspecified types of fields and return types from\n' 323 help: 'Infer unspecified types of fields and return types from\n'
311 'definitions in supertypes', 324 'definitions in supertypes',
312 defaultsTo: ResolverOptions.inferFromOverridesDefault) 325 defaultsTo: ResolverOptions.inferFromOverridesDefault)
313 ..addFlag('infer-transitively', 326 ..addFlag('infer-transitively',
314 help: 'Infer consts/fields from definitions in other libraries', 327 help: 'Infer consts/fields from definitions in other libraries',
315 defaultsTo: ResolverOptions.inferTransitivelyDefault) 328 defaultsTo: ResolverOptions.inferTransitivelyDefault)
316 ..addFlag('infer-only-finals', 329 ..addFlag('infer-only-finals',
317 help: 'Do not infer non-const or non-final fields', 330 help: 'Do not infer non-const or non-final fields',
318 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault) 331 defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // The pub-cache directory is two levels up, but we verify that the layout 416 // The pub-cache directory is two levels up, but we verify that the layout
404 // looks correct. 417 // looks correct.
405 if (path.basename(dir) != 'dev_compiler') return null; 418 if (path.basename(dir) != 'dev_compiler') return null;
406 dir = path.dirname(dir); 419 dir = path.dirname(dir);
407 if (path.basename(dir) != 'global_packages') return null; 420 if (path.basename(dir) != 'global_packages') return null;
408 dir = path.dirname(dir); 421 dir = path.dirname(dir);
409 return path.join(dir, cacheDir, 'lib', 'runtime'); 422 return path.join(dir, cacheDir, 'lib', 'runtime');
410 } 423 }
411 return null; 424 return null;
412 } 425 }
OLDNEW
« no previous file with comments | « lib/src/info.dart ('k') | lib/src/testing.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698