I have an instance of the object VMemRead (let’s call it r). The constructor for VMemRead looks like
VMemRead(SourcePos sourcePos, VVarRef dest, VMemRef source)
with fields dest and source. I know when I want to access dest, I can just do r.dest. However, I want to go “deeper” into source.
VMRef has two nested classes VMemRef.Global and VMemRef.Stack. VMemRef.Global has the constructor
VMemRef.Global(SourcePos sourcePos, VAddr<VDataSegment> base, int byteOffset)
I want to access the int byteOffset. In effect, I want to do something like r.source.Global.byteOffset but Java doesn’t let me do this.
Is there any way I can access that value?
Documentation:
VMemRead: http://cs.ucla.edu/classes/spring11/cs132/kannan/vapor-parser/vapor-parser-javadoc/cs132/vapor/ast/VMemRead.html#source
VMemRef.Global: http://cs.ucla.edu/classes/spring11/cs132/kannan/vapor-parser/vapor-parser-javadoc/cs132/vapor/ast/VMemRef.Global.html
Thank you very much!
Those nested classes are static. For each of them, you need a reference to an instance in order to access the field values. An instance ofVMemRefdoes not have (documented) member fields of typeVMemRef.GlobalorVMemRef.Stack. You’ll have to look somewhere else than inrfor data from those classes.In other words, simply because you have an instance of
VMemRefinr, it doesn’t mean that there are any instances ofVMemRef.GlobalorVMemRef.Stackaround. So there’s no way to access “those values” because “those values” don’t necessarily exist!EDIT After re-reading the API, I see that
VMemRefis an abstract class andr.sourceis an instance of eitherVMemRef.GlobalorVMemRef.Static. That changes the story. You can do something like this: