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

Unified Diff: pkg/compiler/lib/src/tree/nodes.dart

Issue 1325843003: Add optional message to assert in Dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Reintroduce assertHelper for asserts without messages. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/tree/nodes.dart
diff --git a/pkg/compiler/lib/src/tree/nodes.dart b/pkg/compiler/lib/src/tree/nodes.dart
index 6c4516b416efd886b4e4afb3fa48870660a0b5f5..7ef28dcb7764aeaf3647454e861978f1e42e0a87 100644
--- a/pkg/compiler/lib/src/tree/nodes.dart
+++ b/pkg/compiler/lib/src/tree/nodes.dart
@@ -9,6 +9,7 @@ abstract class Visitor<R> {
R visitNode(Node node);
+ R visitAssert(Assert node) => visitStatement(node);
R visitAsyncForIn(AsyncForIn node) => visitLoop(node);
R visitAsyncModifier(AsyncModifier node) => visitNode(node);
R visitAwait(Await node) => visitExpression(node);
@@ -146,6 +147,7 @@ abstract class Node extends NullTreeElementMixin implements Spannable {
Token getEndToken();
+ Assert asAssert() => null;
AsyncModifier asAsyncModifier() => null;
Await asAwait() => null;
Block asBlock() => null;
@@ -1211,6 +1213,30 @@ class Await extends Expression {
Token getEndToken() => expression.getEndToken();
}
+class Assert extends Statement {
+ final Token assertToken;
+ final Expression condition;
+ /** Message may be `null`. */
+ final Expression message;
+ final Token semicolonToken;
+
+ Assert(this.assertToken, this.condition, this.message, this.semicolonToken);
+
+ Assert asAssert() => this;
+
+ bool get hasMessage => message != null;
+
+ accept(Visitor visitor) => visitor.visitAssert(this);
+
+ visitChildren(Visitor visitor) {
+ condition.accept(visitor);
+ if (message != null) message.accept(visitor);
+ }
+
+ Token getBeginToken() => assertToken;
+ Token getEndToken() => semicolonToken;
+}
+
class Rethrow extends Statement {
final Token throwToken;
final Token endToken;

Powered by Google App Engine
This is Rietveld 408576698