| 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 part of dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 void assembleProgram() { | 148 void assembleProgram() { |
| 149 // Conservatively traverse all platform libraries and collect member names. | 149 // Conservatively traverse all platform libraries and collect member names. |
| 150 // TODO(antonm): ideally we should only collect names of used members, | 150 // TODO(antonm): ideally we should only collect names of used members, |
| 151 // however as of today there are problems with names of some core library | 151 // however as of today there are problems with names of some core library |
| 152 // interfaces, most probably for interfaces of literals. | 152 // interfaces, most probably for interfaces of literals. |
| 153 final fixedMemberNames = new Set<String>(); | 153 final fixedMemberNames = new Set<String>(); |
| 154 for (final library in compiler.libraries.values) { | 154 for (final library in compiler.libraries.values) { |
| 155 if (!library.isPlatformLibrary) continue; | 155 if (!library.isPlatformLibrary) continue; |
| 156 library.implementation.forEachLocalMember((Element element) { | 156 library.implementation.forEachLocalMember((Element element) { |
| 157 if (element.isClass()) { | 157 if (element.isClass) { |
| 158 ClassElement classElement = element; | 158 ClassElement classElement = element; |
| 159 // Make sure we parsed the class to initialize its local members. | 159 // Make sure we parsed the class to initialize its local members. |
| 160 // TODO(smok): Figure out if there is a better way to fill local | 160 // TODO(smok): Figure out if there is a better way to fill local |
| 161 // members. | 161 // members. |
| 162 element.parseNode(compiler); | 162 element.parseNode(compiler); |
| 163 classElement.forEachLocalMember((member) { | 163 classElement.forEachLocalMember((member) { |
| 164 final name = member.name; | 164 final name = member.name; |
| 165 // Skip operator names. | 165 // Skip operator names. |
| 166 if (!name.startsWith(r'operator$')) { | 166 if (!name.startsWith(r'operator$')) { |
| 167 // Fetch name of named constructors and factories if any, | 167 // Fetch name of named constructors and factories if any, |
| 168 // otherwise store regular name. | 168 // otherwise store regular name. |
| 169 // TODO(antonm): better way to analyze the name. | 169 // TODO(antonm): better way to analyze the name. |
| 170 fixedMemberNames.add(name.split(r'$').last); | 170 fixedMemberNames.add(name.split(r'$').last); |
| 171 } | 171 } |
| 172 }); | 172 }); |
| 173 } | 173 } |
| 174 // Even class names are added due to a delicate problem we have: | 174 // Even class names are added due to a delicate problem we have: |
| 175 // if one imports dart:core with a prefix, we cannot tell prefix.name | 175 // if one imports dart:core with a prefix, we cannot tell prefix.name |
| 176 // from dynamic invocation (alas!). So we'd better err on preserving | 176 // from dynamic invocation (alas!). So we'd better err on preserving |
| 177 // those names. | 177 // those names. |
| 178 fixedMemberNames.add(element.name); | 178 fixedMemberNames.add(element.name); |
| 179 }); | 179 }); |
| 180 for (Element export in library.exports) { | 180 for (Element export in library.exports) { |
| 181 if (!library.isInternalLibrary && | 181 if (!library.isInternalLibrary && |
| 182 export.getLibrary().isInternalLibrary) { | 182 export.library.isInternalLibrary) { |
| 183 // If an element of an internal library is reexported by a platform | 183 // If an element of an internal library is reexported by a platform |
| 184 // library, we have to import the reexporting library instead of the | 184 // library, we have to import the reexporting library instead of the |
| 185 // internal library, because the internal library is an | 185 // internal library, because the internal library is an |
| 186 // implementation detail of dart2js. | 186 // implementation detail of dart2js. |
| 187 reexportingLibraries[export] = library; | 187 reexportingLibraries[export] = library; |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 // As of now names of named optionals are not renamed. Therefore add all | 191 // As of now names of named optionals are not renamed. Therefore add all |
| 192 // field names used as named optionals into [fixedMemberNames]. | 192 // field names used as named optionals into [fixedMemberNames]. |
| 193 for (final element in resolvedElements.keys) { | 193 for (final element in resolvedElements.keys) { |
| 194 if (!element.isConstructor()) continue; | 194 if (!element.isConstructor) continue; |
| 195 Link<Element> optionalParameters = | 195 Link<Element> optionalParameters = |
| 196 element.computeSignature(compiler).optionalParameters; | 196 element.computeSignature(compiler).optionalParameters; |
| 197 for (final optional in optionalParameters) { | 197 for (final optional in optionalParameters) { |
| 198 if (optional.kind != ElementKind.FIELD_PARAMETER) continue; | 198 if (optional.kind != ElementKind.FIELD_PARAMETER) continue; |
| 199 fixedMemberNames.add(optional.name); | 199 fixedMemberNames.add(optional.name); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 // The VM will automatically invoke the call method of objects | 202 // The VM will automatically invoke the call method of objects |
| 203 // that are invoked as functions. Make sure to not rename that. | 203 // that are invoked as functions. Make sure to not rename that. |
| 204 fixedMemberNames.add('call'); | 204 fixedMemberNames.add('call'); |
| 205 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in | 205 // TODO(antonm): TypeError.srcType and TypeError.dstType are defined in |
| 206 // runtime/lib/error.dart. Overall, all DartVM specific libs should be | 206 // runtime/lib/error.dart. Overall, all DartVM specific libs should be |
| 207 // accounted for. | 207 // accounted for. |
| 208 fixedMemberNames.add('srcType'); | 208 fixedMemberNames.add('srcType'); |
| 209 fixedMemberNames.add('dstType'); | 209 fixedMemberNames.add('dstType'); |
| 210 | 210 |
| 211 if (useMirrorHelperLibrary && compiler.mirrorsLibrary != null) { | 211 if (useMirrorHelperLibrary && compiler.mirrorsLibrary != null) { |
| 212 mirrorRenamer = new MirrorRenamer(compiler, this); | 212 mirrorRenamer = new MirrorRenamer(compiler, this); |
| 213 } else { | 213 } else { |
| 214 useMirrorHelperLibrary = false; | 214 useMirrorHelperLibrary = false; |
| 215 } | 215 } |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * Tells whether we should output given element. Corelib classes like | 218 * Tells whether we should output given element. Corelib classes like |
| 219 * Object should not be in the resulting code. | 219 * Object should not be in the resulting code. |
| 220 */ | 220 */ |
| 221 bool shouldOutput(Element element) { | 221 bool shouldOutput(Element element) { |
| 222 return (element.kind != ElementKind.VOID | 222 return (element.kind != ElementKind.VOID |
| 223 && isUserLibrary(element.getLibrary()) | 223 && isUserLibrary(element.library) |
| 224 && !element.isSynthesized | 224 && !element.isSynthesized |
| 225 && element is !AbstractFieldElement) | 225 && element is !AbstractFieldElement) |
| 226 || element.getLibrary() == mirrorHelperLibrary; | 226 || element.library == mirrorHelperLibrary; |
| 227 } | 227 } |
| 228 | 228 |
| 229 final elementAsts = new Map<Element, ElementAst>(); | 229 final elementAsts = new Map<Element, ElementAst>(); |
| 230 | 230 |
| 231 ElementAst parse(Element element, TreeElements treeElements) { | 231 ElementAst parse(Element element, TreeElements treeElements) { |
| 232 Node node; | 232 Node node; |
| 233 if (!compiler.irBuilder.hasIr(element)) { | 233 if (!compiler.irBuilder.hasIr(element)) { |
| 234 node = element.parseNode(compiler); | 234 node = element.parseNode(compiler); |
| 235 } else { | 235 } else { |
| 236 ir.FunctionDefinition function = compiler.irBuilder.getIr(element); | 236 ir.FunctionDefinition function = compiler.irBuilder.getIr(element); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 }; | 293 }; |
| 294 | 294 |
| 295 compiler.resolverWorld.instantiatedClasses.forEach( | 295 compiler.resolverWorld.instantiatedClasses.forEach( |
| 296 (ClassElement classElement) { | 296 (ClassElement classElement) { |
| 297 if (shouldOutput(classElement)) addClass(classElement); | 297 if (shouldOutput(classElement)) addClass(classElement); |
| 298 }); | 298 }); |
| 299 resolvedElements.forEach((element, treeElements) { | 299 resolvedElements.forEach((element, treeElements) { |
| 300 if (!shouldOutput(element) || treeElements == null) return; | 300 if (!shouldOutput(element) || treeElements == null) return; |
| 301 ElementAst elementAst = parse(element, treeElements); | 301 ElementAst elementAst = parse(element, treeElements); |
| 302 | 302 |
| 303 if (element.isMember()) { | 303 if (element.isMember) { |
| 304 ClassElement enclosingClass = element.getEnclosingClass(); | 304 ClassElement enclosingClass = element.enclosingClass; |
| 305 assert(enclosingClass.isClass()); | 305 assert(enclosingClass.isClass); |
| 306 assert(enclosingClass.isTopLevel()); | 306 assert(enclosingClass.isTopLevel); |
| 307 assert(shouldOutput(enclosingClass)); | 307 assert(shouldOutput(enclosingClass)); |
| 308 addClass(enclosingClass); | 308 addClass(enclosingClass); |
| 309 classMembers[enclosingClass].add(element); | 309 classMembers[enclosingClass].add(element); |
| 310 processElement(element, elementAst); | 310 processElement(element, elementAst); |
| 311 } else { | 311 } else { |
| 312 if (element.isTopLevel()) { | 312 if (element.isTopLevel) { |
| 313 addTopLevel(element, elementAst); | 313 addTopLevel(element, elementAst); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 }); | 316 }); |
| 317 Set<ClassElement> emitNoMembersFor = new Set<ClassElement>(); | 317 Set<ClassElement> emitNoMembersFor = new Set<ClassElement>(); |
| 318 usedTypeLiterals.forEach((ClassElement element) { | 318 usedTypeLiterals.forEach((ClassElement element) { |
| 319 if (shouldOutput(element)) { | 319 if (shouldOutput(element)) { |
| 320 if (!topLevelElements.contains(element)) { | 320 if (!topLevelElements.contains(element)) { |
| 321 // The class is only referenced by type literals. | 321 // The class is only referenced by type literals. |
| 322 emitNoMembersFor.add(element); | 322 emitNoMembersFor.add(element); |
| 323 } | 323 } |
| 324 addClass(element); | 324 addClass(element); |
| 325 } | 325 } |
| 326 }); | 326 }); |
| 327 | 327 |
| 328 // Add synthesized constructors to classes with no resolved constructors, | 328 // Add synthesized constructors to classes with no resolved constructors, |
| 329 // but which originally had any constructor. That should prevent | 329 // but which originally had any constructor. That should prevent |
| 330 // those classes from being instantiable with default constructor. | 330 // those classes from being instantiable with default constructor. |
| 331 Identifier synthesizedIdentifier = new Identifier( | 331 Identifier synthesizedIdentifier = new Identifier( |
| 332 new StringToken.fromString(IDENTIFIER_INFO, '', -1)); | 332 new StringToken.fromString(IDENTIFIER_INFO, '', -1)); |
| 333 | 333 |
| 334 NextClassElement: | 334 NextClassElement: |
| 335 for (ClassElement classElement in classMembers.keys) { | 335 for (ClassElement classElement in classMembers.keys) { |
| 336 if (emitNoMembersFor.contains(classElement)) continue; | 336 if (emitNoMembersFor.contains(classElement)) continue; |
| 337 for (Element member in classMembers[classElement]) { | 337 for (Element member in classMembers[classElement]) { |
| 338 if (member.isConstructor()) continue NextClassElement; | 338 if (member.isConstructor) continue NextClassElement; |
| 339 } | 339 } |
| 340 if (classElement.constructors.isEmpty) continue NextClassElement; | 340 if (classElement.constructors.isEmpty) continue NextClassElement; |
| 341 | 341 |
| 342 // TODO(antonm): check with AAR team if there is better approach. | 342 // TODO(antonm): check with AAR team if there is better approach. |
| 343 // As an idea: provide template as a Dart code---class C { C.name(); }--- | 343 // As an idea: provide template as a Dart code---class C { C.name(); }--- |
| 344 // and then overwrite necessary parts. | 344 // and then overwrite necessary parts. |
| 345 var classNode = classElement.parseNode(compiler); | 345 var classNode = classElement.parseNode(compiler); |
| 346 SynthesizedConstructorElementX constructor = | 346 SynthesizedConstructorElementX constructor = |
| 347 new SynthesizedConstructorElementX( | 347 new SynthesizedConstructorElementX( |
| 348 classElement.name, null, classElement, false); | 348 classElement.name, null, classElement, false); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 | 366 |
| 367 // Create all necessary placeholders. | 367 // Create all necessary placeholders. |
| 368 PlaceholderCollector collector = | 368 PlaceholderCollector collector = |
| 369 new PlaceholderCollector(compiler, fixedMemberNames, elementAsts); | 369 new PlaceholderCollector(compiler, fixedMemberNames, elementAsts); |
| 370 // Add synthesizedIdentifier to set of unresolved names to rename it to | 370 // Add synthesizedIdentifier to set of unresolved names to rename it to |
| 371 // some unused identifier. | 371 // some unused identifier. |
| 372 collector.unresolvedNodes.add(synthesizedIdentifier); | 372 collector.unresolvedNodes.add(synthesizedIdentifier); |
| 373 makePlaceholders(element) { | 373 makePlaceholders(element) { |
| 374 bool oldUseHelper = useMirrorHelperLibrary; | 374 bool oldUseHelper = useMirrorHelperLibrary; |
| 375 useMirrorHelperLibrary = (useMirrorHelperLibrary | 375 useMirrorHelperLibrary = (useMirrorHelperLibrary |
| 376 && element.getLibrary() != mirrorHelperLibrary); | 376 && element.library != mirrorHelperLibrary); |
| 377 collector.collect(element); | 377 collector.collect(element); |
| 378 useMirrorHelperLibrary = oldUseHelper; | 378 useMirrorHelperLibrary = oldUseHelper; |
| 379 | 379 |
| 380 if (element.isClass()) { | 380 if (element.isClass) { |
| 381 classMembers[element].forEach(makePlaceholders); | 381 classMembers[element].forEach(makePlaceholders); |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 topLevelElements.forEach(makePlaceholders); | 384 topLevelElements.forEach(makePlaceholders); |
| 385 // Create renames. | 385 // Create renames. |
| 386 bool shouldCutDeclarationTypes = forceStripTypes | 386 bool shouldCutDeclarationTypes = forceStripTypes |
| 387 || (compiler.enableMinification | 387 || (compiler.enableMinification |
| 388 && isSafeToRemoveTypeDeclarations(classMembers)); | 388 && isSafeToRemoveTypeDeclarations(classMembers)); |
| 389 renamePlaceholders( | 389 renamePlaceholders( |
| 390 compiler, collector, renames, imports, | 390 compiler, collector, renames, imports, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 402 if (outputAst) { | 402 if (outputAst) { |
| 403 // TODO(antonm): Ideally XML should be a separate backend. | 403 // TODO(antonm): Ideally XML should be a separate backend. |
| 404 // TODO(antonm): obey renames and minification, at least as an option. | 404 // TODO(antonm): obey renames and minification, at least as an option. |
| 405 StringBuffer sb = new StringBuffer(); | 405 StringBuffer sb = new StringBuffer(); |
| 406 outputElement(element) { | 406 outputElement(element) { |
| 407 sb.write(element.parseNode(compiler).toDebugString()); | 407 sb.write(element.parseNode(compiler).toDebugString()); |
| 408 } | 408 } |
| 409 | 409 |
| 410 // Emit XML for AST instead of the program. | 410 // Emit XML for AST instead of the program. |
| 411 for (final topLevel in sortedTopLevels) { | 411 for (final topLevel in sortedTopLevels) { |
| 412 if (topLevel.isClass() && !emitNoMembersFor.contains(topLevel)) { | 412 if (topLevel.isClass && !emitNoMembersFor.contains(topLevel)) { |
| 413 // TODO(antonm): add some class info. | 413 // TODO(antonm): add some class info. |
| 414 sortedClassMembers[topLevel].forEach(outputElement); | 414 sortedClassMembers[topLevel].forEach(outputElement); |
| 415 } else { | 415 } else { |
| 416 outputElement(topLevel); | 416 outputElement(topLevel); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 compiler.assembledCode = '<Program>\n$sb</Program>\n'; | 419 compiler.assembledCode = '<Program>\n$sb</Program>\n'; |
| 420 return; | 420 return; |
| 421 } | 421 } |
| 422 | 422 |
| 423 final topLevelNodes = <Node>[]; | 423 final topLevelNodes = <Node>[]; |
| 424 for (final element in sortedTopLevels) { | 424 for (final element in sortedTopLevels) { |
| 425 topLevelNodes.add(elementAsts[element].ast); | 425 topLevelNodes.add(elementAsts[element].ast); |
| 426 if (element.isClass() && !element.isMixinApplication) { | 426 if (element.isClass && !element.isMixinApplication) { |
| 427 final members = <Node>[]; | 427 final members = <Node>[]; |
| 428 for (final member in sortedClassMembers[element]) { | 428 for (final member in sortedClassMembers[element]) { |
| 429 members.add(elementAsts[member].ast); | 429 members.add(elementAsts[member].ast); |
| 430 } | 430 } |
| 431 memberNodes[elementAsts[element].ast] = members; | 431 memberNodes[elementAsts[element].ast] = members; |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 | 434 |
| 435 if (useMirrorHelperLibrary) { | 435 if (useMirrorHelperLibrary) { |
| 436 mirrorRenamer.addRenames(renames, topLevelNodes, collector); | 436 mirrorRenamer.addRenames(renames, topLevelNodes, collector); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 mirrorHelperSymbolsMap = mirrorHelperLibrary.find( | 477 mirrorHelperSymbolsMap = mirrorHelperLibrary.find( |
| 478 MirrorRenamer.MIRROR_HELPER_SYMBOLS_MAP_NAME); | 478 MirrorRenamer.MIRROR_HELPER_SYMBOLS_MAP_NAME); |
| 479 }); | 479 }); |
| 480 } | 480 } |
| 481 return new Future.value(); | 481 return new Future.value(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 void registerTypeLiteral(Element element, | 484 void registerTypeLiteral(Element element, |
| 485 Enqueuer enqueuer, | 485 Enqueuer enqueuer, |
| 486 TreeElements elements) { | 486 TreeElements elements) { |
| 487 if (element.isClass()) { | 487 if (element.isClass) { |
| 488 usedTypeLiterals.add(element); | 488 usedTypeLiterals.add(element); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 void registerStaticSend(Element element, Node node) { | 492 void registerStaticSend(Element element, Node node) { |
| 493 if (useMirrorHelperLibrary) { | 493 if (useMirrorHelperLibrary) { |
| 494 mirrorRenamer.registerStaticSend(element, node); | 494 mirrorRenamer.registerStaticSend(element, node); |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| 498 void registerMirrorHelperElement(Element element, Node node) { | 498 void registerMirrorHelperElement(Element element, Node node) { |
| 499 if (mirrorHelperLibrary != null | 499 if (mirrorHelperLibrary != null |
| 500 && element.getLibrary() == mirrorHelperLibrary) { | 500 && element.library == mirrorHelperLibrary) { |
| 501 mirrorRenamer.registerHelperElement(element, node); | 501 mirrorRenamer.registerHelperElement(element, node); |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 | 504 |
| 505 void registerStaticUse(Element element, Enqueuer enqueuer) { | 505 void registerStaticUse(Element element, Enqueuer enqueuer) { |
| 506 if (useMirrorHelperLibrary && | 506 if (useMirrorHelperLibrary && |
| 507 element == compiler.mirrorSystemGetNameFunction) { | 507 element == compiler.mirrorSystemGetNameFunction) { |
| 508 enqueuer.addToWorkList(mirrorHelperGetNameFunction); | 508 enqueuer.addToWorkList(mirrorHelperGetNameFunction); |
| 509 } | 509 } |
| 510 } | 510 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 visitNode(Node node) { | 561 visitNode(Node node) { |
| 562 node.visitChildren(this); | 562 node.visitChildren(this); |
| 563 } | 563 } |
| 564 | 564 |
| 565 visitTypeAnnotation(TypeAnnotation typeAnnotation) { | 565 visitTypeAnnotation(TypeAnnotation typeAnnotation) { |
| 566 TreeElements treeElements = elementAst.treeElements; | 566 TreeElements treeElements = elementAst.treeElements; |
| 567 final DartType type = treeElements.getType(typeAnnotation); | 567 final DartType type = treeElements.getType(typeAnnotation); |
| 568 assert(invariant(typeAnnotation, type != null, | 568 assert(invariant(typeAnnotation, type != null, |
| 569 message: "Missing type for type annotation: $treeElements.")); | 569 message: "Missing type for type annotation: $treeElements.")); |
| 570 Element typeElement = type.element; | 570 Element typeElement = type.element; |
| 571 if (typeElement.isTypedef()) newTypedefElementCallback(typeElement); | 571 if (typeElement.isTypedef) newTypedefElementCallback(typeElement); |
| 572 if (typeElement.isClass()) newClassElementCallback(typeElement); | 572 if (typeElement.isClass) newClassElementCallback(typeElement); |
| 573 typeAnnotation.visitChildren(this); | 573 typeAnnotation.visitChildren(this); |
| 574 } | 574 } |
| 575 | 575 |
| 576 void collect() { | 576 void collect() { |
| 577 compiler.withCurrentElement(element, () { | 577 compiler.withCurrentElement(element, () { |
| 578 elementAst.ast.accept(this); | 578 elementAst.ast.accept(this); |
| 579 }); | 579 }); |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 | 582 |
| 583 Comparator compareBy(f) => (x, y) => f(x).compareTo(f(y)); | 583 Comparator compareBy(f) => (x, y) => f(x).compareTo(f(y)); |
| 584 | 584 |
| 585 List sorted(Iterable l, comparison) { | 585 List sorted(Iterable l, comparison) { |
| 586 final result = new List.from(l); | 586 final result = new List.from(l); |
| 587 result.sort(comparison); | 587 result.sort(comparison); |
| 588 return result; | 588 return result; |
| 589 } | 589 } |
| 590 | 590 |
| 591 compareElements(e0, e1) { | 591 compareElements(e0, e1) { |
| 592 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 592 int result = compareBy((e) => e.library.canonicalUri.toString())(e0, e1); |
| 593 if (result != 0) return result; | 593 if (result != 0) return result; |
| 594 return compareBy((e) => e.position().charOffset)(e0, e1); | 594 return compareBy((e) => e.position.charOffset)(e0, e1); |
| 595 } | 595 } |
| 596 | 596 |
| 597 List<Element> sortElements(Iterable<Element> elements) => | 597 List<Element> sortElements(Iterable<Element> elements) => |
| 598 sorted(elements, compareElements); | 598 sorted(elements, compareElements); |
| 599 | 599 |
| 600 /// [ConstantCompilerTask] for compilation of constants for the Dart backend. | 600 /// [ConstantCompilerTask] for compilation of constants for the Dart backend. |
| 601 /// | 601 /// |
| 602 /// Since this task needs no distinction between frontend and backend constants | 602 /// Since this task needs no distinction between frontend and backend constants |
| 603 /// it also serves as the [BackendConstantEnvironment]. | 603 /// it also serves as the [BackendConstantEnvironment]. |
| 604 class DartConstantTask extends ConstantCompilerTask | 604 class DartConstantTask extends ConstantCompilerTask |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 642 } |
| 643 | 643 |
| 644 Constant compileMetadata(MetadataAnnotation metadata, | 644 Constant compileMetadata(MetadataAnnotation metadata, |
| 645 Node node, | 645 Node node, |
| 646 TreeElements elements) { | 646 TreeElements elements) { |
| 647 return measure(() { | 647 return measure(() { |
| 648 return constantCompiler.compileMetadata(metadata, node, elements); | 648 return constantCompiler.compileMetadata(metadata, node, elements); |
| 649 }); | 649 }); |
| 650 } | 650 } |
| 651 } | 651 } |
| OLD | NEW |