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

Unified Diff: frog/leg/ssa/codegen.dart

Issue 9190038: Handle escapes in string literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add dependency on characters.dart to mini_parser.dart. Created 8 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/ssa/codegen.dart
diff --git a/frog/leg/ssa/codegen.dart b/frog/leg/ssa/codegen.dart
index fad8f53490ea5fd45fb44311d6566a5880cb33f8..e747396f3912885ede4ed033fbd2a55d11c09da1 100644
--- a/frog/leg/ssa/codegen.dart
+++ b/frog/leg/ssa/codegen.dart
@@ -460,11 +460,6 @@ class SsaCodeGenerator implements HVisitor {
buffer.add(')');
}
- static String makeStringLiteral(SourceString literal) {
- // TODO(lrn): Escape string content.
- return literal.toString();
- }
-
visitLiteral(HLiteral node) {
if (node.isLiteralNull()) {
buffer.add("(void 0)");
@@ -472,7 +467,13 @@ class SsaCodeGenerator implements HVisitor {
buffer.add('(${node.value})');
} else if (node.isLiteralString()) {
QuotedString string = node.value;
- string.printOn(buffer);
+ String quote = string.quoteChar;
+ buffer.add(quote);
+ string.writeEscaped(buffer, string.quoteCharCode,
+ (String reason) {
+ compiler.cancel(reason, instruction: node);
+ });
+ buffer.add(quote);
} else {
buffer.add(node.value);
}

Powered by Google App Engine
This is Rietveld 408576698