mirror of
https://github.com/github/codeql.git
synced 2025-12-25 13:16:33 +01:00
Module: make main predicates cached
This commit is contained in:
@@ -10,13 +10,29 @@ private import codeql_ruby.ast.Scope
|
||||
private string builtin() { result = ["Object", "Kernel", "BasicObject", "Class", "Module"] }
|
||||
|
||||
cached
|
||||
newtype TModule =
|
||||
TResolved(string qName) {
|
||||
qName = builtin()
|
||||
module Cached {
|
||||
cached
|
||||
newtype TModule =
|
||||
TResolved(string qName) {
|
||||
qName = builtin()
|
||||
or
|
||||
qName = constantDefinition(_)
|
||||
} or
|
||||
TUnresolved(Namespace n) { not exists(constantDefinition(n)) }
|
||||
|
||||
cached
|
||||
string constantDefinition(ConstantWriteAccess n) {
|
||||
isToplevel(n) and result = n.getName()
|
||||
or
|
||||
qName = constantDefinition(_)
|
||||
} or
|
||||
TUnresolved(Namespace n) { not exists(constantDefinition(n)) }
|
||||
not isToplevel(n) and
|
||||
not exists(n.getScopeExpr()) and
|
||||
result = scopeAppend(constantDefinition(n.getEnclosingModule()), n.getName())
|
||||
or
|
||||
result = scopeAppend(resolveScopeExpr(n.getScopeExpr()), n.getName())
|
||||
}
|
||||
}
|
||||
|
||||
import Cached
|
||||
|
||||
private predicate isToplevel(ConstantAccess n) {
|
||||
not exists(n.getScopeExpr()) and
|
||||
@@ -27,16 +43,6 @@ private predicate isToplevel(ConstantAccess n) {
|
||||
)
|
||||
}
|
||||
|
||||
string constantDefinition(ConstantWriteAccess n) {
|
||||
isToplevel(n) and result = n.getName()
|
||||
or
|
||||
not isToplevel(n) and
|
||||
not exists(n.getScopeExpr()) and
|
||||
result = scopeAppend(constantDefinition(n.getEnclosingModule()), n.getName())
|
||||
or
|
||||
result = scopeAppend(resolveScopeExpr(n.getScopeExpr()), n.getName())
|
||||
}
|
||||
|
||||
private predicate isDefinedConstant(string qualifiedModuleName) {
|
||||
qualifiedModuleName = [builtin(), constantDefinition0(_)]
|
||||
}
|
||||
@@ -64,7 +70,6 @@ private string resolveScopeExpr(ConstantReadAccess r) {
|
||||
)
|
||||
}
|
||||
|
||||
cached
|
||||
private int maxDepth() { result = max(ConstantAccess c | | count(c.getEnclosingModule+())) }
|
||||
|
||||
private ModuleBase enclosing(ModuleBase m, int level) {
|
||||
|
||||
Reference in New Issue
Block a user