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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/code_emitter_task.dart

Issue 1072043002: dart2js: retain constants that are used as annotations in constructors and setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « no previous file | tests/lib/mirrors/parameter_annotation_mirror_test.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 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 */ 189 */
190 void computeNeededConstants() { 190 void computeNeededConstants() {
191 // Make sure we retain all metadata of all elements. This could add new 191 // Make sure we retain all metadata of all elements. This could add new
192 // constants to the handler. 192 // constants to the handler.
193 if (backend.mustRetainMetadata) { 193 if (backend.mustRetainMetadata) {
194 // TODO(floitsch): verify that we don't run through the same elements 194 // TODO(floitsch): verify that we don't run through the same elements
195 // multiple times. 195 // multiple times.
196 for (Element element in backend.generatedCode.keys) { 196 for (Element element in backend.generatedCode.keys) {
197 if (backend.isAccessibleByReflection(element)) { 197 if (backend.isAccessibleByReflection(element)) {
198 bool shouldRetainMetadata = backend.retainMetadataOf(element); 198 bool shouldRetainMetadata = backend.retainMetadataOf(element);
199 if (shouldRetainMetadata && element.isFunction) { 199 if (shouldRetainMetadata &&
200 (element.isFunction || element.isConstructor ||
201 element.isSetter)) {
200 FunctionElement function = element; 202 FunctionElement function = element;
201 function.functionSignature.forEachParameter( 203 function.functionSignature.forEachParameter(
202 backend.retainMetadataOf); 204 backend.retainMetadataOf);
203 } 205 }
204 } 206 }
205 } 207 }
206 for (ClassElement cls in neededClasses) { 208 for (ClassElement cls in neededClasses) {
207 final onlyForRti = typeTestRegistry.rtiNeededClasses.contains(cls); 209 final onlyForRti = typeTestRegistry.rtiNeededClasses.contains(cls);
208 if (!onlyForRti) { 210 if (!onlyForRti) {
209 backend.retainMetadataOf(cls); 211 backend.retainMetadataOf(cls);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 jsAst.Expression generateFunctionThatReturnsNull(); 444 jsAst.Expression generateFunctionThatReturnsNull();
443 445
444 int compareConstants(ConstantValue a, ConstantValue b); 446 int compareConstants(ConstantValue a, ConstantValue b);
445 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); 447 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant);
446 448
447 /// Returns the JS code for accessing the given [constant]. 449 /// Returns the JS code for accessing the given [constant].
448 jsAst.Expression constantReference(ConstantValue constant); 450 jsAst.Expression constantReference(ConstantValue constant);
449 451
450 void invalidateCaches(); 452 void invalidateCaches();
451 } 453 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/mirrors/parameter_annotation_mirror_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698