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

Unified Diff: frog/leg/ssa/nodes.dart

Issue 9642001: Make string juxtaposition combine properly with string interpolations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove last bugs and clean up builder. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/ssa/nodes.dart
diff --git a/frog/leg/ssa/nodes.dart b/frog/leg/ssa/nodes.dart
index 9657192e0ab9f538fa21b398e125f20d321abe67..80dfedbe90cca3e83d014502b5b40efc6c163994 100644
--- a/frog/leg/ssa/nodes.dart
+++ b/frog/leg/ssa/nodes.dart
@@ -1387,6 +1387,28 @@ class HAdd extends HBinaryArithmetic {
}
AddOperation get operation() => const AddOperation();
+
+ HInstruction fold(HGraph graph) {
ngeoffray 2012/03/14 12:29:58 Is that dead code? There is no fold method in the
Lasse Reichstein Nielsen 2012/03/14 13:04:49 It's probably dead, just leftover of a merge that
+ // TODO(floitsch): move this code to the compile-time-constant handler.
+ if (left.isConstantString() && right is HConstant) {
+ HConstant op1 = left;
+ HConstant op2 = right;
+ DartString leftString = op1.constant.value;
+ DartString otherString = null;
+ if (right.isConstantString()) {
+ otherString = op2.constant.value;
+ } else {
+ assert(op2.isConstantNumber() ||
+ op2.isConstantBoolean() ||
+ op2.isConstantNull());
+ otherString = new DartString.literal(op2.constant.value.toString());
+ }
+ DartString cons = new DartString.concat(leftString, otherString);
+ return graph.addConstantString(cons);
+ }
+ return super.fold(graph);
+ }
+
int typeCode() => 5;
bool typeEquals(other) => other is HAdd;
bool dataEquals(HInstruction other) => true;

Powered by Google App Engine
This is Rietveld 408576698