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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend.dart

Issue 746993002: Avoid patching in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
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 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 29 matching lines...) Expand all
40 } 40 }
41 41
42 BackendConstantEnvironment get constants => constantCompilerTask; 42 BackendConstantEnvironment get constants => constantCompilerTask;
43 43
44 DartConstantTask constantCompilerTask; 44 DartConstantTask constantCompilerTask;
45 45
46 DartResolutionCallbacks resolutionCallbacks; 46 DartResolutionCallbacks resolutionCallbacks;
47 47
48 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>(); 48 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>();
49 49
50 /// The set of visible platform classes that are implementated by instantiated
floitsch 2014/11/21 12:14:49 implemented
Johnni Winther 2014/11/21 13:20:31 Done.
51 /// user classes.
52 final Set<ClassElement> _userImplementedPlatformClasses =
53 new Set<ClassElement>();
54
50 /** 55 /**
51 * Tells whether it is safe to remove type declarations from variables, 56 * Tells whether it is safe to remove type declarations from variables,
52 * functions parameters. It becomes not safe if: 57 * functions parameters. It becomes not safe if:
53 * 1) TypeError is used somewhere in the code, 58 * 1) TypeError is used somewhere in the code,
54 * 2) The code has typedefs in right hand side of IS checks, 59 * 2) The code has typedefs in right hand side of IS checks,
55 * 3) The code has classes which extend typedefs, have type arguments typedefs 60 * 3) The code has classes which extend typedefs, have type arguments typedefs
56 * or type variable bounds typedefs. 61 * or type variable bounds typedefs.
57 * These restrictions can be less strict. 62 * These restrictions can be less strict.
58 */ 63 */
59 bool isSafeToRemoveTypeDeclarations( 64 bool isSafeToRemoveTypeDeclarations(
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 nonPlatformSize += compilationUnit.script.file.length; 259 nonPlatformSize += compilationUnit.script.file.length;
255 } 260 }
256 } 261 }
257 int percentage = totalOutputSize * 100 ~/ nonPlatformSize; 262 int percentage = totalOutputSize * 100 ~/ nonPlatformSize;
258 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' 263 log('Total used non-platform files size: ${nonPlatformSize} bytes, '
259 'Output total size: $totalOutputSize bytes (${percentage}%)'); 264 'Output total size: $totalOutputSize bytes (${percentage}%)');
260 } 265 }
261 266
262 log(String message) => compiler.log('[DartBackend] $message'); 267 log(String message) => compiler.log('[DartBackend] $message');
263 268
269 @override
264 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { 270 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) {
265 // All platform classes must be resolved to ensure that their member names 271 // All platform classes must be resolved to ensure that their member names
266 // are preserved. 272 // are preserved.
267 loadedLibraries.forEachLibrary((LibraryElement library) { 273 loadedLibraries.forEachLibrary((LibraryElement library) {
268 if (library.isPlatformLibrary) { 274 if (library.isPlatformLibrary) {
269 library.forEachLocalMember((Element element) { 275 library.forEachLocalMember((Element element) {
270 if (element.isClass) { 276 if (element.isClass) {
271 ClassElement classElement = element; 277 ClassElement classElement = element;
272 classElement.ensureResolved(compiler); 278 classElement.ensureResolved(compiler);
273 } 279 }
274 }); 280 });
275 } 281 }
276 }); 282 });
277 if (useMirrorHelperLibrary && 283 if (useMirrorHelperLibrary &&
278 loadedLibraries.containsLibrary(Compiler.DART_MIRRORS)) { 284 loadedLibraries.containsLibrary(Compiler.DART_MIRRORS)) {
279 return compiler.libraryLoader.loadLibrary( 285 return compiler.libraryLoader.loadLibrary(
280 compiler.translateResolvedUri( 286 compiler.translateResolvedUri(
281 loadedLibraries.getLibrary(Compiler.DART_MIRRORS), 287 loadedLibraries.getLibrary(Compiler.DART_MIRRORS),
282 MirrorRenamerImpl.DART_MIRROR_HELPER, null)). 288 MirrorRenamerImpl.DART_MIRROR_HELPER, null)).
283 then((LibraryElement library) { 289 then((LibraryElement library) {
284 mirrorRenamer = new MirrorRenamerImpl(compiler, this, library); 290 mirrorRenamer = new MirrorRenamerImpl(compiler, this, library);
285 }); 291 });
286 } 292 }
287 return new Future.value(); 293 return new Future.value();
288 } 294 }
289 295
296 @override
290 void registerStaticUse(Element element, Enqueuer enqueuer) { 297 void registerStaticUse(Element element, Enqueuer enqueuer) {
291 if (element == compiler.mirrorSystemGetNameFunction) { 298 if (element == compiler.mirrorSystemGetNameFunction) {
292 FunctionElement getNameFunction = mirrorRenamer.getNameFunction; 299 FunctionElement getNameFunction = mirrorRenamer.getNameFunction;
293 if (getNameFunction != null) { 300 if (getNameFunction != null) {
294 enqueuer.addToWorkList(getNameFunction); 301 enqueuer.addToWorkList(getNameFunction);
295 } 302 }
296 } 303 }
297 } 304 }
305
306 @override
307 void registerInstantiatedType(InterfaceType type, Registry registry) {
308 ClassElement cls = type.element;
309 if (!cls.library.isPlatformLibrary) {
310 for (Link<DartType> link = cls.allSupertypes;
floitsch 2014/11/21 12:14:49 Give a general description of what you trying to a
Johnni Winther 2014/11/21 13:20:31 Done.
311 !link.isEmpty;
312 link = link.tail) {
313 InterfaceType supertype = link.head;
314 ClassElement superclass = supertype.element;
315 LibraryElement library = superclass.library;
316 if (library.isPlatformLibrary) {
317 if (_userImplementedPlatformClasses.add(superclass)) {
318 // Register selectors for all instance methods since these might
319 // be called on user classes from within the platform
320 // implementation.
321 superclass.forEachLocalMember((Element element) {
322 if (element.isConstructor || element.isStatic) return;
323
324 FunctionElement function = element.asFunctionElement();
325 if (function != null) {
326 function.computeSignature(compiler);
327 }
328 Selector selector = new Selector.fromElement(element);
329 if (selector.isGetter) {
330 registry.registerDynamicGetter(selector);
331 } else if (selector.isSetter) {
332 registry.registerDynamicSetter(selector);
333 } else {
334 registry.registerDynamicInvocation(selector);
335 }
336 });
337 }
338 }
339 }
340 }
341
342 }
298 } 343 }
299 344
300 class DartResolutionCallbacks extends ResolutionCallbacks { 345 class DartResolutionCallbacks extends ResolutionCallbacks {
301 final DartBackend backend; 346 final DartBackend backend;
302 347
303 DartResolutionCallbacks(this.backend); 348 DartResolutionCallbacks(this.backend);
304 349
305 void onTypeLiteral(DartType type, Registry registry) { 350 void onTypeLiteral(DartType type, Registry registry) {
306 if (type.isInterfaceType) { 351 if (type.isInterfaceType) {
307 backend.usedTypeLiterals.add(type.element); 352 backend.usedTypeLiterals.add(type.element);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 486 }
442 487
443 ConstantExpression compileMetadata(MetadataAnnotation metadata, 488 ConstantExpression compileMetadata(MetadataAnnotation metadata,
444 Node node, 489 Node node,
445 TreeElements elements) { 490 TreeElements elements) {
446 return measure(() { 491 return measure(() {
447 return constantCompiler.compileMetadata(metadata, node, elements); 492 return constantCompiler.compileMetadata(metadata, node, elements);
448 }); 493 });
449 } 494 }
450 } 495 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698