[code-reflection] RFR: CodeElement ancestor functionality [v3]
Paul Sandoz
psandoz at openjdk.org
Tue Jul 8 17:36:23 UTC 2025
> Declare common ancestor methods on `CodeElement`. This enables more uniform traversal up the tree of code elements and querying of ancestors.
>
> The expression `e.ancestorOp().ancestorOp()` will first traverse up the code model tree from `e` to the nearest ancestor operation and then traverse again to the subsequent nearest ancestor operation, both skipping intermediate block and body elements. The first traversal can start from any kind of code element.
>
> The methods `ancestor{Op, Body, Block}` are currently implemented as default methods. While the implementations are simple it is easy to make mistakes handling unbound or root operations. They can be more directly implemented in a follow on PR.
Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:
Remove findChildAncestor. Update HAT.
-------------
Changes:
- all: https://git.openjdk.org/babylon/pull/479/files
- new: https://git.openjdk.org/babylon/pull/479/files/54107d94..4f1c4132
Webrevs:
- full: https://webrevs.openjdk.org/?repo=babylon&pr=479&range=02
- incr: https://webrevs.openjdk.org/?repo=babylon&pr=479&range=01-02
Stats: 63 lines in 8 files changed: 23 ins; 26 del; 14 mod
Patch: https://git.openjdk.org/babylon/pull/479.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/479/head:pull/479
PR: https://git.openjdk.org/babylon/pull/479
More information about the babylon-dev
mailing list