Author: fperrad
Date: Mon May 21 00:14:40 2007
New Revision: 18606
Modified:
trunk/languages/lua/lib/lfs.pir
trunk/languages/lua/lib/luaaux.pir
trunk/languages/lua/lib/luaos.pir
trunk/languages/lua/lib/luapackage.pir
trunk/languages/lua/lib/luastring.pir
Log:
[Lua]
- refactor *_error calls
Modified: trunk/languages/lua/lib/lfs.pir
==============================================================================
--- trunk/languages/lua/lib/lfs.pir (original)
+++ trunk/languages/lua/lib/lfs.pir Mon May 21 00:14:40 2007
@@ -116,8 +116,7 @@
lua_checkudata(narg, fh, 'ParrotIO')
ret = getattribute fh, 'data'
unless null ret goto L1
- $S0 = concat funcname, ": closed file"
- lua_error($S0)
+ lua_error(funcname, ": closed file")
L1:
.return (ret)
.end
@@ -518,10 +517,7 @@
.local pmc e
.local string s
.get_results (e, s)
- $S0 = concat "cannot open ", $S0
- $S0 = concat ": "
- $S0 = concat s
- lua_error($S0)
+ lua_error("cannot open ", $S0, ": ", s)
.end
.sub 'dir_aux' :anon :lex :outer(dir)
Modified: trunk/languages/lua/lib/luaaux.pir
==============================================================================
--- trunk/languages/lua/lib/luaaux.pir (original)
+++ trunk/languages/lua/lib/luaaux.pir Mon May 21 00:14:40 2007
@@ -16,23 +16,17 @@
.HLL 'Lua', 'lua_group'
-=item C<lua_argerror (narg, extramsg)>
+=item C<lua_argerror (narg, extramsg, ...)>
=cut
.sub 'lua_argerror'
.param int narg
- .param string extramsg
+ .param pmc extramsg :slurpy
$S1 = narg
- $S0 = "bad argument #" . $S1
- $S0 .= " to '"
new $P0, .Lua
- $S1 = $P0.'caller'()
- $S0 .= $S1
- $S0 .= "' ("
- $S0 .= extramsg
- $S0 .= ")"
- lua_error($S0)
+ $S0 = $P0.'caller'()
+ lua_error("bad argument #", $S1, " to '", $S0, "' (", extramsg :flat, ")")
.end
@@ -96,10 +90,7 @@
inc i
goto L1
L2:
- $S0 = "invalid option '"
- concat $S0, name
- concat $S0, "'"
- lua_argerror(narg, $S0)
+ lua_argerror(narg, "invalid option '", name, "'")
.end
@@ -175,15 +166,16 @@
.end
-=item C<lua_error (message)>
+=item C<lua_error (message, ...)>
=cut
.sub 'lua_error'
- .param string message
+ .param pmc message :slurpy
+ $S0 = join '', message
.local pmc ex
ex = new .Exception
- ex['_message'] = message
+ ex['_message'] = $S0
throw ex
.end
@@ -427,10 +419,7 @@
.param int narg
.param string got
.param string expec
- $S0 = expec
- concat $S0, " expected, got "
- concat $S0, got
- lua_argerror(narg, $S0)
+ lua_argerror(narg, expec, " expected, got ", got)
.end
Modified: trunk/languages/lua/lib/luaos.pir
==============================================================================
--- trunk/languages/lua/lib/luaos.pir (original)
+++ trunk/languages/lua/lib/luaos.pir Mon May 21 00:14:40 2007
@@ -464,10 +464,7 @@
goto L2
L1:
unless d < 0 goto L3
- $S0 = "field '"
- $S0 .= key
- $S0 .= "' missing in date table"
- lua_error($S0)
+ lua_error("field '", key, "' missing in date table")
L3:
ret = d
L2:
Modified: trunk/languages/lua/lib/luapackage.pir
==============================================================================
--- trunk/languages/lua/lib/luapackage.pir (original)
+++ trunk/languages/lua/lib/luapackage.pir Mon May 21 00:14:40 2007
@@ -130,10 +130,7 @@
$P0 = $P0[$P1]
$I0 = isa $P0, 'LuaString'
if $I0 goto L1
- $S0 = "'package."
- $S0 .= pname
- $S0 .= "' must be a string"
- lua_error($S0)
+ lua_error("'package.", pname, "' must be a string")
L1:
.local string path
.local string tmpl
@@ -188,13 +185,7 @@
.param string name
.param string filename
.param string msg
- $S0 = "error loading module '"
- $S0 .= name
- $S0 .= "' from file '"
- $S0 .= filename
- $S0 .= "':\n\t"
- $S0 .= msg
- lua_error($S0)
+ lua_error("error loading module '", name, "' from file '", filename,
"':\n\t", msg)
.end
.sub 'loader_Lua' :anon
@@ -350,10 +341,7 @@
$P0 = global '_G'
m = lua_findtable($P0, $S1)
unless null m goto L2
- $S0 = "name conflict for module '"
- $S0 .= $S1
- $S0 .= "'"
- lua_error($S0)
+ lua_error("name conflict for module '", $S1, "'")
L2:
_LOADED[name] = m
L1:
@@ -432,10 +420,7 @@
unless $I0 goto L1
$I0 = isa ret, 'LuaUserdata'
unless $I0 goto L2
- $S0 = "loop or previous error loading module '"
- $S0 .= $S1
- $S0 .= "'"
- lua_error($S0)
+ lua_error("loop or previous error loading module '", $S1, "'")
L2:
# package is already loaded
.return (ret)
@@ -456,12 +441,8 @@
$P0 = loaders[i] # get a loader
$I0 = isa $P0, 'LuaNil'
unless $I0 goto L4
- $S0 = "module '"
- $S0 .= $S1
- $S0 .= "' not found:"
- $S1 = msg
- $S0 .= $S1
- lua_error($S0)
+ $S0 = msg
+ lua_error("module '", $S1, "' not found:", $S0)
L4:
new $P1, .LuaNil
$P1 = $P0(modname) # call it
Modified: trunk/languages/lua/lib/luastring.pir
==============================================================================
--- trunk/languages/lua/lib/luastring.pir (original)
+++ trunk/languages/lua/lib/luastring.pir Mon May 21 00:14:40 2007
@@ -512,9 +512,7 @@
buff = sprintf form, $P1
goto L6
L10:
- $S1 = "invalid option '%" . $S0
- $S1 .= "' to 'format'"
- lua_error($S1)
+ lua_error("invalid option '%", $S0, "' to 'format'")
L6:
b .= buff
inc idx
@@ -793,11 +791,8 @@
if $I0 goto L8
$I0 = isa $P1, 'LuaNumber'
if $I0 goto L8
- $S0 = "invalid replacement value (a "
$S1 = typeof $P1
- $S0 .= $S1
- $S0 .= ")"
- lua_error($S0)
+ lua_error("invalid replacement value (a ", $S1, ")")
L8:
$S1 = b
$I0 = match.'from'()