Skip to content

Commit 29ea1b2

Browse files
committed
Ruby: rename getSelfVariableAccess to getReceiver
1 parent f6ca392 commit 29ea1b2

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

ruby/ql/lib/codeql/ruby/ast/Variable.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ class InstanceVariableAccess extends VariableAccess instanceof InstanceVariableA
183183
final override string getAPrimaryQlClass() { result = "InstanceVariableAccess" }
184184

185185
/**
186-
* Gets a synthetic `self` variable access.
186+
* Gets the synthetic receiver(`self`) of this instance variable access.
187187
*/
188-
final SelfVariableAccess getSelfVariableAccess() { synthChild(this, 0, result) }
188+
final SelfVariableAccess getReceiver() { synthChild(this, 0, result) }
189189

190190
final override AstNode getAChild(string pred) {
191191
result = VariableAccess.super.getAChild(pred)
192192
or
193-
pred = "getSelfVariableAccess" and result = this.getSelfVariableAccess()
193+
pred = "getReceiver" and result = this.getReceiver()
194194
}
195195
}
196196

ruby/ql/lib/codeql/ruby/controlflow/CfgNodes.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ module ExprNodes {
616616
}
617617

618618
private class InstanceVariableAccessMapping extends ExprChildMapping, InstanceVariableAccess {
619-
override predicate relevantChild(AstNode n) { n = this.getSelfVariableAccess() }
619+
override predicate relevantChild(AstNode n) { n = this.getReceiver() }
620620
}
621621

622622
/** A control-flow node that wraps a `InstanceVariableAccess` AST expression. */
@@ -626,9 +626,9 @@ module ExprNodes {
626626
final override InstanceVariableAccess getExpr() { result = ExprCfgNode.super.getExpr() }
627627

628628
/**
629-
* Gets a synthetic `self` variable access.
629+
* Gets the synthetic receiver(`self`) of this instance variable access.
630630
*/
631-
final CfgNode getSelfVariableAccess() { e.hasCfgChild(e.getSelfVariableAccess(), this, result) }
631+
final CfgNode getReceiver() { e.hasCfgChild(e.getReceiver(), this, result) }
632632
}
633633

634634
/** A control-flow node that wraps a `VariableWriteAccess` AST expression. */

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ module Trees {
10081008

10091009
private class InstanceVariableTree extends StandardPostOrderTree, InstanceVariableAccess {
10101010
final override ControlFlowTree getChildElement(int i) {
1011-
result = this.getSelfVariableAccess() and i = 0
1011+
result = this.getReceiver() and i = 0
10121012
}
10131013
}
10141014

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private module Cached {
219219
TBlockParameterNode(MethodBase m) or
220220
TExprPostUpdateNode(CfgNodes::ExprCfgNode n) {
221221
n instanceof Argument or
222-
n = any(CfgNodes::ExprNodes::InstanceVariableAccessCfgNode v).getSelfVariableAccess()
222+
n = any(CfgNodes::ExprNodes::InstanceVariableAccessCfgNode v).getReceiver()
223223
} or
224224
TSummaryNode(
225225
FlowSummaryImpl::Public::SummarizedCallable c,
@@ -804,7 +804,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
804804
ct.getName() = var.getExpr().getVariable().getName()
805805
))
806806
)
807-
).getSelfVariableAccess()
807+
).getReceiver()
808808
or
809809
FlowSummaryImpl::Private::Steps::summaryStoreStep(node1, c, node2)
810810
}
@@ -817,7 +817,7 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
817817
node2.asExpr() =
818818
any(CfgNodes::ExprNodes::InstanceVariableAccessCfgNode var |
819819
var.getExpr() instanceof InstanceVariableReadAccess and
820-
node1.asExpr() = var.getSelfVariableAccess() and
820+
node1.asExpr() = var.getReceiver() and
821821
c.isSingleton(any(Content::FieldContent ct |
822822
ct.getName() = var.getExpr().getVariable().getName()
823823
))

ruby/ql/test/library-tests/ast/Ast.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ control/cases.rb:
12341234
# 150| getBranch: [InClause] in ... then ...
12351235
# 150| getPattern: [ReferencePattern] ^...
12361236
# 150| getExpr: [InstanceVariableAccess] @foo
1237-
# 150| getSelfVariableAccess: [SelfVariableAccess] self
1237+
# 150| getReceiver: [SelfVariableAccess] self
12381238
# 151| getBranch: [InClause] in ... then ...
12391239
# 151| getPattern: [ReferencePattern] ^...
12401240
# 151| getExpr: [ClassVariableAccess] @@foo
@@ -1247,7 +1247,7 @@ control/cases.rb:
12471247
# 156| getBranch: [InClause] in ... then ...
12481248
# 156| getPattern: [ReferencePattern] ^...
12491249
# 156| getExpr: [InstanceVariableAccess] @foo
1250-
# 156| getSelfVariableAccess: [SelfVariableAccess] self
1250+
# 156| getReceiver: [SelfVariableAccess] self
12511251
# 157| getBranch: [InClause] in ... then ...
12521252
# 157| getPattern: [ReferencePattern] ^...
12531253
# 157| getExpr: [AddExpr] ... + ...
@@ -2773,11 +2773,11 @@ operations/operations.rb:
27732773
# 87| getStmt: [ClassDeclaration] X
27742774
# 88| getStmt: [AssignExpr] ... = ...
27752775
# 88| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x
2776-
# 88| getSelfVariableAccess: [SelfVariableAccess] self
2776+
# 88| getReceiver: [SelfVariableAccess] self
27772777
# 88| getAnOperand/getRightOperand: [IntegerLiteral] 1
27782778
# 89| getStmt: [AssignAddExpr] ... += ...
27792779
# 89| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x
2780-
# 89| getSelfVariableAccess: [SelfVariableAccess] self
2780+
# 89| getReceiver: [SelfVariableAccess] self
27812781
# 89| getAnOperand/getRightOperand: [IntegerLiteral] 2
27822782
# 91| getStmt: [AssignExpr] ... = ...
27832783
# 91| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y

ruby/ql/test/library-tests/ast/AstDesugar.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,10 @@ operations/operations.rb:
836836
# 89| [AssignAddExpr] ... += ...
837837
# 89| getDesugared: [AssignExpr] ... = ...
838838
# 89| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x
839-
# 89| getSelfVariableAccess: [SelfVariableAccess] self
839+
# 89| getReceiver: [SelfVariableAccess] self
840840
# 89| getAnOperand/getRightOperand: [AddExpr] ... + ...
841841
# 89| getAnOperand/getLeftOperand/getReceiver: [InstanceVariableAccess] @x
842-
# 89| getSelfVariableAccess: [SelfVariableAccess] self
842+
# 89| getReceiver: [SelfVariableAccess] self
843843
# 89| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 2
844844
# 92| [AssignDivExpr] ... /= ...
845845
# 92| getDesugared: [AssignExpr] ... = ...

0 commit comments

Comments
 (0)