jastrachan | 25 Jan 14:25 2005
Picon

Re: [groovy-dev] Fix for 704, "double wide" method arguments


On 25 Jan 2005, at 13:19, Martin C. Martin wrote:

> Hey James,
>
> Thanks for taking it the last mile!

:)

> But wouldn't it be cleaner to leave the variable stack the way it was, 
> and change AsmClassGenerator2.getNextVariableID() to iterate over the 
> variable stack, adding up the size of each variable (1 or 2)?  Or 
> return lastVariableIndex + 1 or 2?  Someone else hacking on Groovy 
> could be forgiven for thinking that variableStack contains one entry 
> per variable on the stack, rather than one entry per frame (as the JVM 
> docs call it.)
>
> I can even submit a patch if you like...

Sure, please do. I'd prefer to go even further if we could. Have a 
VariableStack class, which allows us to add new variables to it, it 
automatically updates the nextVariableID counter internally, based on 
the size of the type. But that we can do push / pop operations, to 
create new scopes and pop them again.

e.g.

def x = 1
if (foo) {
   def y = 123
}
else {
     String y = "foo"
}

etc

which would make 3 different VariableStack's, 2 of which would be 
children of the other etc.

It amounts to pretty much the same thing you said - its just it'd be 
nice to wrap up the entire data structure into a simple API and hide 
how the VariableStack assigns IDs inside its implementation

James
-------
http://radio.weblogs.com/0112098/


Gmane