| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); | 7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Generates the code for all used classes in the program. Static fields (even | 10 * Generates the code for all used classes in the program. Static fields (even |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 | 122 |
| 123 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e) { | 123 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e) { |
| 124 return emitter.closureClassConstructorAccess(e); | 124 return emitter.closureClassConstructorAccess(e); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void registerReadTypeVariable(TypeVariableElement element) { | 127 void registerReadTypeVariable(TypeVariableElement element) { |
| 128 readTypeVariables.add(element); | 128 readTypeVariables.add(element); |
| 129 } | 129 } |
| 130 | 130 |
| 131 Set<ClassElement> interceptorsReferencedFromConstants() { | 131 Set<ClassElement> computeInterceptorsReferencedFromConstants() { |
| 132 Set<ClassElement> classes = new Set<ClassElement>(); | 132 Set<ClassElement> classes = new Set<ClassElement>(); |
| 133 JavaScriptConstantCompiler handler = backend.constants; | 133 JavaScriptConstantCompiler handler = backend.constants; |
| 134 List<ConstantValue> constants = handler.getConstantsForEmission(); | 134 List<ConstantValue> constants = handler.getConstantsForEmission(); |
| 135 for (ConstantValue constant in constants) { | 135 for (ConstantValue constant in constants) { |
| 136 if (constant is InterceptorConstantValue) { | 136 if (constant is InterceptorConstantValue) { |
| 137 InterceptorConstantValue interceptorConstant = constant; | 137 InterceptorConstantValue interceptorConstant = constant; |
| 138 classes.add(interceptorConstant.dispatchedType.element); | 138 classes.add(interceptorConstant.dispatchedType.element); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 return classes; | 141 return classes; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 156 // Go over specialized interceptors and then constants to know which | 156 // Go over specialized interceptors and then constants to know which |
| 157 // interceptors are needed. | 157 // interceptors are needed. |
| 158 Set<ClassElement> needed = new Set<ClassElement>(); | 158 Set<ClassElement> needed = new Set<ClassElement>(); |
| 159 backend.specializedGetInterceptors.forEach( | 159 backend.specializedGetInterceptors.forEach( |
| 160 (_, Iterable<ClassElement> elements) { | 160 (_, Iterable<ClassElement> elements) { |
| 161 needed.addAll(elements); | 161 needed.addAll(elements); |
| 162 } | 162 } |
| 163 ); | 163 ); |
| 164 | 164 |
| 165 // Add interceptors referenced by constants. | 165 // Add interceptors referenced by constants. |
| 166 needed.addAll(interceptorsReferencedFromConstants()); | 166 needed.addAll(computeInterceptorsReferencedFromConstants()); |
| 167 | 167 |
| 168 // Add unneeded interceptors to the [unneededClasses] set. | 168 // Add unneeded interceptors to the [unneededClasses] set. |
| 169 for (ClassElement interceptor in backend.interceptedClasses) { | 169 for (ClassElement interceptor in backend.interceptedClasses) { |
| 170 if (!needed.contains(interceptor) | 170 if (!needed.contains(interceptor) |
| 171 && interceptor != compiler.objectClass) { | 171 && interceptor != compiler.objectClass) { |
| 172 unneededClasses.add(interceptor); | 172 unneededClasses.add(interceptor); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 // These classes are just helpers for the backend's type system. | 176 // These classes are just helpers for the backend's type system. |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 jsAst.Expression typeAccess(Element e); | 461 jsAst.Expression typeAccess(Element e); |
| 462 | 462 |
| 463 /// Returns the JS constructor for the given closure class [e]. | 463 /// Returns the JS constructor for the given closure class [e]. |
| 464 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e); | 464 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e); |
| 465 | 465 |
| 466 int compareConstants(ConstantValue a, ConstantValue b); | 466 int compareConstants(ConstantValue a, ConstantValue b); |
| 467 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 467 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 468 | 468 |
| 469 void invalidateCaches(); | 469 void invalidateCaches(); |
| 470 } | 470 } |
| OLD | NEW |