| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 /** | 252 /** |
| 253 * Write the contents of the quoted string to a [CodeBuffer] in | 253 * Write the contents of the quoted string to a [CodeBuffer] in |
| 254 * a form that is valid as JavaScript string literal content. | 254 * a form that is valid as JavaScript string literal content. |
| 255 * The string is assumed quoted by double quote characters. | 255 * The string is assumed quoted by double quote characters. |
| 256 */ | 256 */ |
| 257 @override | 257 @override |
| 258 jsAst.Expression visitString(StringConstantValue constant, [_]) { | 258 jsAst.Expression visitString(StringConstantValue constant, [_]) { |
| 259 return js.escapedString(constant.primitiveValue.slowToString()); | 259 StringBuffer sb = new StringBuffer(); |
| 260 writeJsonEscapedCharsOn(constant.primitiveValue.slowToString(), sb); |
| 261 return new jsAst.LiteralString('"$sb"'); |
| 260 } | 262 } |
| 261 | 263 |
| 262 @override | 264 @override |
| 263 jsAst.Expression visitList(ListConstantValue constant, [_]) { | 265 jsAst.Expression visitList(ListConstantValue constant, [_]) { |
| 264 List<jsAst.Expression> elements = _array(constant.entries); | 266 List<jsAst.Expression> elements = _array(constant.entries); |
| 265 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); | 267 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); |
| 266 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); | 268 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); |
| 267 return maybeAddTypeArguments(constant.type, value); | 269 return maybeAddTypeArguments(constant.type, value); |
| 268 } | 270 } |
| 269 | 271 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 [value, argumentList]); | 413 [value, argumentList]); |
| 412 } | 414 } |
| 413 return value; | 415 return value; |
| 414 } | 416 } |
| 415 | 417 |
| 416 @override | 418 @override |
| 417 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 419 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
| 418 return constantEmitter.reference(constant.referenced); | 420 return constantEmitter.reference(constant.referenced); |
| 419 } | 421 } |
| 420 } | 422 } |
| OLD | NEW |