develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33802 - trunk/languages/lua

From:
fperrad
Date:
December 11, 2008 08:43
Subject:
[svn:parrot] r33802 - trunk/languages/lua
Message ID:
20081211164322.1C47CCB9AF@x12.develooper.com
Author: fperrad
Date: Thu Dec 11 08:43:21 2008
New Revision: 33802

Modified:
   trunk/languages/lua/luad.pir

Log:
[Lua] pdd22io
- more FileHandle
- refactor exception handling

Modified: trunk/languages/lua/luad.pir
==============================================================================
--- trunk/languages/lua/luad.pir	(original)
+++ trunk/languages/lua/luad.pir	Thu Dec 11 08:43:21 2008
@@ -35,10 +35,9 @@
     if argc != 2 goto USAGE
     progname = shift argv
     filename = shift argv
+    push_eh _handler
     content = load_file(filename)
-    unless content goto L1
     .local pmc script
-    push_eh _handler
     new $P0, 'LuaBytecode'
     script = $P0.'undump'(content)
     .local string basename
@@ -49,18 +48,15 @@
     script.'brief'(basename)
     pop_eh
     end
+  USAGE:
+    printerr "Usage: parrot luad.pir filename\n"
+    exit -1
   _handler:
     .local pmc e
     .local string msg
     .get_results (e)
     msg = e
-    print msg
-    print "\n"
-  L1:
-    end
-  USAGE:
-    printerr "Usage: parrot luad.pir filename\n"
-    exit -1
+    say msg
 .end
 
 .sub 'load_file'
@@ -71,16 +67,16 @@
     push_eh _handler
     content = fh.'readall'(filename)
     pop_eh
-    if content goto L1
-    $S0 = err
-    print "Can't slurp '"
-    print filename
-    print "' ("
-    print $S0
-    print ")\n"
-  L1:
-  _handler:
     .return (content)
+  _handler:
+    $S0 = "Can't slurp '"
+    $S0 .= filename
+    $S0 .= "' ("
+    $S1 = err
+    $S0 .= $S1
+    $S0 .= ")\n"
+    printerr $S0
+    .return ('')
 .end
 
 .include 'languages/lua/src/lib/luabytecode.pir'



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