-
Notifications
You must be signed in to change notification settings - Fork 29
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
Simplify generated code for variable declarations with initialization expressions #572
base: master
Are you sure you want to change the base?
Conversation
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.
The desugarer is not the place to generate inhales to encode assignments. This is clearly part of the encoding. I liked your idea of adding an argument to the initialize node. I think you should do that instead.
Also, I would not mix code analysis and the desugarer. The necessary information for the desugaring step should be collecting by the Info object. The main concern is that the desugarer is getting way too complicated and hard to maintain. |
// assign to left (which implies exhaling and inhaling the footprint). Instead, we can just assume directly the | ||
// equality between left and right. | ||
val eq = in.ExprAssertion(in.GhostEqCmp(left.op, implicitConversion(right.typ, left.op.typ, right))(newInfo))(newInfo) | ||
in.Inhale(eq)(newInfo) |
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.
If it is ultra urgent, then you could introduce another internal node, e.g. "InitialAssignment" and then replace the inhales with that. That would still be an ugly solution, but at it maintaines the separation of purposes somewhat.
This may be a nice use-case for quasi-havoc |
Shared variables
Whenever we have an assignment of the form
Gobra translates this as following (internal representation)
At the Viper level, this is expanded roughly to
This PR simplifies that to
Non-shared variables
Gobra translates this as following (internal representation)
At the Viper level, this is expanded roughly to
Instead, this PR encodes it as follows
PS: in both cases, the new encoding is only applied if the identifier is being defined. otherwise, it uses the old encoding.