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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart2js.dart

Issue 185743002: Make analyze-all imply analyze-only. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/dart2js.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart2js.dart b/sdk/lib/_internal/compiler/implementation/dart2js.dart
index b44541509d61898caba2c840451aa51e13d98d03..bc203ed8a98093253c5e55a665e25fbc983365d5 100644
--- a/sdk/lib/_internal/compiler/implementation/dart2js.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart
@@ -56,7 +56,7 @@ String extractParameter(String argument) {
// m[0] is the entire match (which will be equal to argument). m[1]
// is something like "-o" or "--out=", and m[2] is the parameter.
Match m = new RegExp('^(-[a-z]|--.+=)(.*)').firstMatch(argument);
- if (m == null) helpAndFail('Error: Unknown option "$argument".');
+ if (m == null) helpAndFail('Unknown option "$argument".');
return m[2];
}
@@ -109,6 +109,9 @@ Future compile(List<String> argv) {
String outputLanguage = 'JavaScript';
bool stripArgumentSet = false;
bool analyzeOnly = false;
+ bool analyzeAll = false;
+ // List of provided options that imply that output is expected.
+ List<String> optionsImplyCompilation = <String>[];
bool hasDisallowUnsafeEval = false;
// TODO(johnniwinther): Measure time for reading files.
SourceFileProvider inputProvider = new CompilerSourceFileProvider();
@@ -130,6 +133,7 @@ Future compile(List<String> argv) {
}
setOutput(Iterator<String> arguments) {
+ optionsImplyCompilation.add(arguments.current);
String path;
if (arguments.current == '-o') {
if (!arguments.moveNext()) {
@@ -145,6 +149,7 @@ Future compile(List<String> argv) {
}
setOutputType(String argument) {
+ optionsImplyCompilation.add(argument);
if (argument == '--output-type=dart') {
outputLanguage = OUTPUT_LANGUAGE_DART;
if (!explicitOut) {
@@ -162,6 +167,7 @@ Future compile(List<String> argv) {
}
setStrip(String argument) {
+ optionsImplyCompilation.add(argument);
stripArgumentSet = true;
passThrough(argument);
}
@@ -171,11 +177,21 @@ Future compile(List<String> argv) {
passThrough(argument);
}
+ setAnalyzeAll(String argument) {
+ analyzeAll = true;
+ passThrough(argument);
+ }
+
setVerbose(_) {
diagnosticHandler.verbose = true;
passThrough('--verbose');
}
+ implyCompilation(String argument) {
+ optionsImplyCompilation.add(argument);
+ passThrough(argument);
+ }
+
addInEnvironment(String argument) {
int eqIndex = argument.indexOf('=');
String name = argument.substring(2, eqIndex);
@@ -198,7 +214,7 @@ Future compile(List<String> argv) {
String allowedCategoriesString = allowedCategoriesList.join(', ');
for (String category in categories) {
if (!allowedCategories.contains(category)) {
- fail('Error: unsupported library category "$category", '
+ fail('Unsupported library category "$category", '
'supported categories are: $allowedCategoriesString');
}
}
@@ -221,7 +237,7 @@ Future compile(List<String> argv) {
passThrough('--enable-checked-mode');
break;
case 'm':
- passThrough('--minify');
+ implyCompilation('--minify');
break;
default:
throw 'Internal error: "$shortOption" did not match';
@@ -255,7 +271,7 @@ Future compile(List<String> argv) {
new OptionHandler('--library-root=.+', setLibraryRoot),
new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true),
new OptionHandler('--allow-mock-compilation', passThrough),
- new OptionHandler('--minify|-m', passThrough),
+ new OptionHandler('--minify|-m', implyCompilation),
new OptionHandler('--force-strip=.*', setStrip),
new OptionHandler('--disable-diagnostic-colors',
(_) => diagnosticHandler.enableColors = false),
@@ -264,19 +280,20 @@ Future compile(List<String> argv) {
new OptionHandler('--enable[_-]checked[_-]mode|--checked',
(_) => passThrough('--enable-checked-mode')),
new OptionHandler('--enable-concrete-type-inference',
- (_) => passThrough('--enable-concrete-type-inference')),
+ (_) => implyCompilation(
+ '--enable-concrete-type-inference')),
new OptionHandler('--trust-type-annotations',
- (_) => passThrough('--trust-type-annotations')),
+ (_) => implyCompilation('--trust-type-annotations')),
new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true),
new OptionHandler('--package-root=.+|-p.+', setPackageRoot),
- new OptionHandler('--analyze-all', passThrough),
+ new OptionHandler('--analyze-all', setAnalyzeAll),
new OptionHandler('--analyze-only', setAnalyzeOnly),
- new OptionHandler('--analyze-signatures-only', passThrough),
+ new OptionHandler('--analyze-signatures-only', setAnalyzeOnly),
new OptionHandler('--disable-native-live-type-analysis', passThrough),
new OptionHandler('--categories=.*', setCategories),
- new OptionHandler('--disable-type-inference', passThrough),
+ new OptionHandler('--disable-type-inference', implyCompilation),
new OptionHandler('--terse', passThrough),
- new OptionHandler('--dump-info', passThrough),
+ new OptionHandler('--dump-info', implyCompilation),
new OptionHandler('--disallow-unsafe-eval',
(_) => hasDisallowUnsafeEval = true),
new OptionHandler('--hide-package-warnings', passThrough),
@@ -284,7 +301,7 @@ Future compile(List<String> argv) {
// The following two options must come last.
new OptionHandler('-.*', (String argument) {
- helpAndFail('Error: Unknown option "$argument".');
+ helpAndFail("Unknown option '$argument'.");
}),
new OptionHandler('.*', (String argument) {
arguments.add(nativeToUriPath(argument));
@@ -299,21 +316,21 @@ Future compile(List<String> argv) {
if (hasDisallowUnsafeEval) {
String precompiledName =
relativize(currentDirectory, computePrecompiledUri(), isWindows);
- helpAndFail("Error: option '--disallow-unsafe-eval' has been removed."
+ helpAndFail("Option '--disallow-unsafe-eval' has been removed."
" Instead, the compiler generates a file named"
" '$precompiledName'.");
}
if (outputLanguage != OUTPUT_LANGUAGE_DART && stripArgumentSet) {
- helpAndFail('Error: --force-strip may only be used with '
- '--output-type=dart');
+ helpAndFail("Option '--force-strip' may only be used with "
+ "'--output-type=dart'.");
}
if (arguments.isEmpty) {
- helpAndFail('Error: No Dart file specified.');
+ helpAndFail('No Dart file specified.');
}
if (arguments.length > 1) {
var extra = arguments.sublist(1);
- helpAndFail('Error: Extra arguments: ${extra.join(" ")}');
+ helpAndFail('Extra arguments: ${extra.join(" ")}');
}
Uri uri = currentDirectory.resolve(arguments[0]);
@@ -321,7 +338,22 @@ Future compile(List<String> argv) {
packageRoot = uri.resolve('./packages/');
}
- diagnosticHandler.info('package root is $packageRoot');
+ if ((analyzeOnly || analyzeAll) && !optionsImplyCompilation.isEmpty) {
+ if (!analyzeOnly) {
+ diagnosticHandler.info(
+ "Option '--analyze-all' implies '--analyze-only'.",
+ api.Diagnostic.INFO);
+ }
+ diagnosticHandler.info(
+ "Options $optionsImplyCompilation indicate that output is expected, "
+ "but compilation is turned off by the option '--analyze-only'.",
+ api.Diagnostic.INFO);
+ }
+ if (analyzeAll) {
floitsch 2014/03/07 14:03:35 *nit*: 'if' on one line.
Johnni Winther 2014/03/10 07:03:08 Done.
+ analyzeOnly = true;
+ }
+
+ diagnosticHandler.info('Package root is $packageRoot');
int totalCharactersWritten = 0;
@@ -332,7 +364,7 @@ Future compile(List<String> argv) {
compilationDone(String code) {
if (analyzeOnly) return;
if (code == null) {
- fail('Error: Compilation failed.');
+ fail('Compilation failed.');
}
writeString(Uri.parse('$out.deps'),
getDepsOutput(inputProvider.sourceFiles));
@@ -375,14 +407,14 @@ Future compile(List<String> argv) {
String outName = out.path.substring(out.path.lastIndexOf('/') + 1);
uri = out.resolve('${outName}.$extension');
} else {
- fail('Error: Unknown extension: $extension');
+ fail('Unknown extension: $extension');
}
} else {
uri = out.resolve('$name.$extension');
}
if (uri.scheme != 'file') {
- fail('Error: Unhandled scheme ${uri.scheme} in $uri.');
+ fail('Unhandled scheme ${uri.scheme} in $uri.');
}
RandomAccessFile output;
@@ -460,7 +492,7 @@ class AbortLeg {
void writeString(Uri uri, String text) {
if (uri.scheme != 'file') {
- fail('Error: Unhandled scheme ${uri.scheme}.');
+ fail('Unhandled scheme ${uri.scheme}.');
}
var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE);
file.writeStringSync(text);
@@ -472,7 +504,7 @@ void fail(String message) {
diagnosticHandler.diagnosticHandler(
null, -1, -1, message, api.Diagnostic.ERROR);
} else {
- print(message);
+ print('Error: $message');
}
exitFunc(1);
}
@@ -534,9 +566,7 @@ Supported options:
--analyze-all
Analyze all code. Without this option, the compiler only analyzes
- code that is reachable from [main]. This option is useful for
- finding errors in libraries, but using it can result in bigger and
- slower output.
+ code that is reachable from [main]. This option implies --analyze-only.
--analyze-only
Analyze but do not generate code.

Powered by Google App Engine
This is Rietveld 408576698