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

[svn:parrot] r33720 - in trunk/languages/WMLScript: . src

From:
fperrad
Date:
December 9, 2008 10:53
Subject:
[svn:parrot] r33720 - in trunk/languages/WMLScript: . src
Message ID:
20081209185300.02756CB9AF@x12.develooper.com
Author: fperrad
Date: Tue Dec  9 10:52:59 2008
New Revision: 33720

Modified:
   trunk/languages/WMLScript/src/wmlsstdlibs.pir
   trunk/languages/WMLScript/wmls2pbc.pir
   trunk/languages/WMLScript/wmls2pir.pir
   trunk/languages/WMLScript/wmlsd.pir
   trunk/languages/WMLScript/wmlsi.pir

Log:
[WMLScript]
- fix exception handling

Modified: trunk/languages/WMLScript/src/wmlsstdlibs.pir
==============================================================================
--- trunk/languages/WMLScript/src/wmlsstdlibs.pir	(original)
+++ trunk/languages/WMLScript/src/wmlsstdlibs.pir	Tue Dec  9 10:52:59 2008
@@ -68,6 +68,7 @@
     push_eh _handler
     $P1 = $P0[lindex]
     $P2 = $P1[findex]
+    pop_eh
     .return ($P2)
   _handler:
     .const 'Sub' not_implemented = 'not_implemented'
@@ -89,7 +90,7 @@
     .local pmc loader
     .local pmc script
     new loader, 'WmlsBytecode'
-    push_eh _handler_1
+    push_eh _handler
     script = loader.'load'(content)
     script['filename'] = url
     .local string gen_pir
@@ -101,26 +102,14 @@
     $P0 = pbc_out[0]
     $P0()
     pop_eh
-#    push_eh _handler_2
     .local pmc entry
     $S0 = url
     $S0 .= ':'
     $S0 .= function
     entry = get_hll_global $S0
-    if_null entry, _handler_2
+    if_null entry, L2
     .return (entry)
-  _handler_1:
-    .local pmc e
-    .local string msg
-    .get_results (e)
-    msg = e
-    print msg
-    print "\n"
-    $S0 = "verification failed (can't translate '"
-    $S0 .= url
-    $S0 .= "')"
-    die $S0
-  _handler_2:
+  L2:
     $S0 = "external function '"
     $S0 .= function
     $S0 .= "' not found in '"
@@ -129,6 +118,17 @@
     die $S0
   L1:
     die "unable to load compilation unit"
+  _handler:
+    .local pmc e
+    .local string msg
+    .get_results (e)
+    msg = e
+    say msg
+    $S0 = "verification failed (can't translate '"
+    $S0 .= url
+    $S0 .= "')"
+    e = $S0
+    rethrow e
 .end
 
 .sub 'load_script'
@@ -136,10 +136,11 @@
     .local pmc fh
     .local string content
     fh = new 'FileHandle'
-#    push_eh _handler
+    push_eh _handler
     content = fh.'readall'(filename)
-#    pop_eh
-    if content goto L1
+    pop_eh
+    .return (content)
+  _handler:
     $S0 = err
     print "Can't slurp '"
     print filename
@@ -147,8 +148,7 @@
     print $S0
     print ")\n"
   L1:
-  _handler:
-    .return(content)
+    .return ('')
 .end
 
 .sub 'save_pbc'
@@ -165,9 +165,7 @@
     fh.'close'()
     .return (output)
   _handler:
-    .local pmc e
-    .get_results (e)
-    $S0 = e
+    $S0 = err
     print "Can't open '"
     print output
     print "' ("
@@ -189,9 +187,7 @@
     fh.'close'()
     .return ()
   _handler:
-    .local pmc e
-    .get_results (e)
-    $S0 = e
+    $S0 = err
     print "Can't open '"
     print output
     print "' ("

Modified: trunk/languages/WMLScript/wmls2pbc.pir
==============================================================================
--- trunk/languages/WMLScript/wmls2pbc.pir	(original)
+++ trunk/languages/WMLScript/wmls2pbc.pir	Tue Dec  9 10:52:59 2008
@@ -49,19 +49,19 @@
     pir_comp = compreg 'PIR'
     pbc_out = pir_comp(gen_pir)
     save_pbc(pbc_out, filename)
-    end
-  _handler:
-    .local pmc e
-    .local string s
-    .get_results (e)
-    s = e
-    print s
-    print "\n"
+    pop_eh
   L1:
     end
   USAGE:
     printerr "Usage: parrot wmls2pir.pbc filename\n"
     exit -1
+  _handler:
+    .local pmc e
+    .local string msg
+    .get_results (e)
+    msg = e
+    say msg
+    end
 .end
 
 

Modified: trunk/languages/WMLScript/wmls2pir.pir
==============================================================================
--- trunk/languages/WMLScript/wmls2pir.pir	(original)
+++ trunk/languages/WMLScript/wmls2pir.pir	Tue Dec  9 10:52:59 2008
@@ -45,19 +45,19 @@
     .local string gen_pir
     gen_pir = script.'translate'()
     save_pir(gen_pir, filename)
-    end
-  _handler:
-    .local pmc e
-    .local string s
-    .get_results (e)
-    s = e
-    print s
-    print "\n"
+    pop_eh
   L1:
     end
   USAGE:
     printerr "Usage: parrot wmls2pir.pbc filename\n"
     exit -1
+  _handler:
+    .local pmc e
+    .local string msg
+    .get_results (e)
+    msg = e
+    say msg
+    end
 .end
 
 

Modified: trunk/languages/WMLScript/wmlsd.pir
==============================================================================
--- trunk/languages/WMLScript/wmlsd.pir	(original)
+++ trunk/languages/WMLScript/wmlsd.pir	Tue Dec  9 10:52:59 2008
@@ -41,21 +41,21 @@
     new loader, 'WmlsBytecode'
     push_eh _handler
     script = loader.'load'(content)
+    pop_eh
     script['filename'] = filename
     script.'dump'()
+  L1:
     end
+  USAGE:
+    printerr "Usage: parrot wmlsd.pbc filename\n"
+    exit -1
   _handler:
     .local pmc e
     .local string msg
     .get_results (e)
     msg = e
-    print msg
-    print "\n"
-  L1:
+    say msg
     end
-  USAGE:
-    printerr "Usage: parrot wmlsd.pbc filename\n"
-    exit -1
 .end
 
 

Modified: trunk/languages/WMLScript/wmlsi.pir
==============================================================================
--- trunk/languages/WMLScript/wmlsi.pir	(original)
+++ trunk/languages/WMLScript/wmlsi.pir	Tue Dec  9 10:52:59 2008
@@ -74,19 +74,19 @@
     end
   L4:
     entry(params :flat)
-    end
-  _handler:
-    .local pmc e
-    .local string s
-    .get_results (e)
-    s = e
-    print s
-    print "\n"
+    pop_eh
   L1:
     end
   USAGE:
     printerr "Usage: parrot wmlsi.pbc filename entry\n"
     exit -1
+  _handler:
+    .local pmc e
+    .local string msg
+    .get_results (e)
+    msg = e
+    say msg
+    end
 .end
 
 



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