-
Notifications
You must be signed in to change notification settings - Fork 163
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
[decompiler] rewrite set lets as just sets #1858
Conversation
* dest-var | ||
* ) | ||
* to: | ||
* (set! something src) |
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 think this change is unsafe to make - for example:
(let ((temp (foo)))
(set! (-> (bar) field) temp)
)
will call foo
before bar
, but
(set! (-> (bar) field) (foo))
will call bar
before foo
.
Which is why I think this detection has to happen before expression building.
If we do it here, we also lose the ability to detect things like *!
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.
Math macros like *!
also seemed unaffected, looking at the refs.
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 it looks like you're right - both the compiler and decompiler agree about this, and I made a comment about it being flipped here
I think that means this is safe, but I do want to think about it a little more.
The *!
thing would only apply in cases where we don't detect *!
currently - if you had something that was originally (*! foo bar)
, but it got split up due to this set/let issue, then this fix will give us (set! foo (* foo bar))
. Which I wouldn't worry about too much.
A few other things I want to think about
uint128
/vf
stuff : seems like it doesn't get applied for vf stuff because that doesn't become aset
- dropping casts for
float
/int
convers: I think it won't but I want to review some more - dropping casts for
(the-as
- not sure, I kinda think this will be wrong - bitfield stuff: the compile makes
set!
on a bitfield returnnone
, but we could change this
Only problem might be that it won't cast things like enums or |
Rewrites specific kinds of lets where the return value of the
set!
itself is meant to be used to just beset!
s. Implemented at the let rewrite level. Seems to work for Jak 2 so far.Fixes #1854 .