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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 String generate(WorkElement work, HGraph graph) { 9 String generate(WorkElement work, HGraph graph) {
10 return measure(() { 10 return measure(() {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 buffer.add('new $jsClassReference('); 429 buffer.add('new $jsClassReference(');
430 // We can't use 'visitArguments', since our arguments start at input[0]. 430 // We can't use 'visitArguments', since our arguments start at input[0].
431 List<HInstruction> inputs = node.inputs; 431 List<HInstruction> inputs = node.inputs;
432 for (int i = 0; i < inputs.length; i++) { 432 for (int i = 0; i < inputs.length; i++) {
433 if (i != 0) buffer.add(', '); 433 if (i != 0) buffer.add(', ');
434 use(inputs[i]); 434 use(inputs[i]);
435 } 435 }
436 buffer.add(')'); 436 buffer.add(')');
437 } 437 }
438 438
439 static String makeStringLiteral(SourceString literal) {
440 // TODO(lrn): Escape string content.
441 return literal.toString();
442 }
443
444
445 visitLiteral(HLiteral node) { 439 visitLiteral(HLiteral node) {
446 if (node.isLiteralNull()) { 440 if (node.isLiteralNull()) {
447 buffer.add("(void 0)"); 441 buffer.add("(void 0)");
448 } else if (node.value is num && node.value < 0) { 442 } else if (node.value is num && node.value < 0) {
449 buffer.add('(${node.value})'); 443 buffer.add('(${node.value})');
450 } else if (node.isLiteralString()) { 444 } else if (node.isLiteralString()) {
451 QuotedString string = node.value; 445 QuotedString string = node.value;
452 string.printOn(buffer); 446 String quote = string.quoteChar;
447 buffer.add(quote);
448 string.writeEscaped(buffer, quote);
449 buffer.add(quote);
453 } else { 450 } else {
454 buffer.add(node.value); 451 buffer.add(node.value);
455 } 452 }
456 } 453 }
457 454
458 visitLoopBranch(HLoopBranch node) { 455 visitLoopBranch(HLoopBranch node) {
459 HBasicBlock branchBlock = currentBlock; 456 HBasicBlock branchBlock = currentBlock;
460 buffer.add('if (!('); 457 buffer.add('if (!(');
461 use(node.inputs[0]); 458 use(node.inputs[0]);
462 buffer.add(')) break;\n'); 459 buffer.add(')) break;\n');
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 secondBlock.last.tryGenerateAtUseSite(); 933 secondBlock.last.tryGenerateAtUseSite();
937 } 934 }
938 935
939 void visitBasicBlock(HBasicBlock block) { 936 void visitBasicBlock(HBasicBlock block) {
940 if (!block.phis.isEmpty() && 937 if (!block.phis.isEmpty() &&
941 block.phis.first == block.phis.last) { 938 block.phis.first == block.phis.last) {
942 detectLogicControlFlow(block.phis.first); 939 detectLogicControlFlow(block.phis.first);
943 } 940 }
944 } 941 }
945 } 942 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | frog/leg/ssa/nodes.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698