On Thu, Apr 17, 2008 at 10:10:29PM -0500, Jonathan Scott Duff wrote:
> I was annoyed that
>    parrot perl6.pbc --target=PAST -e 'say "Hello"'
> didn't seem to work, so I modified PCT/HLLCompiler so that it does. 
> 
> I'm not sure it's entirely correct though as I only tested it for the
> limited functionality I was after.
> 
> I've attached the patch though.

I'm rejecting the patch for now.  The patch refactors all of the output
functionality for --target into HLLCompilers 'eval' method, and somehow
I think that 'eval' should only be responsible for performing evaluation 
and not for dumping output.

There also seems to be a bug in the patch, at least for some combinations
of arguments.  After the patch is applied, the 'eval' method reads:

    $P0 = self.'compile'(code, adverbs :flat :named)
    $I0 = isa $P0, 'String'
    if $I0 goto end
    .local string target
    target = adverbs['target']
    if target != '' goto end
    ...
  end:
    if null $P0 goto real_end
    unless target goto real_end
    if target == 'pir' goto target_pir
    '_dumper'($P0,target)
    goto real_end
  target_pir:
    say $P0
  real_end:

We can never get to the 'say $P0' line following target_pir.  If the
command line specified --target=pir, then self.'compile'(...) will
return a String object, and we end up bypassing the 
target = adverbs['target'] line altogether.

Simply moving the target = adverbs['target'] line above the test
for a String will introduce other problems, as then the PIR from
--target=PIR will be displayed regardless of any setting of the 
--output= option.

Overall I think we may need a larger refactor of 
interactive/evalfiles/eval_line to be able to handle this
more cleanly.  But keep in mind the processing for each case isn't
exactly identical -- handling of exceptions and results can differ 
among the three.  For example, interactive mode traps exceptions,
while the others don't.

We should also keep in mind that we will likely want a --target=pbc
option at some point in the not-too-distant future.

Thanks!

Pm
  • PCT patch Jonathan Scott Duff
    • Re: PCT patch Patrick R. Michaud

Reply via email to