- Notifications
You must be signed in to change notification settings - Fork259
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Refactorcheck_unique
toChecked{Graph,Node}
#668
base:kkysen/pfb/unique-checking/check-unique-refactor
Are you sure you want to change the base?
Refactorcheck_unique
toChecked{Graph,Node}
#668
Conversation
328afba
to449a7e3
Compare34bc78f
to7510aec
Compare…d running `.check_unique()`. It also preserves the Rust source code in debug info.
449a7e3
toee941dd
CompareThere 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.
Not sure this is really necessary, but it certainly doesn't hurt
let a = g.mk_addr_of_local("let mut a = 0", false, 0_u32); | ||
let b1 = g.mk_copy("let b = &mut a", false, a); | ||
g.mk_store_addr("*b = 0", false, b1); |
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 aboutlet _b2 = g.mk_store_addr(...)
, so the nameb2
is visible here for matching with the graph above?
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.
Sure, I can add them back and just_
-prepend them.
fn mk_node( | ||
&mut self, | ||
stmt: &'static str, | ||
unique: bool, |
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.
nit pick: i think i'd rather this be an enum than a bool
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.
optional change, just my two cents
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.
What's the advantage of anenum
? If we're calling themUnique
andNonUnique
, I'm not sure there's an advantage over abool
. One is just non the other. Plus, then we should just change theunique
field inNodeInfo::unique
to the sameenum
.
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.
Plus, then we should just change the unique field in NodeInfo::unique to the same enum.
I agree that should be done. My preference is because I don't like relying on IDEs to tell me what the bool represents. A typeUnique
orNonUnique
is very clear, despite it being semantically the same as abool
. In cases where functions take more than one bool (not the case here), it prevents mixing argument order by making things type safe.
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.
Okay, that makes sense. Plus we could change it toUnique
andAliases
if we want, too. I do think we should save that for a later PR, though.
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.
that sounds okay
This refactors
check_unique
toChecked{Graph,Node}
.CheckedNode
stores not just theNodeId
like as passed to the previouscheck_unique
, but also if it should be unique (thus we ensure we don't forget to check anyNode
s (we did)), as well as the Rust source code statement for thatNode
as debug info.Then
CheckedGraph
stores aGraph
and aVec<CheckedNode>
. When.mk_*
methods are called on it, it adds theCheckedNode
to theVec
, and then when.check_unique()
is called at the end, it uses all theseCheckedNode
s.The benefits of this are:
unique
value is right next to the call that creates thatNode
Node
s have to be markedunique
or not, so we don't forget any (we did)assert!
ion fails and we print theNodeId
andGraphs
, we also print the Rust source code as the debug info (previously this was left blank).