On Thu, 12 Jan 2023 12:17:32 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

> There is a concept of push/popScope and then there's a separate concept of 
> call stack (which is just a list of diagnostic position up to the point). I 
> wonder if this could be better modeled by using a single class e.g. 
> Scope/Frame which has a diagnostic position, plus other useful things.

I think that would be more confusing, because they're really two different 
animals.

Scopes only have meaning within a single method. They simply serve to bracket 
the lifetimes of `VarRef` references, following Java curly brace scope. When 
you "invoke" a method, you put aside the current stack of scopes and start over 
with an empty scope stack. They don't bridge between methods.

Call stacks are just a list of method+code position therein, and they exist 
outside of any single method. They have nothing to do with Java scopes defined 
by curly braces.

> Perhaps it might even be helpful to have a ref set on each scope, so that you 
> don't have to attach a "depth" to each ref - the depth of the ref would be 
> determined by the "scope" in which it appears.

That's another way to skin the same cat... in fact I had a design like that 
before but then realized it was a lot simpler to just carry around one `RefSet`.

-------------

PR: https://git.openjdk.org/jdk/pull/11874

Reply via email to