Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 } | 57 } |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Tells whether we should output given element. Corelib classes like | 60 * Tells whether we should output given element. Corelib classes like |
| 61 * Object should not be in the resulting code. | 61 * Object should not be in the resulting code. |
| 62 */ | 62 */ |
| 63 final LIBS_TO_IGNORE = [ | 63 final LIBS_TO_IGNORE = [ |
| 64 compiler.jsHelperLibrary, | 64 compiler.jsHelperLibrary, |
| 65 compiler.interceptorsLibrary, | 65 compiler.interceptorsLibrary, |
| 66 ]; | 66 ]; |
| 67 compiler.libraries.forEach((uri, lib) { | |
| 68 if (uri.startsWith('dart:')) LIBS_TO_IGNORE.add(lib); | |
| 69 }); | |
| 70 bool shouldOutput(Element element) => | 67 bool shouldOutput(Element element) => |
| 71 element.kind !== ElementKind.VOID && | 68 element.kind !== ElementKind.VOID && |
| 72 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1; | 69 LIBS_TO_IGNORE.indexOf(element.getLibrary()) == -1 && |
| 70 !isDartCoreLib(compiler, element.getLibrary()); | |
| 73 | 71 |
| 74 try { | 72 try { |
| 75 Emitter emitter = new Emitter(compiler); | 73 Emitter emitter = new Emitter(compiler); |
| 76 resolvedElements.forEach((element, treeElements) { | 74 resolvedElements.forEach((element, treeElements) { |
| 77 if (!shouldOutput(element)) return; | 75 if (!shouldOutput(element)) return; |
| 78 if (element.isMember()) { | 76 if (element.isMember()) { |
| 79 var enclosingClass = element.enclosingElement; | 77 var enclosingClass = element.enclosingElement; |
| 80 assert(enclosingClass.isClass()); | 78 assert(enclosingClass.isClass()); |
| 81 assert(enclosingClass.isTopLevel()); | 79 assert(enclosingClass.isTopLevel()); |
| 82 addMemberToClass(element, enclosingClass); | 80 addMemberToClass(element, enclosingClass); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 96 compiler.assembledCode = ''' | 94 compiler.assembledCode = ''' |
| 97 main() { | 95 main() { |
| 98 final bailout_reason = "${e.reason}"; | 96 final bailout_reason = "${e.reason}"; |
| 99 } | 97 } |
| 100 '''; | 98 '''; |
| 101 } | 99 } |
| 102 } | 100 } |
| 103 | 101 |
| 104 log(String message) => compiler.log('[DartBackend] $message'); | 102 log(String message) => compiler.log('[DartBackend] $message'); |
| 105 } | 103 } |
| 104 | |
| 105 /** | |
| 106 * Checks if [:libraryElement:] is a core lib, that is a library | |
| 107 * provided by the implementation like dart:core, dart:coreimpl, etc. | |
| 108 */ | |
| 109 bool isDartCoreLib(Compiler compiler, LibraryElement libraryElement) { | |
| 110 final libraries = compiler.libraries; | |
| 111 for (final uri in libraries.getKeys()) { | |
| 112 if (libraryElement === libraries[uri]) { | |
| 113 if (uri.startsWith('dart:')) return true; | |
|
Roman
2012/07/30 14:43:30
you can check the uri scheme, I think, maybe that
Anton Muhin
2012/07/30 14:54:31
Do you want me to parse the string and then check
Roman
2012/07/30 15:03:42
Ah sorry, I thought it's a Uri object.
| |
| 114 } | |
| 115 } | |
| 116 return false; | |
| 117 } | |
| OLD | NEW |