Author: fperrad Date: Wed May 2 08:16:29 2007 New Revision: 18396 Modified: trunk/CREDITS trunk/languages/lua/Lua/pir.pm
Log: [Lua] [perl #41726] [PATCH] make lua fail more gracefully with an exception handler Courtesy of Julian Fondren ([EMAIL PROTECTED]) Modified: trunk/CREDITS ============================================================================== --- trunk/CREDITS (original) +++ trunk/CREDITS Wed May 2 08:16:29 2007 @@ -291,7 +291,7 @@ N: Jonathan Stowe N: Jonathan Worthington -D: Bits of Win32 support, PBC utilities, debug segment work, .Net +D: Bits of Win32 support, PBC utilities, debug segment work, .Net D: to PIR translator and various patches E: [EMAIL PROTECTED] W: http://www.jwcs.net/~jonathan/ @@ -321,6 +321,7 @@ N: Julian Fondren E: [EMAIL PROTECTED] D: Standardize and add languages/*/MAINTAINER files +D: a patch to catch exception in Lua N: Karl Forner D: shootout examples testing @@ -335,7 +336,7 @@ N: Kevin Falcone N: Kevin Tew -D: Cardinal(Ruby on Parrot), ECMAScript PGE grammar, +D: Cardinal(Ruby on Parrot), ECMAScript PGE grammar, D: Python PGE grammar, C99 PGE Grammar D: Various Config Fixes, Compiler Warnings, etc Modified: trunk/languages/lua/Lua/pir.pm ============================================================================== --- trunk/languages/lua/Lua/pir.pm (original) +++ trunk/languages/lua/Lua/pir.pm Wed May 2 08:16:29 2007 @@ -24,6 +24,7 @@ $P0 = new .Array set $P0, $I0 $I1 = 0 + push_eh root_exception_handler L1: unless $I1 < $I0 goto L2 $S0 = shift args @@ -50,7 +51,22 @@ .local pmc env env = get_global '_G' main.'setfenv'(env) - main($P0 :flat) + .return main($P0 :flat) + +root_exception_handler: + .include 'except_severity.pasm' + .local int severity + get_results '(0, 0)', $P0, $S0 + severity = $P0[2] + if severity == .EXCEPT_EXIT goto lua_exited + $S1 = $P0[0] + $S0 = "Unhandled exception: " + $S0 .= $S1 + $S0 .= "\n" + printerr $S0 + exit 1 +lua_exited: + rethrow $P0 .end .sub '__onload' :anon :init
