| OLD | NEW |
| 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 Loading... |
| 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 include injected members? |
| 204 library.forEachLocalMember((Element element) { |
| 204 if (element is ClassElement) { | 205 if (element is ClassElement) { |
| 205 ClassElement classElement = element; | 206 ClassElement classElement = element; |
| 206 for (final member in classElement.localMembers) { | 207 for (final member in classElement.localMembers) { |
| 207 final name = member.name.slowToString(); | 208 final name = member.name.slowToString(); |
| 208 // Skip operator names. | 209 // Skip operator names. |
| 209 if (name.startsWith(@'operator$')) continue; | 210 if (name.startsWith(@'operator$')) continue; |
| 210 // Fetch name of named constructors and factories if any, | 211 // Fetch name of named constructors and factories if any, |
| 211 // otherwise store regular name. | 212 // otherwise store regular name. |
| 212 // TODO(antonm): better way to analyze the name. | 213 // TODO(antonm): better way to analyze the name. |
| 213 fixedMemberNames.add(name.split(@'$').last()); | 214 fixedMemberNames.add(name.split(@'$').last()); |
| 214 } | 215 } |
| 215 } else { | 216 } else { |
| 216 fixedMemberNames.add(element.name.slowToString()); | 217 fixedMemberNames.add(element.name.slowToString()); |
| 217 } | 218 } |
| 218 } | 219 }); |
| 219 } | 220 } |
| 220 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in | 221 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in |
| 221 // runtime/lib/error.dart. Overall, all DartVM specific libs should be | 222 // runtime/lib/error.dart. Overall, all DartVM specific libs should be |
| 222 // accounted for. | 223 // accounted for. |
| 223 fixedMemberNames.add('srcType'); | 224 fixedMemberNames.add('srcType'); |
| 224 fixedMemberNames.add('dstType'); | 225 fixedMemberNames.add('dstType'); |
| 225 | 226 |
| 226 /** | 227 /** |
| 227 * Tells whether we should output given element. Corelib classes like | 228 * Tells whether we should output given element. Corelib classes like |
| 228 * Object should not be in the resulting code. | 229 * Object should not be in the resulting code. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 434 } |
| 434 | 435 |
| 435 compareElements(e0, e1) { | 436 compareElements(e0, e1) { |
| 436 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); | 437 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); |
| 437 if (result != 0) return result; | 438 if (result != 0) return result; |
| 438 return compareBy((e) => e.position().charOffset)(e0, e1); | 439 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 439 } | 440 } |
| 440 | 441 |
| 441 List<Element> sortElements(Collection<Element> elements) => | 442 List<Element> sortElements(Collection<Element> elements) => |
| 442 sorted(elements, compareElements); | 443 sorted(elements, compareElements); |
| OLD | NEW |