On Mon, Apr 14, 2008 at 12:26 AM, via RT Bob Rogers <[EMAIL PROTECTED]> wrote: > # New Ticket Created by Bob Rogers > # Please include the string: [perl #52858] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=52858 > > > > If you run the following PASM code: > > new P0, 'Integer' > set P0, 77 > set $N1, 1 > set $N2, 2 > set $N3, 3 > print $N1 > print ' ' > print $N2 > print ' ' > print $N3 > print "\n" > print P0 > print "\n" > end > > you will see something like the following output: > > [EMAIL PROTECTED]> ./parrot dollar-vars.pasm > 3.000000 3.000000 3.000000 > Segmentation fault > [EMAIL PROTECTED]> > > The reason for this odd behavior is that all of the $N registers are > getting mapped to "N-1" (that's the register *before* N0); disassembly > shows the bogus register numbers clearly. This happens to overwrite P0, > hence the segfault. > > So either the "$" syntax for registers must be disabled in PASM, or > it must be implemented properly. (I don't particularly care, and > haven't the IMCC-fu to do anything about it myself.) > > -- Bob Rogers > http://rgrjr.dyndns.org/ >
IMCC's lexer has a number of states, one of which is "emit". I'm not clear on how all these states are interacting,and to what cases these states correspond, but I think "emit" is "pasm" mode (I might be wrong here! I never really figured out what all states in IMCC are). The lexer recognizes virtual registers (with the $) in this "emit" state too. Ideally, the lexer could be tweaked that when reading $P0 in pasm mode, it emits an error message saying you can't use virtual registers in pasm mode. Rewriting the lexer rules (and states) might be tricky, but a simple solution would to check whether the lexer is in pasm mode in the action body of the rule for registers. (I think there's a flag in IMCC_INFO). I don't have time currently to work on this, unfortunately kjs