Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: lib/compiler/implementation/js_backend/constant_emitter.dart

Issue 11318018: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 implements ConstantVisitor { 7 class ConstantEmitter implements ConstantVisitor {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Namer namer; 9 final Namer namer;
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 buffer.add(r'\r'); 103 buffer.add(r'\r');
104 } else if (identical(code, $LS)) { 104 } else if (identical(code, $LS)) {
105 // This Unicode line terminator and $PS are invalid in JS string 105 // This Unicode line terminator and $PS are invalid in JS string
106 // literals. 106 // literals.
107 buffer.add(r'\u2028'); 107 buffer.add(r'\u2028');
108 } else if (identical(code, $PS)) { 108 } else if (identical(code, $PS)) {
109 buffer.add(r'\u2029'); 109 buffer.add(r'\u2029');
110 } else if (identical(code, $BACKSLASH)) { 110 } else if (identical(code, $BACKSLASH)) {
111 buffer.add(r'\\'); 111 buffer.add(r'\\');
112 } else { 112 } else {
113 if (code > 0xffff) { 113 if (code >= 0xD800 && code <= 0xDFFF) {
ahe 2012/10/28 12:07:02 I think you should just remove this check. If the
siva 2012/10/31 01:21:26 I have decided to drop the change and instead crea
114 compiler.reportError( 114 compiler.reportError(
115 diagnosticNode, 115 diagnosticNode,
116 'Unhandled non-BMP character: U+${code.toRadixString(16)}'); 116 'Unhandled non-BMP character: U+${code.toRadixString(16)}');
117 } 117 }
118 // TODO(lrn): Consider whether all codes above 0x7f really need to 118 // TODO(lrn): Consider whether all codes above 0x7f really need to
119 // be escaped. We build a Dart string here, so it should be a literal 119 // be escaped. We build a Dart string here, so it should be a literal
120 // stage that converts it to, e.g., UTF-8 for a JS interpreter. 120 // stage that converts it to, e.g., UTF-8 for a JS interpreter.
121 if (code < 0x20) { 121 if (code < 0x20) {
122 buffer.add(r'\x'); 122 buffer.add(r'\x');
123 if (code < 0x10) buffer.add('0'); 123 if (code < 0x10) buffer.add('0');
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 buffer.add(getJsConstructor(constant.type.element)); 245 buffer.add(getJsConstructor(constant.type.element));
246 buffer.add("("); 246 buffer.add("(");
247 for (int i = 0; i < constant.fields.length; i++) { 247 for (int i = 0; i < constant.fields.length; i++) {
248 if (i != 0) buffer.add(", "); 248 if (i != 0) buffer.add(", ");
249 _visit(constant.fields[i]); 249 _visit(constant.fields[i]);
250 } 250 }
251 buffer.add(")"); 251 buffer.add(")");
252 } 252 }
253 } 253 }
254 } 254 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/string_validator.dart » ('j') | lib/compiler/implementation/string_validator.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698