-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make more Opcodes
hold a FieldType
#40
Closed
Closed
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9a63153
Make `Multianewarray` hold a `FieldType`
C0D3-M4513R 6311e34
Make ci format check happy?
C0D3-M4513R 1467405
Make `Anewarray` hold a FieldType
C0D3-M4513R 207d62c
Add handwritten test
C0D3-M4513R 21a6f8e
Make `Checkcast` hold a FieldType
C0D3-M4513R 474a208
Make `Instanceof` hold a FieldType
C0D3-M4513R 933458e
Include more exhaustive test
C0D3-M4513R db56c98
remap `BaseType`'s back to their Object types
C0D3-M4513R 70ffbad
Use a new `ReferenceType` instead
C0D3-M4513R c4fc437
Run `cargo fmt`
C0D3-M4513R 3c37c2a
Move all `FieldType`'s in Opcode to `ReferenceType`'s
C0D3-M4513R 1a289f8
Run `cargo fmt`
C0D3-M4513R 9c1c8be
Add proposed test
C0D3-M4513R 3dc37cd
Merge branch 'main' into patch-2
C0D3-M4513R File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right to me. Conceptually the classinfo field contains the name of a class, which is different from a field type. For instance if the class happened to be called "B", parsing it as a field type would turn it into
FieldType::Ty(Ty::Base(BaseType::Byte))
which is incorrect. On top of that this approach of handlingErr
and assuming it is anTy::Object
seems not very robust.Err
can be returned for any number of reasons and is not a good way to handle control flow. You're basically hacking around the fact that ClassInfo structures contain a different syntax (e.g.java/lang/String
) than what field type is intended to parse (Ljava/lang/String;
) but this is not a good solution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to circle back to this, but having to manually parse the Cow of anewarray, instanceof and checkcast for array depths also seems a little strange though
Like imagine casting an Object to an int[].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah like I said in the comment below, I'm not opposed to putting in a structured type here instead of the Cow. I'm just saying using
FieldType
is wrong, and it should be a different structured type that precisely represents the possible range of values here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it wrong? can you not checkcast from Object to [J or [B?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I proposed multiple solutions now, but you find none sufficient.
Tbh I do not know what you want from me at this point.
You say you see too many issues with my solution, so is there something I'm not seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also are you saying that the following sample opcode is wrong too? (also taken from #41)
21: checkcast #21 // class "[Ljava/lang/String;"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this java code:
Look at what the checkcast instruction generates, the string value that you get, and what your parsing code does to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my new parsing code (ReferenceType) I'd expect it to correctly resolve to the Object Variant of ReferenceType.
I did miss a couple of cases of FieldType though, that should be replaced with ReferenceType.