| 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 dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class EnqueueTask extends CompilerTask { | 7 class EnqueueTask extends CompilerTask { |
| 8 final Enqueuer codegen; | 8 final Enqueuer codegen; |
| 9 final Enqueuer resolution; | 9 final Enqueuer resolution; |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // TODO(ngeoffray): Get rid of this check. | 61 // TODO(ngeoffray): Get rid of this check. |
| 62 if (element.enclosingElement.isClosure()) { | 62 if (element.enclosingElement.isClosure()) { |
| 63 closureMapping.ClosureClassElement cls = element.enclosingElement; | 63 closureMapping.ClosureClassElement cls = element.enclosingElement; |
| 64 element = cls.methodElement; | 64 element = cls.methodElement; |
| 65 } | 65 } |
| 66 Element owner = element.getOutermostEnclosingMemberOrTopLevel(); | 66 Element owner = element.getOutermostEnclosingMemberOrTopLevel(); |
| 67 return compiler.enqueuer.resolution.resolvedElements[owner.declaration]; | 67 return compiler.enqueuer.resolution.resolvedElements[owner.declaration]; |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Documentation wanted -- johnniwinther | 71 * Unit test hook that returns code of an element as a String. |
| 72 * | 72 * |
| 73 * Invariant: [element] must be a declaration element. | 73 * Invariant: [element] must be a declaration element. |
| 74 */ | 74 */ |
| 75 String lookupCode(Element element) { | 75 String lookupCode(Element element) { |
| 76 assert(invariant(element, element.isDeclaration)); | 76 assert(invariant(element, element.isDeclaration)); |
| 77 return universe.generatedCode[element].toString(); | 77 return js.prettyPrint(universe.generatedCode[element], compiler).getText(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Documentation wanted -- johnniwinther | 81 * Documentation wanted -- johnniwinther |
| 82 * | 82 * |
| 83 * Invariant: [element] must be a declaration element. | 83 * Invariant: [element] must be a declaration element. |
| 84 */ | 84 */ |
| 85 void addToWorkList(Element element, [TreeElements elements]) { | 85 void addToWorkList(Element element, [TreeElements elements]) { |
| 86 assert(invariant(element, element.isDeclaration)); | 86 assert(invariant(element, element.isDeclaration)); |
| 87 if (element.isForeign(compiler)) return; | 87 if (element.isForeign(compiler)) return; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 String toString() => 'Enqueuer($name)'; | 418 String toString() => 'Enqueuer($name)'; |
| 419 | 419 |
| 420 void logSummary(log(message)) { | 420 void logSummary(log(message)) { |
| 421 log(isResolutionQueue | 421 log(isResolutionQueue |
| 422 ? 'Resolved ${resolvedElements.length} elements.' | 422 ? 'Resolved ${resolvedElements.length} elements.' |
| 423 : 'Compiled ${universe.generatedCode.length} methods.'); | 423 : 'Compiled ${universe.generatedCode.length} methods.'); |
| 424 nativeEnqueuer.logSummary(log); | 424 nativeEnqueuer.logSummary(log); |
| 425 } | 425 } |
| 426 } | 426 } |
| OLD | NEW |