| 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.resolution; | 5 library dart2js.resolution; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show | 10 import '../common/names.dart' show |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 /** | 509 /** |
| 510 * Load and resolve the supertypes of [cls]. | 510 * Load and resolve the supertypes of [cls]. |
| 511 * | 511 * |
| 512 * Warning: do not call this method directly. It should only be | 512 * Warning: do not call this method directly. It should only be |
| 513 * called by [resolveClass] and [ClassSupertypeResolver]. | 513 * called by [resolveClass] and [ClassSupertypeResolver]. |
| 514 */ | 514 */ |
| 515 void loadSupertypes(BaseClassElementX cls, Spannable from) { | 515 void loadSupertypes(BaseClassElementX cls, Spannable from) { |
| 516 reporter.withCurrentElement(cls, () => measure(() { | 516 measure(() { |
| 517 if (cls.supertypeLoadState == STATE_DONE) return; | 517 if (cls.supertypeLoadState == STATE_DONE) return; |
| 518 if (cls.supertypeLoadState == STATE_STARTED) { | 518 if (cls.supertypeLoadState == STATE_STARTED) { |
| 519 reporter.reportErrorMessage( | 519 reporter.reportErrorMessage( |
| 520 from, | 520 from, |
| 521 MessageKind.CYCLIC_CLASS_HIERARCHY, | 521 MessageKind.CYCLIC_CLASS_HIERARCHY, |
| 522 {'className': cls.name}); | 522 {'className': cls.name}); |
| 523 cls.supertypeLoadState = STATE_DONE; | 523 cls.supertypeLoadState = STATE_DONE; |
| 524 cls.hasIncompleteHierarchy = true; | 524 cls.hasIncompleteHierarchy = true; |
| 525 cls.allSupertypesAndSelf = | 525 cls.allSupertypesAndSelf = |
| 526 coreClasses.objectClass.allSupertypesAndSelf.extendClass( | 526 coreClasses.objectClass.allSupertypesAndSelf.extendClass( |
| 527 cls.computeType(resolution)); | 527 cls.computeType(resolution)); |
| 528 cls.supertype = cls.allSupertypes.head; | 528 cls.supertype = cls.allSupertypes.head; |
| 529 assert(invariant(from, cls.supertype != null, | 529 assert(invariant(from, cls.supertype != null, |
| 530 message: 'Missing supertype on cyclic class $cls.')); | 530 message: 'Missing supertype on cyclic class $cls.')); |
| 531 cls.interfaces = const Link<DartType>(); | 531 cls.interfaces = const Link<DartType>(); |
| 532 return; | 532 return; |
| 533 } | 533 } |
| 534 cls.supertypeLoadState = STATE_STARTED; | 534 cls.supertypeLoadState = STATE_STARTED; |
| 535 reporter.withCurrentElement(cls, () { | 535 reporter.withCurrentElement(cls, () { |
| 536 // TODO(ahe): Cache the node in cls. | 536 // TODO(ahe): Cache the node in cls. |
| 537 cls.parseNode(parsing).accept( | 537 cls.parseNode(parsing).accept( |
| 538 new ClassSupertypeResolver(compiler, cls)); | 538 new ClassSupertypeResolver(compiler, cls)); |
| 539 if (cls.supertypeLoadState != STATE_DONE) { | 539 if (cls.supertypeLoadState != STATE_DONE) { |
| 540 cls.supertypeLoadState = STATE_DONE; | 540 cls.supertypeLoadState = STATE_DONE; |
| 541 } | 541 } |
| 542 }); | 542 }); |
| 543 })); | 543 }); |
| 544 } | 544 } |
| 545 | 545 |
| 546 // TODO(johnniwinther): Remove this queue when resolution has been split into | 546 // TODO(johnniwinther): Remove this queue when resolution has been split into |
| 547 // syntax and semantic resolution. | 547 // syntax and semantic resolution. |
| 548 TypeDeclarationElement currentlyResolvedTypeDeclaration; | 548 TypeDeclarationElement currentlyResolvedTypeDeclaration; |
| 549 Queue<ClassElement> pendingClassesToBeResolved = new Queue<ClassElement>(); | 549 Queue<ClassElement> pendingClassesToBeResolved = new Queue<ClassElement>(); |
| 550 Queue<ClassElement> pendingClassesToBePostProcessed = | 550 Queue<ClassElement> pendingClassesToBePostProcessed = |
| 551 new Queue<ClassElement>(); | 551 new Queue<ClassElement>(); |
| 552 | 552 |
| 553 /// Resolve [element] using [resolveTypeDeclaration]. | 553 /// Resolve [element] using [resolveTypeDeclaration]. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 }); | 758 }); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void checkMixinSuperUses(TreeElements resolutionTree, | 761 void checkMixinSuperUses(TreeElements resolutionTree, |
| 762 MixinApplicationElement mixinApplication, | 762 MixinApplicationElement mixinApplication, |
| 763 ClassElement mixin) { | 763 ClassElement mixin) { |
| 764 // TODO(johnniwinther): Avoid the use of [TreeElements] here. | 764 // TODO(johnniwinther): Avoid the use of [TreeElements] here. |
| 765 if (resolutionTree == null) return; | 765 if (resolutionTree == null) return; |
| 766 Iterable<Node> superUses = resolutionTree.superUses; | 766 Iterable<SourceSpan> superUses = resolutionTree.superUses; |
| 767 if (superUses.isEmpty) return; | 767 if (superUses.isEmpty) return; |
| 768 DiagnosticMessage error = reporter.createMessage( | 768 DiagnosticMessage error = reporter.createMessage( |
| 769 mixinApplication, | 769 mixinApplication, |
| 770 MessageKind.ILLEGAL_MIXIN_WITH_SUPER, | 770 MessageKind.ILLEGAL_MIXIN_WITH_SUPER, |
| 771 {'className': mixin.name}); | 771 {'className': mixin.name}); |
| 772 // Show the user the problematic uses of 'super' in the mixin. | 772 // Show the user the problematic uses of 'super' in the mixin. |
| 773 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; | 773 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; |
| 774 for (Node use in superUses) { | 774 for (SourceSpan use in superUses) { |
| 775 infos.add(reporter.createMessage( | 775 infos.add(reporter.createMessage( |
| 776 use, | 776 use, |
| 777 MessageKind.ILLEGAL_MIXIN_SUPER_USE)); | 777 MessageKind.ILLEGAL_MIXIN_SUPER_USE)); |
| 778 } | 778 } |
| 779 reporter.reportError(error, infos); | 779 reporter.reportError(error, infos); |
| 780 } | 780 } |
| 781 | 781 |
| 782 void checkClassMembers(ClassElement cls) { | 782 void checkClassMembers(ClassElement cls) { |
| 783 assert(invariant(cls, cls.isDeclaration)); | 783 assert(invariant(cls, cls.isDeclaration)); |
| 784 if (cls.isObject) return; | 784 if (cls.isObject) return; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 TreeElements get treeElements { | 1127 TreeElements get treeElements { |
| 1128 assert(invariant(this, _treeElements !=null, | 1128 assert(invariant(this, _treeElements !=null, |
| 1129 message: "TreeElements have not been computed for $this.")); | 1129 message: "TreeElements have not been computed for $this.")); |
| 1130 return _treeElements; | 1130 return _treeElements; |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 void reuseElement() { | 1133 void reuseElement() { |
| 1134 _treeElements = null; | 1134 _treeElements = null; |
| 1135 } | 1135 } |
| 1136 } | 1136 } |
| OLD | NEW |