Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle fluent getters for primitive return types #9

Merged
merged 3 commits into from
Jan 14, 2024
Merged

Conversation

Machine-Maker
Copy link
Member

Checks if the method has a primitive return type, and if the instructions with opcodes in the method follow a specific order and type so as to indicate it is a simple getter.

Copy link
Member

@DenWav DenWav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the nitpick.

Copy link
Member

@DenWav DenWav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what all you have targeted for this, so if there are static use-cases then let me know.


// 3 instructions, load "this" local var, getfield, return - TODO maybe if there is a CAST,
private static final IntPredicate[] OPCODES_IN_ORDER = new IntPredicate[] {
i -> i == Opcodes.ALOAD, i -> i == Opcodes.GETFIELD, i -> i >= Opcodes.IRETURN && i <= Opcodes.RETURN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALOAD should always be of slot 0 for this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that I should be checking more than just the opcode in these predicates? that I should also check the slot of the var insn here?

@Machine-Maker Machine-Maker force-pushed the fluent-getters branch 2 times, most recently from 33a63bb to d3b62c0 Compare July 28, 2023 08:49
@DenWav DenWav force-pushed the main branch 3 times, most recently from 990ed71 to 7b5923e Compare July 30, 2023 19:29
@Machine-Maker Machine-Maker force-pushed the fluent-getters branch 3 times, most recently from 53e9d67 to 8408ccb Compare September 15, 2023 01:05
@Machine-Maker
Copy link
Member Author

Updated for modular suggester system

@MiniDigger
Copy link
Member

needs to skip intValue, booleanValue...., plus get

maybe we can even ignore the autoboxing and use the "inner" method? or we special case block state properties
https://i.imgur.com/yxaAy41.png
another case for block state properties: boolean booleanValue = hookState.getOptionalValue(ATTACHED).orElse(false);

@MiniDigger MiniDigger merged commit f21db75 into main Jan 14, 2024
2 checks passed
@MiniDigger MiniDigger deleted the fluent-getters branch January 14, 2024 19:38
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.

3 participants