Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: pkg/dart2js_incremental/lib/library_updater.dart

Issue 835123002: dart2js: Fix incremental compilation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 // updates. 825 // updates.
826 // TODO(ahe): This is a bit convoluted, find a better approach. 826 // TODO(ahe): This is a bit convoluted, find a better approach.
827 emitter.neededClasses 827 emitter.neededClasses
828 ..clear() 828 ..clear()
829 ..addAll(_emittedClasses); 829 ..addAll(_emittedClasses);
830 } 830 }
831 831
832 List<jsAst.Statement> inherits = <jsAst.Statement>[]; 832 List<jsAst.Statement> inherits = <jsAst.Statement>[];
833 833
834 for (ClassElementX cls in newClasses) { 834 for (ClassElementX cls in newClasses) {
835 jsAst.Node classAccess = emitter.classAccess(cls); 835 jsAst.Node classAccess = emitter.constructorAccess(cls);
836 String name = namer.getNameOfClass(cls); 836 String name = namer.getNameOfClass(cls);
837 837
838 updates.add( 838 updates.add(
839 js.statement( 839 js.statement(
840 r'# = #', [classAccess, invokeDefineClass(cls)])); 840 r'# = #', [classAccess, invokeDefineClass(cls)]));
841 841
842 ClassElement superclass = cls.superclass; 842 ClassElement superclass = cls.superclass;
843 if (superclass != null) { 843 if (superclass != null) {
844 jsAst.Node superAccess = emitter.classAccess(superclass); 844 jsAst.Node superAccess = emitter.constructorAccess(superclass);
845 inherits.add( 845 inherits.add(
846 js.statement( 846 js.statement(
847 r'#.inheritFrom(#, #)', [helper, classAccess, superAccess])); 847 r'#.inheritFrom(#, #)', [helper, classAccess, superAccess]));
848 } 848 }
849 } 849 }
850 850
851 // Call inheritFrom after all classes have been created. This way we don't 851 // Call inheritFrom after all classes have been created. This way we don't
852 // need to sort the classes by having superclasses defined before their 852 // need to sort the classes by having superclasses defined before their
853 // subclasses. 853 // subclasses.
854 updates.addAll(inherits); 854 updates.addAll(inherits);
855 855
856 for (ClassElementX cls in changedClasses) { 856 for (ClassElementX cls in changedClasses) {
857 ClassElement superclass = cls.superclass; 857 ClassElement superclass = cls.superclass;
858 jsAst.Node superAccess = 858 jsAst.Node superAccess =
859 superclass == null ? js('null') 859 superclass == null ? js('null')
860 : emitter.classAccess(superclass); 860 : emitter.constructorAccess(superclass);
861 jsAst.Node classAccess = emitter.classAccess(cls); 861 jsAst.Node classAccess = emitter.constructorAccess(cls);
862 updates.add( 862 updates.add(
863 js.statement( 863 js.statement(
864 r'# = #.schemaChange(#, #, #)', 864 r'# = #.schemaChange(#, #, #)',
865 [classAccess, helper, 865 [classAccess, helper,
866 invokeDefineClass(cls), classAccess, superAccess])); 866 invokeDefineClass(cls), classAccess, superAccess]));
867 } 867 }
868 868
869 for (RemovalUpdate update in removals) { 869 for (RemovalUpdate update in removals) {
870 update.writeUpdateJsOn(updates); 870 update.writeUpdateJsOn(updates);
871 } 871 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 938
939 String name = info.name; 939 String name = info.name;
940 jsAst.Node function = info.code; 940 jsAst.Node function = info.code;
941 bool isStatic = !element.isInstanceMember; 941 bool isStatic = !element.isInstanceMember;
942 942
943 /// Either a global object (non-instance members) or a prototype (instance 943 /// Either a global object (non-instance members) or a prototype (instance
944 /// members). 944 /// members).
945 jsAst.Node holder; 945 jsAst.Node holder;
946 946
947 if (element.isInstanceMember) { 947 if (element.isInstanceMember) {
948 holder = js('#.prototype', emitter.classAccess(element.enclosingClass)); 948 holder = emitter.prototypeAccess(element.enclosingClass);
949 } else { 949 } else {
950 holder = js('#', namer.globalObjectFor(element)); 950 holder = js('#', namer.globalObjectFor(element));
951 } 951 }
952 952
953 jsAst.Expression globalFunctionsAccess = 953 jsAst.Expression globalFunctionsAccess =
954 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); 954 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
955 955
956 return js.statement( 956 return js.statement(
957 r'#.addMethod(#, #, #, #, #)', 957 r'#.addMethod(#, #, #, #, #)',
958 [helper, partialDescriptor, js.string(name), holder, 958 [helper, partialDescriptor, js.string(name), holder,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1120
1121 PartialFunctionElement get before => element; 1121 PartialFunctionElement get before => element;
1122 1122
1123 PartialFunctionElement get after => null; 1123 PartialFunctionElement get after => null;
1124 1124
1125 void captureState() { 1125 void captureState() {
1126 if (wasStateCaptured) throw "captureState was called twice."; 1126 if (wasStateCaptured) throw "captureState was called twice.";
1127 wasStateCaptured = true; 1127 wasStateCaptured = true;
1128 1128
1129 if (element.isInstanceMember) { 1129 if (element.isInstanceMember) {
1130 elementAccess = emitter.classAccess(element.enclosingClass); 1130 elementAccess = emitter.constructorAccess(element.enclosingClass);
1131 name = namer.getNameOfMember(element); 1131 name = namer.getNameOfMember(element);
1132 } else { 1132 } else {
1133 elementAccess = emitter.staticFunctionAccess(element); 1133 elementAccess = emitter.staticFunctionAccess(element);
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 PartialFunctionElement apply() { 1137 PartialFunctionElement apply() {
1138 if (!wasStateCaptured) throw "captureState must be called before apply."; 1138 if (!wasStateCaptured) throw "captureState must be called before apply.";
1139 removeFromEnclosing(); 1139 removeFromEnclosing();
1140 reuseElement(); 1140 reuseElement();
(...skipping 27 matching lines...) Expand all
1168 RemovedClassUpdate(Compiler compiler, this.element) 1168 RemovedClassUpdate(Compiler compiler, this.element)
1169 : super(compiler); 1169 : super(compiler);
1170 1170
1171 PartialClassElement get before => element; 1171 PartialClassElement get before => element;
1172 1172
1173 PartialClassElement get after => null; 1173 PartialClassElement get after => null;
1174 1174
1175 void captureState() { 1175 void captureState() {
1176 if (wasStateCaptured) throw "captureState was called twice."; 1176 if (wasStateCaptured) throw "captureState was called twice.";
1177 wasStateCaptured = true; 1177 wasStateCaptured = true;
1178 accessToStatics.add(emitter.classAccess(element)); 1178 accessToStatics.add(emitter.constructorAccess(element));
1179 1179
1180 element.forEachLocalMember((ElementX member) { 1180 element.forEachLocalMember((ElementX member) {
1181 if (!member.isInstanceMember) { 1181 if (!member.isInstanceMember) {
1182 accessToStatics.add(emitter.staticFunctionAccess(member)); 1182 accessToStatics.add(emitter.staticFunctionAccess(member));
1183 } 1183 }
1184 }); 1184 });
1185 } 1185 }
1186 1186
1187 PartialClassElement apply() { 1187 PartialClassElement apply() {
1188 if (!wasStateCaptured) { 1188 if (!wasStateCaptured) {
(...skipping 23 matching lines...) Expand all
1212 updates.add(js.statement('delete #', [access])); 1212 updates.add(js.statement('delete #', [access]));
1213 } 1213 }
1214 } 1214 }
1215 } 1215 }
1216 1216
1217 class RemovedFieldUpdate extends RemovalUpdate with JsFeatures { 1217 class RemovedFieldUpdate extends RemovalUpdate with JsFeatures {
1218 final FieldElementX element; 1218 final FieldElementX element;
1219 1219
1220 bool wasStateCaptured = false; 1220 bool wasStateCaptured = false;
1221 1221
1222 jsAst.Node elementAccess; 1222 jsAst.Node prototypeAccess;
1223 1223
1224 String getterName; 1224 String getterName;
1225 1225
1226 String setterName; 1226 String setterName;
1227 1227
1228 RemovedFieldUpdate(Compiler compiler, this.element) 1228 RemovedFieldUpdate(Compiler compiler, this.element)
1229 : super(compiler); 1229 : super(compiler);
1230 1230
1231 PartialFieldList get before => element.declarationSite; 1231 PartialFieldList get before => element.declarationSite;
1232 1232
1233 PartialFieldList get after => null; 1233 PartialFieldList get after => null;
1234 1234
1235 void captureState() { 1235 void captureState() {
1236 if (wasStateCaptured) throw "captureState was called twice."; 1236 if (wasStateCaptured) throw "captureState was called twice.";
1237 wasStateCaptured = true; 1237 wasStateCaptured = true;
1238 1238
1239 elementAccess = emitter.classAccess(element.enclosingClass); 1239 prototypeAccess = emitter.prototypeAccess(element.enclosingClass);
1240 getterName = namer.getterName(element); 1240 getterName = namer.getterName(element);
1241 setterName = namer.setterName(element); 1241 setterName = namer.setterName(element);
1242 } 1242 }
1243 1243
1244 FieldElementX apply() { 1244 FieldElementX apply() {
1245 if (!wasStateCaptured) { 1245 if (!wasStateCaptured) {
1246 throw new StateError("captureState must be called before apply."); 1246 throw new StateError("captureState must be called before apply.");
1247 } 1247 }
1248 1248
1249 removeFromEnclosing(); 1249 removeFromEnclosing();
1250 1250
1251 return element; 1251 return element;
1252 } 1252 }
1253 1253
1254 void writeUpdateJsOn(List<jsAst.Statement> updates) { 1254 void writeUpdateJsOn(List<jsAst.Statement> updates) {
1255 if (!wasStateCaptured) { 1255 if (!wasStateCaptured) {
1256 throw new StateError( 1256 throw new StateError(
1257 "captureState must be called before writeUpdateJsOn."); 1257 "captureState must be called before writeUpdateJsOn.");
1258 } 1258 }
1259 1259
1260 updates.add( 1260 updates.add(
1261 js.statement('delete #.prototype.#', [elementAccess, getterName])); 1261 js.statement('delete #.prototype.#', [prototypeAccess, getterName]));
1262 updates.add( 1262 updates.add(
1263 js.statement('delete #.prototype.#', [elementAccess, setterName])); 1263 js.statement('delete #.prototype.#', [prototypeAccess, setterName]));
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 class AddedFunctionUpdate extends Update with JsFeatures { 1267 class AddedFunctionUpdate extends Update with JsFeatures {
1268 final PartialFunctionElement element; 1268 final PartialFunctionElement element;
1269 1269
1270 final /* ScopeContainerElement */ container; 1270 final /* ScopeContainerElement */ container;
1271 1271
1272 AddedFunctionUpdate(Compiler compiler, this.element, this.container) 1272 AddedFunctionUpdate(Compiler compiler, this.element, this.container)
1273 : super(compiler) { 1273 : super(compiler) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 List<String> computeFields(ClassElement cls) { 1474 List<String> computeFields(ClassElement cls) {
1475 // TODO(ahe): Rewrite for new emitter. 1475 // TODO(ahe): Rewrite for new emitter.
1476 ClassBuilder builder = new ClassBuilder(cls, namer); 1476 ClassBuilder builder = new ClassBuilder(cls, namer);
1477 classEmitter.emitFields(cls, builder); 1477 classEmitter.emitFields(cls, builder);
1478 return builder.fields; 1478 return builder.fields;
1479 } 1479 }
1480 } 1480 }
1481 1481
1482 // TODO(ahe): Remove this method. 1482 // TODO(ahe): Remove this method.
1483 NO_WARN(x) => x; 1483 NO_WARN(x) => x;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698