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

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

Issue 2944843002: All strong mode cleaning of dart2js. (Closed)
Patch Set: More issues discovered during testing. Created 3 years, 6 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
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 /// Should [name] be retained for reflection? 71 /// Should [name] be retained for reflection?
72 bool shouldRetainName(String name); 72 bool shouldRetainName(String name);
73 73
74 /// Returns `true` if the class [element] is covered by a `MirrorsUsed` 74 /// Returns `true` if the class [element] is covered by a `MirrorsUsed`
75 /// annotation. 75 /// annotation.
76 /// 76 ///
77 /// Note that it might still be ok to tree shake the element away if no 77 /// Note that it might still be ok to tree shake the element away if no
78 /// reflection is used in the program (and thus [isTreeShakingDisabled] is 78 /// reflection is used in the program (and thus [isTreeShakingDisabled] is
79 /// still false). Therefore _do not_ use this predicate to decide inclusion 79 /// still false). Therefore _do not_ use this predicate to decide inclusion
80 /// in the tree, use [requiredByMirrorSystem] instead. 80 /// in the tree, use [requiredByMirrorSystem] instead.
81 bool isClassReferencedFromMirrorSystem(ClassEntity element); 81 bool isClassReferencedFromMirrorSystem(covariant ClassEntity element);
82 82
83 /// Returns `true` if the member [element] is covered by a `MirrorsUsed` 83 /// Returns `true` if the member [element] is covered by a `MirrorsUsed`
84 /// annotation. 84 /// annotation.
85 /// 85 ///
86 /// Note that it might still be ok to tree shake the element away if no 86 /// Note that it might still be ok to tree shake the element away if no
87 /// reflection is used in the program (and thus [isTreeShakingDisabled] is 87 /// reflection is used in the program (and thus [isTreeShakingDisabled] is
88 /// still false). Therefore _do not_ use this predicate to decide inclusion 88 /// still false). Therefore _do not_ use this predicate to decide inclusion
89 /// in the tree, use [requiredByMirrorSystem] instead. 89 /// in the tree, use [requiredByMirrorSystem] instead.
90 bool isMemberReferencedFromMirrorSystem(MemberEntity element); 90 bool isMemberReferencedFromMirrorSystem(covariant MemberEntity element);
91 91
92 /// Returns `true` if the library [element] is covered by a `MirrorsUsed` 92 /// Returns `true` if the library [element] is covered by a `MirrorsUsed`
93 /// annotation. 93 /// annotation.
94 bool isLibraryReferencedFromMirrorSystem(LibraryEntity element); 94 bool isLibraryReferencedFromMirrorSystem(covariant LibraryEntity element);
95 95
96 /// Returns `true` if the typedef [element] needs reflection information at 96 /// Returns `true` if the typedef [element] needs reflection information at
97 /// runtime. 97 /// runtime.
98 /// 98 ///
99 /// This property is used to tag emitted elements with a marker which is 99 /// This property is used to tag emitted elements with a marker which is
100 /// checked by the runtime system to throw an exception if an element is 100 /// checked by the runtime system to throw an exception if an element is
101 /// accessed (invoked, get, set) that is not accessible for the reflective 101 /// accessed (invoked, get, set) that is not accessible for the reflective
102 /// system. 102 /// system.
103 bool isTypedefAccessibleByReflection(TypedefElement element); 103 bool isTypedefAccessibleByReflection(TypedefElement element);
104 104
(...skipping 12 matching lines...) Expand all
117 /// This property is used to tag emitted elements with a marker which is 117 /// This property is used to tag emitted elements with a marker which is
118 /// checked by the runtime system to throw an exception if an element is 118 /// checked by the runtime system to throw an exception if an element is
119 /// accessed (invoked, get, set) that is not accessible for the reflective 119 /// accessed (invoked, get, set) that is not accessible for the reflective
120 /// system. 120 /// system.
121 bool isMemberAccessibleByReflection(MemberEntity element); 121 bool isMemberAccessibleByReflection(MemberEntity element);
122 122
123 // TODO(johnniwinther): Remove this. 123 // TODO(johnniwinther): Remove this.
124 @deprecated 124 @deprecated
125 bool isAccessibleByReflection(Element element); 125 bool isAccessibleByReflection(Element element);
126 126
127 bool retainMetadataOfLibrary(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(ClassEntity element); 130 bool retainMetadataOfClass(covariant ClassEntity element);
131 bool retainMetadataOfMember(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); 134 bool invokedReflectively(Element element);
135 135
136 /// Returns true if this element has to be enqueued due to 136 /// Returns true if this element has to be enqueued due to
137 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if 137 /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if
138 /// normal tree shaking is still active ([isTreeShakingDisabled] is false). 138 /// normal tree shaking is still active ([isTreeShakingDisabled] is false).
139 bool requiredByMirrorSystem(Element element); 139 bool requiredByMirrorSystem(Element element);
140 } 140 }
141 141
142 abstract class MirrorsDataBuilder { 142 abstract class MirrorsDataBuilder {
143 void registerUsedMember(MemberElement member); 143 void registerUsedMember(MemberElement member);
144 144
145 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed 145 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed
146 /// annotations. The arguments corresponds to the unions of the corresponding 146 /// annotations. The arguments corresponds to the unions of the corresponding
147 /// fields of the annotations. 147 /// fields of the annotations.
148 void registerMirrorUsage( 148 void registerMirrorUsage(
149 Set<String> symbols, Set<Element> targets, Set<Element> metaTargets); 149 Set<String> symbols, Set<Element> targets, Set<Element> metaTargets);
150 150
151 /// Called when `const Symbol(name)` is seen. 151 /// Called when `const Symbol(name)` is seen.
152 void registerConstSymbol(String name); 152 void registerConstSymbol(String name);
153 153
154 void maybeMarkClosureAsNeededForReflection( 154 void maybeMarkClosureAsNeededForReflection(
155 ClosureClassElement globalizedElement, 155 ClosureClassElement globalizedElement,
156 FunctionElement callFunction, 156 MethodElement callFunction,
157 FunctionElement function); 157 LocalFunctionElement function);
158 158
159 void computeMembersNeededForReflection( 159 void computeMembersNeededForReflection(
160 ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld); 160 ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld);
161 } 161 }
162 162
163 class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder { 163 class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder {
164 /// True if a call to preserveMetadataMarker has been seen. This means that 164 /// True if a call to preserveMetadataMarker has been seen. This means that
165 /// metadata must be retained for dart:mirrors to work correctly. 165 /// metadata must be retained for dart:mirrors to work correctly.
166 bool mustRetainMetadata = false; 166 bool mustRetainMetadata = false;
167 167
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 704 }
705 705
706 /// Called when `const Symbol(name)` is seen. 706 /// Called when `const Symbol(name)` is seen.
707 void registerConstSymbol(String name) { 707 void registerConstSymbol(String name) {
708 symbolsUsed.add(name); 708 symbolsUsed.add(name);
709 if (name.endsWith('=')) { 709 if (name.endsWith('=')) {
710 symbolsUsed.add(name.substring(0, name.length - 1)); 710 symbolsUsed.add(name.substring(0, name.length - 1));
711 } 711 }
712 } 712 }
713 } 713 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/mirrors_analysis.dart ('k') | pkg/compiler/lib/src/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698