| OLD | NEW |
| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class ConstantEmitter { | 7 class ConstantEmitter { |
| 8 ConstantReferenceEmitter _referenceEmitter; | 8 ConstantReferenceEmitter _referenceEmitter; |
| 9 ConstantLiteralEmitter _literalEmitter; | 9 ConstantLiteralEmitter _literalEmitter; |
| 10 | 10 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * Write the contents of the quoted string to a [CodeBuffer] in | 284 * Write the contents of the quoted string to a [CodeBuffer] in |
| 285 * a form that is valid as JavaScript string literal content. | 285 * a form that is valid as JavaScript string literal content. |
| 286 * The string is assumed quoted by double quote characters. | 286 * The string is assumed quoted by double quote characters. |
| 287 */ | 287 */ |
| 288 @override | 288 @override |
| 289 jsAst.Expression visitString(StringConstantValue constant, [_]) { | 289 jsAst.Expression visitString(StringConstantValue constant, [_]) { |
| 290 return js.escapedString(constant.primitiveValue.slowToString()); | 290 StringBuffer sb = new StringBuffer(); |
| 291 writeJsonEscapedCharsOn(constant.primitiveValue.slowToString(), sb); |
| 292 return new jsAst.LiteralString('"$sb"'); |
| 291 } | 293 } |
| 292 | 294 |
| 293 @override | 295 @override |
| 294 jsAst.Expression visitList(ListConstantValue constant, [_]) { | 296 jsAst.Expression visitList(ListConstantValue constant, [_]) { |
| 295 List<jsAst.Expression> elements = _array(constant.entries); | 297 List<jsAst.Expression> elements = _array(constant.entries); |
| 296 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); | 298 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); |
| 297 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); | 299 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); |
| 298 return maybeAddTypeArguments(constant.type, value); | 300 return maybeAddTypeArguments(constant.type, value); |
| 299 } | 301 } |
| 300 | 302 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 [value, argumentList]); | 444 [value, argumentList]); |
| 443 } | 445 } |
| 444 return value; | 446 return value; |
| 445 } | 447 } |
| 446 | 448 |
| 447 @override | 449 @override |
| 448 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 450 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
| 449 return constantEmitter.reference(constant.referenced); | 451 return constantEmitter.reference(constant.referenced); |
| 450 } | 452 } |
| 451 } | 453 } |
| OLD | NEW |