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

Side by Side Diff: pkg/compiler/lib/src/tree/unparser.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of tree; 5 part of tree;
6 6
7 String unparse(Node node, {minify: true}) { 7 String unparse(Node node, {minify: true}) {
8 Unparser unparser = new Unparser(minify: minify); 8 Unparser unparser = new Unparser(minify: minify);
9 unparser.unparse(node); 9 unparser.unparse(node);
10 return unparser.result; 10 return unparser.result;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 sb.write(s); 51 sb.write(s);
52 onEmptyLine = false; 52 onEmptyLine = false;
53 } 53 }
54 54
55 unparse(Node node) { visit(node); } 55 unparse(Node node) { visit(node); }
56 56
57 visit(Node node) { 57 visit(Node node) {
58 if (node != null) node.accept(this); 58 if (node != null) node.accept(this);
59 } 59 }
60 60
61 visitAssert(Assert node) {
62 write(node.assertToken.value);
63 write('(');
64 visit(node.condition);
65 if (node.hasMessage) {
66 write(',');
67 space();
68 visit(node.message);
69 }
70 write(');');
71 }
72
61 visitBlock(Block node) => unparseBlockStatements(node.statements); 73 visitBlock(Block node) => unparseBlockStatements(node.statements);
62 74
63 unparseBlockStatements(NodeList statements) { 75 unparseBlockStatements(NodeList statements) {
64 addToken(statements.beginToken); 76 addToken(statements.beginToken);
65 77
66 Link<Node> nodes = statements.nodes; 78 Link<Node> nodes = statements.nodes;
67 if (nodes != null && !nodes.isEmpty) { 79 if (nodes != null && !nodes.isEmpty) {
68 indentMore(); 80 indentMore();
69 newline(); 81 newline();
70 visit(nodes.head); 82 visit(nodes.head);
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 862 }
851 863
852 visitStatement(Statement node) { 864 visitStatement(Statement node) {
853 throw 'internal error'; // Should not be called. 865 throw 'internal error'; // Should not be called.
854 } 866 }
855 867
856 visitStringNode(StringNode node) { 868 visitStringNode(StringNode node) {
857 throw 'internal error'; // Should not be called. 869 throw 'internal error'; // Should not be called.
858 } 870 }
859 } 871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698