Index: compilers/pct/src/PCT/HLLCompiler.pir =================================================================== --- compilers/pct/src/PCT/HLLCompiler.pir (revisione 41924) +++ compilers/pct/src/PCT/HLLCompiler.pir (copia locale) @@ -18,7 +18,7 @@ load_bytecode 'P6object.pbc' load_bytecode 'Parrot/Exception.pbc' $P0 = new 'P6metaclass' - $S0 = '@stages $parsegrammar $parseactions $astgrammar $commandline_banner $commandline_prompt @cmdoptions $usage $version' + $S0 = '@stages $parsegrammar $parseactions $astgrammar $commandline_banner $commandline_prompt $commandline_result_prompt @cmdoptions $usage $version' $P0.'new_class'('PCT::HLLCompiler', 'attr'=>$S0) .end @@ -146,6 +146,12 @@ The prompt is displayed in interactive mode at each point where the compiler is ready for code to be compiled and executed. +=item commandline_result_prompt([string value]) + +Set the command-line prompt for result of this computation to C. +The prompt is displayed in interactive mode after each point where +the code is inserted showing the result of the computation. + =cut .sub 'stages' :method @@ -184,6 +190,12 @@ .tailcall self.'attr'('$commandline_prompt', value, has_value) .end +.sub 'commandline_result_prompt' :method + .param string value :optional + .param int has_value :opt_flag + .tailcall self.'attr'('$commandline_result_prompt', value, has_value) +.end + =item removestage(string stagename) Delete a stage from the compilation process queue. @@ -575,6 +587,16 @@ $P0 = self.'commandline_banner'() printerr $P0 + # set result prompt once + .local string result_prompt + result_prompt = '=> ' + $P0 = self.'commandline_result_prompt'() + $I0 = defined $P0 + unless $I0 goto has_result_prompt + result_prompt = $P0 + + has_result_prompt: + .local pmc stdin .local int has_readline stdin = getstdin @@ -587,7 +609,7 @@ unless stdin goto interactive_end .local string prompt - prompt = '> ' + prompt = '>> ' $P0 = self.'commandline_prompt'() $I0 = defined $P0 unless $I0 goto have_prompt @@ -604,9 +626,13 @@ $P0 = self.'eval'(code, adverbs :flat :named) pop_eh if null $P0 goto interactive_loop - unless target goto interactive_loop + unless target goto interactive_print if target == 'pir' goto target_pir self.'dumper'($P0, target, adverbs :flat :named) + interactive_print: + print result_prompt + print $P0 + print "\n" goto interactive_loop target_pir: say $P0