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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 997203002: Add FunctionElement.isEntryPoint getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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 library engine.resolver; 5 library engine.resolver;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 6994 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 7005
7006 @override 7006 @override
7007 String toString() => librarySource.shortName; 7007 String toString() => librarySource.shortName;
7008 } 7008 }
7009 7009
7010 /** 7010 /**
7011 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library. 7011 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library.
7012 */ 7012 */
7013 class LibraryElementBuilder { 7013 class LibraryElementBuilder {
7014 /** 7014 /**
7015 * The name of the function used as an entry point.
7016 */
7017 static String ENTRY_POINT_NAME = "main";
7018
7019 /**
7020 * The analysis context in which the element model will be built. 7015 * The analysis context in which the element model will be built.
7021 */ 7016 */
7022 final InternalAnalysisContext _analysisContext; 7017 final InternalAnalysisContext _analysisContext;
7023 7018
7024 /** 7019 /**
7025 * The listener to which errors will be reported. 7020 * The listener to which errors will be reported.
7026 */ 7021 */
7027 final AnalysisErrorListener _errorListener; 7022 final AnalysisErrorListener _errorListener;
7028 7023
7029 /** 7024 /**
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
7264 7259
7265 /** 7260 /**
7266 * Search the top-level functions defined in the given compilation unit for th e entry point. 7261 * Search the top-level functions defined in the given compilation unit for th e entry point.
7267 * 7262 *
7268 * @param element the compilation unit to be searched 7263 * @param element the compilation unit to be searched
7269 * @return the entry point that was found, or `null` if the compilation unit d oes not define 7264 * @return the entry point that was found, or `null` if the compilation unit d oes not define
7270 * an entry point 7265 * an entry point
7271 */ 7266 */
7272 FunctionElement _findEntryPoint(CompilationUnitElementImpl element) { 7267 FunctionElement _findEntryPoint(CompilationUnitElementImpl element) {
7273 for (FunctionElement function in element.functions) { 7268 for (FunctionElement function in element.functions) {
7274 if (function.name == ENTRY_POINT_NAME) { 7269 if (function.isEntryPoint) {
7275 return function; 7270 return function;
7276 } 7271 }
7277 } 7272 }
7278 return null; 7273 return null;
7279 } 7274 }
7280 7275
7281 /** 7276 /**
7282 * Return the name of the library that the given part is declared to be a part of, or `null` 7277 * Return the name of the library that the given part is declared to be a part of, or `null`
7283 * if the part does not contain a part-of directive. 7278 * if the part does not contain a part-of directive.
7284 * 7279 *
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
8011 importElement.importedLibrary = _coreLibrary.libraryElement; 8006 importElement.importedLibrary = _coreLibrary.libraryElement;
8012 importElement.synthetic = true; 8007 importElement.synthetic = true;
8013 imports.add(importElement); 8008 imports.add(importElement);
8014 } 8009 }
8015 LibraryElementImpl libraryElement = library.libraryElement; 8010 LibraryElementImpl libraryElement = library.libraryElement;
8016 libraryElement.imports = imports; 8011 libraryElement.imports = imports;
8017 libraryElement.exports = exports; 8012 libraryElement.exports = exports;
8018 if (libraryElement.entryPoint == null) { 8013 if (libraryElement.entryPoint == null) {
8019 Namespace namespace = new NamespaceBuilder() 8014 Namespace namespace = new NamespaceBuilder()
8020 .createExportNamespaceForLibrary(libraryElement); 8015 .createExportNamespaceForLibrary(libraryElement);
8021 Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME); 8016 Element element = namespace.get(FunctionElement.MAIN_FUNCTION_NAME);
8022 if (element is FunctionElement) { 8017 if (element is FunctionElement) {
8023 libraryElement.entryPoint = element; 8018 libraryElement.entryPoint = element;
8024 } 8019 }
8025 } 8020 }
8026 } 8021 }
8027 } 8022 }
8028 8023
8029 /** 8024 /**
8030 * Build element models for all of the libraries in the current cycle. 8025 * Build element models for all of the libraries in the current cycle.
8031 * 8026 *
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
8717 importElement.importedLibrary = _coreLibrary.libraryElement; 8712 importElement.importedLibrary = _coreLibrary.libraryElement;
8718 importElement.synthetic = true; 8713 importElement.synthetic = true;
8719 imports.add(importElement); 8714 imports.add(importElement);
8720 } 8715 }
8721 LibraryElementImpl libraryElement = library.libraryElement; 8716 LibraryElementImpl libraryElement = library.libraryElement;
8722 libraryElement.imports = imports; 8717 libraryElement.imports = imports;
8723 libraryElement.exports = exports; 8718 libraryElement.exports = exports;
8724 if (libraryElement.entryPoint == null) { 8719 if (libraryElement.entryPoint == null) {
8725 Namespace namespace = new NamespaceBuilder() 8720 Namespace namespace = new NamespaceBuilder()
8726 .createExportNamespaceForLibrary(libraryElement); 8721 .createExportNamespaceForLibrary(libraryElement);
8727 Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME); 8722 Element element = namespace.get(FunctionElement.MAIN_FUNCTION_NAME);
8728 if (element is FunctionElement) { 8723 if (element is FunctionElement) {
8729 libraryElement.entryPoint = element; 8724 libraryElement.entryPoint = element;
8730 } 8725 }
8731 } 8726 }
8732 } 8727 }
8733 } 8728 }
8734 8729
8735 /** 8730 /**
8736 * Build element models for all of the libraries in the current cycle. 8731 * Build element models for all of the libraries in the current cycle.
8737 * 8732 *
(...skipping 6656 matching lines...) Expand 10 before | Expand all | Expand 10 after
15394 * library. 15389 * library.
15395 */ 15390 */
15396 final HashSet<String> members = new HashSet<String>(); 15391 final HashSet<String> members = new HashSet<String>();
15397 15392
15398 /** 15393 /**
15399 * Names of resolved or unresolved class members that are read in the 15394 * Names of resolved or unresolved class members that are read in the
15400 * library. 15395 * library.
15401 */ 15396 */
15402 final HashSet<String> readMembers = new HashSet<String>(); 15397 final HashSet<String> readMembers = new HashSet<String>();
15403 } 15398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698