| 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.world; | 5 library dart2js.world; |
| 6 | 6 |
| 7 import 'closure.dart' show | 7 import 'closure.dart' show |
| 8 SynthesizedCallMethodElementX; | 8 SynthesizedCallMethodElementX; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'common/backend_api.dart' show | 10 import 'common/backend_api.dart' show |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 bool fieldNeverChanges(Element element) { | 668 bool fieldNeverChanges(Element element) { |
| 669 if (!element.isField) return false; | 669 if (!element.isField) return false; |
| 670 if (backend.isNative(element)) { | 670 if (backend.isNative(element)) { |
| 671 // Some native fields are views of data that may be changed by operations. | 671 // Some native fields are views of data that may be changed by operations. |
| 672 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2). | 672 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2). |
| 673 // TODO(sra): Refine the effect classification so that native effects are | 673 // TODO(sra): Refine the effect classification so that native effects are |
| 674 // distinct from ordinary Dart effects. | 674 // distinct from ordinary Dart effects. |
| 675 return false; | 675 return false; |
| 676 } | 676 } |
| 677 | 677 |
| 678 return element.isFinal | 678 if (element.isFinal || element.isConst) { |
| 679 || element.isConst | 679 return true; |
| 680 || (element.isInstanceMember | 680 } |
| 681 && !compiler.resolverWorld.hasInvokedSetter(element, this)); | 681 if (element.isInstanceMember) { |
| 682 return !compiler.resolverWorld.hasInvokedSetter(element, this) && |
| 683 !compiler.resolverWorld.fieldSetters.contains(element); |
| 684 } |
| 685 return false; |
| 682 } | 686 } |
| 683 | 687 |
| 684 SideEffects getSideEffectsOfElement(Element element) { | 688 SideEffects getSideEffectsOfElement(Element element) { |
| 685 // The type inferrer (where the side effects are being computed), | 689 // The type inferrer (where the side effects are being computed), |
| 686 // does not see generative constructor bodies because they are | 690 // does not see generative constructor bodies because they are |
| 687 // created by the backend. Also, it does not make any distinction | 691 // created by the backend. Also, it does not make any distinction |
| 688 // between a constructor and its body for side effects. This | 692 // between a constructor and its body for side effects. This |
| 689 // implies that currently, the side effects of a constructor body | 693 // implies that currently, the side effects of a constructor body |
| 690 // contain the side effects of the initializers. | 694 // contain the side effects of the initializers. |
| 691 assert(!element.isGenerativeConstructorBody); | 695 assert(!element.isGenerativeConstructorBody); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 // function expressions's element. | 753 // function expressions's element. |
| 750 // TODO(herhut): Generate classes for function expressions earlier. | 754 // TODO(herhut): Generate classes for function expressions earlier. |
| 751 if (element is SynthesizedCallMethodElementX) { | 755 if (element is SynthesizedCallMethodElementX) { |
| 752 return getMightBePassedToApply(element.expression); | 756 return getMightBePassedToApply(element.expression); |
| 753 } | 757 } |
| 754 return functionsThatMightBePassedToApply.contains(element); | 758 return functionsThatMightBePassedToApply.contains(element); |
| 755 } | 759 } |
| 756 | 760 |
| 757 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 761 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
| 758 } | 762 } |
| OLD | NEW |