JavaScript: Add utility predicate getBasePortal(i).

This iterates the existing `getBasePortal()` predicate `i` times.
This commit is contained in:
Max Schaefer
2020-07-09 09:08:18 +01:00
parent bb9c8881d6
commit 8b4b5781e6

View File

@@ -96,6 +96,20 @@ class Portal extends TPortal {
cached
ReturnPortal getReturn() { result.getBasePortal() = this }
/**
* Gets the `i`th base portal of this portal.
*
* The `0`th base portal is the portal itself, the `n+1`st base portal is the `n`th base portal
* of the portal `p` of which this is a member, instance, parameter, or return portal.
*/
cached
Portal getBasePortal(int i) {
i = 0 and
result = this
or
result = this.(CompoundPortal).getBasePortal().getBasePortal(i - 1)
}
/**
* Gets a textual representation of this portal.
*