@@ -91,25 +91,6 @@ predicate succEntry(CfgScope::Range_ scope, AstNode first) { scope.entry(first)
9191pragma [ nomagic]
9292predicate succExit ( CfgScope:: Range_ scope , AstNode last , Completion c ) { scope .exit ( last , c ) }
9393
94- // TODO: remove this class; it should be replaced with an implicit non AST node
95- private class ForIn extends AstNode , ASTInternal:: TForIn {
96- final override string toString ( ) { result = "In" }
97- }
98-
99- // TODO: remove this class; it should be replaced with an implicit non AST node
100- private class ForRange extends ForExpr {
101- override AstNode getAChild ( string pred ) {
102- result = super .getAChild ( pred )
103- or
104- pred = "<in>" and
105- result = this .getIn ( )
106- }
107-
108- ForIn getIn ( ) {
109- result = ASTInternal:: TForIn ( ASTInternal:: toGenerated ( this ) .( Ruby:: For ) .getValue ( ) )
110- }
111- }
112-
11394/** Defines the CFG by dispatch on the various AST types. */
11495module Trees {
11596 private class AliasStmtTree extends StandardPreOrderTree , AliasStmt {
@@ -610,89 +591,6 @@ module Trees {
610591
611592 private class ForwardParameterTree extends LeafTree , ForwardParameter { }
612593
613- private class ForInTree extends LeafTree , ForIn { }
614-
615- /**
616- * Control flow of a for-in loop
617- *
618- * For example, this program fragment:
619- *
620- * ```rb
621- * for arg in args do
622- * puts arg
623- * end
624- * puts "done";
625- * ```
626- *
627- * has the following control flow graph:
628- *
629- * ```
630- * args
631- * |
632- * in------<-----
633- * / \ \
634- * / \ |
635- * / \ |
636- * / \ |
637- * empty non-empty |
638- * | \ |
639- * for \ |
640- * | arg |
641- * | | |
642- * puts "done" puts arg |
643- * \___/
644- * ```
645- */
646- private class ForTree extends PostOrderTree , ForRange {
647- final override predicate propagatesAbnormal ( AstNode child ) {
648- child = this .getPattern ( ) or child = this .getValue ( )
649- }
650-
651- final override predicate first ( AstNode first ) { first ( this .getValue ( ) , first ) }
652-
653- /**
654- * for pattern in array do body end
655- * ```
656- * array +-> in +--[non empty]--> pattern -> body -> in
657- * |--[empty]--> for
658- * ```
659- */
660- final override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
661- last ( this .getValue ( ) , pred , c ) and
662- first ( this .getIn ( ) , succ ) and
663- c instanceof SimpleCompletion
664- or
665- last ( this .getIn ( ) , pred , c ) and
666- first ( this .getPattern ( ) , succ ) and
667- c .( EmptinessCompletion ) .getValue ( ) = false
668- or
669- last ( this .getPattern ( ) , pred , c ) and
670- first ( this .getBody ( ) , succ ) and
671- c instanceof NormalCompletion
672- or
673- last ( this .getBody ( ) , pred , c ) and
674- first ( this .getIn ( ) , succ ) and
675- c .continuesLoop ( )
676- or
677- last ( this .getBody ( ) , pred , c ) and
678- first ( this .getBody ( ) , succ ) and
679- c instanceof RedoCompletion
680- or
681- succ = this and
682- (
683- last ( this .getIn ( ) , pred , c ) and
684- c .( EmptinessCompletion ) .getValue ( ) = true
685- or
686- last ( this .getBody ( ) , pred , c ) and
687- not c .continuesLoop ( ) and
688- not c instanceof BreakCompletion and
689- not c instanceof RedoCompletion
690- or
691- last ( this .getBody ( ) , pred , c .( NestedBreakCompletion ) .getAnInnerCompatibleCompletion ( ) )
692- )
693- }
694- }
695-
696594 private class GlobalVariableTree extends LeafTree , GlobalVariableAccess { }
697595
698596 private class HashLiteralTree extends StandardPostOrderTree , HashLiteral {
0 commit comments