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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2753523002: VM: [KERNEL] handle single-argument string interpolation in VM (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.h » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta.body_builder; 5 library fasta.body_builder;
6 6
7 import '../parser/parser.dart' show FormalParameterType, optional; 7 import '../parser/parser.dart' show FormalParameterType, optional;
8 8
9 import '../parser/error_kind.dart' show ErrorKind; 9 import '../parser/error_kind.dart' show ErrorKind;
10 10
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 debugEvent("endLiteralString"); 811 debugEvent("endLiteralString");
812 if (interpolationCount == 0) { 812 if (interpolationCount == 0) {
813 Token token = pop(); 813 Token token = pop();
814 push(new StringLiteral(unescapeString(token.lexeme))); 814 push(new StringLiteral(unescapeString(token.lexeme)));
815 } else { 815 } else {
816 List parts = popList(1 + interpolationCount * 2); 816 List parts = popList(1 + interpolationCount * 2);
817 Token first = parts.first; 817 Token first = parts.first;
818 Token last = parts.last; 818 Token last = parts.last;
819 Quote quote = analyzeQuote(first.lexeme); 819 Quote quote = analyzeQuote(first.lexeme);
820 List<Expression> expressions = <Expression>[]; 820 List<Expression> expressions = <Expression>[];
821 expressions 821 // Contains more then just \' or \".
ahe 2017/03/14 14:58:44 than.
822 if (first.lexeme.length > 1) {
823 expressions
822 .add(new StringLiteral(unescapeFirstStringPart(first.lexeme, quote))); 824 .add(new StringLiteral(unescapeFirstStringPart(first.lexeme, quote)));
825 }
823 for (int i = 1; i < parts.length - 1; i++) { 826 for (int i = 1; i < parts.length - 1; i++) {
824 var part = parts[i]; 827 var part = parts[i];
825 if (part is Token) { 828 if (part is Token) {
826 expressions.add(new StringLiteral(unescape(part.lexeme, quote))); 829 if (part.lexeme.length != 0) {
830 expressions.add(new StringLiteral(unescape(part.lexeme, quote)));
831 }
827 } else { 832 } else {
828 expressions.add(toValue(part)); 833 expressions.add(toValue(part));
829 } 834 }
830 } 835 }
831 expressions 836 // Contains more then just \' or \".
ahe 2017/03/14 14:58:44 Than.
837 if (last.lexeme.length > 1) {
838 expressions
832 .add(new StringLiteral(unescapeLastStringPart(last.lexeme, quote))); 839 .add(new StringLiteral(unescapeLastStringPart(last.lexeme, quote)));
840 }
833 push(new StringConcatenation(expressions) 841 push(new StringConcatenation(expressions)
834 ..fileOffset = endToken.charOffset); 842 ..fileOffset = endToken.charOffset);
835 } 843 }
836 } 844 }
837 845
838 @override 846 @override
839 void handleScript(Token token) { 847 void handleScript(Token token) {
840 debugEvent("Script"); 848 debugEvent("Script");
841 } 849 }
842 850
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 } else if (node is PrefixBuilder) { 2777 } else if (node is PrefixBuilder) {
2770 return node.name; 2778 return node.name;
2771 } else if (node is ThisAccessor) { 2779 } else if (node is ThisAccessor) {
2772 return node.isSuper ? "super" : "this"; 2780 return node.isSuper ? "super" : "this";
2773 } else if (node is BuilderAccessor) { 2781 } else if (node is BuilderAccessor) {
2774 return node.plainNameForRead; 2782 return node.plainNameForRead;
2775 } else { 2783 } else {
2776 return internalError("Unhandled: ${node.runtimeType}"); 2784 return internalError("Unhandled: ${node.runtimeType}");
2777 } 2785 }
2778 } 2786 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698