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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 14173003: Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
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 js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 Function computeClassFilter() { 1722 Function computeClassFilter() {
1723 Set<ClassElement> unneededClasses = new Set<ClassElement>(); 1723 Set<ClassElement> unneededClasses = new Set<ClassElement>();
1724 // The [Bool] class is not marked as abstract, but has a factory 1724 // The [Bool] class is not marked as abstract, but has a factory
1725 // constructor that always throws. We never need to emit it. 1725 // constructor that always throws. We never need to emit it.
1726 unneededClasses.add(compiler.boolClass); 1726 unneededClasses.add(compiler.boolClass);
1727 1727
1728 // Go over specialized interceptors and then constants to know which 1728 // Go over specialized interceptors and then constants to know which
1729 // interceptors are needed. 1729 // interceptors are needed.
1730 Set<ClassElement> needed = new Set<ClassElement>(); 1730 Set<ClassElement> needed = new Set<ClassElement>();
1731 backend.specializedGetInterceptors.forEach( 1731 backend.specializedGetInterceptors.forEach(
1732 (_, Collection<ClassElement> elements) { 1732 (_, Iterable<ClassElement> elements) {
1733 needed.addAll(elements); 1733 needed.addAll(elements);
1734 } 1734 }
1735 ); 1735 );
1736 1736
1737 // Add interceptors referenced by constants. 1737 // Add interceptors referenced by constants.
1738 ConstantHandler handler = compiler.constantHandler; 1738 ConstantHandler handler = compiler.constantHandler;
1739 List<Constant> constants = handler.getConstantsForEmission(); 1739 List<Constant> constants = handler.getConstantsForEmission();
1740 for (Constant constant in constants) { 1740 for (Constant constant in constants) {
1741 if (constant is InterceptorConstant) { 1741 if (constant is InterceptorConstant) {
1742 needed.add(constant.dispatchedType.element); 1742 needed.add(constant.dispatchedType.element);
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 } else { 2413 } else {
2414 ${mainCall}; 2414 ${mainCall};
2415 } 2415 }
2416 } 2416 }
2417 """); 2417 """);
2418 addComment('END invoke [main].', buffer); 2418 addComment('END invoke [main].', buffer);
2419 } 2419 }
2420 2420
2421 void emitGetInterceptorMethod(CodeBuffer buffer, 2421 void emitGetInterceptorMethod(CodeBuffer buffer,
2422 String key, 2422 String key,
2423 Collection<ClassElement> classes) { 2423 Iterable<ClassElement> classes) {
2424 jsAst.Statement buildReturnInterceptor(ClassElement cls) { 2424 jsAst.Statement buildReturnInterceptor(ClassElement cls) {
2425 return js.return_(js(namer.isolateAccess(cls))['prototype']); 2425 return js.return_(js(namer.isolateAccess(cls))['prototype']);
2426 } 2426 }
2427 2427
2428 /** 2428 /**
2429 * Build a JavaScrit AST node for doing a type check on 2429 * Build a JavaScrit AST node for doing a type check on
2430 * [cls]. [cls] must be an interceptor class. 2430 * [cls]. [cls] must be an interceptor class.
2431 */ 2431 */
2432 jsAst.Statement buildInterceptorCheck(ClassElement cls) { 2432 jsAst.Statement buildInterceptorCheck(ClassElement cls) {
2433 jsAst.Expression condition; 2433 jsAst.Expression condition;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 compiler)); 2583 compiler));
2584 buffer.write(N); 2584 buffer.write(N);
2585 } 2585 }
2586 2586
2587 /** 2587 /**
2588 * Emit all versions of the [:getInterceptor:] method. 2588 * Emit all versions of the [:getInterceptor:] method.
2589 */ 2589 */
2590 void emitGetInterceptorMethods(CodeBuffer buffer) { 2590 void emitGetInterceptorMethods(CodeBuffer buffer) {
2591 var specializedGetInterceptors = backend.specializedGetInterceptors; 2591 var specializedGetInterceptors = backend.specializedGetInterceptors;
2592 for (String name in specializedGetInterceptors.keys.toList()..sort()) { 2592 for (String name in specializedGetInterceptors.keys.toList()..sort()) {
2593 Collection<ClassElement> classes = specializedGetInterceptors[name]; 2593 Iterable<ClassElement> classes = specializedGetInterceptors[name];
2594 emitGetInterceptorMethod(buffer, name, classes); 2594 emitGetInterceptorMethod(buffer, name, classes);
2595 } 2595 }
2596 } 2596 }
2597 2597
2598 /** 2598 /**
2599 * Compute all the classes that must be emitted. 2599 * Compute all the classes that must be emitted.
2600 */ 2600 */
2601 void computeNeededClasses() { 2601 void computeNeededClasses() {
2602 instantiatedClasses = 2602 instantiatedClasses =
2603 compiler.codegenWorld.instantiatedClasses.where(computeClassFilter()) 2603 compiler.codegenWorld.instantiatedClasses.where(computeClassFilter())
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 """; 3057 """;
3058 const String HOOKS_API_USAGE = """ 3058 const String HOOKS_API_USAGE = """
3059 // The code supports the following hooks: 3059 // The code supports the following hooks:
3060 // dartPrint(message) - if this function is defined it is called 3060 // dartPrint(message) - if this function is defined it is called
3061 // instead of the Dart [print] method. 3061 // instead of the Dart [print] method.
3062 // dartMainRunner(main) - if this function is defined, the Dart [main] 3062 // dartMainRunner(main) - if this function is defined, the Dart [main]
3063 // method will not be invoked directly. 3063 // method will not be invoked directly.
3064 // Instead, a closure that will invoke [main] is 3064 // Instead, a closure that will invoke [main] is
3065 // passed to [dartMainRunner]. 3065 // passed to [dartMainRunner].
3066 """; 3066 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698