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

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: Added hadnling of scanner exceptions. 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..b1f1da582c8014fe3ad17fff18c77bd76e20d4cd 100644
--- a/frog/leg/ssa/codegen.dart
+++ b/frog/leg/ssa/codegen.dart
@@ -33,6 +33,7 @@ class SsaCodeGeneratorTask extends CompilerTask {
// since we don't do code motion after this point.
new SsaCheckInstructionUnuser().visitGraph(graph);
new SsaConditionMerger().visitGraph(graph);
+ // JavaScript only supports characters in the BMP.
new SsaPhiEliminator().visitGraph(graph);
if (GENERATE_SSA_TRACE) {
new HTracer.singleton().traceGraph("no-phi", graph);
@@ -460,11 +461,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 +468,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