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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 49003012: 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 final Tracer tracer; 409 final Tracer tracer;
410 410
411 CompilerTask measuredTask; 411 CompilerTask measuredTask;
412 Element _currentElement; 412 Element _currentElement;
413 LibraryElement coreLibrary; 413 LibraryElement coreLibrary;
414 LibraryElement isolateLibrary; 414 LibraryElement isolateLibrary;
415 LibraryElement isolateHelperLibrary; 415 LibraryElement isolateHelperLibrary;
416 LibraryElement jsHelperLibrary; 416 LibraryElement jsHelperLibrary;
417 LibraryElement interceptorsLibrary; 417 LibraryElement interceptorsLibrary;
418 LibraryElement foreignLibrary; 418 LibraryElement foreignLibrary;
419
419 LibraryElement mainApp; 420 LibraryElement mainApp;
421 FunctionElement mainFunction;
420 422
421 /// Initialized when dart:mirrors is loaded. 423 /// Initialized when dart:mirrors is loaded.
422 LibraryElement mirrorsLibrary; 424 LibraryElement mirrorsLibrary;
423 425
424 /// Initialized when dart:typed_data is loaded. 426 /// Initialized when dart:typed_data is loaded.
425 LibraryElement typedDataLibrary; 427 LibraryElement typedDataLibrary;
426 428
427 ClassElement objectClass; 429 ClassElement objectClass;
428 ClassElement closureClass; 430 ClassElement closureClass;
429 ClassElement boundClosureClass; 431 ClassElement boundClosureClass;
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 } 1020 }
1019 }).then((_) { 1021 }).then((_) {
1020 compileLoadedLibraries(); 1022 compileLoadedLibraries();
1021 }); 1023 });
1022 } 1024 }
1023 1025
1024 /// Performs the compilation when all libraries have been loaded. 1026 /// Performs the compilation when all libraries have been loaded.
1025 void compileLoadedLibraries() { 1027 void compileLoadedLibraries() {
1026 Element main = null; 1028 Element main = null;
1027 if (mainApp != null) { 1029 if (mainApp != null) {
1028 main = mainApp.find(MAIN); 1030 main = mainApp.findExported(MAIN);
1029 if (main == null) { 1031 if (main == null) {
1030 if (!analyzeOnly) { 1032 if (!analyzeOnly) {
1031 // Allow analyze only of libraries with no main. 1033 // Allow analyze only of libraries with no main.
1032 reportFatalError( 1034 reportFatalError(
1033 mainApp, 1035 mainApp,
1034 MessageKind.GENERIC, 1036 MessageKind.GENERIC,
1035 {'text': "Error: Could not find '$MAIN'."}); 1037 {'text': "Error: Could not find '$MAIN'."});
1036 } else if (!analyzeAll) { 1038 } else if (!analyzeAll) {
1037 reportFatalError( 1039 reportFatalError(
1038 mainApp, 1040 mainApp,
1039 MessageKind.GENERIC, 1041 MessageKind.GENERIC,
1040 {'text': "Error: Could not find '$MAIN'. " 1042 {'text': "Error: Could not find '$MAIN'. "
1041 "No source will be analyzed. " 1043 "No source will be analyzed. "
1042 "Use '--analyze-all' to analyze all code in the library."}); 1044 "Use '--analyze-all' to analyze all code in the library."});
1043 } 1045 }
1044 } else { 1046 } else {
1045 if (!main.isFunction()) { 1047 if (!main.isFunction()) {
Johnni Winther 2013/11/04 11:57:22 If [main] is ambiguous, we should probably report
1046 reportFatalError( 1048 reportFatalError(
1047 main, 1049 main,
1048 MessageKind.GENERIC, 1050 MessageKind.GENERIC,
1049 {'text': "Error: '$MAIN' is not a function."}); 1051 {'text': "Error: '$MAIN' is not a function."});
1050 } 1052 }
1051 FunctionElement mainMethod = main; 1053 mainFunction = main;
1052 FunctionSignature parameters = mainMethod.computeSignature(this); 1054 FunctionSignature parameters = mainFunction.computeSignature(this);
1053 if (parameters.parameterCount > 2) { 1055 if (parameters.parameterCount > 2) {
1054 int index = 0; 1056 int index = 0;
1055 parameters.forEachParameter((Element parameter) { 1057 parameters.forEachParameter((Element parameter) {
1056 if (index++ < 2) return; 1058 if (index++ < 2) return;
1057 reportError( 1059 reportError(
1058 parameter, 1060 parameter,
1059 MessageKind.GENERIC, 1061 MessageKind.GENERIC,
1060 {'text': 1062 {'text':
1061 "Error: '$MAIN' cannot have more than two parameters."}); 1063 "Error: '$MAIN' cannot have more than two parameters."});
1062 }); 1064 });
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1105
1104 log('Inferring types...'); 1106 log('Inferring types...');
1105 typesTask.onResolutionComplete(main); 1107 typesTask.onResolutionComplete(main);
1106 1108
1107 log('Compiling...'); 1109 log('Compiling...');
1108 phase = PHASE_COMPILING; 1110 phase = PHASE_COMPILING;
1109 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. 1111 // TODO(johnniwinther): Move these to [CodegenEnqueuer].
1110 if (hasIsolateSupport()) { 1112 if (hasIsolateSupport()) {
1111 enqueuer.codegen.addToWorkList( 1113 enqueuer.codegen.addToWorkList(
1112 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); 1114 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE));
1113 enqueuer.codegen.registerGetOfStaticFunction(mainApp.find(MAIN)); 1115 enqueuer.codegen.registerGetOfStaticFunction(main);
1114 } 1116 }
1115 if (enabledNoSuchMethod) { 1117 if (enabledNoSuchMethod) {
1116 backend.enableNoSuchMethod(enqueuer.codegen); 1118 backend.enableNoSuchMethod(enqueuer.codegen);
1117 } 1119 }
1118 if (compileAll) { 1120 if (compileAll) {
1119 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib, 1121 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib,
1120 enqueuer.codegen)); 1122 enqueuer.codegen));
1121 } 1123 }
1122 processQueue(enqueuer.codegen, main); 1124 processQueue(enqueuer.codegen, main);
1123 enqueuer.codegen.logSummary(log); 1125 enqueuer.codegen.logSummary(log);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 1647
1646 void close() {} 1648 void close() {}
1647 1649
1648 toString() => name; 1650 toString() => name;
1649 1651
1650 /// Convenience method for getting an [api.CompilerOutputProvider]. 1652 /// Convenience method for getting an [api.CompilerOutputProvider].
1651 static NullSink outputProvider(String name, String extension) { 1653 static NullSink outputProvider(String name, String extension) {
1652 return new NullSink('$name.$extension'); 1654 return new NullSink('$name.$extension');
1653 } 1655 }
1654 } 1656 }
OLDNEW
« 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