Chromium Code Reviews| Index: frog/member.dart |
| diff --git a/frog/member.dart b/frog/member.dart |
| index 2793de4153de8014d3f6b665dd6fd38bbc33c4af..6161b823a2f60074ef590e1b1db90da0e27d4e80 100644 |
| --- a/frog/member.dart |
| +++ b/frog/member.dart |
| @@ -1177,13 +1177,29 @@ class MethodMember extends Member { |
| } else if (name == '\$add') { |
| if (allConst) { |
| var val0 = target.dynamic.actualValue; |
| + var quote0 = val0[0]; |
| val0 = val0.substring(1, val0.length - 1); |
| var val1 = args.values[0].dynamic.actualValue; |
| + var quote1 = null; |
| if (args.values[0].type.isString) { |
| + quote1 = val1[0]; |
| val1 = val1.substring(1, val1.length - 1); |
| } |
| - var value = '${val0}${val1}'; |
| - value = '"' + value.replaceAll('"', '\\"') + '"'; |
| + // ensure that both strings use the same quote char: |
|
Jennifer Messerly
2011/11/29 18:55:48
it'd be really nice if this was pulled out into it
Siggi Cherem (dart-lang)
2011/11/29 19:09:26
Done.
|
| + var value; |
| + if (quote0 == quote1 || quote1 == null) { |
| + // if both strings use the same quote, then merge them together |
| + value = '$quote0${val0}${val1}$quote0'; |
| + } else if (quote0 == '"') { |
| + // if they are different, escape the single-quote to be double-quote |
| + // the choice of single vs double is arbitrary, but choosing one |
| + // ensures that we only do this escaping once on a string portion. |
| + assert(quote1 == "'"); |
| + value = '$quote0${val0}${toDoubleQuote(val1)}$quote0'; |
| + } else { |
| + assert(quote1 == '"'); |
| + value = '$quote1${toDoubleQuote(val0)}${val1}$quote1'; |
| + } |
| return new EvaluatedValue(world.stringType, value, value, node.span); |
| } |