[code-reflection] Integrated: CodeElement ancestor functionality
Paul Sandoz
psandoz at openjdk.org
Tue Jul 8 17:36:24 UTC 2025
On Thu, 3 Jul 2025 22:29:33 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: bf9ceea9
Author: Paul Sandoz <psandoz at openjdk.org>
URL: https://git.openjdk.org/babylon/commit/bf9ceea95246d958fd111fdd869f315ee33dd282
Stats: 525 lines in 36 files changed: 323 ins; 112 del; 90 mod
CodeElement ancestor functionality
-------------
PR: https://git.openjdk.org/babylon/pull/479
More information about the babylon-dev
mailing list