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

Side by Side Diff: pkg/compiler/lib/src/js_backend/mirrors_data.dart

Issue 2970953003: Use entities in ParameterTypeInformation (Closed)
Patch Set: Fix Created 3 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common_elements.dart'; 7 import '../common_elements.dart';
8 import '../compiler.dart'; 8 import '../compiler.dart';
9 import '../constants/values.dart'; 9 import '../constants/values.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 @deprecated 124 @deprecated
125 bool isAccessibleByReflection(Element element); 125 bool isAccessibleByReflection(Element element);
126 126
127 bool retainMetadataOfLibrary(covariant LibraryEntity element, 127 bool retainMetadataOfLibrary(covariant LibraryEntity element,
128 {bool addForEmission: true}); 128 {bool addForEmission: true});
129 bool retainMetadataOfTypedef(TypedefElement element); 129 bool retainMetadataOfTypedef(TypedefElement element);
130 bool retainMetadataOfClass(covariant ClassEntity element); 130 bool retainMetadataOfClass(covariant ClassEntity element);
131 bool retainMetadataOfMember(covariant MemberEntity element); 131 bool retainMetadataOfMember(covariant MemberEntity element);
132 bool retainMetadataOfParameter(ParameterElement element); 132 bool retainMetadataOfParameter(ParameterElement element);
133 133
134 bool invokedReflectively(Element element);
135
136 /// Returns true if this element has to be enqueued due to 134 /// Returns true if this element has to be enqueued due to
137 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if 135 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if
138 /// normal tree shaking is still active ([isTreeShakingDisabled] is false). 136 /// normal tree shaking is still active ([isTreeShakingDisabled] is false).
139 bool requiredByMirrorSystem(Element element); 137 bool requiredByMirrorSystem(Element element);
140 } 138 }
141 139
142 abstract class MirrorsDataBuilder { 140 abstract class MirrorsDataBuilder {
143 void registerUsedMember(MemberElement member); 141 void registerUsedMember(MemberElement member);
144 142
145 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed 143 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 for (MetadataAnnotation metadata in element.metadata) { 305 for (MetadataAnnotation metadata in element.metadata) {
308 metadata.ensureResolved(_compiler.resolution); 306 metadata.ensureResolved(_compiler.resolution);
309 ConstantValue constant = _constants.getConstantValueForMetadata(metadata); 307 ConstantValue constant = _constants.getConstantValueForMetadata(metadata);
310 if (addForEmission) { 308 if (addForEmission) {
311 CodegenWorldBuilder worldBuilder = _compiler.codegenWorldBuilder; 309 CodegenWorldBuilder worldBuilder = _compiler.codegenWorldBuilder;
312 worldBuilder.addCompileTimeConstantForEmission(constant); 310 worldBuilder.addCompileTimeConstantForEmission(constant);
313 } 311 }
314 } 312 }
315 } 313 }
316 314
317 bool invokedReflectively(Element element) {
318 if (element.isParameter) {
319 ParameterElement parameter = element;
320 if (invokedReflectively(parameter.functionDeclaration)) return true;
321 }
322
323 if (element.isField) {
324 if (Elements.isStaticOrTopLevel(element) &&
325 (element.isFinal || element.isConst)) {
326 return false;
327 }
328 }
329
330 return isAccessibleByReflection(element.declaration);
331 }
332
333 /// Sets of elements that are needed by reflection. Computed using 315 /// Sets of elements that are needed by reflection. Computed using
334 /// [computeMembersNeededForReflection] on first use. 316 /// [computeMembersNeededForReflection] on first use.
335 Set<ClassElement> _classesNeededForReflection; 317 Set<ClassElement> _classesNeededForReflection;
336 Set<TypedefElement> _typedefsNeededForReflection; 318 Set<TypedefElement> _typedefsNeededForReflection;
337 Set<MemberElement> _membersNeededForReflection; 319 Set<MemberElement> _membersNeededForReflection;
338 Set<LocalFunctionElement> _closuresNeededForReflection; 320 Set<LocalFunctionElement> _closuresNeededForReflection;
339 321
340 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed 322 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed
341 /// annotations. The arguments corresponds to the unions of the corresponding 323 /// annotations. The arguments corresponds to the unions of the corresponding
342 /// fields of the annotations. 324 /// fields of the annotations.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 686 }
705 687
706 /// Called when `const Symbol(name)` is seen. 688 /// Called when `const Symbol(name)` is seen.
707 void registerConstSymbol(String name) { 689 void registerConstSymbol(String name) {
708 symbolsUsed.add(name); 690 symbolsUsed.add(name);
709 if (name.endsWith('=')) { 691 if (name.endsWith('=')) {
710 symbolsUsed.add(name.substring(0, name.length - 1)); 692 symbolsUsed.add(name.substring(0, name.length - 1));
711 } 693 }
712 } 694 }
713 } 695 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698