| 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 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant); | 7 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant); |
| 8 | 8 |
| 9 typedef jsAst.Expression _ConstantListGenerator(jsAst.Expression array); | 9 typedef jsAst.Expression _ConstantListGenerator(jsAst.Expression array); |
| 10 | 10 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Write the contents of the quoted string to a [CodeBuffer] in | 150 * Write the contents of the quoted string to a [CodeBuffer] in |
| 151 * a form that is valid as JavaScript string literal content. | 151 * a form that is valid as JavaScript string literal content. |
| 152 * The string is assumed quoted by double quote characters. | 152 * The string is assumed quoted by double quote characters. |
| 153 */ | 153 */ |
| 154 @override | 154 @override |
| 155 jsAst.Expression visitString(StringConstantValue constant, [_]) { | 155 jsAst.Expression visitString(StringConstantValue constant, [_]) { |
| 156 StringBuffer sb = new StringBuffer(); | 156 return js.escapedString(constant.primitiveValue.slowToString(), |
| 157 writeJsonEscapedCharsOn(constant.primitiveValue.slowToString(), sb); | 157 ascii: true); |
| 158 return new jsAst.LiteralString('"$sb"'); | |
| 159 } | 158 } |
| 160 | 159 |
| 161 @override | 160 @override |
| 162 jsAst.Expression visitList(ListConstantValue constant, [_]) { | 161 jsAst.Expression visitList(ListConstantValue constant, [_]) { |
| 163 List<jsAst.Expression> elements = constant.entries | 162 List<jsAst.Expression> elements = constant.entries |
| 164 .map(constantReferenceGenerator) | 163 .map(constantReferenceGenerator) |
| 165 .toList(growable: false); | 164 .toList(growable: false); |
| 166 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); | 165 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); |
| 167 jsAst.Expression value = makeConstantList(array); | 166 jsAst.Expression value = makeConstantList(array); |
| 168 return maybeAddTypeArguments(constant.type, value); | 167 return maybeAddTypeArguments(constant.type, value); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 [value, argumentList]); | 319 [value, argumentList]); |
| 321 } | 320 } |
| 322 return value; | 321 return value; |
| 323 } | 322 } |
| 324 | 323 |
| 325 @override | 324 @override |
| 326 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 325 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
| 327 return constantReferenceGenerator(constant.referenced); | 326 return constantReferenceGenerator(constant.referenced); |
| 328 } | 327 } |
| 329 } | 328 } |
| OLD | NEW |