| 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 class ConstantEmitter implements ConstantVisitor { | 5 class ConstantEmitter implements ConstantVisitor { |
| 6 final Compiler compiler; | 6 final Compiler compiler; |
| 7 final Namer namer; | 7 final Namer namer; |
| 8 | 8 |
| 9 CodeBuffer buffer; | 9 CodeBuffer buffer; |
| 10 bool shouldEmitCanonicalVersion; | 10 bool shouldEmitCanonicalVersion; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Write the contents of the quoted string to a [CodeBuffer] in | 86 * Write the contents of the quoted string to a [CodeBuffer] in |
| 87 * a form that is valid as JavaScript string literal content. | 87 * a form that is valid as JavaScript string literal content. |
| 88 * The string is assumed quoted by single quote characters. | 88 * The string is assumed quoted by single quote characters. |
| 89 */ | 89 */ |
| 90 void writeEscapedString(DartString string, | 90 void writeEscapedString(DartString string, |
| 91 CodeBuffer buffer, | 91 CodeBuffer buffer, |
| 92 Node diagnosticNode) { | 92 Node diagnosticNode) { |
| 93 Iterator<int> iterator = string.iterator(); | 93 Iterator<int> iterator = string.iterator(); |
| 94 while (iterator.hasNext()) { | 94 while (iterator.hasNext) { |
| 95 int code = iterator.next(); | 95 int code = iterator.next(); |
| 96 if (identical(code, $SQ)) { | 96 if (identical(code, $SQ)) { |
| 97 buffer.add(r"\'"); | 97 buffer.add(r"\'"); |
| 98 } else if (identical(code, $LF)) { | 98 } else if (identical(code, $LF)) { |
| 99 buffer.add(r'\n'); | 99 buffer.add(r'\n'); |
| 100 } else if (identical(code, $CR)) { | 100 } else if (identical(code, $CR)) { |
| 101 buffer.add(r'\r'); | 101 buffer.add(r'\r'); |
| 102 } else if (identical(code, $LS)) { | 102 } else if (identical(code, $LS)) { |
| 103 // This Unicode line terminator and $PS are invalid in JS string | 103 // This Unicode line terminator and $PS are invalid in JS string |
| 104 // literals. | 104 // literals. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 buffer.add(getJsConstructor(constant.type.element)); | 243 buffer.add(getJsConstructor(constant.type.element)); |
| 244 buffer.add("("); | 244 buffer.add("("); |
| 245 for (int i = 0; i < constant.fields.length; i++) { | 245 for (int i = 0; i < constant.fields.length; i++) { |
| 246 if (i != 0) buffer.add(", "); | 246 if (i != 0) buffer.add(", "); |
| 247 _visit(constant.fields[i]); | 247 _visit(constant.fields[i]); |
| 248 } | 248 } |
| 249 buffer.add(")"); | 249 buffer.add(")"); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |