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

Side by Side Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10905305: Patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Replaced includeInjectedMembers by implementation Created 8 years, 2 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) 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 const bool REMOVE_ASSERTS = false; 5 const bool REMOVE_ASSERTS = false;
6 6
7 class ElementAst { 7 class ElementAst {
8 final Node ast; 8 final Node ast;
9 final TreeElements treeElements; 9 final TreeElements treeElements;
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Collection<LibraryElement> libraries) { } 193 Collection<LibraryElement> libraries) { }
194 194
195 void assembleProgram() { 195 void assembleProgram() {
196 // Conservatively traverse all platform libraries and collect member names. 196 // Conservatively traverse all platform libraries and collect member names.
197 // TODO(antonm): ideally we should only collect names of used members, 197 // TODO(antonm): ideally we should only collect names of used members,
198 // however as of today there are problems with names of some core library 198 // however as of today there are problems with names of some core library
199 // interfaces, most probably for interfaces of literals. 199 // interfaces, most probably for interfaces of literals.
200 final fixedMemberNames = new Set<String>(); 200 final fixedMemberNames = new Set<String>();
201 for (final library in compiler.libraries.getValues()) { 201 for (final library in compiler.libraries.getValues()) {
202 if (!library.isPlatformLibrary) continue; 202 if (!library.isPlatformLibrary) continue;
203 for (final element in library.localMembers) { 203 // TODO(johnniwinther): Should we use the implementation element to
204 // include injected members?
ahe 2012/10/02 13:27:04 Yes
Johnni Winther 2012/10/03 09:22:59 Done.
205 library.forEachLocalMember((Element element) {
204 if (element is ClassElement) { 206 if (element is ClassElement) {
205 ClassElement classElement = element; 207 ClassElement classElement = element;
206 for (final member in classElement.localMembers) { 208 for (final member in classElement.localMembers) {
207 final name = member.name.slowToString(); 209 final name = member.name.slowToString();
208 // Skip operator names. 210 // Skip operator names.
209 if (name.startsWith(@'operator$')) continue; 211 if (name.startsWith(@'operator$')) continue;
210 // Fetch name of named constructors and factories if any, 212 // Fetch name of named constructors and factories if any,
211 // otherwise store regular name. 213 // otherwise store regular name.
212 // TODO(antonm): better way to analyze the name. 214 // TODO(antonm): better way to analyze the name.
213 fixedMemberNames.add(name.split(@'$').last()); 215 fixedMemberNames.add(name.split(@'$').last());
214 } 216 }
215 } else { 217 } else {
216 fixedMemberNames.add(element.name.slowToString()); 218 fixedMemberNames.add(element.name.slowToString());
217 } 219 }
218 } 220 });
219 } 221 }
220 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in 222 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in
221 // runtime/lib/error.dart. Overall, all DartVM specific libs should be 223 // runtime/lib/error.dart. Overall, all DartVM specific libs should be
222 // accounted for. 224 // accounted for.
223 fixedMemberNames.add('srcType'); 225 fixedMemberNames.add('srcType');
224 fixedMemberNames.add('dstType'); 226 fixedMemberNames.add('dstType');
225 227
226 /** 228 /**
227 * Tells whether we should output given element. Corelib classes like 229 * Tells whether we should output given element. Corelib classes like
228 * Object should not be in the resulting code. 230 * Object should not be in the resulting code.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 435 }
434 436
435 compareElements(e0, e1) { 437 compareElements(e0, e1) {
436 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 438 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
437 if (result != 0) return result; 439 if (result != 0) return result;
438 return compareBy((e) => e.position().charOffset)(e0, e1); 440 return compareBy((e) => e.position().charOffset)(e0, e1);
439 } 441 }
440 442
441 List<Element> sortElements(Collection<Element> elements) => 443 List<Element> sortElements(Collection<Element> elements) =>
442 sorted(elements, compareElements); 444 sorted(elements, compareElements);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698