[code-reflection] RFR: Support storing the code that builds the code model [v18]
Mourad Abbay
mabbay at openjdk.org
Sat Mar 15 02:53:03 UTC 2025
On Thu, 13 Mar 2025 14:29:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 20 additional commits since the last revision:
>>
>> - Merge branch 'code-reflection' into code-model-storage-option
>> - Load OpFactory and TypeElementFactory before invocation of opMethod only if the opMethod has there params.
>> - Fix the remaining compiler tests failures
>> - Fix some of the test failures (3 remains)
>> - Fix the remaining test failures of SwitchExpressionTest2
>> - Fix almost all test failures of SwitchExpressionTest2 (one remaining)
>> - Pass arrayType instead of eleType in OpBuilder.buildArray
>> - Ensure that block params are inserted in the correct order
>> - Add missing imports
>> - Merge branch 'code-reflection' into code-model-storage-option
>> - ... and 10 more: https://git.openjdk.org/babylon/compare/9300a6df...966005ce
>
> src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/CodeModelToAST.java line 222:
>
>> 220: // TODO add VarOps in OpBuilder
>> 221: funcOp = addVarsWhenNecessary(funcOp);
>> 222: funcOp.writeTo(System.out);
>
> This should be removed?
`addVarsWhenNecessary` is used to add necessary VarOp in the code model before transformation to AST. For example if an op result is used more than once, we introduce a VarOp to hold the value, because that's what the equivalent Java code will have. This makes the transformation from code model to AST a bit easier.
We also use it to in case we want an Op (e.g. InvokeOp) to be appended right away to the method we are building. As you now the block of a method is a list of statements, some operations maps to an expression, so they won't be appended until needed.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/305#discussion_r1996526001
More information about the babylon-dev
mailing list