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

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: Rebased. 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 210 }
211 211
212 void assembleProgram() { 212 void assembleProgram() {
213 // Conservatively traverse all platform libraries and collect member names. 213 // Conservatively traverse all platform libraries and collect member names.
214 // TODO(antonm): ideally we should only collect names of used members, 214 // TODO(antonm): ideally we should only collect names of used members,
215 // however as of today there are problems with names of some core library 215 // however as of today there are problems with names of some core library
216 // interfaces, most probably for interfaces of literals. 216 // interfaces, most probably for interfaces of literals.
217 final fixedMemberNames = new Set<String>(); 217 final fixedMemberNames = new Set<String>();
218 for (final library in compiler.libraries.getValues()) { 218 for (final library in compiler.libraries.getValues()) {
219 if (!library.isPlatformLibrary) continue; 219 if (!library.isPlatformLibrary) continue;
220 for (final element in library.localMembers) { 220 library.implementation.forEachLocalMember((Element element) {
221 if (element is ClassElement) { 221 if (element is ClassElement) {
222 ClassElement classElement = element; 222 ClassElement classElement = element;
223 // Make sure we parsed the class to initialize its local members. 223 // Make sure we parsed the class to initialize its local members.
224 // TODO(smok): Figure out if there is a better way to fill local 224 // TODO(smok): Figure out if there is a better way to fill local
225 // members. 225 // members.
226 element.parseNode(compiler); 226 element.parseNode(compiler);
227 for (final member in classElement.localMembers) { 227 for (final member in classElement.localMembers) {
228 final name = member.name.slowToString(); 228 final name = member.name.slowToString();
229 // Skip operator names. 229 // Skip operator names.
230 if (name.startsWith(r'operator$')) continue; 230 if (name.startsWith(r'operator$')) continue;
231 // Fetch name of named constructors and factories if any, 231 // Fetch name of named constructors and factories if any,
232 // otherwise store regular name. 232 // otherwise store regular name.
233 // TODO(antonm): better way to analyze the name. 233 // TODO(antonm): better way to analyze the name.
234 fixedMemberNames.add(name.split(r'$').last()); 234 fixedMemberNames.add(name.split(r'$').last());
235 } 235 }
236 } 236 }
237 // Even class names are added due to a delicate problem we have: 237 // Even class names are added due to a delicate problem we have:
238 // if one imports dart:core with a prefix, we cannot tell prefix.name 238 // if one imports dart:core with a prefix, we cannot tell prefix.name
239 // from dynamic invocation (alas!). So we'd better err on preserving 239 // from dynamic invocation (alas!). So we'd better err on preserving
240 // those names. 240 // those names.
241 fixedMemberNames.add(element.name.slowToString()); 241 fixedMemberNames.add(element.name.slowToString());
242 } 242 });
243 } 243 }
244 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in 244 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in
245 // runtime/lib/error.dart. Overall, all DartVM specific libs should be 245 // runtime/lib/error.dart. Overall, all DartVM specific libs should be
246 // accounted for. 246 // accounted for.
247 fixedMemberNames.add('srcType'); 247 fixedMemberNames.add('srcType');
248 fixedMemberNames.add('dstType'); 248 fixedMemberNames.add('dstType');
249 249
250 /** 250 /**
251 * Tells whether we should output given element. Corelib classes like 251 * Tells whether we should output given element. Corelib classes like
252 * Object should not be in the resulting code. 252 * Object should not be in the resulting code.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 530 }
531 531
532 compareElements(e0, e1) { 532 compareElements(e0, e1) {
533 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 533 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
534 if (result != 0) return result; 534 if (result != 0) return result;
535 return compareBy((e) => e.position().charOffset)(e0, e1); 535 return compareBy((e) => e.position().charOffset)(e0, e1);
536 } 536 }
537 537
538 List<Element> sortElements(Collection<Element> elements) => 538 List<Element> sortElements(Collection<Element> elements) =>
539 sorted(elements, compareElements); 539 sorted(elements, compareElements);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698