Skip to content

Commit

Permalink
Rust: Refactor to avoid needing getNumberOfSelfParams
Browse files Browse the repository at this point in the history
  • Loading branch information
paldepind committed Nov 20, 2024
1 parent 24adbb8 commit aab0d5e
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ import CfgImpl
class CallableScopeTree extends StandardTree, PreOrderTree, PostOrderTree, Scope::CallableScope {
override predicate propagatesAbnormal(AstNode child) { none() }

private int getNumberOfSelfParams() {
if this.getParamList().hasSelfParam() then result = 1 else result = 0
}

override AstNode getChildNode(int i) {
i = 0 and
result = this.getParamList().getSelfParam()
or
result = this.getParamList().getParam(i - this.getNumberOfSelfParams())
result = this.getParamList().getParam(i - 1)
or
i = this.getParamList().getNumberOfParams() + this.getNumberOfSelfParams() and
i = this.getParamList().getNumberOfParams() + 1 and
result = this.getBody()
}
}
Expand Down

0 comments on commit aab0d5e

Please sign in to comment.