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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10887012: Rename members and named constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | lib/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: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
index 5d09263d84998173d879ae815de9fa7a735ea957..3dccfb21cfbbe672b81fb42241a64db12ddfd252 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -14,12 +14,53 @@ class DartBackend extends Backend {
: tasks = <CompilerTask>[],
super(compiler);
- void enqueueHelpers(Enqueuer world) { }
+ void enqueueHelpers(Enqueuer world) {
+ // Right now resolver doesn't always resolve interfaces needed
+ // for literals, so force them. TODO(antonm): fix in the resolver.
+ final LITERAL_TYPE_NAMES = const [
+ 'Map', 'List', 'num', 'int', 'double', 'bool'
+ ];
+ final coreLibrary = compiler.coreLibrary;
+ for (final name in LITERAL_TYPE_NAMES) {
+ ClassElement classElement = coreLibrary.findLocal(new SourceString(name));
+ classElement.ensureResolved(compiler);
+ }
+ }
void codegen(WorkItem work) { }
void processNativeClasses(Enqueuer world,
Collection<LibraryElement> libraries) { }
void assembleProgram() {
+ // Conservatively traverse all platform libraries and collect member names.
+ // TODO(antonm): ideally we should only collect names of used members,
+ // however as of today there are problems with names of some core library
+ // interfaces, most probably for interfaces of literals.
+ final fixedMemberNames = new Set<String>();
+ for (final library in compiler.libraries.getValues()) {
+ if (!library.isPlatformLibrary) continue;
+ for (final element in library.localMembers) {
+ if (element is ClassElement) {
+ ClassElement classElement = element;
+ for (final member in classElement.localMembers) {
+ final name = member.name.slowToString();
+ // Skip operator names.
+ if (name.startsWith(@'operator$')) continue;
+ // Fetch name of named constructors and factories if any,
+ // otherwise store regular name.
+ // TODO(antonm): better way to analyze the name.
+ fixedMemberNames.add(name.split(@'$').last());
+ }
+ } else {
+ fixedMemberNames.add(element.name.slowToString());
+ }
+ }
+ }
+ // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in
+ // runtime/lib/error.dart. Overall, all DartVM specific libs should be
+ // accounted for.
+ fixedMemberNames.add('srcType');
+ fixedMemberNames.add('dstType');
+
/**
* Tells whether we should output given element. Corelib classes like
* Object should not be in the resulting code.
@@ -89,7 +130,8 @@ class DartBackend extends Backend {
});
// Create all necessary placeholders.
- PlaceholderCollector collector = new PlaceholderCollector(compiler);
+ PlaceholderCollector collector =
+ new PlaceholderCollector(compiler, fixedMemberNames);
makePlaceholders(element) {
TreeElements treeElements = resolvedElements[element];
if (treeElements === null) treeElements = emptyTreeElements;
@@ -104,7 +146,8 @@ class DartBackend extends Backend {
Map<Node, String> renames = new Map<Node, String>();
Map<LibraryElement, String> imports = new Map<LibraryElement, String>();
renamePlaceholders(
- compiler, collector, renames, imports, minify, cutDeclarationTypes);
+ compiler, collector, renames, imports,
+ fixedMemberNames, minify, cutDeclarationTypes);
// Sort elements.
final sortedTopLevels = sortElements(topLevelElements);
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/placeholder_collector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698