Skip to content

Commit c427299

Browse files
osa1Commit Queue
authored and
Commit Queue
committed
[kernel] Add an example and a note in kernel BreakStatement docs
Change-Id: Ic0153a084950d2eea53e9fd8a0ee0332de5e2ae3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261841 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Ömer Ağacan <[email protected]>
1 parent cba19c0 commit c427299

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

pkg/kernel/lib/ast.dart

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9617,24 +9617,42 @@ class LabeledStatement extends Statement {
96179617

96189618
/// Breaks out of an enclosing [LabeledStatement].
96199619
///
9620-
/// Both `break` and loop `continue` statements are translated into this node.
9620+
/// Both `break` and `continue` statements are translated into this node.
96219621
///
9622-
/// For example, the following loop with a `continue` will be desugared:
9622+
/// Example `break` desugaring:
96239623
///
9624-
/// while(x) {
9624+
/// while (x) {
9625+
/// if (y) break;
9626+
/// BODY
9627+
/// }
9628+
///
9629+
/// ==>
9630+
///
9631+
/// L: while (x) {
9632+
/// if (y) break L;
9633+
/// BODY
9634+
/// }
9635+
///
9636+
/// Example `continue` desugaring:
9637+
///
9638+
/// while (x) {
96259639
/// if (y) continue;
9626-
/// BODY'
9640+
/// BODY
96279641
/// }
96289642
///
96299643
/// ==>
96309644
///
9631-
/// while(x) {
9645+
/// while (x) {
96329646
/// L: {
96339647
/// if (y) break L;
9634-
/// BODY'
9648+
/// BODY
96359649
/// }
96369650
/// }
9637-
//
9651+
///
9652+
/// Note: Compiler-generated [LabeledStatement]s for [WhileStatement]s and
9653+
/// [ForStatement]s are only generated when needed. If there isn't a `break` or
9654+
/// `continue` in a loop, the kernel for the loop won't have a generated
9655+
/// [LabeledStatement].
96389656
class BreakStatement extends Statement {
96399657
LabeledStatement target;
96409658

0 commit comments

Comments
 (0)