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

Side by Side Diff: dart/pkg/compiler/lib/src/constants/expressions.dart

Issue 829033004: Non-fatal errors in compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42767. Created 5 years, 11 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
« no previous file with comments | « dart/pkg/compiler/lib/src/compile_time_constants.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/compile_time_constants.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698