why don't you manage your own basic call stack in an array or PerlArray or something? trying to map that mess of call/return poo onto a proper compiler with register allocation is going to lose us the services of leo while he recuperates at the hospital for homicidal BASIC coders.
Naw. I'm not homocidal. Suicidal with a masochistic bent, that's all.
And I don't think I've ever asked for anything from the Parrot team other than opinions on honest-to-goodness bugs or understanding of some area of how to target this platform. Hope no-one's going to need a pshrink after this. I only ask odd questions because sometimes I'm dealing with odd things. Like programs that are essentially one big compilation unit -- almost, and doing odd things with bsr/ret...
you will just have to bite the bullet and emulate your own virtual engine over parrot and not try to map BASIC directly to it. so code a VM with BASIC flow control. you can probably do something odd like make each BASIC statement into a parrot sub. then just compile your basic into a simple flow control IL that just calls parrot subs. the subs all have access to your need globals (with the obvious find_global/set_global :) a primary global now is the BASIC VM PC.
As far as I know, BASIC only gets weird with flow control in two places. One is 'RETURN X', another is computed goto 'goto X'. The former I'm handling be wrapping bsr/ret with a little bit of code (after each bsr, the code asks "was the ret destined for me or not?"). The latter is handled by a table inserted into the code mapping the compile-time labels over to runtime destinations. So that:
branch USERLABEL_100 # Normal goto
USERLABEL_100:
# Expression, etc... result in $S0
branch COMPUTED_GOTOCOMPUTED_GOTO:
eq $S0, "USERLABEL_10", USERLABEL_10
eq $S0, "USERLABEL_20", USERLABEL_20
etc...
print "Label "
print $S0
print " does not exist at line "
print BASICLINE
endAnd the COMPUTED_GOTO jumptable gets inserted in the code only if the program does something stupid like a computed goto. BASIC compilers/interpreters have always felt free to punish the programmer with space/speed tradeoffs for programmer laziness.
feel free to tell me this is total cocky-pop. :)
In the first incarnation (04/2002) the Parrot VM (pre-PerlHashes mind you) was an inconvenience and BASIC essentially was inside it's own little VM on top of this odd processor. I'd like to exercise as many the facilities available to me now for speed and whatnot. This re-targeting from PASM to PIR is much easier than the original PASM port to begin with.
