Add more flags, fix missing initialization of a couple flags

BUG=
R=vsm@google.com

Review URL: https://chromereviews.googleplex.com/150577015
This commit is contained in:
Sigmund Cherem 2015-02-19 16:13:21 -08:00
parent 0ddedfb3da
commit c1f84cfada
3 changed files with 33 additions and 8 deletions

View file

@ -49,13 +49,18 @@ final ArgParser argParser = new ArgParser()
'the list of directories where to look for packages.', defaultsTo: '')
..addFlag('sdk-check',
abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
..addFlag('infer-statics-from-others',
..addFlag('infer-from-overrides',
help: 'Infer unspecified types of fields and return types from '
'definitions in supertypes', defaultsTo: true)
..addFlag('infer-transitively',
help: 'Infer consts/fields from definitions in other libraries',
defaultsTo: false)
..addFlag('ignore-inference-order',
help: 'Allow a non-stable order of inferencing types for consts and '
'fields. (experimental, used to test for possible inference with a '
'proper implementation in the future)', defaultsTo: false);
..addFlag('infer-only-finals',
help: 'Do not infer non-const or non-final fields', defaultsTo: false)
..addFlag('infer-eagerly',
help: 'experimental: allows a non-stable order of transitive inference on'
' consts and fields. This is used to test for possible inference with a '
'proper implementation in the future.', defaultsTo: false);
void _showUsageAndExit() {
print('usage: dartdevc [<options>] <file.dart>\n');
@ -106,7 +111,11 @@ void main(List<String> argv) {
useColors: useColors,
useMultiPackage: args['use-multi-package'],
packageRoot: args['package-root'],
packagePaths: args['package-paths'].split(','));
packagePaths: args['package-paths'].split(','),
inferFromOverrides: args['infer-from-overrides'],
inferStaticsFromIdentifiers: args['infer-transitively'],
inferInNonStableOrder: args['infer-eagerly'],
onlyInferConstsAndFinalFields: args['infer-only-finals']);
var typeResolver = shouldMockSdk
? new TypeResolver.fromMock(mockSdkSources, options)

View file

@ -244,6 +244,11 @@ class RestrictedStaticTypeAnalyzer extends StaticTypeAnalyzer {
// we rule out cases that could depend on the order in which we process
// them.
if (element is! LocalVariableElement) {
if (_options.onlyInferConstsAndFinalFields &&
!element.isConst &&
!element.isFinal) {
return;
}
// Only infer types if the library is not in a cycle. Otherwise we can't
// guarantee that we are order independent (we can't guarantee that we'll
// visit all top-level declarations in all libraries, before we visit

View file

@ -42,10 +42,15 @@ class ResolverOptions {
/// ordering concerns.
final bool inferInNonStableOrder;
/// Restrict inference of fields and top-levels to those that are final and
/// const.
final bool onlyInferConstsAndFinalFields;
ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/',
this.packagePaths: const [], this.inferFromOverrides: true,
this.inferStaticsFromIdentifiers: false,
this.inferInNonStableOrder: false});
this.inferInNonStableOrder: false,
this.onlyInferConstsAndFinalFields: false});
}
/// Options used by ddc's RestrictedRules.
@ -123,6 +128,11 @@ class CompilerOptions implements RulesOptions, ResolverOptions {
@override
final bool inferInNonStableOrder;
/// Restrict inference of fields and top-levels to those that are final and
/// const.
@override
final bool onlyInferConstsAndFinalFields;
CompilerOptions({this.checkSdk: false, this.dumpInfo: false,
this.dumpInfoFile, this.dumpSrcDir, this.forceCompile: false,
this.formatOutput: false, this.outputDir, this.outputDart: false,
@ -130,5 +140,6 @@ class CompilerOptions implements RulesOptions, ResolverOptions {
this.relaxedCasts: true, this.useMultiPackage: false,
this.packageRoot: 'packages/', this.packagePaths: const [],
this.inferFromOverrides: true, this.inferStaticsFromIdentifiers: false,
this.inferInNonStableOrder: false});
this.inferInNonStableOrder: false,
this.onlyInferConstsAndFinalFields: false});
}