Skip to content

Commit

Permalink
Ruby: Restrict CfgScope
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Sep 25, 2024
1 parent 1bd504b commit 656969e
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ abstract class CfgScopeImpl extends AstNode {
}

private class ToplevelScope extends CfgScopeImpl, Toplevel {
ToplevelScope() { exists(this.getAStmt()) }

final override predicate entry(AstNode first) { first(this, first) }

final override predicate exit(AstNode last, Completion c) { last(this, last, c) }
}

private class EndBlockScope extends CfgScopeImpl, EndBlock {
EndBlockScope() { exists(this.getAStmt()) }

final override predicate entry(AstNode first) {
first(this.(Trees::EndBlockTree).getBodyChild(0, _), first)
}
Expand All @@ -95,6 +99,8 @@ private class EndBlockScope extends CfgScopeImpl, EndBlock {
}

private class BodyStmtCallableScope extends CfgScopeImpl, AstInternal::TBodyStmt, Callable {
BodyStmtCallableScope() { exists(this.getAStmt()) }

final override predicate entry(AstNode first) { this.(Trees::BodyStmtTree).firstInner(first) }

final override predicate exit(AstNode last, Completion c) {
Expand All @@ -103,6 +109,8 @@ private class BodyStmtCallableScope extends CfgScopeImpl, AstInternal::TBodyStmt
}

private class BraceBlockScope extends CfgScopeImpl, BraceBlock {
BraceBlockScope() { exists(this.getAStmt()) }

final override predicate entry(AstNode first) {
first(this.(Trees::BraceBlockTree).getBodyChild(0, _), first)
}
Expand Down

0 comments on commit 656969e

Please sign in to comment.