Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 | 1390 |
| 1391 // TODO(1603): The class should be marked as abstract. | 1391 // TODO(1603): The class should be marked as abstract. |
| 1392 abstract BinaryOperation get operation(); | 1392 abstract BinaryOperation get operation(); |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 class HAdd extends HBinaryArithmetic { | 1395 class HAdd extends HBinaryArithmetic { |
| 1396 HAdd(HStatic target, HInstruction left, HInstruction right) | 1396 HAdd(HStatic target, HInstruction left, HInstruction right) |
| 1397 : super(target, left, right); | 1397 : super(target, left, right); |
| 1398 accept(HVisitor visitor) => visitor.visitAdd(this); | 1398 accept(HVisitor visitor) => visitor.visitAdd(this); |
| 1399 | 1399 |
| 1400 bool get builtin() { | 1400 bool get builtin() => left.isNumber() && right.isNumber(); |
|
kasperl
2012/06/18 11:35:55
This isn't needed anymore.
ahe
2012/06/18 11:47:19
Because this is what the superclass does already.
| |
| 1401 return (left.isNumber() && right.isNumber()) | |
| 1402 || (left.isString() && right.isString()) | |
| 1403 || (left.isString() && right is HConstant); | |
| 1404 } | |
| 1405 | 1401 |
| 1406 HType computeTypeFromInputTypes() { | 1402 HType computeTypeFromInputTypes() { |
| 1407 if (left.isInteger() && right.isInteger()) return left.propagatedType; | 1403 if (left.isInteger() && right.isInteger()) return left.propagatedType; |
| 1408 if (left.isNumber()) { | 1404 if (left.isNumber()) { |
| 1409 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; | 1405 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; |
| 1410 return HType.NUMBER; | 1406 return HType.NUMBER; |
| 1411 } | 1407 } |
| 1412 if (left.isString()) return HType.STRING; | |
| 1413 return HType.UNKNOWN; | 1408 return HType.UNKNOWN; |
| 1414 } | 1409 } |
| 1415 | 1410 |
| 1416 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1411 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1417 // If the desired output type is an integer we want two integers as input. | 1412 // If the desired output type is an integer we want two integers as input. |
| 1418 if (propagatedType.isInteger()) { | 1413 if (propagatedType.isInteger()) { |
| 1419 return HType.INTEGER; | 1414 return HType.INTEGER; |
| 1420 } | 1415 } |
| 1421 // TODO(floitsch): remove string specialization once string+ is removed | |
| 1422 // from dart2js. | |
| 1423 if (propagatedType.isString() || left.isString() || right.isString()) { | |
| 1424 return HType.STRING; | |
| 1425 } | |
| 1426 // If the desired output is a number or any of the inputs is a number | 1416 // If the desired output is a number or any of the inputs is a number |
| 1427 // ask for a number. Note that we might return the input's (say 'left') | 1417 // ask for a number. Note that we might return the input's (say 'left') |
| 1428 // type depending on its (the 'left's) type. But that shouldn't matter. | 1418 // type depending on its (the 'left's) type. But that shouldn't matter. |
| 1429 if (propagatedType.isNumber() || left.isNumber() || right.isNumber()) { | 1419 if (propagatedType.isNumber() || left.isNumber() || right.isNumber()) { |
| 1430 return HType.NUMBER; | 1420 return HType.NUMBER; |
| 1431 } | 1421 } |
| 1432 return HType.UNKNOWN; | 1422 return HType.UNKNOWN; |
| 1433 } | 1423 } |
| 1434 | 1424 |
| 1435 HType get likelyType() { | 1425 HType get likelyType() { |
| 1436 if (left.isString() || right.isString()) return HType.STRING; | |
| 1437 if (left.isTypeUnknown() || left.isNumber()) return HType.NUMBER; | 1426 if (left.isTypeUnknown() || left.isNumber()) return HType.NUMBER; |
| 1438 return HType.UNKNOWN; | 1427 return HType.UNKNOWN; |
| 1439 } | 1428 } |
| 1440 | 1429 |
| 1441 AddOperation get operation() => const AddOperation(); | 1430 AddOperation get operation() => const AddOperation(); |
| 1442 | 1431 |
| 1443 int typeCode() => 5; | 1432 int typeCode() => 5; |
| 1444 bool typeEquals(other) => other is HAdd; | 1433 bool typeEquals(other) => other is HAdd; |
| 1445 bool dataEquals(HInstruction other) => true; | 1434 bool dataEquals(HInstruction other) => true; |
| 1446 } | 1435 } |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2593 HBasicBlock get start() => expression.start; | 2582 HBasicBlock get start() => expression.start; |
| 2594 HBasicBlock get end() { | 2583 HBasicBlock get end() { |
| 2595 // We don't create a switch block if there are no cases. | 2584 // We don't create a switch block if there are no cases. |
| 2596 assert(!statements.isEmpty()); | 2585 assert(!statements.isEmpty()); |
| 2597 return statements.last().end; | 2586 return statements.last().end; |
| 2598 } | 2587 } |
| 2599 | 2588 |
| 2600 bool accept(HStatementInformationVisitor visitor) => | 2589 bool accept(HStatementInformationVisitor visitor) => |
| 2601 visitor.visitSwitchInfo(this); | 2590 visitor.visitSwitchInfo(this); |
| 2602 } | 2591 } |
| OLD | NEW |