| 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 package com.google.dart.compiler.ast; | 5 package com.google.dart.compiler.ast; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Implements the "assert" statement. | 8 * Implements the "assert" statement. |
| 9 */ | 9 */ |
| 10 public class DartAssertion extends DartStatement { | 10 public class DartAssertion extends DartStatement { |
| 11 private DartExpression expression; | 11 private DartExpression expression; |
| 12 private DartExpression message; | |
| 13 | 12 |
| 14 public DartAssertion(DartExpression expression, DartExpression message) { | 13 public DartAssertion(DartExpression expression) { |
| 15 this.expression = becomeParentOf(expression); | 14 this.expression = becomeParentOf(expression); |
| 16 this.message = becomeParentOf(message); | |
| 17 } | 15 } |
| 18 | 16 |
| 19 public void setExpression(DartExpression expression) { | 17 public void setExpression(DartExpression expression) { |
| 20 this.expression = expression; | 18 this.expression = expression; |
| 21 } | 19 } |
| 22 | 20 |
| 23 public DartExpression getExpression() { | 21 public DartExpression getExpression() { |
| 24 return expression; | 22 return expression; |
| 25 } | 23 } |
| 26 | 24 |
| 27 public void setMessage(DartExpression message) { | |
| 28 this.message = message; | |
| 29 } | |
| 30 | |
| 31 public DartExpression getMessage() { | |
| 32 return message; | |
| 33 } | |
| 34 | |
| 35 @Override | 25 @Override |
| 36 public void traverse(DartVisitor v, DartContext ctx) { | 26 public void traverse(DartVisitor v, DartContext ctx) { |
| 37 if (v.visit(this, ctx)) { | 27 if (v.visit(this, ctx)) { |
| 38 expression = becomeParentOf(v.accept(expression)); | 28 expression = becomeParentOf(v.accept(expression)); |
| 39 if (message != null) { | |
| 40 message = becomeParentOf(v.accept(message)); | |
| 41 } | |
| 42 } | 29 } |
| 43 v.endVisit(this, ctx); | 30 v.endVisit(this, ctx); |
| 44 } | 31 } |
| 45 | 32 |
| 46 @Override | 33 @Override |
| 47 public void visitChildren(DartPlainVisitor<?> visitor) { | 34 public void visitChildren(DartPlainVisitor<?> visitor) { |
| 48 expression.accept(visitor); | 35 expression.accept(visitor); |
| 49 if (message != null) { | |
| 50 message.accept(visitor); | |
| 51 } | |
| 52 } | 36 } |
| 53 | 37 |
| 54 @Override | 38 @Override |
| 55 public <R> R accept(DartPlainVisitor<R> visitor) { | 39 public <R> R accept(DartPlainVisitor<R> visitor) { |
| 56 return visitor.visitAssertion(this); | 40 return visitor.visitAssertion(this); |
| 57 } | 41 } |
| 58 } | 42 } |
| OLD | NEW |