develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35441 - trunk/languages/befunge

From:
jquelin
Date:
January 12, 2009 08:04
Subject:
[svn:parrot] r35441 - trunk/languages/befunge
Message ID:
20090112160409.D2B77CB9F9@x12.develooper.com
Author: jquelin
Date: Mon Jan 12 08:04:08 2009
New Revision: 35441

Modified:
   trunk/languages/befunge/README
   trunk/languages/befunge/befunge.pir
   trunk/languages/befunge/load.pir

Log:
supporting new io subsystem, courtesy of francois perrad++


Modified: trunk/languages/befunge/README
==============================================================================
--- trunk/languages/befunge/README	(original)
+++ trunk/languages/befunge/README	Mon Jan 12 08:04:08 2009
@@ -84,6 +84,6 @@
 
 SEE ALSO
 --------
-* http://www.parrotcode.org
+* http://www.parrot.org
 * http://www.catseye.mb.ca/esoteric/befunge/
 

Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir	(original)
+++ trunk/languages/befunge/befunge.pir	Mon Jan 12 08:04:08 2009
@@ -11,8 +11,9 @@
     .param pmc argv
 
     # disable buffering on stdout
-    #getstdout stdout
-    #pioctl I10, P10, 3, 0
+    .local pmc stdout
+    getstdout stdout
+    stdout.'buffer_type'("unbuffered")
 
     # parsing argv
     .local int debug

Modified: trunk/languages/befunge/load.pir
==============================================================================
--- trunk/languages/befunge/load.pir	(original)
+++ trunk/languages/befunge/load.pir	Mon Jan 12 08:04:08 2009
@@ -18,13 +18,16 @@
 
 
     # read the befunge program
-    fh        = open file, 'r'
+    fh = new 'FileHandle'
+    push_eh catch
+    fh.'open'(file, 'r')
+    pop_eh
     noline    = 0
   LOAD__READ_NEXT_LINE:
     inc noline
     if noline > 25 goto LOAD__COMPLETE
 
-    line = readline fh
+    line = fh.'readline'()
     len  = length line
     if len <= 0 goto LOAD__EOF
 
@@ -50,9 +53,21 @@
 
     # file loaded, return the playfield
   LOAD__COMPLETE:
-    close fh
+    fh.'close'()
     .return(playfield)
 
+  catch:
+    .local pmc ex
+    .get_results (ex)
+    $S0 = "Can't open '"
+    $S0 .= file
+    $S0 .= "' ("
+    $S1 = err
+    $S0 .= $S1
+    $S0 .= ")\n"
+    printerr $S0
+    rethrow ex
+
 .end
 
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About