| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.constants.expressions; | 5 library dart2js.constants.expressions; |
| 6 | 6 |
| 7 import '../dart2jslib.dart' show assertDebugMode; | 7 import '../dart2jslib.dart' show assertDebugMode; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart' show | 9 import '../elements/elements.dart' show |
| 10 Element, | 10 Element, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return printer.toString(); | 38 return printer.toString(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 String toString() { | 41 String toString() { |
| 42 assertDebugMode('Use ConstantExpression.getText() instead of ' | 42 assertDebugMode('Use ConstantExpression.getText() instead of ' |
| 43 'ConstantExpression.toString()'); | 43 'ConstantExpression.toString()'); |
| 44 return getText(); | 44 return getText(); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 /// A synthetic constant used to recover from errors. |
| 49 class ErroneousConstantExpression extends ConstantExpression { |
| 50 final PrimitiveConstantValue value = new NullConstantValue(); |
| 51 |
| 52 ErroneousConstantExpression(); |
| 53 |
| 54 accept(ConstantExpressionVisitor visitor, [context]) { |
| 55 // Do nothing. This is an error. |
| 56 } |
| 57 } |
| 58 |
| 48 /// Boolean, int, double, string, or null constant. | 59 /// Boolean, int, double, string, or null constant. |
| 49 class PrimitiveConstantExpression extends ConstantExpression { | 60 class PrimitiveConstantExpression extends ConstantExpression { |
| 50 final PrimitiveConstantValue value; | 61 final PrimitiveConstantValue value; |
| 51 | 62 |
| 52 PrimitiveConstantExpression(this.value) { | 63 PrimitiveConstantExpression(this.value) { |
| 53 assert(value != null); | 64 assert(value != null); |
| 54 } | 65 } |
| 55 | 66 |
| 56 accept(ConstantExpressionVisitor visitor, [context]) { | 67 accept(ConstantExpressionVisitor visitor, [context]) { |
| 57 return visitor.visitPrimitive(this, context); | 68 return visitor.visitPrimitive(this, context); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 void visitConditional(ConditionalConstantExpression exp, [_]) { | 459 void visitConditional(ConditionalConstantExpression exp, [_]) { |
| 449 write(exp, exp.condition, leftAssociative: false); | 460 write(exp, exp.condition, leftAssociative: false); |
| 450 sb.write(' ? '); | 461 sb.write(' ? '); |
| 451 write(exp, exp.trueExp); | 462 write(exp, exp.trueExp); |
| 452 sb.write(' : '); | 463 sb.write(' : '); |
| 453 write(exp, exp.falseExp); | 464 write(exp, exp.falseExp); |
| 454 } | 465 } |
| 455 | 466 |
| 456 String toString() => sb.toString(); | 467 String toString() => sb.toString(); |
| 457 } | 468 } |
| OLD | NEW |