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

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

Issue 2688413003: Extract BackendUsage, MirrorsData, and CheckedModeHelpers from Backend. (Closed)
Patch Set: Cleanup Created 3 years, 10 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library dart2js.mirrors_handler; 5 library dart2js.mirrors_handler;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart'; 8 import '../common/resolution.dart';
9 import '../diagnostics/diagnostic_listener.dart'; 9 import '../diagnostics/diagnostic_listener.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 /** 72 /**
73 * Decides whether an element should be included to satisfy requirements 73 * Decides whether an element should be included to satisfy requirements
74 * of the mirror system. 74 * of the mirror system.
75 * 75 *
76 * During resolution, we have to resort to matching elements against the 76 * During resolution, we have to resort to matching elements against the
77 * [MirrorsUsed] pattern, as we do not have a complete picture of the world, 77 * [MirrorsUsed] pattern, as we do not have a complete picture of the world,
78 * yet. 78 * yet.
79 */ 79 */
80 bool _shouldIncludeElementDueToMirrors(Element element, 80 bool _shouldIncludeElementDueToMirrors(Element element,
81 {bool includedEnclosing}) { 81 {bool includedEnclosing}) {
82 return includedEnclosing || _backend.requiredByMirrorSystem(element); 82 return includedEnclosing ||
83 _backend.mirrorsData.requiredByMirrorSystem(element);
83 } 84 }
84 85
85 /// Enqueue the constructor [ctor] if it is required for reflection. 86 /// Enqueue the constructor [ctor] if it is required for reflection.
86 /// 87 ///
87 /// [enclosingWasIncluded] provides a hint whether the enclosing element was 88 /// [enclosingWasIncluded] provides a hint whether the enclosing element was
88 /// needed for reflection. 89 /// needed for reflection.
89 void _enqueueReflectiveConstructor(ConstructorElement constructor, 90 void _enqueueReflectiveConstructor(ConstructorElement constructor,
90 {bool enclosingWasIncluded}) { 91 {bool enclosingWasIncluded}) {
91 if (_shouldIncludeElementDueToMirrors(constructor, 92 if (_shouldIncludeElementDueToMirrors(constructor,
92 includedEnclosing: enclosingWasIncluded)) { 93 includedEnclosing: enclosingWasIncluded)) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 /// Enqueue special classes that might not be visible by normal means or that 167 /// Enqueue special classes that might not be visible by normal means or that
167 /// would not normally be enqueued: 168 /// would not normally be enqueued:
168 /// 169 ///
169 /// [Closure] is treated specially as it is the superclass of all closures. 170 /// [Closure] is treated specially as it is the superclass of all closures.
170 /// Although it is in an internal library, we mark it as reflectable. Note 171 /// Although it is in an internal library, we mark it as reflectable. Note
171 /// that none of its methods are reflectable, unless reflectable by 172 /// that none of its methods are reflectable, unless reflectable by
172 /// inheritance. 173 /// inheritance.
173 void _enqueueReflectiveSpecialClasses() { 174 void _enqueueReflectiveSpecialClasses() {
174 Iterable<ClassElement> classes = _backend.classesRequiredForReflection; 175 Iterable<ClassElement> classes = _backend.classesRequiredForReflection;
175 for (ClassElement cls in classes) { 176 for (ClassElement cls in classes) {
176 if (_backend.referencedFromMirrorSystem(cls)) { 177 if (_backend.mirrorsData.referencedFromMirrorSystem(cls)) {
177 _logEnqueueReflectiveAction(cls); 178 _logEnqueueReflectiveAction(cls);
178 cls.ensureResolved(_resolution); 179 cls.ensureResolved(_resolution);
179 impactBuilder 180 impactBuilder
180 .registerTypeUse(new TypeUse.mirrorInstantiation(cls.rawType)); 181 .registerTypeUse(new TypeUse.mirrorInstantiation(cls.rawType));
181 } 182 }
182 } 183 }
183 } 184 }
184 185
185 /// Enqueue all local members of the library [lib] if they are required for 186 /// Enqueue all local members of the library [lib] if they are required for
186 /// reflection. 187 /// reflection.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 /// usage through `MirrorsUsed`. 245 /// usage through `MirrorsUsed`.
245 // TODO(johnniwinther): Compute [WorldImpact] instead of enqueuing directly. 246 // TODO(johnniwinther): Compute [WorldImpact] instead of enqueuing directly.
246 void enqueueReflectiveStaticFields(Iterable<Element> elements) { 247 void enqueueReflectiveStaticFields(Iterable<Element> elements) {
247 if (hasEnqueuedReflectiveStaticFields) return; 248 if (hasEnqueuedReflectiveStaticFields) return;
248 hasEnqueuedReflectiveStaticFields = true; 249 hasEnqueuedReflectiveStaticFields = true;
249 for (Element element in elements) { 250 for (Element element in elements) {
250 _enqueueReflectiveMember(element, true); 251 _enqueueReflectiveMember(element, true);
251 } 252 }
252 } 253 }
253 } 254 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart ('k') | pkg/compiler/lib/src/js_backend/mirrors_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698