| Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| index ba5a9d942b1601a124e8965b402ca29ff86d88c6..f7d7de8f41daecb45ac1e3dcc5ab55cc36dc92c3 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| @@ -81,13 +81,17 @@ class CodeEmitterTask extends CompilerTask {
|
| });
|
| }
|
|
|
| - void writeConstantToBuffer(Constant value, CodeBuffer buffer,
|
| - {emitCanonicalVersion: true}) {
|
| - if (emitCanonicalVersion) {
|
| - constantEmitter.emitCanonicalVersionOfConstant(value, buffer);
|
| - } else {
|
| - constantEmitter.emitJavaScriptCodeForConstant(value, buffer);
|
| - }
|
| + js.Expression constantReference(Constant value) {
|
| + return constantEmitter.reference(value);
|
| + }
|
| +
|
| + js.Expression constantInitializerExpression(Constant value) {
|
| + return constantEmitter.initializationExpression(value);
|
| + }
|
| +
|
| + // Deprecated. Remove after last use is converted to JS ASTs.
|
| + void writeConstantToBuffer(Constant value, CodeBuffer buffer) {
|
| + buffer.add(js.prettyPrint(constantReference(value), compiler));
|
| }
|
|
|
| String get name => 'CodeEmitter';
|
| @@ -1319,12 +1323,17 @@ $classesCollector.$mangledName = {'':
|
| List<VariableElement> staticNonFinalFields =
|
| handler.getStaticNonFinalFieldsForEmission();
|
| for (Element element in staticNonFinalFields) {
|
| - buffer.add('$isolateProperties.${namer.getName(element)} = ');
|
| compiler.withCurrentElement(element, () {
|
| - Constant initialValue = handler.getInitialValueFor(element);
|
| - writeConstantToBuffer(initialValue, buffer);
|
| - });
|
| - buffer.add(';\n');
|
| + Constant initialValue = handler.getInitialValueFor(element);
|
| + js.Expression init =
|
| + new js.Assignment(
|
| + new js.PropertyAccess.field(
|
| + new js.VariableUse(isolateProperties),
|
| + namer.getName(element)),
|
| + constantEmitter.referenceInInitializationContext(initialValue));
|
| + buffer.add(js.prettyPrint(init, compiler));
|
| + buffer.add(';\n');
|
| + });
|
| }
|
| }
|
|
|
| @@ -1382,8 +1391,13 @@ $classesCollector.$mangledName = {'':
|
| addedMakeConstantList = true;
|
| emitMakeConstantList(buffer);
|
| }
|
| - buffer.add('$isolateProperties.$name = ');
|
| - writeConstantToBuffer(constant, buffer, emitCanonicalVersion: false);
|
| + js.Expression init =
|
| + new js.Assignment(
|
| + new js.PropertyAccess.field(
|
| + new js.VariableUse(isolateProperties),
|
| + name),
|
| + constantInitializerExpression(constant));
|
| + buffer.add(js.prettyPrint(init, compiler));
|
| buffer.add(';\n');
|
| }
|
| }
|
|
|