[code-reflection] RFR: Remove op name state from Op

Paul Sandoz psandoz at openjdk.org
Tue Sep 23 17:26:28 UTC 2025


On Mon, 22 Sep 2025 09:58:25 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> At this point I wonder if it wouldn't be more succinct to have a single `externalize` method that returned an `ExternalizedOp` ? (although, admittedly, this might go back to some similar state we had previously)

I was wondering the same. 

`ExernalizedOp::externalizeOp` deconstructs an operation from which we can re-construct an independent copy. It maps values/successors and copy bodies using a given copy context.

For writing we don't want to deconstruct to create an independent copy, we need direct access to all the operations components.

So there are two kinds of deconstruction, and suggests we need another record `DeconstructedOp` that has a more direct relationship but it cannot be used directly to reconstruct an independent copy.


public record DeconstructedOp(String name,
                             Location location,
                             List<Value> operands,
                             List<Block.Reference> successors,
                             TypeElement resultType,
                             Map<String, Object> attributes,
                             List<Body> body) { 
                             
    // Helper constructor accepting Op, name, attributes
}


So the relationship could be this:

Op -> DeconstructedOp -> ExernalizedOp -> Op`

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

PR Comment: https://git.openjdk.org/babylon/pull/577#issuecomment-3324915910


More information about the babylon-dev mailing list