[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pointers from locals to uses and definitions
On Wed, 12 Feb 2003, Chris Pickett wrote:
> Given a local in the Chain of Locals obtained from Body.getLocals(), I
> would like to know all the uses and defs of that Local within the Body.
> Is this easily done? I can't seem to find appropriate methods in the API.
What you want to do is to iterate on Body.getUnits(); for each unit, call
getUseAndDefsBoxes. This is O(n) because you visit every unit only once.
> So far, the best I can see is to call Body.getUseAndDefBoxes(), and then
> compare every Value against each Local in the Chain and if see if they
> match. Which is kind of n^2 looking to me . . .
Here you're asking a question about all locals, not any particular one. I
think that answering the question for all locals would be O(mn), where m
is the number of locals and n is the number of units.
pat