Skip to content

Use local var context with static position methods#14

Merged
MiniDigger merged 1 commit into
mainfrom
better-positions
Jan 14, 2024
Merged

Use local var context with static position methods#14
MiniDigger merged 1 commit into
mainfrom
better-positions

Conversation

@Machine-Maker
Copy link
Copy Markdown
Member

Ok, so this isn't working 100%, but I don't think I know enough to figure out to accurately get the LocalVariableNode referenced by a VarInsnNode. I thought it was enough to just get the MethodNode.localVariables field, iterate through and find one with the matching index, but there seem to be duplicates. I noticed this while looking at CrashReportCategory#formatLocation L47. The sectionPosX should have an index pointing to that local var node, but there is a second one in the list that points towards the Throwable in the catch block above.

@Machine-Maker Machine-Maker changed the title Use local var context with static position methods WIP Use local var context with static position methods Jul 27, 2023
@Machine-Maker
Copy link
Copy Markdown
Member Author

Ok, the issue where it matched the wrong local var has been fixed by just walking back on the instruction chain until you find a label node that matches the start label of one of the matching local vars.

@Machine-Maker Machine-Maker changed the title WIP Use local var context with static position methods Use local var context with static position methods Jul 28, 2023
@Machine-Maker
Copy link
Copy Markdown
Member Author

Ok, this should be good to go now. Handles methods on SectionPos, QuartPos, and BlockPos and names stuff accordingly. One future optimization could be to detect simple math surrounding the parameter to a method in order to persist the var, method, field name through that logic.

@DenWav DenWav force-pushed the main branch 2 times, most recently from 42706b9 to 7976d1d Compare July 29, 2023 04:29
@Machine-Maker
Copy link
Copy Markdown
Member Author

Machine-Maker commented Jan 14, 2024

Rebased and re-tested.

It's not simple to add tests for the QuartPos, SectionPos stuff, because it uses the ContainerContext to see if it can find already named lvt (like from parameters)

@Machine-Maker Machine-Maker force-pushed the better-positions branch 3 times, most recently from 56593f4 to 7ee3b4b Compare January 14, 2024 19:39
@MiniDigger MiniDigger merged commit a6f7366 into main Jan 14, 2024
@MiniDigger MiniDigger deleted the better-positions branch January 14, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants