Optimise join orders

This commit is contained in:
Chris Smowton
2024-10-01 14:12:51 +01:00
parent d04a0f4b87
commit 74cba9056b
2 changed files with 16 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ class AstNode extends @node, Locatable {
}
/** Gets the innermost function definition to which this AST node belongs, if any. */
pragma[nomagic]
FuncDef getEnclosingFunction() { result = this.getParent().parentInSameFunction*() }
/**

View File

@@ -479,6 +479,13 @@ class Function extends ValueEntity, @functionobject {
ResultVariable getAResult() { result = this.getResult(_) }
}
pragma[inline_late]
bindingset[m]
private Type implementsIncludingInterfaceMethodsCand(Method m, string mname) {
result.implements(m.getReceiverType().getUnderlyingType()) and
mname = m.getName()
}
/**
* A method, that is, a function with a receiver variable, or a function declared in an interface.
*
@@ -580,9 +587,14 @@ class Method extends Function {
predicate implementsIncludingInterfaceMethods(Method m) {
this = m
or
exists(Type t |
this = t.getMethod(m.getName()) and
t.implements(m.getReceiverType().getUnderlyingType())
// Take all methods
// Get receiver type then underlying type ==> [method, recvutype]
// Map through Type.implements ==> [method, candtype]
// Get method name ==> [mname, candtype]
// Get corresponding method
exists(Type t, string mname |
t = implementsIncludingInterfaceMethodsCand(m, mname) and
this = t.getMethod(mname)
)
}