PS: Don't include the this parameter in getParameter.

This commit is contained in:
Mathias Vorreiter Pedersen
2025-03-27 18:01:28 +00:00
parent cea435cf1f
commit dcb98ab5a1
2 changed files with 31 additions and 3 deletions

View File

@@ -79,6 +79,9 @@ class ScriptBlock extends Ast, TScriptBlock {
result = this.getParameter(index)
)
or
i = ThisVar() and
result = this.getThisParameter()
or
exists(int index |
i = scriptBlockUsing(index) and
result = this.getUsingStmt(index)
@@ -90,13 +93,14 @@ class ScriptBlock extends Ast, TScriptBlock {
or
any(Synthesis s).pipelineParameterHasIndex(this, i) and
synthChild(getRawAst(this), PipelineParamVar(), result)
or
i = -1 and
synthChild(getRawAst(this), ThisVar(), result)
}
Parameter getThisParameter() { synthChild(getRawAst(this), ThisVar(), result) }
/**
* Gets a parameter of this block.
*
* Note: This does not include the `this` parameter, but it does include pipeline parameters.
*/
Parameter getAParameter() { result = this.getParameter(_) }

View File

@@ -151,6 +151,30 @@ module Trees {
override predicate succ(AstNode pred, AstNode succ, Completion c) {
this.succEntry(pred, c) and
(
first(super.getThisParameter(), succ)
or
not exists(super.getThisParameter()) and
first(super.getParameter(0), succ)
or
not exists(super.getThisParameter()) and
not exists(super.getAParameter()) and
first(super.getBeginBlock(), succ)
or
not exists(super.getThisParameter()) and
not exists(super.getAParameter()) and
not exists(super.getBeginBlock()) and
first(super.getProcessBlock(), succ)
or
not exists(super.getThisParameter()) and
not exists(super.getAParameter()) and
not exists(super.getBeginBlock()) and
not exists(super.getProcessBlock()) and
first(super.getEndBlock(), succ)
)
or
last(super.getThisParameter(), pred, c) and
completionIsNormal(c) and
(
first(super.getParameter(0), succ)
or