@@ -41,61 +41,59 @@ private import codeql.ruby.controlflow.ControlFlowGraph
4141private import Completion
4242import ControlFlowGraphImplShared
4343
44- module CfgScope {
45- abstract class Range_ extends AstNode {
46- abstract predicate entry ( AstNode first ) ;
44+ abstract class CfgScopeImpl extends AstNode {
45+ abstract predicate entry ( AstNode first ) ;
4746
48- abstract predicate exit ( AstNode last , Completion c ) ;
49- }
47+ abstract predicate exit ( AstNode last , Completion c ) ;
48+ }
5049
51- private class ToplevelScope extends Range_ , Toplevel {
52- final override predicate entry ( AstNode first ) { first ( this , first ) }
50+ private class ToplevelScope extends CfgScopeImpl , Toplevel {
51+ final override predicate entry ( AstNode first ) { first ( this , first ) }
5352
54- final override predicate exit ( AstNode last , Completion c ) { last ( this , last , c ) }
55- }
53+ final override predicate exit ( AstNode last , Completion c ) { last ( this , last , c ) }
54+ }
5655
57- private class EndBlockScope extends Range_ , EndBlock {
58- final override predicate entry ( AstNode first ) {
59- first ( this .( Trees:: EndBlockTree ) .getBodyChild ( 0 , _) , first )
60- }
56+ private class EndBlockScope extends CfgScopeImpl , EndBlock {
57+ final override predicate entry ( AstNode first ) {
58+ first ( this .( Trees:: EndBlockTree ) .getBodyChild ( 0 , _) , first )
59+ }
6160
62- final override predicate exit ( AstNode last , Completion c ) {
63- last ( this .( Trees:: EndBlockTree ) .getLastBodyChild ( ) , last , c )
64- or
65- last ( this .( Trees:: EndBlockTree ) .getBodyChild ( _, _) , last , c ) and
66- not c instanceof NormalCompletion
67- }
61+ final override predicate exit ( AstNode last , Completion c ) {
62+ last ( this .( Trees:: EndBlockTree ) .getLastBodyChild ( ) , last , c )
63+ or
64+ last ( this .( Trees:: EndBlockTree ) .getBodyChild ( _, _) , last , c ) and
65+ not c instanceof NormalCompletion
6866 }
67+ }
6968
70- private class BodyStmtCallableScope extends Range_ , ASTInternal:: TBodyStmt , Callable {
71- final override predicate entry ( AstNode first ) { this .( Trees:: BodyStmtTree ) .firstInner ( first ) }
69+ private class BodyStmtCallableScope extends CfgScopeImpl , ASTInternal:: TBodyStmt , Callable {
70+ final override predicate entry ( AstNode first ) { this .( Trees:: BodyStmtTree ) .firstInner ( first ) }
7271
73- final override predicate exit ( AstNode last , Completion c ) {
74- this .( Trees:: BodyStmtTree ) .lastInner ( last , c )
75- }
72+ final override predicate exit ( AstNode last , Completion c ) {
73+ this .( Trees:: BodyStmtTree ) .lastInner ( last , c )
7674 }
75+ }
7776
78- private class BraceBlockScope extends Range_ , BraceBlock {
79- final override predicate entry ( AstNode first ) {
80- first ( this .( Trees:: BraceBlockTree ) .getBodyChild ( 0 , _) , first )
81- }
77+ private class BraceBlockScope extends CfgScopeImpl , BraceBlock {
78+ final override predicate entry ( AstNode first ) {
79+ first ( this .( Trees:: BraceBlockTree ) .getBodyChild ( 0 , _) , first )
80+ }
8281
83- final override predicate exit ( AstNode last , Completion c ) {
84- last ( this .( Trees:: BraceBlockTree ) .getLastBodyChild ( ) , last , c )
85- or
86- last ( this .( Trees:: BraceBlockTree ) .getBodyChild ( _, _) , last , c ) and
87- not c instanceof NormalCompletion
88- }
82+ final override predicate exit ( AstNode last , Completion c ) {
83+ last ( this .( Trees:: BraceBlockTree ) .getLastBodyChild ( ) , last , c )
84+ or
85+ last ( this .( Trees:: BraceBlockTree ) .getBodyChild ( _, _) , last , c ) and
86+ not c instanceof NormalCompletion
8987 }
9088}
9189
9290/** Holds if `first` is first executed when entering `scope`. */
9391pragma [ nomagic]
94- predicate succEntry ( CfgScope :: Range_ scope , AstNode first ) { scope .entry ( first ) }
92+ predicate succEntry ( CfgScopeImpl scope , AstNode first ) { scope .entry ( first ) }
9593
9694/** Holds if `last` with completion `c` can exit `scope`. */
9795pragma [ nomagic]
98- predicate succExit ( CfgScope :: Range_ scope , AstNode last , Completion c ) { scope .exit ( last , c ) }
96+ predicate succExit ( CfgScopeImpl scope , AstNode last , Completion c ) { scope .exit ( last , c ) }
9997
10098/** Defines the CFG by dispatch on the various AST types. */
10199module Trees {
@@ -1431,7 +1429,7 @@ module Trees {
14311429
14321430private Scope parent ( Scope n ) {
14331431 result = n .getOuterScope ( ) and
1434- not n instanceof CfgScope :: Range_
1432+ not n instanceof CfgScopeImpl
14351433}
14361434
14371435cached
0 commit comments