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

Side by Side Diff: dart/lib/compiler/implementation/operations.dart

Issue 10553007: Remove support for String operator + from dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update co19 status 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 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 interface Operation { 5 interface Operation {
6 final SourceString name; 6 final SourceString name;
7 bool isUserDefinable(); 7 bool isUserDefinable();
8 } 8 }
9 9
10 interface UnaryOperation extends Operation { 10 interface UnaryOperation extends Operation {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const AddOperation(); 221 const AddOperation();
222 Constant fold(Constant left, Constant right) { 222 Constant fold(Constant left, Constant right) {
223 if (left.isInt() && right.isInt()) { 223 if (left.isInt() && right.isInt()) {
224 IntConstant leftInt = left; 224 IntConstant leftInt = left;
225 IntConstant rightInt = right; 225 IntConstant rightInt = right;
226 return new IntConstant(leftInt.value + rightInt.value); 226 return new IntConstant(leftInt.value + rightInt.value);
227 } else if (left.isNum() && right.isNum()) { 227 } else if (left.isNum() && right.isNum()) {
228 NumConstant leftNum = left; 228 NumConstant leftNum = left;
229 NumConstant rightNum = right; 229 NumConstant rightNum = right;
230 return new DoubleConstant(leftNum.value + rightNum.value); 230 return new DoubleConstant(leftNum.value + rightNum.value);
231 } else if (left.isString() && !right.isObject()) {
232 PrimitiveConstant primitiveRight = right;
233 DartString rightDartString = primitiveRight.toDartString();
234 StringConstant leftString = left;
235 if (rightDartString.isEmpty()) {
236 return left;
237 } else if (leftString.value.isEmpty()) {
238 return new StringConstant(rightDartString, leftString.node);
239 } else {
240 DartString concatenated =
241 new ConsDartString(leftString.value, rightDartString);
242 return new StringConstant(concatenated, leftString.node);
243 }
244 } else { 231 } else {
245 return null; 232 return null;
246 } 233 }
247 } 234 }
248 } 235 }
249 236
250 class RelationalNumOperation implements BinaryOperation { 237 class RelationalNumOperation implements BinaryOperation {
251 bool isUserDefinable() => true; 238 bool isUserDefinable() => true;
252 const RelationalNumOperation(); 239 const RelationalNumOperation();
253 Constant fold(Constant left, Constant right) { 240 Constant fold(Constant left, Constant right) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 bool isUserDefinable() => false; 300 bool isUserDefinable() => false;
314 const IdentityOperation(); 301 const IdentityOperation();
315 Constant fold(Constant left, Constant right) { 302 Constant fold(Constant left, Constant right) {
316 // In order to preserve runtime semantics which says that NaN !== NaN don't 303 // In order to preserve runtime semantics which says that NaN !== NaN don't
317 // constant fold NaN === NaN. Otherwise the output depends on inlined 304 // constant fold NaN === NaN. Otherwise the output depends on inlined
318 // variables and other optimizations. 305 // variables and other optimizations.
319 if (left.isNaN() && right.isNaN()) return null; 306 if (left.isNaN() && right.isNaN()) return null;
320 return new BoolConstant(left == right); 307 return new BoolConstant(left == right);
321 } 308 }
322 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698