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

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: Rewrote to use iterators on SourceString. 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) 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 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(WorkItem work, HGraph graph) { 9 String generate(WorkItem work, HGraph graph) {
10 return measure(() { 10 return measure(() {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 buffer.add('new $jsClassReference('); 453 buffer.add('new $jsClassReference(');
454 // We can't use 'visitArguments', since our arguments start at input[0]. 454 // We can't use 'visitArguments', since our arguments start at input[0].
455 List<HInstruction> inputs = node.inputs; 455 List<HInstruction> inputs = node.inputs;
456 for (int i = 0; i < inputs.length; i++) { 456 for (int i = 0; i < inputs.length; i++) {
457 if (i != 0) buffer.add(', '); 457 if (i != 0) buffer.add(', ');
458 use(inputs[i]); 458 use(inputs[i]);
459 } 459 }
460 buffer.add(')'); 460 buffer.add(')');
461 } 461 }
462 462
463 static String makeStringLiteral(SourceString literal) {
464 // TODO(lrn): Escape string content.
465 return literal.toString();
466 }
467
468 visitLiteral(HLiteral node) { 463 visitLiteral(HLiteral node) {
469 if (node.isLiteralNull()) { 464 if (node.isLiteralNull()) {
470 buffer.add("(void 0)"); 465 buffer.add("(void 0)");
471 } else if (node.value is num && node.value < 0) { 466 } else if (node.value is num && node.value < 0) {
472 buffer.add('(${node.value})'); 467 buffer.add('(${node.value})');
473 } else if (node.isLiteralString()) { 468 } else if (node.isLiteralString()) {
474 QuotedString string = node.value; 469 QuotedString string = node.value;
475 string.printOn(buffer); 470 String quote = string.quoteChar;
471 buffer.add(quote);
472 string.writeEscaped(buffer, string.quoteCharCode);
473 buffer.add(quote);
476 } else { 474 } else {
477 buffer.add(node.value); 475 buffer.add(node.value);
478 } 476 }
479 } 477 }
480 478
481 visitLoopBranch(HLoopBranch node) { 479 visitLoopBranch(HLoopBranch node) {
482 HBasicBlock branchBlock = currentBlock; 480 HBasicBlock branchBlock = currentBlock;
483 buffer.add('if (!('); 481 buffer.add('if (!(');
484 use(node.inputs[0]); 482 use(node.inputs[0]);
485 buffer.add(')) break;\n'); 483 buffer.add(')) break;\n');
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 : super(compiler, work, buffer, parameters, parameterNames); 761 : super(compiler, work, buffer, parameters, parameterNames);
764 762
765 void visitTypeGuard(HTypeGuard guard) { 763 void visitTypeGuard(HTypeGuard guard) {
766 compiler.internalError('Type guard in an unoptimized method'); 764 compiler.internalError('Type guard in an unoptimized method');
767 } 765 }
768 766
769 visitBailoutTarget(HBailoutTarget node) { 767 visitBailoutTarget(HBailoutTarget node) {
770 buffer.add('// Bailout target ${node.state}'); 768 buffer.add('// Bailout target ${node.state}');
771 } 769 }
772 } 770 }
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