| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_incremental.library_updater; | 5 library dart2js_incremental.library_updater; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:convert' show | 10 import 'dart:convert' show |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 List<Update> removals = <Update>[]; | 539 List<Update> removals = <Update>[]; |
| 540 List<Element> updatedElements = applyUpdates(removals); | 540 List<Element> updatedElements = applyUpdates(removals); |
| 541 if (compiler.progress != null) { | 541 if (compiler.progress != null) { |
| 542 compiler.progress.reset(); | 542 compiler.progress.reset(); |
| 543 } | 543 } |
| 544 for (Element element in updatedElements) { | 544 for (Element element in updatedElements) { |
| 545 if (!element.isClass) { | 545 if (!element.isClass) { |
| 546 compiler.enqueuer.resolution.addToWorkList(element); | 546 compiler.enqueuer.resolution.addToWorkList(element); |
| 547 } else { | 547 } else { |
| 548 element.ensureResolved(compiler); | 548 NO_WARN(element).ensureResolved(compiler); |
| 549 } | 549 } |
| 550 } | 550 } |
| 551 compiler.processQueue(compiler.enqueuer.resolution, null); | 551 compiler.processQueue(compiler.enqueuer.resolution, null); |
| 552 | 552 |
| 553 compiler.phase = Compiler.PHASE_DONE_RESOLVING; | 553 compiler.phase = Compiler.PHASE_DONE_RESOLVING; |
| 554 | 554 |
| 555 // TODO(ahe): Clean this up. Don't call this method in analyze-only mode. | 555 // TODO(ahe): Clean this up. Don't call this method in analyze-only mode. |
| 556 if (compiler.analyzeOnly) return "/* analyze only */"; | 556 if (compiler.analyzeOnly) return "/* analyze only */"; |
| 557 | 557 |
| 558 Set<ClassElementX> changedClasses = | 558 Set<ClassElementX> changedClasses = |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 PartialFunctionElement get before; | 749 PartialFunctionElement get before; |
| 750 | 750 |
| 751 /// Reset various caches and remove this element from the compiler's internal | 751 /// Reset various caches and remove this element from the compiler's internal |
| 752 /// state. | 752 /// state. |
| 753 void reuseElement() { | 753 void reuseElement() { |
| 754 compiler.forgetElement(before); | 754 compiler.forgetElement(before); |
| 755 before.reuseElement(); | 755 before.reuseElement(); |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 | 758 |
| 759 class RemovalUpdate extends Update { | 759 abstract class RemovalUpdate extends Update { |
| 760 ElementX get element; | 760 ElementX get element; |
| 761 | 761 |
| 762 RemovalUpdate(Compiler compiler) | 762 RemovalUpdate(Compiler compiler) |
| 763 : super(compiler); | 763 : super(compiler); |
| 764 | 764 |
| 765 bool get isRemoval => true; | 765 bool get isRemoval => true; |
| 766 | 766 |
| 767 void writeUpdateJsOn(List<jsAst.Statement> updates); | 767 void writeUpdateJsOn(List<jsAst.Statement> updates); |
| 768 | 768 |
| 769 void removeFromEnclosing() { | 769 void removeFromEnclosing() { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 912 |
| 913 for (jsAst.Node access in accessToStatics) { | 913 for (jsAst.Node access in accessToStatics) { |
| 914 updates.add(js.statement('delete #', [access])); | 914 updates.add(js.statement('delete #', [access])); |
| 915 } | 915 } |
| 916 } | 916 } |
| 917 } | 917 } |
| 918 | 918 |
| 919 class RemovedFieldUpdate extends RemovalUpdate with JsFeatures { | 919 class RemovedFieldUpdate extends RemovalUpdate with JsFeatures { |
| 920 final FieldElementX element; | 920 final FieldElementX element; |
| 921 | 921 |
| 922 bool wasStateCaptured; | 922 bool wasStateCaptured = false; |
| 923 | 923 |
| 924 jsAst.Node elementAccess; | 924 jsAst.Node elementAccess; |
| 925 | 925 |
| 926 String getterName; | 926 String getterName; |
| 927 | 927 |
| 928 String setterName; | 928 String setterName; |
| 929 | 929 |
| 930 RemovedFieldUpdate(Compiler compiler, this.element) | 930 RemovedFieldUpdate(Compiler compiler, this.element) |
| 931 : super(compiler); | 931 : super(compiler); |
| 932 | 932 |
| 933 PartialFieldList get before => element.declarationSite; |
| 934 |
| 935 PartialFieldList get after => null; |
| 936 |
| 933 void captureState() { | 937 void captureState() { |
| 934 if (wasStateCaptured) throw "captureState was called twice."; | 938 if (wasStateCaptured) throw "captureState was called twice."; |
| 935 wasStateCaptured = true; | 939 wasStateCaptured = true; |
| 936 | 940 |
| 937 elementAccess = namer.elementAccess(element.enclosingClass); | 941 elementAccess = namer.elementAccess(element.enclosingClass); |
| 938 getterName = namer.getterName(element); | 942 getterName = namer.getterName(element); |
| 939 setterName = namer.setterName(element); | 943 setterName = namer.setterName(element); |
| 940 } | 944 } |
| 941 | 945 |
| 942 FieldElementX apply() { | 946 FieldElementX apply() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 | 982 |
| 979 PartialFunctionElement get after => element; | 983 PartialFunctionElement get after => element; |
| 980 | 984 |
| 981 PartialFunctionElement apply() { | 985 PartialFunctionElement apply() { |
| 982 Element enclosing = container; | 986 Element enclosing = container; |
| 983 if (enclosing.isLibrary) { | 987 if (enclosing.isLibrary) { |
| 984 // TODO(ahe): Reuse compilation unit of element instead? | 988 // TODO(ahe): Reuse compilation unit of element instead? |
| 985 enclosing = enclosing.compilationUnit; | 989 enclosing = enclosing.compilationUnit; |
| 986 } | 990 } |
| 987 PartialFunctionElement copy = element.copyWithEnclosing(enclosing); | 991 PartialFunctionElement copy = element.copyWithEnclosing(enclosing); |
| 988 container.addMember(copy, compiler); | 992 NO_WARN(container).addMember(copy, compiler); |
| 989 return copy; | 993 return copy; |
| 990 } | 994 } |
| 991 } | 995 } |
| 992 | 996 |
| 993 class AddedClassUpdate extends Update with JsFeatures { | 997 class AddedClassUpdate extends Update with JsFeatures { |
| 994 final PartialClassElement element; | 998 final PartialClassElement element; |
| 995 | 999 |
| 996 final LibraryElementX library; | 1000 final LibraryElementX library; |
| 997 | 1001 |
| 998 AddedClassUpdate(Compiler compiler, this.element, this.library) | 1002 AddedClassUpdate(Compiler compiler, this.element, this.library) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1018 | 1022 |
| 1019 AddedFieldUpdate(Compiler compiler, this.element, this.container) | 1023 AddedFieldUpdate(Compiler compiler, this.element, this.container) |
| 1020 : super(compiler); | 1024 : super(compiler); |
| 1021 | 1025 |
| 1022 PartialFieldList get before => null; | 1026 PartialFieldList get before => null; |
| 1023 | 1027 |
| 1024 PartialFieldList get after => element.declarationSite; | 1028 PartialFieldList get after => element.declarationSite; |
| 1025 | 1029 |
| 1026 FieldElementX apply() { | 1030 FieldElementX apply() { |
| 1027 FieldElementX copy = element.copyWithEnclosing(container); | 1031 FieldElementX copy = element.copyWithEnclosing(container); |
| 1028 container.addMember(copy, compiler); | 1032 NO_WARN(container).addMember(copy, compiler); |
| 1029 return copy; | 1033 return copy; |
| 1030 } | 1034 } |
| 1031 } | 1035 } |
| 1032 | 1036 |
| 1033 | 1037 |
| 1034 class ClassUpdate extends Update with JsFeatures { | 1038 class ClassUpdate extends Update with JsFeatures { |
| 1035 final PartialClassElement before; | 1039 final PartialClassElement before; |
| 1036 | 1040 |
| 1037 final PartialClassElement after; | 1041 final PartialClassElement after; |
| 1038 | 1042 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 | 1162 |
| 1159 ClassEmitter get classEmitter => backend.emitter.oldEmitter.classEmitter; | 1163 ClassEmitter get classEmitter => backend.emitter.oldEmitter.classEmitter; |
| 1160 | 1164 |
| 1161 List<String> computeFields(ClassElement cls) { | 1165 List<String> computeFields(ClassElement cls) { |
| 1162 // TODO(ahe): Rewrite for new emitter. | 1166 // TODO(ahe): Rewrite for new emitter. |
| 1163 ClassBuilder builder = new ClassBuilder(cls, namer); | 1167 ClassBuilder builder = new ClassBuilder(cls, namer); |
| 1164 classEmitter.emitFields(cls, builder, ""); | 1168 classEmitter.emitFields(cls, builder, ""); |
| 1165 return builder.fields; | 1169 return builder.fields; |
| 1166 } | 1170 } |
| 1167 } | 1171 } |
| 1172 |
| 1173 // TODO(ahe): Remove this method. |
| 1174 NO_WARN(x) => x; |
| OLD | NEW |