@@ -35,9 +35,7 @@ private newtype TCompletion =
3535 TBreakCompletion ( ) or
3636 TBreakNormalCompletion ( ) or
3737 TContinueCompletion ( ) or
38- TGotoLabelCompletion ( GotoLabelStmt goto ) or
39- TGotoCaseCompletion ( GotoCaseStmt goto ) or
40- TGotoDefaultCompletion ( ) or
38+ TGotoCompletion ( string label ) { label = any ( GotoStmt gs ) .getLabel ( ) } or
4139 TThrowCompletion ( ExceptionClass ec ) or
4240 TExitCompletion ( ) or
4341 TNestedCompletion ( NormalCompletion inner , Completion outer ) {
@@ -47,11 +45,7 @@ private newtype TCompletion =
4745 or
4846 outer = TContinueCompletion ( )
4947 or
50- outer = TGotoLabelCompletion ( _)
51- or
52- outer = TGotoCaseCompletion ( _)
53- or
54- outer = TGotoDefaultCompletion ( )
48+ outer = TGotoCompletion ( _)
5549 or
5650 outer = TThrowCompletion ( _)
5751 or
@@ -122,22 +116,17 @@ class Completion extends TCompletion {
122116 if cfe instanceof ContinueStmt
123117 then this = TContinueCompletion ( )
124118 else
125- if cfe instanceof GotoDefaultStmt
126- then this = TGotoDefaultCompletion ( )
119+ if cfe instanceof GotoStmt
120+ then this = TGotoCompletion ( cfe . ( GotoStmt ) . getLabel ( ) )
127121 else
128- if cfe instanceof GotoStmt
129- then
130- this = TGotoLabelCompletion ( cfe ) or
131- this = TGotoCaseCompletion ( cfe )
122+ if cfe instanceof ReturnStmt
123+ then this = TReturnCompletion ( )
132124 else
133- if cfe instanceof ReturnStmt
134- then this = TReturnCompletion ( )
135- else
136- if cfe instanceof YieldBreakStmt
137- then
138- // `yield break` behaves like a return statement
139- this = TReturnCompletion ( )
140- else this = TNormalCompletion ( )
125+ if cfe instanceof YieldBreakStmt
126+ then
127+ // `yield break` behaves like a return statement
128+ this = TReturnCompletion ( )
129+ else this = TNormalCompletion ( )
141130 )
142131 }
143132
@@ -726,69 +715,20 @@ class ContinueCompletion extends Completion {
726715 * A completion that represents evaluation of a statement or an
727716 * expression resulting in a `goto` jump.
728717 */
729- abstract class GotoCompletion extends Completion { }
730-
731- /**
732- * A completion that represents evaluation of a statement or an
733- * expression resulting in a `goto label` jump.
734- */
735- class GotoLabelCompletion extends GotoCompletion {
736- private GotoLabelStmt goto ;
737-
738- GotoLabelCompletion ( ) {
739- this = TGotoLabelCompletion ( goto ) or
740- this = TNestedCompletion ( _, TGotoLabelCompletion ( goto ) )
741- }
742-
743- /** Gets the target of the `goto label` completion. */
744- string getLabel ( ) { result = this .getGotoStmt ( ) .getLabel ( ) }
745-
746- /** Gets the statement that resulted in this `goto label` completion. */
747- GotoLabelStmt getGotoStmt ( ) { result = goto }
748-
749- override string toString ( ) {
750- // `NestedCompletion` defines `toString()` for the other case
751- this = TGotoLabelCompletion ( goto ) and result = "goto(" + this .getLabel ( ) + ")"
752- }
753- }
754-
755- /**
756- * A completion that represents evaluation of a statement or an
757- * expression resulting in a `goto case` jump.
758- */
759- class GotoCaseCompletion extends GotoCompletion {
760- private GotoCaseStmt goto ;
718+ class GotoCompletion extends Completion {
719+ private string label ;
761720
762- GotoCaseCompletion ( ) {
763- this = TGotoCaseCompletion ( goto ) or
764- this = TNestedCompletion ( _, TGotoCaseCompletion ( goto ) )
721+ GotoCompletion ( ) {
722+ this = TGotoCompletion ( label ) or
723+ this = TNestedCompletion ( _, TGotoCompletion ( label ) )
765724 }
766725
767- /** Gets the target of the `goto case` completion. */
768- string getLabel ( ) { result = this .getGotoStmt ( ) .getLabel ( ) }
769-
770- /** Gets the statement that resulted in this `goto case` completion. */
771- GotoCaseStmt getGotoStmt ( ) { result = goto }
772-
773- override string toString ( ) {
774- // `NestedCompletion` defines `toString()` for the other case
775- this = TGotoCaseCompletion ( goto ) and result = "goto case(" + this .getLabel ( ) + ")"
776- }
777- }
778-
779- /**
780- * A completion that represents evaluation of a statement or an
781- * expression resulting in a `goto default` jump.
782- */
783- class GotoDefaultCompletion extends GotoCompletion {
784- GotoDefaultCompletion ( ) {
785- this = TGotoDefaultCompletion ( ) or
786- this = TNestedCompletion ( _, TGotoDefaultCompletion ( ) )
787- }
726+ /** Gets the label of the `goto` completion. */
727+ string getLabel ( ) { result = label }
788728
789729 override string toString ( ) {
790730 // `NestedCompletion` defines `toString()` for the other case
791- this = TGotoDefaultCompletion ( ) and result = "goto default "
731+ this = TGotoCompletion ( label ) and result = "goto(" + label + ") "
792732 }
793733}
794734
0 commit comments