| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 import 'package:compiler/src/js/js.dart' show | 56 import 'package:compiler/src/js/js.dart' show |
| 57 js; | 57 js; |
| 58 | 58 |
| 59 import 'package:compiler/src/js/js.dart' as jsAst; | 59 import 'package:compiler/src/js/js.dart' as jsAst; |
| 60 | 60 |
| 61 import 'package:compiler/src/js_emitter/js_emitter.dart' show | 61 import 'package:compiler/src/js_emitter/js_emitter.dart' show |
| 62 ClassBuilder, | 62 ClassBuilder, |
| 63 ClassEmitter, | 63 ClassEmitter, |
| 64 CodeEmitterTask, | 64 CodeEmitterTask, |
| 65 ContainerBuilder, | 65 ContainerBuilder, |
| 66 OldEmitter, | |
| 67 MemberInfo, | 66 MemberInfo, |
| 68 computeMixinClass; | 67 computeMixinClass; |
| 69 | 68 |
| 69 import 'package:compiler/src/js_emitter/full_emitter/emitter.dart' |
| 70 as full show Emitter; |
| 71 |
| 70 import 'package:compiler/src/js_emitter/model.dart' show | 72 import 'package:compiler/src/js_emitter/model.dart' show |
| 71 Class, | 73 Class, |
| 72 Method; | 74 Method; |
| 73 | 75 |
| 74 import 'package:compiler/src/js_emitter/program_builder/program_builder.dart' | 76 import 'package:compiler/src/js_emitter/program_builder/program_builder.dart' |
| 75 show ProgramBuilder; | 77 show ProgramBuilder; |
| 76 | 78 |
| 77 import 'package:js_runtime/shared/embedded_names.dart' | 79 import 'package:js_runtime/shared/embedded_names.dart' |
| 78 as embeddedNames; | 80 as embeddedNames; |
| 79 | 81 |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 compiler.backend.constants.compiledConstants); | 893 compiler.backend.constants.compiledConstants); |
| 892 newConstants.removeAll(_compiledConstants); | 894 newConstants.removeAll(_compiledConstants); |
| 893 | 895 |
| 894 if (!newConstants.isEmpty) { | 896 if (!newConstants.isEmpty) { |
| 895 _ensureAllNeededEntitiesComputed(); | 897 _ensureAllNeededEntitiesComputed(); |
| 896 List<ConstantValue> constants = | 898 List<ConstantValue> constants = |
| 897 emitter.outputConstantLists[compiler.deferredLoadTask.mainOutputUnit]; | 899 emitter.outputConstantLists[compiler.deferredLoadTask.mainOutputUnit]; |
| 898 if (constants != null) { | 900 if (constants != null) { |
| 899 for (ConstantValue constant in constants) { | 901 for (ConstantValue constant in constants) { |
| 900 if (!_compiledConstants.contains(constant)) { | 902 if (!_compiledConstants.contains(constant)) { |
| 901 OldEmitter fullEmitter = emitter.emitter; | 903 full.Emitter fullEmitter = emitter.emitter; |
| 902 jsAst.Statement constantInitializer = | 904 jsAst.Statement constantInitializer = |
| 903 fullEmitter.buildConstantInitializer(constant).toStatement(); | 905 fullEmitter.buildConstantInitializer(constant).toStatement(); |
| 904 updates.add(constantInitializer); | 906 updates.add(constantInitializer); |
| 905 } | 907 } |
| 906 } | 908 } |
| 907 } | 909 } |
| 908 } | 910 } |
| 909 | 911 |
| 910 updates.add(js.statement(r''' | 912 updates.add(js.statement(r''' |
| 911 if (this.pendingStubs) { | 913 if (this.pendingStubs) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 } | 972 } |
| 971 | 973 |
| 972 List<jsAst.Statement> computeFieldUpdateJs(FieldElementX element) { | 974 List<jsAst.Statement> computeFieldUpdateJs(FieldElementX element) { |
| 973 if (element.isInstanceMember) { | 975 if (element.isInstanceMember) { |
| 974 // Any initializers are inlined in factory methods, and the field is | 976 // Any initializers are inlined in factory methods, and the field is |
| 975 // declared by adding its class to [_classesWithSchemaChanges]. | 977 // declared by adding its class to [_classesWithSchemaChanges]. |
| 976 return const <jsAst.Statement>[]; | 978 return const <jsAst.Statement>[]; |
| 977 } | 979 } |
| 978 // A static (or top-level) field. | 980 // A static (or top-level) field. |
| 979 if (backend.constants.lazyStatics.contains(element)) { | 981 if (backend.constants.lazyStatics.contains(element)) { |
| 980 OldEmitter fullEmitter = emitter.emitter; | 982 full.Emitter fullEmitter = emitter.emitter; |
| 981 jsAst.Expression init = | 983 jsAst.Expression init = |
| 982 fullEmitter.buildLazilyInitializedStaticField( | 984 fullEmitter.buildLazilyInitializedStaticField( |
| 983 element, isolateProperties: namer.currentIsolate); | 985 element, isolateProperties: namer.currentIsolate); |
| 984 if (init == null) { | 986 if (init == null) { |
| 985 throw new StateError("Initializer optimized away for $element"); | 987 throw new StateError("Initializer optimized away for $element"); |
| 986 } | 988 } |
| 987 return <jsAst.Statement>[init.toStatement()]; | 989 return <jsAst.Statement>[init.toStatement()]; |
| 988 } else { | 990 } else { |
| 989 // TODO(ahe): When a field is referenced it is enqueued. If the field has | 991 // TODO(ahe): When a field is referenced it is enqueued. If the field has |
| 990 // no initializer, it will not have any associated code, so it will | 992 // no initializer, it will not have any associated code, so it will |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 abstract class JsFeatures { | 1468 abstract class JsFeatures { |
| 1467 Compiler get compiler; | 1469 Compiler get compiler; |
| 1468 | 1470 |
| 1469 JavaScriptBackend get backend => compiler.backend; | 1471 JavaScriptBackend get backend => compiler.backend; |
| 1470 | 1472 |
| 1471 Namer get namer => backend.namer; | 1473 Namer get namer => backend.namer; |
| 1472 | 1474 |
| 1473 CodeEmitterTask get emitter => backend.emitter; | 1475 CodeEmitterTask get emitter => backend.emitter; |
| 1474 | 1476 |
| 1475 ContainerBuilder get containerBuilder { | 1477 ContainerBuilder get containerBuilder { |
| 1476 OldEmitter fullEmitter = emitter.emitter; | 1478 full.Emitter fullEmitter = emitter.emitter; |
| 1477 return fullEmitter.containerBuilder; | 1479 return fullEmitter.containerBuilder; |
| 1478 } | 1480 } |
| 1479 | 1481 |
| 1480 EnqueueTask get enqueuer => compiler.enqueuer; | 1482 EnqueueTask get enqueuer => compiler.enqueuer; |
| 1481 } | 1483 } |
| 1482 | 1484 |
| 1483 class EmitterHelper extends JsFeatures { | 1485 class EmitterHelper extends JsFeatures { |
| 1484 final Compiler compiler; | 1486 final Compiler compiler; |
| 1485 | 1487 |
| 1486 EmitterHelper(this.compiler); | 1488 EmitterHelper(this.compiler); |
| 1487 | 1489 |
| 1488 ClassEmitter get classEmitter { | 1490 ClassEmitter get classEmitter { |
| 1489 OldEmitter fullEmitter = emitter.emitter; | 1491 full.Emitter fullEmitter = emitter.emitter; |
| 1490 return fullEmitter.classEmitter; | 1492 return fullEmitter.classEmitter; |
| 1491 } | 1493 } |
| 1492 | 1494 |
| 1493 List<String> computeFields(ClassElement classElement) { | 1495 List<String> computeFields(ClassElement classElement) { |
| 1494 Class cls = new ProgramBuilder(compiler, namer, emitter) | 1496 Class cls = new ProgramBuilder(compiler, namer, emitter) |
| 1495 .buildFieldsHackForIncrementalCompilation(classElement); | 1497 .buildFieldsHackForIncrementalCompilation(classElement); |
| 1496 // TODO(ahe): Rewrite for new emitter. | 1498 // TODO(ahe): Rewrite for new emitter. |
| 1497 ClassBuilder builder = new ClassBuilder(classElement, namer); | 1499 ClassBuilder builder = new ClassBuilder(classElement, namer); |
| 1498 classEmitter.emitFields(cls, builder); | 1500 classEmitter.emitFields(cls, builder); |
| 1499 return builder.fields; | 1501 return builder.fields; |
| 1500 } | 1502 } |
| 1501 } | 1503 } |
| 1502 | 1504 |
| 1503 // TODO(ahe): Remove this method. | 1505 // TODO(ahe): Remove this method. |
| 1504 NO_WARN(x) => x; | 1506 NO_WARN(x) => x; |
| OLD | NEW |