OLD | NEW |
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; | 5 part of dart2js; |
6 | 6 |
7 typedef ItemCompilationContext ItemCompilationContextCreator(); | 7 typedef ItemCompilationContext ItemCompilationContextCreator(); |
8 | 8 |
9 class EnqueueTask extends CompilerTask { | 9 class EnqueueTask extends CompilerTask { |
10 final ResolutionEnqueuer resolution; | 10 final ResolutionEnqueuer resolution; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // are virtual instantiation points and escape points. | 182 // are virtual instantiation points and escape points. |
183 } else { | 183 } else { |
184 // All field initializers must be resolved as they could | 184 // All field initializers must be resolved as they could |
185 // have an observable side-effect (and cannot be tree-shaken | 185 // have an observable side-effect (and cannot be tree-shaken |
186 // away). | 186 // away). |
187 addToWorkList(member); | 187 addToWorkList(member); |
188 return; | 188 return; |
189 } | 189 } |
190 } else if (member.kind == ElementKind.FUNCTION) { | 190 } else if (member.kind == ElementKind.FUNCTION) { |
191 FunctionElement function = member; | 191 FunctionElement function = member; |
192 function.computeSignature(compiler); | 192 function.computeType(compiler); |
193 if (function.name == Compiler.NO_SUCH_METHOD) { | 193 if (function.name == Compiler.NO_SUCH_METHOD) { |
194 registerNoSuchMethod(function); | 194 registerNoSuchMethod(function); |
195 } | 195 } |
196 if (function.name == Compiler.CALL_OPERATOR_NAME && | 196 if (function.name == Compiler.CALL_OPERATOR_NAME && |
197 !cls.typeVariables.isEmpty) { | 197 !cls.typeVariables.isEmpty) { |
198 registerCallMethodWithFreeTypeVariables( | 198 registerCallMethodWithFreeTypeVariables( |
199 function, compiler.globalDependencies); | 199 function, compiler.globalDependencies); |
200 } | 200 } |
201 // If there is a property access with the same name as a method we | 201 // If there is a property access with the same name as a method we |
202 // need to emit the method. | 202 // need to emit the method. |
203 if (universe.hasInvokedGetter(function, compiler.world)) { | 203 if (universe.hasInvokedGetter(function, compiler.world)) { |
204 registerClosurizedMember(function, compiler.globalDependencies); | 204 registerClosurizedMember(function, compiler.globalDependencies); |
205 addToWorkList(function); | 205 addToWorkList(function); |
206 return; | 206 return; |
207 } | 207 } |
208 // Store the member in [instanceFunctionsByName] to catch | 208 // Store the member in [instanceFunctionsByName] to catch |
209 // getters on the function. | 209 // getters on the function. |
210 instanceFunctionsByName.putIfAbsent(memberName, () => new Set<Element>()) | 210 instanceFunctionsByName.putIfAbsent(memberName, () => new Set<Element>()) |
211 .add(member); | 211 .add(member); |
212 if (universe.hasInvocation(function, compiler.world)) { | 212 if (universe.hasInvocation(function, compiler.world)) { |
213 addToWorkList(function); | 213 addToWorkList(function); |
214 return; | 214 return; |
215 } | 215 } |
216 } else if (member.kind == ElementKind.GETTER) { | 216 } else if (member.kind == ElementKind.GETTER) { |
217 FunctionElement getter = member; | 217 FunctionElement getter = member; |
218 getter.computeSignature(compiler); | 218 getter.computeType(compiler); |
219 if (universe.hasInvokedGetter(getter, compiler.world)) { | 219 if (universe.hasInvokedGetter(getter, compiler.world)) { |
220 addToWorkList(getter); | 220 addToWorkList(getter); |
221 return; | 221 return; |
222 } | 222 } |
223 // We don't know what selectors the returned closure accepts. If | 223 // We don't know what selectors the returned closure accepts. If |
224 // the set contains any selector we have to assume that it matches. | 224 // the set contains any selector we have to assume that it matches. |
225 if (universe.hasInvocation(getter, compiler.world)) { | 225 if (universe.hasInvocation(getter, compiler.world)) { |
226 addToWorkList(getter); | 226 addToWorkList(getter); |
227 return; | 227 return; |
228 } | 228 } |
229 } else if (member.kind == ElementKind.SETTER) { | 229 } else if (member.kind == ElementKind.SETTER) { |
230 FunctionElement setter = member; | 230 FunctionElement setter = member; |
231 setter.computeSignature(compiler); | 231 setter.computeType(compiler); |
232 if (universe.hasInvokedSetter(setter, compiler.world)) { | 232 if (universe.hasInvokedSetter(setter, compiler.world)) { |
233 addToWorkList(setter); | 233 addToWorkList(setter); |
234 return; | 234 return; |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 // The element is not yet used. Add it to the list of instance | 238 // The element is not yet used. Add it to the list of instance |
239 // members to still be processed. | 239 // members to still be processed. |
240 instanceMembersByName.putIfAbsent(memberName, () => new Set<Element>()) | 240 instanceMembersByName.putIfAbsent(memberName, () => new Set<Element>()) |
241 .add(member); | 241 .add(member); |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 void processWorkItem(void f(WorkItem work), WorkItem work) { | 944 void processWorkItem(void f(WorkItem work), WorkItem work) { |
945 f(work); | 945 f(work); |
946 } | 946 } |
947 } | 947 } |
948 | 948 |
949 void removeFromSet(Map<String, Set<Element>> map, Element element) { | 949 void removeFromSet(Map<String, Set<Element>> map, Element element) { |
950 Set<Element> set = map[element.name]; | 950 Set<Element> set = map[element.name]; |
951 if (set == null) return; | 951 if (set == null) return; |
952 set.remove(element); | 952 set.remove(element); |
953 } | 953 } |
OLD | NEW |