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

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

Issue 57433004: Re-land "Search for main in the exported names of the main library, not in the library itself." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix package1 test. Created 7 years, 1 month 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 067ee8832462ed521dcf011f14cf57bf43853467..e0de9ffee27b0c102d411996203d5534b3ced5d3 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -416,7 +416,9 @@ abstract class Compiler implements DiagnosticListener {
LibraryElement jsHelperLibrary;
LibraryElement interceptorsLibrary;
LibraryElement foreignLibrary;
+
LibraryElement mainApp;
+ FunctionElement mainFunction;
/// Initialized when dart:mirrors is loaded.
LibraryElement mirrorsLibrary;
@@ -1025,7 +1027,7 @@ abstract class Compiler implements DiagnosticListener {
void compileLoadedLibraries() {
Element main = null;
if (mainApp != null) {
- main = mainApp.find(MAIN);
+ main = mainApp.findExported(MAIN);
if (main == null) {
if (!analyzeOnly) {
// Allow analyze only of libraries with no main.
@@ -1042,14 +1044,19 @@ abstract class Compiler implements DiagnosticListener {
"Use '--analyze-all' to analyze all code in the library."});
}
} else {
- if (!main.isFunction()) {
+ if (main.isErroneous()) {
+ reportFatalError(
+ main,
+ MessageKind.GENERIC,
+ {'text': "Error: Cannot determine which '$MAIN' to use."});
+ } else if (!main.isFunction()) {
reportFatalError(
main,
MessageKind.GENERIC,
{'text': "Error: '$MAIN' is not a function."});
}
- FunctionElement mainMethod = main;
- FunctionSignature parameters = mainMethod.computeSignature(this);
+ mainFunction = main;
+ FunctionSignature parameters = mainFunction.computeSignature(this);
if (parameters.parameterCount > 2) {
int index = 0;
parameters.forEachParameter((Element parameter) {
@@ -1110,7 +1117,7 @@ abstract class Compiler implements DiagnosticListener {
if (hasIsolateSupport()) {
enqueuer.codegen.addToWorkList(
isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE));
- enqueuer.codegen.registerGetOfStaticFunction(mainApp.find(MAIN));
+ enqueuer.codegen.registerGetOfStaticFunction(main);
}
if (enabledNoSuchMethod) {
backend.enableNoSuchMethod(enqueuer.codegen);
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698