Ticket #1115: the_p_in_repl.patch

File the_p_in_repl.patch, 2.5 KB (added by riffraff, 12 years ago)

adds a field for printout banner in HLLCompiler's interactive loop

  • compilers/pct/src/PCT/HLLCompiler.pir

     
    1818    load_bytecode 'P6object.pbc' 
    1919    load_bytecode 'Parrot/Exception.pbc' 
    2020    $P0 = new 'P6metaclass' 
    21     $S0 = '@stages $parsegrammar $parseactions $astgrammar $commandline_banner $commandline_prompt @cmdoptions $usage $version' 
     21    $S0 = '@stages $parsegrammar $parseactions $astgrammar $commandline_banner $commandline_prompt $commandline_result_prompt @cmdoptions $usage $version' 
    2222    $P0.'new_class'('PCT::HLLCompiler', 'attr'=>$S0) 
    2323.end 
    2424 
     
    146146The prompt is displayed in interactive mode at each point where 
    147147the compiler is ready for code to be compiled and executed. 
    148148 
     149=item commandline_result_prompt([string value]) 
     150 
     151Set the command-line prompt for result of this computation to C<value>. 
     152The prompt is displayed in interactive mode after each point where 
     153the code is inserted showing the result of the computation. 
     154 
    149155=cut 
    150156 
    151157.sub 'stages' :method 
     
    184190    .tailcall self.'attr'('$commandline_prompt', value, has_value) 
    185191.end 
    186192 
     193.sub 'commandline_result_prompt' :method 
     194    .param string value        :optional 
     195    .param int has_value       :opt_flag 
     196    .tailcall self.'attr'('$commandline_result_prompt', value, has_value) 
     197.end 
     198 
    187199=item removestage(string stagename) 
    188200 
    189201Delete a stage from the compilation process queue. 
     
    575587    $P0 = self.'commandline_banner'() 
    576588    printerr $P0 
    577589 
     590    # set result prompt once  
     591    .local string result_prompt 
     592    result_prompt = '=> ' 
     593    $P0 = self.'commandline_result_prompt'() 
     594    $I0 = defined $P0 
     595    unless $I0 goto has_result_prompt 
     596    result_prompt = $P0 
     597 
     598  has_result_prompt: 
     599 
    578600    .local pmc stdin 
    579601    .local int has_readline 
    580602    stdin = getstdin 
     
    587609    unless stdin goto interactive_end 
    588610 
    589611    .local string prompt 
    590     prompt = '> ' 
     612    prompt = '>> ' 
    591613    $P0 = self.'commandline_prompt'() 
    592614    $I0 = defined $P0 
    593615    unless $I0 goto have_prompt 
     
    604626    $P0 = self.'eval'(code, adverbs :flat :named) 
    605627    pop_eh 
    606628    if null $P0 goto interactive_loop 
    607     unless target goto interactive_loop 
     629    unless target goto interactive_print 
    608630    if target == 'pir' goto target_pir 
    609631    self.'dumper'($P0, target, adverbs :flat :named) 
     632  interactive_print: 
     633    print result_prompt 
     634    print $P0 
     635    print "\n" 
    610636    goto interactive_loop 
    611637  target_pir: 
    612638    say $P0