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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10544026: Simplify generated code for string interpolation by delaying the constant folding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index e4437cf32676fd576ae0f599a32e9e656bff0308..d3bbb7906630c7ad76dc4dc31b8842cc8bc740db 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1810,6 +1810,33 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
}
+ void visitStringConcat(HStringConcat node) {
+ JSBinaryOperatorPrecedence operatorPrecedences = JSPrecedence.binary['+'];
+ beginExpression(operatorPrecedences.precedence);
+ useStringified(node.inputs[0], operatorPrecedences.left);
+ buffer.add(' + ');
+ // If the right hand side is a string concatenation itself it is
+ // safe to make it left associative.
+ JSPrecedence rightPrecedence = (node.inputs[1] is HStringConcat)
Lasse Reichstein Nielsen 2012/06/06 12:11:40 JSPrecedence -> int. The JSPrecedence class is jus
kasperl 2012/06/06 13:31:03 Done.
+ ? JSPrecedence.ADDITIVE_PRECEDENCE
+ : operatorPrecedences.right;
+ useStringified(node.inputs[1], rightPrecedence);
+ endExpression(operatorPrecedences.precedence);
+ }
+
+ void useStringified(HInstruction node, JSPrecedence precedence) {
+ if (node.isString()) {
+ use(node, precedence);
+ } else {
+ Element convertToString = compiler.findHelper(const SourceString("S"));
+ world.registerStaticUse(convertToString);
+ buffer.add(compiler.namer.isolateAccess(convertToString));
Lasse Reichstein Nielsen 2012/06/06 12:11:40 Maybe we should have a function that does all this
+ buffer.add('(');
+ use(node, JSPrecedence.EXPRESSION_PRECEDENCE);
+ buffer.add(')');
+ }
+ }
+
void visitLiteralList(HLiteralList node) {
generateArrayLiteral(node);
}

Powered by Google App Engine
This is Rietveld 408576698