On Nov 28, 2005, at 2:46 PM, Chip Salzenberg wrote:
On Mon, Nov 28, 2005 at 01:16:49PM -0500, Will Coleda wrote:
With patches from myself (to tcl) and leo (to parrot), partcl is once
again passing 100% of the tests, using PDD20.
Yay!
The biggest hurdle was having some arbitrary (non :lex-ified) parrot
sub issue our find_lex and store_lex for us to ease transition. As
more of tcl becomes compiled, we can probably eliminate this code
path entirely, but that's a ways off.
Yow. The below code looks a bunch like what the find_lex opcode is
supposed to do. What made it necessary?
Tcl variables can be either globals or lexicals (inside a [proc]).
So, all the code to get a PMC from a varname was factored out to a
single routine that returns the right PMC (global or lexical)
depending on call level. So, our "find_lex" was no where near where
we'd tack on a :lex to the sub.
pre-pdd20, this worked because there was a global stack of lexpads. I
could just say "new_pad" at the appropriate spot, and any find_lex
from that point out would find the right lex, regardless of whether
or not it was in the same parrot sub. However, with the current
implementation (and design, as I understand it), you can only use
"find_lex" *in* the sub that has the :lex definition. Since this was
in a helper sub that had no :lex, the find_lex failed to find anything.
As the compiler gets smarter, we can probably avoid most uses of
this .sub. But for now, this made the transition far less painful
than doing a major rewrite.
.sub find_lex_pdd20
.param string variable_name
.local pmc interp, lexpad, variable
.local int depth
interp = getinterp
depth = 2 # we know it's not us or our direct caller.
get_lexpad:
# Is there a lexpad at this depth?
lexpad = interp["lexpad";depth]
unless_null lexpad, got_lexpad
# try again
inc depth
goto get_lexpad
got_lexpad:
variable = lexpad[variable_name]
.return(variable)
.end
--
Chip Salzenberg <[EMAIL PROTECTED]>