}
private FunctionDecl resolveCall(String name) {
ListIterator<FunctionContext> iterator = functionStack.listIterator(functionStack.size());
while (iterator.hasPrevious()) {
FunctionDecl functionDecl = iterator.previous().function;
List<Node> whereBlock = functionDecl.whereBlock();
// Well, first see if this is a direct call (usually catches recursion).
if (name.equals(functionDecl.name()))
return functionDecl;
// First attempt to resolve in local function scope.
for (Node node : whereBlock) {
if (node instanceof FunctionDecl) {
FunctionDecl inner = (FunctionDecl) node;
if (name.equals(inner.name()))
return inner;
}
}
}
// Then attempt to resolve in module(s).
FunctionDecl target = unit.resolveFunction(name, true /* resolve in deps */);
if (target != null)
return target;
return null;
}