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

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_emitter.dart

Issue 2864363002: Remove DartString from constants. (Closed)
Patch Set: Remove toDartString Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import '../common.dart'; 5 import '../common.dart';
6 import '../compiler.dart' show Compiler; 6 import '../compiler.dart' show Compiler;
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../elements/resolution_types.dart'; 8 import '../elements/resolution_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/code_output.dart'; 10 import '../io/code_output.dart';
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 } 159 }
160 160
161 /** 161 /**
162 * Write the contents of the quoted string to a [CodeBuffer] in 162 * Write the contents of the quoted string to a [CodeBuffer] in
163 * a form that is valid as JavaScript string literal content. 163 * a form that is valid as JavaScript string literal content.
164 * The string is assumed quoted by double quote characters. 164 * The string is assumed quoted by double quote characters.
165 */ 165 */
166 @override 166 @override
167 jsAst.Expression visitString(StringConstantValue constant, [_]) { 167 jsAst.Expression visitString(StringConstantValue constant, [_]) {
168 return js.escapedString(constant.primitiveValue.slowToString(), 168 return js.escapedString(constant.primitiveValue, ascii: true);
169 ascii: true);
170 } 169 }
171 170
172 @override 171 @override
173 jsAst.Expression visitList(ListConstantValue constant, [_]) { 172 jsAst.Expression visitList(ListConstantValue constant, [_]) {
174 List<jsAst.Expression> elements = constant.entries 173 List<jsAst.Expression> elements = constant.entries
175 .map(constantReferenceGenerator) 174 .map(constantReferenceGenerator)
176 .toList(growable: false); 175 .toList(growable: false);
177 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); 176 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements);
178 jsAst.Expression value = makeConstantList(array); 177 jsAst.Expression value = makeConstantList(array);
179 return maybeAddTypeArguments(constant.type, value); 178 return maybeAddTypeArguments(constant.type, value);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 "Unexpected DummyConstantKind ${constant.kind}"); 295 "Unexpected DummyConstantKind ${constant.kind}");
297 return null; 296 return null;
298 } 297 }
299 } 298 }
300 299
301 @override 300 @override
302 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) { 301 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) {
303 ClassElement element = constant.type.element; 302 ClassElement element = constant.type.element;
304 if (backend.isForeign(element) && element.name == 'JS_CONST') { 303 if (backend.isForeign(element) && element.name == 'JS_CONST') {
305 StringConstantValue str = constant.fields.values.single; 304 StringConstantValue str = constant.fields.values.single;
306 String value = str.primitiveValue.slowToString(); 305 String value = str.primitiveValue;
307 return new jsAst.LiteralExpression(stripComments(value)); 306 return new jsAst.LiteralExpression(stripComments(value));
308 } 307 }
309 jsAst.Expression constructor = 308 jsAst.Expression constructor =
310 backend.emitter.constructorAccess(constant.type.element); 309 backend.emitter.constructorAccess(constant.type.element);
311 List<jsAst.Expression> fields = <jsAst.Expression>[]; 310 List<jsAst.Expression> fields = <jsAst.Expression>[];
312 element.forEachInstanceField((_, FieldElement field) { 311 element.forEachInstanceField((_, FieldElement field) {
313 fields.add(constantReferenceGenerator(constant.fields[field])); 312 fields.add(constantReferenceGenerator(constant.fields[field]));
314 }, includeSuperAndInjectedMembers: true); 313 }, includeSuperAndInjectedMembers: true);
315 if (backend.rtiNeed.classNeedsRtiField(constant.type.element)) { 314 if (backend.rtiNeed.classNeedsRtiField(constant.type.element)) {
316 fields.add(_reifiedTypeArguments(constant.type)); 315 fields.add(_reifiedTypeArguments(constant.type));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 backend.emitter.emitter, argument, unexpected)); 350 backend.emitter.emitter, argument, unexpected));
352 } 351 }
353 return new jsAst.ArrayInitializer(arguments); 352 return new jsAst.ArrayInitializer(arguments);
354 } 353 }
355 354
356 @override 355 @override
357 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 356 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
358 return constantReferenceGenerator(constant.referenced); 357 return constantReferenceGenerator(constant.referenced);
359 } 358 }
360 } 359 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_system.dart ('k') | pkg/compiler/lib/src/js_backend/constant_system_javascript.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698