Skip to content

Commit 5a39708

Browse files
committed
move TLabel to the Impl module and cache it
1 parent daa96cc commit 5a39708

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

ruby/ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -600,36 +600,40 @@ module API {
600600
/** Gets the shortest distance from the root to `nd` in the API graph. */
601601
cached
602602
int distanceFromRoot(TApiNode nd) = shortestDistances(MkRoot/0, edge/2)(_, nd, result)
603+
604+
/** All the possible labels in the API graph. */
605+
cached
606+
newtype TLabel =
607+
MkLabelMember(string member) { member = any(ConstantReadAccess a).getName() } or
608+
MkLabelUnknownMember() or
609+
MkLabelMethod(string m) { m = any(DataFlow::CallNode c).getMethodName() } or
610+
MkLabelReturn() or
611+
MkLabelSubclass() or
612+
MkLabelKeywordParameter(string name) {
613+
any(DataFlowDispatch::ArgumentPosition arg).isKeyword(name)
614+
or
615+
any(DataFlowDispatch::ParameterPosition arg).isKeyword(name)
616+
} or
617+
MkLabelParameter(int n) {
618+
any(DataFlowDispatch::ArgumentPosition c).isPositional(n)
619+
or
620+
any(DataFlowDispatch::ParameterPosition c).isPositional(n)
621+
} or
622+
MkLabelBlockParameter()
603623
}
604624

605625
/** Provides classes modeling the various edges (labels) in the API graph. */
606626
module Label {
607627
/** A label in the API-graph */
608-
class ApiLabel extends TLabel {
628+
class ApiLabel extends Impl::TLabel {
609629
/** Gets a string representation of this label. */
610630
string toString() { result = "???" }
611631
}
612632

613633
private import LabelImpl
614634

615635
private module LabelImpl {
616-
newtype TLabel =
617-
MkLabelMember(string member) { member = any(ConstantReadAccess a).getName() } or
618-
MkLabelUnknownMember() or
619-
MkLabelMethod(string m) { m = any(DataFlow::CallNode c).getMethodName() } or
620-
MkLabelReturn() or
621-
MkLabelSubclass() or
622-
MkLabelKeywordParameter(string name) {
623-
any(DataFlowDispatch::ArgumentPosition arg).isKeyword(name)
624-
or
625-
any(DataFlowDispatch::ParameterPosition arg).isKeyword(name)
626-
} or
627-
MkLabelParameter(int n) {
628-
any(DataFlowDispatch::ArgumentPosition c).isPositional(n)
629-
or
630-
any(DataFlowDispatch::ParameterPosition c).isPositional(n)
631-
} or
632-
MkLabelBlockParameter()
636+
private import Impl
633637

634638
/** A label for a member, for example a constant. */
635639
class LabelMember extends ApiLabel {

0 commit comments

Comments
 (0)