[code-reflection] Integrated: Regularize parsing of refs/types in op attributes

Maurizio Cimadamore mcimadamore at openjdk.org
Wed May 28 09:29:07 UTC 2025


On Mon, 26 May 2025 11:41:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR builds on https://git.openjdk.org/babylon/pull/432 and simplifies the way in which the various op factories handle attributes that are either `JavaRef` or `JavaType`.
> Previously, such attribute values were written as strings -- and then the op factory would need to parse them back using one of the `JavaType::ofString`, or `XYZRef::ofString` parsing factories.
> 
> In this PR, type elements are serialized into strings using `TypeElement::externalize` (as usual, we also apply flattening, to turn the external forms into something more readable).
> When parsing back, we then check whether we're staring at an externalized form or not. If so, we parse it back, we inflate it and turn it back into a `TypeElement` using the selected type factory.
> 
> As a result op factories can just work on type elements directly, all the parsing will already have occurred at that point. This simplfies the op factory code, and, crucially, allows us to drop the various `ofString` factories. This means that the code model API no longer relies on the textual form of Java types/refs.
> 
> #### Next steps
> * enhance attribute parsing to special case all Java literals (so that we can drop even more parsing in the common cases)
> * unify grammar between attributes and types

This pull request has now been integrated.

Changeset: 44735d0d
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/44735d0d39e2c1141332bfa75d6b4ec822d58013
Stats:     729 lines in 49 files changed: 48 ins; 37 del; 644 mod

Regularize parsing of refs/types in op attributes

-------------

PR: https://git.openjdk.org/babylon/pull/433


More information about the babylon-dev mailing list