| 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 library dart2js.enqueue; | 5 library dart2js.enqueue; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import 'cache_strategy.dart'; | 9 import 'cache_strategy.dart'; |
| 10 import 'common/backend_api.dart' show Backend; | 10 import 'common/backend_api.dart' show Backend; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void checkClass(ClassEntity cls) { | 212 void checkClass(ClassEntity cls) { |
| 213 _universe.processClassMembers(cls, | 213 _universe.processClassMembers(cls, |
| 214 (MemberEntity member, EnumSet<MemberUse> useSet) { | 214 (MemberEntity member, EnumSet<MemberUse> useSet) { |
| 215 if (useSet.isNotEmpty) { | 215 if (useSet.isNotEmpty) { |
| 216 _reporter.internalError(member, | 216 _reporter.internalError(member, |
| 217 'Unenqueued use of $member: ${useSet.iterable(MemberUse.values)}'); | 217 'Unenqueued use of $member: ${useSet.iterable(MemberUse.values)}'); |
| 218 } | 218 } |
| 219 }); | 219 }); |
| 220 } | 220 } |
| 221 | 221 |
| 222 /// Callback for applying the first seen use of a [member]. | |
| 223 void _applyFirstMemberUse(MemberElement member, EnumSet<MemberUse> useSet) { | |
| 224 ClassElement cls = member.enclosingClass; | |
| 225 if (member.isFunction) { | |
| 226 MemberElement function = member; | |
| 227 if (function.name == Identifiers.noSuchMethod_) { | |
| 228 _registerNoSuchMethod(function); | |
| 229 } | |
| 230 if (function.name == Identifiers.call && !cls.typeVariables.isEmpty) { | |
| 231 _registerCallMethodWithFreeTypeVariables(function); | |
| 232 } | |
| 233 } | |
| 234 _applyMemberUse(member, useSet); | |
| 235 } | |
| 236 | |
| 237 /// Callback for applying the use of a [member]. | 222 /// Callback for applying the use of a [member]. |
| 238 void _applyMemberUse(Entity member, EnumSet<MemberUse> useSet) { | 223 void _applyMemberUse(Entity member, EnumSet<MemberUse> useSet) { |
| 239 if (useSet.contains(MemberUse.NORMAL)) { | 224 if (useSet.contains(MemberUse.NORMAL)) { |
| 240 _addToWorkList(member); | 225 _addToWorkList(member); |
| 241 } | 226 } |
| 242 if (useSet.contains(MemberUse.CLOSURIZE)) { | 227 if (useSet.contains(MemberUse.CLOSURIZE)) { |
| 243 _registerClosurizedMember(member); | 228 _registerClosurizedMember(member); |
| 244 } | 229 } |
| 245 } | 230 } |
| 246 | 231 |
| 247 /// Callback for applying the use of a [cls]. | 232 /// Callback for applying the use of a [cls]. |
| 248 void _applyClassUse(ClassEntity cls, EnumSet<ClassUse> useSet) { | 233 void _applyClassUse(ClassEntity cls, EnumSet<ClassUse> useSet) { |
| 249 if (useSet.contains(ClassUse.INSTANTIATED)) { | 234 if (useSet.contains(ClassUse.INSTANTIATED)) { |
| 250 _recentClasses.add(cls); | 235 _recentClasses.add(cls); |
| 251 _universe.processClassMembers(cls, _applyFirstMemberUse); | 236 _universe.processClassMembers(cls, _applyMemberUse); |
| 252 // We only tell the backend once that [cls] was instantiated, so | 237 // We only tell the backend once that [cls] was instantiated, so |
| 253 // any additional dependencies must be treated as global | 238 // any additional dependencies must be treated as global |
| 254 // dependencies. | 239 // dependencies. |
| 255 applyImpact(backend.registerInstantiatedClass(cls, forResolution: true)); | 240 applyImpact(backend.registerInstantiatedClass(cls, forResolution: true)); |
| 256 } | 241 } |
| 257 if (useSet.contains(ClassUse.IMPLEMENTED)) { | 242 if (useSet.contains(ClassUse.IMPLEMENTED)) { |
| 258 applyImpact(backend.registerImplementedClass(cls, forResolution: true)); | 243 applyImpact(backend.registerImplementedClass(cls, forResolution: true)); |
| 259 } | 244 } |
| 260 } | 245 } |
| 261 | 246 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 311 } |
| 327 | 312 |
| 328 void _registerIsCheck(DartType type) { | 313 void _registerIsCheck(DartType type) { |
| 329 type = _universe.registerIsCheck(type, _resolution); | 314 type = _universe.registerIsCheck(type, _resolution); |
| 330 // Even in checked mode, type annotations for return type and argument | 315 // Even in checked mode, type annotations for return type and argument |
| 331 // types do not imply type checks, so there should never be a check | 316 // types do not imply type checks, so there should never be a check |
| 332 // against the type variable of a typedef. | 317 // against the type variable of a typedef. |
| 333 assert(!type.isTypeVariable || !type.element.enclosingElement.isTypedef); | 318 assert(!type.isTypeVariable || !type.element.enclosingElement.isTypedef); |
| 334 } | 319 } |
| 335 | 320 |
| 336 void _registerCallMethodWithFreeTypeVariables(Element element) { | |
| 337 applyImpact(backend.registerCallMethodWithFreeTypeVariables(element, | |
| 338 forResolution: true)); | |
| 339 _universe.callMethodsWithFreeTypeVariables.add(element); | |
| 340 } | |
| 341 | |
| 342 void _registerClosurizedMember(MemberElement element) { | 321 void _registerClosurizedMember(MemberElement element) { |
| 343 assert(element.isInstanceMember); | 322 assert(element.isInstanceMember); |
| 344 if (element.type.containsTypeVariables) { | 323 if (element.type.containsTypeVariables) { |
| 345 applyImpact(backend.registerClosureWithFreeTypeVariables(element, | 324 applyImpact(backend.registerClosureWithFreeTypeVariables(element, |
| 346 forResolution: true)); | 325 forResolution: true)); |
| 347 _universe.closuresWithFreeTypeVariables.add(element); | 326 _universe.closuresWithFreeTypeVariables.add(element); |
| 348 } | 327 } |
| 349 applyImpact(backend.registerBoundClosure()); | 328 applyImpact(backend.registerBoundClosure()); |
| 350 _universe.closurizedMembers.add(element); | 329 _universe.closurizedMembers.add(element); |
| 351 } | 330 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 element, "Resolution work list is closed. Trying to add $element."); | 389 element, "Resolution work list is closed. Trying to add $element."); |
| 411 } | 390 } |
| 412 | 391 |
| 413 applyImpact(backend.registerUsedElement(element, forResolution: true)); | 392 applyImpact(backend.registerUsedElement(element, forResolution: true)); |
| 414 _openWorld.registerUsedElement(element); | 393 _openWorld.registerUsedElement(element); |
| 415 | 394 |
| 416 ResolutionWorkItem workItem = _resolution.createWorkItem(element); | 395 ResolutionWorkItem workItem = _resolution.createWorkItem(element); |
| 417 _queue.add(workItem); | 396 _queue.add(workItem); |
| 418 } | 397 } |
| 419 | 398 |
| 420 void _registerNoSuchMethod(Element element) { | |
| 421 backend.registerNoSuchMethod(element); | |
| 422 } | |
| 423 | |
| 424 /// Adds an action to the deferred task queue. | 399 /// Adds an action to the deferred task queue. |
| 425 /// The action is performed the next time the resolution queue has been | 400 /// The action is performed the next time the resolution queue has been |
| 426 /// emptied. | 401 /// emptied. |
| 427 /// | 402 /// |
| 428 /// The queue is processed in FIFO order. | 403 /// The queue is processed in FIFO order. |
| 429 void addDeferredAction(Entity entity, void action()) { | 404 void addDeferredAction(Entity entity, void action()) { |
| 430 if (queueIsClosed) { | 405 if (queueIsClosed) { |
| 431 throw new SpannableAssertionFailure( | 406 throw new SpannableAssertionFailure( |
| 432 entity, | 407 entity, |
| 433 "Resolution work list is closed. " | 408 "Resolution work list is closed. " |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 528 } |
| 554 | 529 |
| 555 typedef void _DeferredActionFunction(); | 530 typedef void _DeferredActionFunction(); |
| 556 | 531 |
| 557 class _DeferredAction { | 532 class _DeferredAction { |
| 558 final Element element; | 533 final Element element; |
| 559 final _DeferredActionFunction action; | 534 final _DeferredActionFunction action; |
| 560 | 535 |
| 561 _DeferredAction(this.element, this.action); | 536 _DeferredAction(this.element, this.action); |
| 562 } | 537 } |
| OLD | NEW |