I am trying to structure how to get VC and PC from Expression Statements. As far as I understand, only the assignment expressions have PC and not even VC. In that sense, I thought maybe I can just implement a function only for assignments and then check whether the expression in the expression statement is an assignment (by using instanceof) and then get a PC from that assignment. However, getPC() for other expressions would be undefined. Would it be a right way to go or can cause problems later on ?
Do expression statements have VC or are they just true? I think it is just true but I could not be sure about it.
Expressions have no side-effects, except if there is an assignment at top-level. Since they have no side-effects otherwise, there is no effect, they behave like the empty block. You must ensure that there are no nested side-effects, tho.
Oops, does that mean that any expression statement that does not contain an assignment is automatically valid? I currently reject any program that features an expression statement without a top level assign. (And of course any nested assign is rejected.)
Yes. But it turns out we do not test for this. So whether you reject those, or not, is up to you.