Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10829076: Support imports for dart: libs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
114 }
115 }
116 return false;
117 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698