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

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

Issue 2625713002: Rename Enqueuer.universe to worldBuilder. (Closed)
Patch Set: Updated cf. comments Created 3 years, 11 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.program_builder; 5 part of dart2js.js_emitter.program_builder;
6 6
7 /** 7 /**
8 * [member] is a field (instance, static, or top level). 8 * [member] is a field (instance, static, or top level).
9 * 9 *
10 * [name] is the field name that the [Namer] has picked for this field's 10 * [name] is the field name that the [Namer] has picked for this field's
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } else if (element.isLibrary) { 65 } else if (element.isLibrary) {
66 isLibrary = true; 66 isLibrary = true;
67 assert(invariant(element, visitStatics)); 67 assert(invariant(element, visitStatics));
68 } else { 68 } else {
69 throw new SpannableAssertionFailure( 69 throw new SpannableAssertionFailure(
70 element, 'Expected a ClassElement or a LibraryElement.'); 70 element, 'Expected a ClassElement or a LibraryElement.');
71 } 71 }
72 72
73 // If the class is never instantiated we still need to set it up for 73 // If the class is never instantiated we still need to set it up for
74 // inheritance purposes, but we can simplify its JavaScript constructor. 74 // inheritance purposes, but we can simplify its JavaScript constructor.
75 bool isInstantiated = 75 bool isInstantiated = compiler
76 compiler.codegenWorld.directlyInstantiatedClasses.contains(element); 76 .codegenWorldBuilder.directlyInstantiatedClasses
77 .contains(element);
77 78
78 void visitField(Element holder, FieldElement field) { 79 void visitField(Element holder, FieldElement field) {
79 assert(invariant(element, field.isDeclaration)); 80 assert(invariant(element, field.isDeclaration));
80 81
81 // Keep track of whether or not we're dealing with a field mixin 82 // Keep track of whether or not we're dealing with a field mixin
82 // into a native class. 83 // into a native class.
83 bool isMixinNativeField = 84 bool isMixinNativeField =
84 isClass && backend.isNative(element) && holder.isMixinApplication; 85 isClass && backend.isNative(element) && holder.isMixinApplication;
85 86
86 // See if we can dynamically create getters and setters. 87 // See if we can dynamically create getters and setters.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 cls.implementation.forEachInstanceField(visitField, 135 cls.implementation.forEachInstanceField(visitField,
135 includeSuperAndInjectedMembers: isInstantiated); 136 includeSuperAndInjectedMembers: isInstantiated);
136 } 137 }
137 } 138 }
138 139
139 bool fieldNeedsGetter(VariableElement field) { 140 bool fieldNeedsGetter(VariableElement field) {
140 assert(field.isField); 141 assert(field.isField);
141 if (fieldAccessNeverThrows(field)) return false; 142 if (fieldAccessNeverThrows(field)) return false;
142 if (backend.shouldRetainGetter(field)) return true; 143 if (backend.shouldRetainGetter(field)) return true;
143 return field.isClassMember && 144 return field.isClassMember &&
144 compiler.codegenWorld.hasInvokedGetter(field, closedWorld); 145 compiler.codegenWorldBuilder.hasInvokedGetter(field, closedWorld);
145 } 146 }
146 147
147 bool fieldNeedsSetter(VariableElement field) { 148 bool fieldNeedsSetter(VariableElement field) {
148 assert(field.isField); 149 assert(field.isField);
149 if (fieldAccessNeverThrows(field)) return false; 150 if (fieldAccessNeverThrows(field)) return false;
150 if (field.isFinal || field.isConst) return false; 151 if (field.isFinal || field.isConst) return false;
151 if (backend.shouldRetainSetter(field)) return true; 152 if (backend.shouldRetainSetter(field)) return true;
152 return field.isClassMember && 153 return field.isClassMember &&
153 compiler.codegenWorld.hasInvokedSetter(field, closedWorld); 154 compiler.codegenWorldBuilder.hasInvokedSetter(field, closedWorld);
154 } 155 }
155 156
156 static bool fieldAccessNeverThrows(VariableElement field) { 157 static bool fieldAccessNeverThrows(VariableElement field) {
157 return 158 return
158 // We never access a field in a closure (a captured variable) without 159 // We never access a field in a closure (a captured variable) without
159 // knowing that it is there. Therefore we don't need to use a getter 160 // knowing that it is there. Therefore we don't need to use a getter
160 // (that will throw if the getter method is missing), but can always 161 // (that will throw if the getter method is missing), but can always
161 // access the field directly. 162 // access the field directly.
162 field is ClosureFieldElement; 163 field is ClosureFieldElement;
163 } 164 }
164 165
165 bool canAvoidGeneratedCheckedSetter(VariableElement member) { 166 bool canAvoidGeneratedCheckedSetter(VariableElement member) {
166 // We never generate accessors for top-level/static fields. 167 // We never generate accessors for top-level/static fields.
167 if (!member.isInstanceMember) return true; 168 if (!member.isInstanceMember) return true;
168 ResolutionDartType type = member.type; 169 ResolutionDartType type = member.type;
169 return type.treatAsDynamic || type.isObject; 170 return type.treatAsDynamic || type.isObject;
170 } 171 }
171 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698