@@ -15,11 +15,18 @@ private newtype TCompletion =
1515 TBooleanCompletion ( boolean b ) { b in [ false , true ] } or
1616 TReturnCompletion ( ) or
1717 TBreakCompletion ( ) or
18+ TContinueCompletion ( ) or
1819 TRaiseCompletion ( ) or
1920 TExitCompletion ( )
2021
2122pragma [ noinline]
22- private predicate completionIsValidForStmt ( Ast n , Completion c ) { none ( ) }
23+ private predicate completionIsValidForStmt ( Ast n , Completion c ) {
24+ n instanceof BreakStmt and
25+ c instanceof BreakCompletion
26+ or
27+ n instanceof ContinueStmt and
28+ c instanceof ContinueCompletion
29+ }
2330
2431/** A completion of a statement or an expression. */
2532abstract class Completion extends TCompletion {
@@ -49,19 +56,10 @@ abstract class Completion extends TCompletion {
4956 * Holds if this completion will continue a loop when it is the completion
5057 * of a loop body.
5158 */
52- predicate continuesLoop ( ) { this instanceof NormalCompletion }
53-
54- /**
55- * Gets the inner completion. This is either the inner completion,
56- * when the completion is nested, or the completion itself.
57- */
58- Completion getInnerCompletion ( ) { result = this }
59-
60- /**
61- * Gets the outer completion. This is either the outer completion,
62- * when the completion is nested, or the completion itself.
63- */
64- Completion getOuterCompletion ( ) { result = this }
59+ predicate continuesLoop ( ) {
60+ this instanceof NormalCompletion or
61+ this instanceof ContinueCompletion
62+ }
6563
6664 /** Gets a successor type that matches this completion. */
6765 abstract SuccessorType getAMatchingSuccessorType ( ) ;
@@ -159,6 +157,16 @@ class BreakCompletion extends Completion, TBreakCompletion {
159157 override string toString ( ) { result = "break" }
160158}
161159
160+ /**
161+ * A completion that represents evaluation of a statement or an
162+ * expression resulting in a continuation of a loop.
163+ */
164+ class ContinueCompletion extends Completion , TContinueCompletion {
165+ override ContinueSuccessor getAMatchingSuccessorType ( ) { any ( ) }
166+
167+ override string toString ( ) { result = "continue" }
168+ }
169+
162170/**
163171 * A completion that represents evaluation of a statement or an
164172 * expression resulting in a thrown exception.
0 commit comments