[svn:parrot] r47323 - in trunk: compilers/pct/src/PCT compilers/tge docs/book/draft examples/pge

plobsing at svn.parrot.org plobsing at svn.parrot.org
Thu Jun 3 06:51:03 UTC 2010


Author: plobsing
Date: Thu Jun  3 06:51:03 2010
New Revision: 47323
URL: https://trac.parrot.org/parrot/changeset/47323

Log:
convert some raw Interp.stdhandle calls to use PIO_x_FILENO macros from stdio.pasm

Modified:
   trunk/compilers/pct/src/PCT/HLLCompiler.pir
   trunk/compilers/tge/tgc.pir
   trunk/docs/book/draft/chXX_hlls.pod
   trunk/examples/pge/demo.pir

Modified: trunk/compilers/pct/src/PCT/HLLCompiler.pir
==============================================================================
--- trunk/compilers/pct/src/PCT/HLLCompiler.pir	Thu Jun  3 06:22:48 2010	(r47322)
+++ trunk/compilers/pct/src/PCT/HLLCompiler.pir	Thu Jun  3 06:51:03 2010	(r47323)
@@ -25,6 +25,7 @@
 .namespace [ 'PCT';'HLLCompiler' ]
 
 .include 'cclass.pasm'
+.include 'stdio.pasm'
 
 .sub 'init' :vtable :method
     load_bytecode 'config.pir'
@@ -330,7 +331,7 @@
     $N1 = time
     $N2 = $N1 - $N0
     $P0 = getinterp
-    $P1 = $P0.'stdhandle'(2)
+    $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     $P1.'print'("Stage '")
     $P1.'print'(stagename)
     $P1.'print'("': ")
@@ -614,13 +615,13 @@
     # on startup show the welcome message
     $P0 = self.'commandline_banner'()
     $P1 = getinterp
-    $P2 = $P1.'stdhandle'(2)
+    $P2 = $P1.'stdhandle'(.PIO_STDERR_FILENO)
     $P2.'print'($P0)
 
     .local pmc stdin
     .local int has_readline
     $P0 = getinterp
-    stdin = $P0.'stdhandle'(0)
+    stdin = $P0.'stdhandle'(.PIO_STDIN_FILENO)
     encoding = adverbs['encoding']
     if encoding == 'fixed_8' goto interactive_loop
     unless encoding goto interactive_loop
@@ -889,7 +890,7 @@
     .local string output
     .local pmc ofh
     $P0 = getinterp
-    ofh = $P0.'stdhandle'(1)
+    ofh = $P0.'stdhandle'(.PIO_STDOUT_FILENO)
     output = adverbs['output']
     if output == '' goto save_output_1
     if output == '-' goto save_output_1
@@ -919,7 +920,7 @@
     pop_eh
     $S0 = self.'backtrace'($P0)
     $P0 = getinterp
-    $P0 = $P0.'stdhandle'(2)
+    $P0 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     print $P0, $S0
     exit 1
 .end

Modified: trunk/compilers/tge/tgc.pir
==============================================================================
--- trunk/compilers/tge/tgc.pir	Thu Jun  3 06:22:48 2010	(r47322)
+++ trunk/compilers/tge/tgc.pir	Thu Jun  3 06:51:03 2010	(r47323)
@@ -25,6 +25,8 @@
 
 =cut
 
+.include 'stdio.pasm'
+
 .sub "main" :main
     .param pmc args
     .local string prog
@@ -65,7 +67,7 @@
 
   OUTPUT_STDOUT:
     $P0 = getinterp
-    outfh = $P0.'stdhandle'(1)
+    outfh = $P0.'stdhandle'(.PIO_STDOUT_FILENO)
     goto OUTPUT_DONE
 
   OUTPUT_FILE:
@@ -103,7 +105,7 @@
 
   USAGE:
     $P0 = getinterp
-    $P1 = $P0.'stdhandle'(2)
+    $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     $P1.'print'("Usage: ")
     $P1.'print'(prog)
     $P1.'print'(" [OPTIONS] FILE\n")
@@ -116,13 +118,13 @@
 
   ERR_TOO_FEW_ARGS:
     $P0 = getinterp
-    $P1 = $P0.'stdhandle'(2)
+    $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     $P1.'print'("Error: too few arguments\n\n")
     goto USAGE
 
   ERR_NO_INFILE:
     $P0 = getinterp
-    $P1 = $P0.'stdhandle'(2)
+    $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     $P1.'print'("Error: file not found: ")
     $P1.'print'(infile)
     $P1.'print'("\n\n")
@@ -130,7 +132,7 @@
 
   ERR_NO_OUTFILE:
     $P0 = getinterp
-    $P1 = $P0.'stdhandle'(2)
+    $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
     $P1.'print'("Error: file not found: ")
     $P1.'print'(outfile)
     $P1.'print'("\n\n")

Modified: trunk/docs/book/draft/chXX_hlls.pod
==============================================================================
--- trunk/docs/book/draft/chXX_hlls.pod	Thu Jun  3 06:22:48 2010	(r47322)
+++ trunk/docs/book/draft/chXX_hlls.pod	Thu Jun  3 06:51:03 2010	(r47323)
@@ -126,9 +126,11 @@
 
 =begin PIR
 
+  .include 'stdio.pasm'
+
   .sub main
     $P0 = getinterp
-    $P0 = $P0.'stdhandle'(0)
+    $P0 = $P0.'stdhandle'(.PIO_STDIN_FILENO)
     $P1 = compreg 'PIR'
     
     loop_top:

Modified: trunk/examples/pge/demo.pir
==============================================================================
--- trunk/examples/pge/demo.pir	Thu Jun  3 06:22:48 2010	(r47322)
+++ trunk/examples/pge/demo.pir	Thu Jun  3 06:51:03 2010	(r47323)
@@ -2,6 +2,7 @@
 # $Id$
 
 .include "errors.pasm"
+.include 'stdio.pasm'
 .sub _main
     .local string x
     .local string pattern
@@ -35,7 +36,7 @@
     print "\ninput \"regex <pattern>\", \"glob <pattern>\", \"save <name>\",\n"
     print "target string, \"pir\", \"exp\", \"trace\", \"next\"\n"
     $P0 = getinterp
-    stdin = $P0.'stdhandle'(0)
+    stdin = $P0.'stdhandle'(.PIO_STDIN_FILENO)
     x = stdin.'readline'()
     length $I0, x
     if $I0 < 1 goto end_demo


More information about the parrot-commits mailing list