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

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: Removed validation from scanner 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
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 (String reason) {
474 compiler.cancel(reason, instruction: node);
475 });
476 buffer.add(quote);
476 } else { 477 } else {
477 buffer.add(node.value); 478 buffer.add(node.value);
478 } 479 }
479 } 480 }
480 481
481 visitLoopBranch(HLoopBranch node) { 482 visitLoopBranch(HLoopBranch node) {
482 HBasicBlock branchBlock = currentBlock; 483 HBasicBlock branchBlock = currentBlock;
483 buffer.add('if (!('); 484 buffer.add('if (!(');
484 use(node.inputs[0]); 485 use(node.inputs[0]);
485 buffer.add(')) break;\n'); 486 buffer.add(')) break;\n');
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 : super(compiler, work, buffer, parameters, parameterNames); 764 : super(compiler, work, buffer, parameters, parameterNames);
764 765
765 void visitTypeGuard(HTypeGuard guard) { 766 void visitTypeGuard(HTypeGuard guard) {
766 compiler.internalError('Type guard in an unoptimized method'); 767 compiler.internalError('Type guard in an unoptimized method');
767 } 768 }
768 769
769 visitBailoutTarget(HBailoutTarget node) { 770 visitBailoutTarget(HBailoutTarget node) {
770 buffer.add('// Bailout target ${node.state}'); 771 buffer.add('// Bailout target ${node.state}');
771 } 772 }
772 } 773 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698