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

Side by Side Diff: lib/compiler/implementation/native_handler.dart

Issue 10106019: Truley compute direct subtypes of native classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « lib/compiler/implementation/native_emitter.dart ('k') | no next file » | 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 #library('native'); 5 #library('native');
6 #import('dart:uri'); 6 #import('dart:uri');
7 #import('leg.dart'); 7 #import('leg.dart');
8 #import('elements/elements.dart'); 8 #import('elements/elements.dart');
9 #import('scanner/scannerlib.dart'); 9 #import('scanner/scannerlib.dart');
10 #import('ssa/ssa.dart'); 10 #import('ssa/ssa.dart');
11 #import('tree/tree.dart'); 11 #import('tree/tree.dart');
12 #import('util/util.dart'); 12 #import('util/util.dart');
13 13
14 void processNativeClasses(Compiler compiler, 14 void processNativeClasses(Compiler compiler,
15 Collection<LibraryElement> libraries) { 15 Collection<LibraryElement> libraries) {
16 for (LibraryElement library in libraries) { 16 for (LibraryElement library in libraries) {
17 processNativeClassesInLibrary(compiler, library); 17 processNativeClassesInLibrary(compiler, library);
18 } 18 }
19 } 19 }
20 20
21 void addSubtypes(ClassElement cls, 21 void addSubtypes(ClassElement cls,
22 NativeEmitter emitter) { 22 NativeEmitter emitter) {
23 for (Type type in cls.allSupertypes) { 23 for (Type type in cls.allSupertypes) {
24 List<Element> subtypes = emitter.subtypes.putIfAbsent( 24 List<Element> subtypes = emitter.subtypes.putIfAbsent(
25 type.element, 25 type.element,
26 () => <ClassElement>[]); 26 () => <ClassElement>[]);
27 subtypes.add(cls); 27 subtypes.add(cls);
28 } 28 }
29
30 List<Element> directSubtypes = emitter.directSubtypes.putIfAbsent(
31 cls.superclass,
32 () => <ClassElement>[]);
33 directSubtypes.add(cls);
29 } 34 }
30 35
31 void processNativeClassesInLibrary(Compiler compiler, 36 void processNativeClassesInLibrary(Compiler compiler,
32 LibraryElement library) { 37 LibraryElement library) {
33 bool hasNativeClass = false; 38 bool hasNativeClass = false;
34 for (Link<Element> link = library.topLevelElements; 39 for (Link<Element> link = library.topLevelElements;
35 !link.isEmpty(); link = link.tail) { 40 !link.isEmpty(); link = link.tail) {
36 Element element = link.head; 41 Element element = link.head;
37 if (element.kind == ElementKind.CLASS) { 42 if (element.kind == ElementKind.CLASS) {
38 ClassElement classElement = element; 43 ClassElement classElement = element;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 String parameters) { 341 String parameters) {
337 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 342 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
338 buffer.add("('$methodName')) {\n"); 343 buffer.add("('$methodName')) {\n");
339 buffer.add(" $code"); 344 buffer.add(" $code");
340 buffer.add(" } else {\n"); 345 buffer.add(" } else {\n");
341 buffer.add(" return Object.prototype.$methodName.call(this"); 346 buffer.add(" return Object.prototype.$methodName.call(this");
342 buffer.add(parameters == '' ? '' : ', $parameters'); 347 buffer.add(parameters == '' ? '' : ', $parameters');
343 buffer.add(");\n"); 348 buffer.add(");\n");
344 buffer.add(" }\n"); 349 buffer.add(" }\n");
345 } 350 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/native_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698