| 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 class BailoutException { | 5 class BailoutException { |
| 6 final String reason; | 6 final String reason; |
| 7 | 7 |
| 8 const BailoutException(this.reason); | 8 const BailoutException(this.reason); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void processNativeClasses(Enqueuer world, | 33 void processNativeClasses(Enqueuer world, |
| 34 Collection<LibraryElement> libraries) { | 34 Collection<LibraryElement> libraries) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Adds given class element with its member element to resolved classes | 38 * Adds given class element with its member element to resolved classes |
| 39 * collections. | 39 * collections. |
| 40 */ | 40 */ |
| 41 void addMemberToClass(Element element, ClassElement classElement) { | 41 void addMemberToClass(Element element, ClassElement classElement) { |
| 42 // ${element} should have ${classElement} as enclosing. | 42 // ${element} should have ${classElement} as enclosing. |
| 43 assert(element.enclosingElement == classElement); | 43 assert(element.isMember()); |
| 44 Set<Element> resolvedElementsInClass = resolvedClassMembers.putIfAbsent( | 44 Set<Element> resolvedElementsInClass = resolvedClassMembers.putIfAbsent( |
| 45 classElement, () => new Set<Element>()); | 45 classElement, () => new Set<Element>()); |
| 46 resolvedElementsInClass.add(element); | 46 resolvedElementsInClass.add(element); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void assembleProgram() { | 49 void assembleProgram() { |
| 50 resolvedElements.forEach((element, treeElements) { | 50 resolvedElements.forEach((element, treeElements) { |
| 51 unparseValidator.check(element); | 51 unparseValidator.check(element); |
| 52 }); | 52 }); |
| 53 | 53 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 67 bool shouldOutput(Element element) => | 67 bool shouldOutput(Element element) => |
| 68 element.kind !== ElementKind.VOID && | 68 element.kind !== ElementKind.VOID && |
| 69 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1 && | 69 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1 && |
| 70 !isDartCoreLib(compiler, element.getLibrary()); | 70 !isDartCoreLib(compiler, element.getLibrary()); |
| 71 | 71 |
| 72 try { | 72 try { |
| 73 Emitter emitter = new Emitter(compiler); | 73 Emitter emitter = new Emitter(compiler); |
| 74 resolvedElements.forEach((element, treeElements) { | 74 resolvedElements.forEach((element, treeElements) { |
| 75 if (!shouldOutput(element)) return; | 75 if (!shouldOutput(element)) return; |
| 76 if (element.isMember()) { | 76 if (element.isMember()) { |
| 77 var enclosingClass = element.enclosingElement; | 77 ClassElement enclosingClass = element.getEnclosingClass(); |
| 78 assert(enclosingClass.isClass()); | 78 assert(enclosingClass.isClass()); |
| 79 assert(enclosingClass.isTopLevel()); | 79 assert(enclosingClass.isTopLevel()); |
| 80 addMemberToClass(element, enclosingClass); | 80 addMemberToClass(element, enclosingClass); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 if (!element.isTopLevel()) { | 83 if (!element.isTopLevel()) { |
| 84 bailout('Cannot process non top-level $element'); | 84 bailout('Cannot process non top-level $element'); |
| 85 } | 85 } |
| 86 | 86 |
| 87 emitter.outputElement(element); | 87 emitter.outputElement(element); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 */ | 108 */ |
| 109 bool isDartCoreLib(Compiler compiler, LibraryElement libraryElement) { | 109 bool isDartCoreLib(Compiler compiler, LibraryElement libraryElement) { |
| 110 final libraries = compiler.libraries; | 110 final libraries = compiler.libraries; |
| 111 for (final uri in libraries.getKeys()) { | 111 for (final uri in libraries.getKeys()) { |
| 112 if (libraryElement === libraries[uri]) { | 112 if (libraryElement === libraries[uri]) { |
| 113 if (uri.startsWith('dart:')) return true; | 113 if (uri.startsWith('dart:')) return true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| OLD | NEW |