| 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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 // TODO(ahe): This is a bit convoluted, find a better approach. | 836 // TODO(ahe): This is a bit convoluted, find a better approach. |
| 837 emitter.neededClasses | 837 emitter.neededClasses |
| 838 ..clear() | 838 ..clear() |
| 839 ..addAll(_emittedClasses); | 839 ..addAll(_emittedClasses); |
| 840 } | 840 } |
| 841 | 841 |
| 842 List<jsAst.Statement> inherits = <jsAst.Statement>[]; | 842 List<jsAst.Statement> inherits = <jsAst.Statement>[]; |
| 843 | 843 |
| 844 for (ClassElementX cls in newClasses) { | 844 for (ClassElementX cls in newClasses) { |
| 845 jsAst.Node classAccess = emitter.constructorAccess(cls); | 845 jsAst.Node classAccess = emitter.constructorAccess(cls); |
| 846 String name = namer.getNameOfClass(cls); | 846 String name = namer.className(cls); |
| 847 | 847 |
| 848 updates.add( | 848 updates.add( |
| 849 js.statement( | 849 js.statement( |
| 850 r'# = #', [classAccess, invokeDefineClass(cls)])); | 850 r'# = #', [classAccess, invokeDefineClass(cls)])); |
| 851 | 851 |
| 852 ClassElement superclass = cls.superclass; | 852 ClassElement superclass = cls.superclass; |
| 853 if (superclass != null) { | 853 if (superclass != null) { |
| 854 jsAst.Node superAccess = emitter.constructorAccess(superclass); | 854 jsAst.Node superAccess = emitter.constructorAccess(superclass); |
| 855 inherits.add( | 855 inherits.add( |
| 856 js.statement( | 856 js.statement( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 ''')); | 914 ''')); |
| 915 | 915 |
| 916 if (updates.length == 1) { | 916 if (updates.length == 1) { |
| 917 return prettyPrintJs(updates.single); | 917 return prettyPrintJs(updates.single); |
| 918 } else { | 918 } else { |
| 919 return prettyPrintJs(js.statement('{#}', [updates])); | 919 return prettyPrintJs(js.statement('{#}', [updates])); |
| 920 } | 920 } |
| 921 } | 921 } |
| 922 | 922 |
| 923 jsAst.Expression invokeDefineClass(ClassElementX cls) { | 923 jsAst.Expression invokeDefineClass(ClassElementX cls) { |
| 924 String name = namer.getNameOfClass(cls); | 924 String name = namer.className(cls); |
| 925 var descriptor = js('Object.create(null)'); | 925 var descriptor = js('Object.create(null)'); |
| 926 return js( | 926 return js( |
| 927 r''' | 927 r''' |
| 928 (new Function( | 928 (new Function( |
| 929 "$collectedClasses", "$desc", | 929 "$collectedClasses", "$desc", |
| 930 this.defineClass(#name, #computeFields) +"\n;return " + #name))( | 930 this.defineClass(#name, #computeFields) +"\n;return " + #name))( |
| 931 {#name: #descriptor})''', | 931 {#name: #descriptor})''', |
| 932 {'name': js.string(name), | 932 {'name': js.string(name), |
| 933 'computeFields': js.stringArray(computeFields(cls)), | 933 'computeFields': js.stringArray(computeFields(cls)), |
| 934 'descriptor': descriptor}); | 934 'descriptor': descriptor}); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 PartialFunctionElement get before => element; | 1134 PartialFunctionElement get before => element; |
| 1135 | 1135 |
| 1136 PartialFunctionElement get after => null; | 1136 PartialFunctionElement get after => null; |
| 1137 | 1137 |
| 1138 void captureState() { | 1138 void captureState() { |
| 1139 if (wasStateCaptured) throw "captureState was called twice."; | 1139 if (wasStateCaptured) throw "captureState was called twice."; |
| 1140 wasStateCaptured = true; | 1140 wasStateCaptured = true; |
| 1141 | 1141 |
| 1142 if (element.isInstanceMember) { | 1142 if (element.isInstanceMember) { |
| 1143 elementAccess = emitter.constructorAccess(element.enclosingClass); | 1143 elementAccess = emitter.constructorAccess(element.enclosingClass); |
| 1144 name = namer.getNameOfMember(element); | 1144 name = namer.instanceMethodName(element); |
| 1145 } else { | 1145 } else { |
| 1146 elementAccess = emitter.staticFunctionAccess(element); | 1146 elementAccess = emitter.staticFunctionAccess(element); |
| 1147 } | 1147 } |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 PartialFunctionElement apply() { | 1150 PartialFunctionElement apply() { |
| 1151 if (!wasStateCaptured) throw "captureState must be called before apply."; | 1151 if (!wasStateCaptured) throw "captureState must be called before apply."; |
| 1152 removeFromEnclosing(); | 1152 removeFromEnclosing(); |
| 1153 reuseElement(); | 1153 reuseElement(); |
| 1154 return null; | 1154 return null; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 | 1243 |
| 1244 PartialFieldList get before => element.declarationSite; | 1244 PartialFieldList get before => element.declarationSite; |
| 1245 | 1245 |
| 1246 PartialFieldList get after => null; | 1246 PartialFieldList get after => null; |
| 1247 | 1247 |
| 1248 void captureState() { | 1248 void captureState() { |
| 1249 if (wasStateCaptured) throw "captureState was called twice."; | 1249 if (wasStateCaptured) throw "captureState was called twice."; |
| 1250 wasStateCaptured = true; | 1250 wasStateCaptured = true; |
| 1251 | 1251 |
| 1252 prototypeAccess = emitter.prototypeAccess(element.enclosingClass); | 1252 prototypeAccess = emitter.prototypeAccess(element.enclosingClass); |
| 1253 getterName = namer.getterName(element); | 1253 getterName = namer.getterForElement(element); |
| 1254 setterName = namer.setterName(element); | 1254 setterName = namer.setterForElement(element); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 FieldElementX apply() { | 1257 FieldElementX apply() { |
| 1258 if (!wasStateCaptured) { | 1258 if (!wasStateCaptured) { |
| 1259 throw new StateError("captureState must be called before apply."); | 1259 throw new StateError("captureState must be called before apply."); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 removeFromEnclosing(); | 1262 removeFromEnclosing(); |
| 1263 | 1263 |
| 1264 return element; | 1264 return element; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 .buildFieldsHackForIncrementalCompilation(classElement); | 1487 .buildFieldsHackForIncrementalCompilation(classElement); |
| 1488 // TODO(ahe): Rewrite for new emitter. | 1488 // TODO(ahe): Rewrite for new emitter. |
| 1489 ClassBuilder builder = new ClassBuilder(classElement, namer); | 1489 ClassBuilder builder = new ClassBuilder(classElement, namer); |
| 1490 classEmitter.emitFields(cls, builder); | 1490 classEmitter.emitFields(cls, builder); |
| 1491 return builder.fields; | 1491 return builder.fields; |
| 1492 } | 1492 } |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 // TODO(ahe): Remove this method. | 1495 // TODO(ahe): Remove this method. |
| 1496 NO_WARN(x) => x; | 1496 NO_WARN(x) => x; |
| OLD | NEW |