Author: fperrad
Date: Sat Feb 3 10:28:40 2007
New Revision: 16887
Modified:
trunk/languages/lua/lib/luabasic.pir
trunk/languages/lua/lib/luacoroutine.pir
trunk/languages/lua/lib/luadebug.pir
trunk/languages/lua/lib/luaio.pir
trunk/languages/lua/lib/luamath.pir
trunk/languages/lua/lib/luaos.pir
trunk/languages/lua/lib/luapackage.pir
trunk/languages/lua/lib/luastring.pir
trunk/languages/lua/lib/luatable.pir
trunk/languages/lua/t/basic.t
Log:
[Lua]
- fix rawset
- fix xpcall
- minor refactor in libraries
Modified: trunk/languages/lua/lib/luabasic.pir
==============================================================================
--- trunk/languages/lua/lib/luabasic.pir (original)
+++ trunk/languages/lua/lib/luabasic.pir Sat Feb 3 10:28:40 2007
@@ -36,7 +36,7 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = new .LuaTable
global '_G' = _lua__GLOBAL
- $P1 = new .LuaString
+ new $P1, .LuaString
=item C<_G>
@@ -47,7 +47,7 @@
=cut
- $P1 = '_G'
+ set $P1, '_G'
_lua__GLOBAL[$P1] = _lua__GLOBAL
=item C<_VERSION>
@@ -57,9 +57,9 @@
=cut
- $P0 = new .LuaString
- $P0 = "Lua 5.1 (on Parrot)"
- $P1 = '_VERSION'
+ new $P0, .LuaString
+ set $P0, "Lua 5.1 (on Parrot)"
+ set $P1, '_VERSION'
_lua__GLOBAL[$P1] = $P0
=back
@@ -71,103 +71,103 @@
=cut
.const .Sub _lua_assert = '_lua_assert'
- $P1 = 'assert'
+ set $P1, 'assert'
_lua__GLOBAL[$P1] = _lua_assert
.const .Sub _lua_collectgarbage = '_lua_collectgarbage'
- $P1 = 'collectgarbage'
+ set $P1, 'collectgarbage'
_lua__GLOBAL[$P1] = _lua_collectgarbage
.const .Sub _lua_dofile = '_lua_dofile'
- $P1 = 'dofile'
+ set $P1, 'dofile'
_lua__GLOBAL[$P1] = _lua_dofile
.const .Sub _lua_error = '_lua_error'
- $P1 = 'error'
+ set $P1, 'error'
_lua__GLOBAL[$P1] = _lua_error
.const .Sub _lua_getfenv = '_lua_getfenv'
- $P1 = 'getfenv'
+ set $P1, 'getfenv'
_lua__GLOBAL[$P1] = _lua_getfenv
.const .Sub _lua_getmetatable = '_lua_getmetatable'
- $P1 = 'getmetatable'
+ set $P1, 'getmetatable'
_lua__GLOBAL[$P1] = _lua_getmetatable
.const .Sub _lua_ipairs = '_lua_ipairs'
- $P1 = 'ipairs'
+ set $P1, 'ipairs'
_lua__GLOBAL[$P1] = _lua_ipairs
.const .Sub _lua_load = '_lua_load'
- $P1 = 'load'
+ set $P1, 'load'
_lua__GLOBAL[$P1] = _lua_load
.const .Sub _lua_loadfile = '_lua_loadfile'
- $P1 = 'loadfile'
+ set $P1, 'loadfile'
_lua__GLOBAL[$P1] = _lua_loadfile
.const .Sub _lua_loadstring = '_lua_loadstring'
- $P1 = 'loadstring'
+ set $P1, 'loadstring'
_lua__GLOBAL[$P1] = _lua_loadstring
.const .Sub _lua_next = '_lua_next'
- $P1 = 'next'
+ set $P1, 'next'
_lua__GLOBAL[$P1] = _lua_next
.const .Sub _lua_pairs = '_lua_pairs'
- $P1 = 'pairs'
+ set $P1, 'pairs'
_lua__GLOBAL[$P1] = _lua_pairs
.const .Sub _lua_pcall = '_lua_pcall'
- $P1 = 'pcall'
+ set $P1, 'pcall'
_lua__GLOBAL[$P1] = _lua_pcall
.const .Sub _lua_print = '_lua_print'
- $P1 = 'print'
+ set $P1, 'print'
_lua__GLOBAL[$P1] = _lua_print
.const .Sub _lua_rawequal = '_lua_rawequal'
- $P1 = 'rawequal'
+ set $P1, 'rawequal'
_lua__GLOBAL[$P1] = _lua_rawequal
.const .Sub _lua_rawget = '_lua_rawget'
- $P1 = 'rawget'
+ set $P1, 'rawget'
_lua__GLOBAL[$P1] = _lua_rawget
.const .Sub _lua_rawset = '_lua_rawset'
- $P1 = 'rawset'
+ set $P1, 'rawset'
_lua__GLOBAL[$P1] = _lua_rawset
.const .Sub _lua_select = '_lua_select'
- $P1 = 'select'
+ set $P1, 'select'
_lua__GLOBAL[$P1] = _lua_select
.const .Sub _lua_setfenv = '_lua_setfenv'
- $P1 = 'setfenv'
+ set $P1, 'setfenv'
_lua__GLOBAL[$P1] = _lua_setfenv
.const .Sub _lua_setmetatable = '_lua_setmetatable'
- $P1 = 'setmetatable'
+ set $P1, 'setmetatable'
_lua__GLOBAL[$P1] = _lua_setmetatable
.const .Sub _lua_tonumber = '_lua_tonumber'
- $P1 = 'tonumber'
+ set $P1, 'tonumber'
_lua__GLOBAL[$P1] = _lua_tonumber
.const .Sub _lua_tostring = '_lua_tostring'
- $P1 = 'tostring'
+ set $P1, 'tostring'
_lua__GLOBAL[$P1] = _lua_tostring
.const .Sub _lua_type = '_lua_type'
- $P1 = 'type'
+ set $P1, 'type'
_lua__GLOBAL[$P1] = _lua_type
.const .Sub _lua_unpack = '_lua_unpack'
- $P1 = 'unpack'
+ set $P1, 'unpack'
_lua__GLOBAL[$P1] = _lua_unpack
.const .Sub _lua_xpcall = '_lua_xpcall'
- $P1 = 'xpcall'
+ set $P1, 'xpcall'
_lua__GLOBAL[$P1] = _lua_xpcall
.end
@@ -186,10 +186,10 @@
.param pmc message :optional
checkany(v)
$I0 = istrue v
- if $I0 goto L0
+ if $I0 goto L1
$S0 = optstring(message, "assertion failed!")
error($S0)
-L0:
+L1:
.return (v, message)
.end
@@ -353,7 +353,7 @@
.param pmc t :optional
.param pmc i :optional
checktype(t, 'table')
- unless_null i, L0
+ unless_null i, L1
.local pmc _G
_G = global '_G'
.const .LuaString key_ipairs = 'ipairs'
@@ -363,15 +363,15 @@
new zero, .LuaNumber
set zero, 0.0
.return (ipairs, t, zero)
-L0:
+L1:
$P0 = checknumber(i)
$P1 = clone $P0
inc $P1
.local pmc ret
ret = t.'rawget'($P1)
- unless ret goto L1
+ unless ret goto L2
.return ($P1, ret)
-L1:
+L2:
.return ()
.end
@@ -460,9 +460,9 @@
.sub '_lua_next' :anon
.param pmc table :optional
- .param pmc index :optional
+ .param pmc idx :optional
checktype(table, 'table')
- $P0 = table.'next'(index)
+ $P0 = table.'next'(idx)
unless $P0 goto L1
.return ($P0 :flat)
L1:
@@ -517,16 +517,16 @@
checkany(f)
push_eh _handler
(ret :slurpy) = f(argv :flat)
- status = 1
+ set status, 1
.return (status, ret :flat)
_handler:
.local pmc e
.local string s
.local pmc msg
.get_results (e, s)
- status = 0
+ set status, 0
new msg, .LuaString
- msg = s
+ set msg, s
.return (status, msg)
.end
@@ -588,11 +588,11 @@
.sub '_lua_rawget' :anon
.param pmc table :optional
- .param pmc index :optional
+ .param pmc idx :optional
.local pmc ret
checktype(table, 'table')
- checkany(index)
- ret = table.'rawget'(index)
+ checkany(idx)
+ ret = table.'rawget'(idx)
.return (ret)
.end
@@ -603,17 +603,19 @@
metamethod. C<table> must be a table, C<index> is any value different from
B<nil>, and C<value> is any Lua value.
+This function returns C<table>.
+
=cut
.sub '_lua_rawset' :anon
.param pmc table :optional
- .param pmc index :optional
+ .param pmc idx :optional
.param pmc value :optional
checktype(table, 'table')
- checkany(index)
+ checkany(idx)
checkany(value)
- table.'rawset'(index, value)
- .return ()
+ table.'rawset'(idx, value)
+ .return (table)
.end
@@ -626,13 +628,13 @@
=cut
.sub '_lua_select' :anon
- .param pmc index :optional
+ .param pmc idx :optional
.param pmc argv :slurpy
.local pmc ret
- unless index goto L1
- $I0 = isa index, 'LuaString'
+ unless idx goto L1
+ $I0 = isa idx, 'LuaString'
unless $I0 goto L1
- $S0 = index
+ $S0 = idx
unless $S0 == '#' goto L1
$I1 = argv
new ret, .LuaNumber
@@ -640,7 +642,7 @@
.return (ret)
L1:
.local int i
- i = checknumber(index)
+ i = checknumber(idx)
.local int n
n = argv
inc n
@@ -699,7 +701,7 @@
given table. If the original metatable has a C<"__metatable"> field, raises
an error.
-This function returns table.
+This function returns C<table>.
=cut
@@ -800,7 +802,7 @@
checkany(v)
$S0 = typeof v
new ret, .LuaString
- ret = $S0
+ set ret, $S0
.return (ret)
.end
@@ -835,7 +837,7 @@
new ret, .Array
set ret, n
new index, .LuaNumber
- index = $I1
+ set index, $I1
idx = 0
L0:
unless idx < n goto L1
@@ -874,14 +876,14 @@
checkany(err)
push_eh _handler
(ret :slurpy) = f()
- status = 1
+ set status, 1
.return (status, ret :flat)
_handler:
.local pmc e
.local pmc msg
- status = 0
+ set status, 0
$S0 = typeof err
- unless $S0 == 'Sub' goto L0
+ unless $S0 == 'function' goto L0
.get_results (e)
(ret :slurpy) = err(e)
.return (status, ret :flat)
Modified: trunk/languages/lua/lib/luacoroutine.pir
==============================================================================
--- trunk/languages/lua/lib/luacoroutine.pir (original)
+++ trunk/languages/lua/lib/luacoroutine.pir Sat Feb 3 10:28:40 2007
@@ -29,38 +29,38 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _coroutine
- _coroutine = new .LuaTable
- $P1 = 'coroutine'
+ new _coroutine, .LuaTable
+ set $P1, 'coroutine'
_lua__GLOBAL[$P1] = _coroutine
.const .Sub _coroutine_create = '_coroutine_create'
- $P1 = 'create'
+ set $P1, 'create'
_coroutine[$P1] = _coroutine_create
.const .Sub _coroutine_resume = '_coroutine_resume'
- $P1 = 'resume'
+ set $P1, 'resume'
_coroutine[$P1] = _coroutine_resume
.const .Sub _coroutine_running = '_coroutine_running'
- $P1 = 'running'
+ set $P1, 'running'
_coroutine[$P1] = _coroutine_running
.const .Sub _coroutine_status = '_coroutine_status'
- $P1 = 'status'
+ set $P1, 'status'
_coroutine[$P1] = _coroutine_status
.const .Sub _coroutine_wrap = '_coroutine_wrap'
- $P1 = 'wrap'
+ set $P1, 'wrap'
_coroutine[$P1] = _coroutine_wrap
.const .Sub _coroutine_yield = '_coroutine_yield'
- $P1 = 'yield'
+ set $P1, 'yield'
_coroutine[$P1] = _coroutine_yield
- $P0 = new .ResizablePMCArray
+ new $P0, .ResizablePMCArray
global '_COROUTINE_STACK' = $P0
.end
@@ -107,14 +107,14 @@
checktype(co, 'thread')
($I0, ret :slurpy) = auxresume(co, argv :flat)
new status, .LuaBoolean
- status = $I0
+ set status, $I0
unless $I0 goto L1
.return (status, ret :flat)
L1:
.local pmc msg
$S0 = ret[0]
new msg, .LuaString
- msg = $S0
+ set msg, $S0
.return (status, msg)
.end
@@ -185,10 +185,10 @@
$P0 = getattribute co, 'co'
$P1 = getattribute $P0, 'state'
if $P1 goto L1
- ret = 'dead'
+ set ret, 'dead'
goto L2
L1:
- ret = 'suspended'
+ set ret, 'suspended'
L2:
.return (ret)
.end
Modified: trunk/languages/lua/lib/luadebug.pir
==============================================================================
--- trunk/languages/lua/lib/luadebug.pir (original)
+++ trunk/languages/lua/lib/luadebug.pir Sat Feb 3 10:28:40 2007
@@ -37,67 +37,67 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _debug
- _debug = new .LuaTable
- $P1 = 'debug'
+ new _debug, .LuaTable
+ set $P1, 'debug'
_lua__GLOBAL[$P1] = _debug
.const .Sub _debug_debug = '_debug_debug'
- $P1 = 'debug'
+ set $P1, 'debug'
_debug[$P1] = _debug_debug
.const .Sub _debug_getfenv = '_debug_getfenv'
- $P1 = 'getfenv'
+ set $P1, 'getfenv'
_debug[$P1] = _debug_getfenv
.const .Sub _debug_gethook = '_debug_gethook'
- $P1 = 'gethook'
+ set $P1, 'gethook'
_debug[$P1] = _debug_gethook
.const .Sub _debug_getinfo = '_debug_getinfo'
- $P1 = 'getinfo'
+ set $P1, 'getinfo'
_debug[$P1] = _debug_getinfo
.const .Sub _debug_getlocal = '_debug_getlocal'
- $P1 = 'getlocal'
+ set $P1, 'getlocal'
_debug[$P1] = _debug_getlocal
.const .Sub _debug_getmetatable = '_debug_getmetatable'
- $P1 = 'getmetatable'
+ set $P1, 'getmetatable'
_debug[$P1] = _debug_getmetatable
.const .Sub _debug_getregistry = '_debug_getregistry'
- $P1 = 'getregistry'
+ set $P1, 'getregistry'
_debug[$P1] = _debug_getregistry
.const .Sub _debug_getupvalue = '_debug_getupvalue'
- $P1 = 'getupvalue'
+ set $P1, 'getupvalue'
_debug[$P1] = _debug_getupvalue
.const .Sub _debug_setfenv = '_debug_setfenv'
- $P1 = 'setfenv'
+ set $P1, 'setfenv'
_debug[$P1] = _debug_setfenv
.const .Sub _debug_sethook = '_debug_sethook'
- $P1 = 'sethook'
+ set $P1, 'sethook'
_debug[$P1] = _debug_sethook
.const .Sub _debug_setlocal = '_debug_setlocal'
- $P1 = 'setlocal'
+ set $P1, 'setlocal'
_debug[$P1] = _debug_setlocal
.const .Sub _debug_setmetatable = '_debug_setmetatable'
- $P1 = 'setmetatable'
+ set $P1, 'setmetatable'
_debug[$P1] = _debug_setmetatable
.const .Sub _debug_setupvalue = '_debug_setupvalue'
- $P1 = 'setupvalue'
+ set $P1, 'setupvalue'
_debug[$P1] = _debug_setupvalue
.const .Sub _debug_traceback = '_debug_traceback'
- $P1 = 'traceback'
+ set $P1, 'traceback'
_debug[$P1] = _debug_traceback
.end
@@ -339,7 +339,7 @@
L1:
table.'set_metatable'(metatable)
new ret, .LuaBoolean
- ret = 1
+ set ret, 1
.return (ret)
.end
Modified: trunk/languages/lua/lib/luaio.pir
==============================================================================
--- trunk/languages/lua/lib/luaio.pir (original)
+++ trunk/languages/lua/lib/luaio.pir Sat Feb 3 10:28:40 2007
@@ -42,55 +42,55 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _io
- _io = new .LuaTable
- $P1 = 'io'
+ new _io, .LuaTable
+ set $P1, 'io'
_lua__GLOBAL[$P1] = _io
.const .Sub _io_close = '_io_close'
- $P1 = 'close'
+ set $P1, 'close'
_io[$P1] = _io_close
.const .Sub _io_flush = '_io_flush'
- $P1 = 'flush'
+ set $P1, 'flush'
_io[$P1] = _io_flush
.const .Sub _io_input = '_io_input'
- $P1 = 'input'
+ set $P1, 'input'
_io[$P1] = _io_input
.const .Sub _io_lines = '_io_lines'
- $P1 = 'lines'
+ set $P1, 'lines'
_io[$P1] = _io_lines
.const .Sub _io_open = '_io_open'
- $P1 = 'open'
+ set $P1, 'open'
_io[$P1] = _io_open
.const .Sub _io_output = '_io_output'
- $P1 = 'output'
+ set $P1, 'output'
_io[$P1] = _io_output
.const .Sub _io_popen = '_io_popen'
- $P1 = 'popen'
+ set $P1, 'popen'
_io[$P1] = _io_popen
.const .Sub _io_read = '_io_read'
- $P1 = 'read'
+ set $P1, 'read'
_io[$P1] = _io_read
.const .Sub _io_tmpfile = '_io_tmpfile'
- $P1 = 'tmpfile'
+ set $P1, 'tmpfile'
_io[$P1] = _io_tmpfile
.const .Sub _io_type = '_io_type'
- $P1 = 'type'
+ set $P1, 'type'
_io[$P1] = _io_type
.const .Sub _io_write = '_io_write'
- $P1 = 'write'
+ set $P1, 'write'
_io[$P1] = _io_write
#
@@ -98,53 +98,53 @@
#
.local pmc _file
- _file = new .LuaTable
+ new _file, .LuaTable
.const .Sub _file_close = '_io_close'
- $P1 = 'close'
+ set $P1, 'close'
_file[$P1] = _file_close
.const .Sub _file_flush = '_file_flush'
- $P1 = 'flush'
+ set $P1, 'flush'
_file[$P1] = _file_flush
.const .Sub _file_lines = '_file_lines'
- $P1 = 'lines'
+ set $P1, 'lines'
_file[$P1] = _file_lines
.const .Sub _file_read = '_file_read'
- $P1 = 'read'
+ set $P1, 'read'
_file[$P1] = _file_read
.const .Sub _file_seek = '_file_seek'
- $P1 = 'seek'
+ set $P1, 'seek'
_file[$P1] = _file_seek
.const .Sub _file_setvbuf = '_file_setvbuf'
- $P1 = 'setvbuf'
+ set $P1, 'setvbuf'
_file[$P1] = _file_setvbuf
.const .Sub _file_write = '_file_write'
- $P1 = 'write'
+ set $P1, 'write'
_file[$P1] = _file_write
# .const .Sub _file__tostring = '_file__tostring'
-# $P1 = '__tostring'
+# set $P1, '__tostring'
# _file[$P1] = _file__tostring
.local pmc _lua_mt_file
- _lua_mt_file = new .LuaTable
- $P1 = '__index'
+ new _lua_mt_file, .LuaTable
+ set $P1, '__index'
_lua_mt_file[$P1] = _file
.const .Sub _file__tostring = '_file__tostring'
- $P1 = '__tostring'
+ set $P1, '__tostring'
_lua_mt_file[$P1] = _file__tostring
.local pmc _lua__REGISTRY
_lua__REGISTRY = global '_REGISTRY'
- $P1 = 'file'
+ set $P1, 'file'
_lua__REGISTRY[$P1] = _lua_mt_file
@@ -154,33 +154,33 @@
.local pmc _lua__ENVIRON
_lua__ENVIRON = global '_ENVIRON'
- $P3 = new .LuaNumber
+ new $P3, .LuaNumber
- $P1 = 'stdin'
+ set $P1, 'stdin'
$P2 = getstdin
- $P0 = new .LuaUserdata
+ new $P0, .LuaUserdata
setattribute $P0, 'data', $P2
$P0.'set_metatable'(_lua_mt_file)
_io[$P1] = $P0
- $P3 = 0
+ set $P3, 0
_lua__ENVIRON[$P3] = $P0
- $P1 = 'stdout'
+ set $P1, 'stdout'
$P2 = getstdout
- $P0 = new .LuaUserdata
+ new $P0, .LuaUserdata
setattribute $P0, 'data', $P2
$P0.'set_metatable'(_lua_mt_file)
_io[$P1] = $P0
- $P3 = 1
+ set $P3, 1
_lua__ENVIRON[$P3] = $P0
- $P1 = 'stderr'
+ set $P1, 'stderr'
$P2 = getstderr
- $P0 = new .LuaUserdata
+ new $P0, .LuaUserdata
setattribute $P0, 'data', $P2
$P0.'set_metatable'(_lua_mt_file)
_io[$P1] = $P0
- $P3 = 2
+ set $P3, 2
_lua__ENVIRON[$P3] = $P0
.end
@@ -193,7 +193,7 @@
.local pmc file
_lua__ENVIRON = global '_ENVIRON'
new io, .LuaNumber
- io = findex
+ set io, findex
file = _lua__ENVIRON[io]
.return (file)
.end
@@ -239,7 +239,7 @@
_lua__REGISTRY = global '_REGISTRY'
.const .LuaString key = 'file'
mt = _lua__REGISTRY[key]
- file = new .LuaUserdata
+ new file, .LuaUserdata
file.'set_metatable'(mt)
.return (file)
.end
@@ -255,7 +255,7 @@
goto L2
L1:
new ret, .LuaString
- ret = $S0
+ set ret, $S0
L2:
.return (ret)
.end
@@ -271,7 +271,7 @@
L1:
chopn $S0, 1
new ret, .LuaString
- ret = $S0
+ set ret, $S0
L2:
.return (ret)
.end
@@ -284,7 +284,7 @@
.local pmc io
_lua__ENVIRON = global '_ENVIRON'
new io, .LuaNumber
- io = findex
+ set io, findex
_lua__ENVIRON[io] = file
.end
@@ -298,7 +298,7 @@
goto L2
L1:
new ret, .LuaString
- ret = ''
+ set ret, ''
L2:
.return (ret)
.end
@@ -388,7 +388,7 @@
tofile(file)
$I0 = aux_close(file)
new ret, .LuaBoolean
- ret = $I0
+ set ret, $I0
.return (ret)
.end
@@ -545,7 +545,7 @@
$S0 = err
concat $S1, ': '
concat $S1, $S0
- msg = $S1
+ set msg, $S1
.return (ret, msg)
.end
@@ -656,10 +656,10 @@
ret = new .LuaString
f = getattribute obj, 'data'
unless_null f, L2
- ret = "closed file"
+ set ret, 'closed file'
goto L3
L2:
- ret = 'file'
+ set ret, 'file'
L3:
.return (ret)
.end
@@ -701,7 +701,7 @@
f = tofile(self)
f.'flush'()
new ret, .LuaBoolean
- ret = 1
+ set ret, 1
.return (ret)
.end
@@ -777,7 +777,7 @@
.local pmc format
narg = formats
new ret, .Array
- ret = narg
+ set ret, narg
i = 0
L2:
unless i < narg goto L3
@@ -861,7 +861,7 @@
.local pmc ret
tofile(self)
new options, .Array
- options = 3
+ set options, 3
options[0] = 'set'
options[1] = 'cur'
options[2] = 'end'
@@ -870,9 +870,9 @@
$I2 = optint(offset, 0)
f = getattribute self, 'data'
seek f, $I2, $I1
- $I3 = tell f
+ $I0 = tell f
new ret, .LuaNumber
- ret = $I3
+ set ret, $I0
.return (ret)
.end
@@ -914,7 +914,7 @@
.local pmc ret
tofile(self)
new options, .Array
- options = 3
+ set options, 3
options[0] = 'no'
options[1] = 'full'
options[2] = 'line'
@@ -960,7 +960,7 @@
goto L1
L2:
new ret, .LuaBoolean
- ret = 1
+ set ret, 1
.return (ret)
.end
@@ -980,7 +980,7 @@
concat $S0, $S1
concat $S0, ")"
L2:
- ret = $S0
+ set ret, $S0
.return (ret)
.end
Modified: trunk/languages/lua/lib/luamath.pir
==============================================================================
--- trunk/languages/lua/lib/luamath.pir (original)
+++ trunk/languages/lua/lib/luamath.pir Sat Feb 3 10:28:40 2007
@@ -56,126 +56,126 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _math
- _math = new .LuaTable
- $P1 = 'math'
+ new _math, .LuaTable
+ set $P1, 'math'
_lua__GLOBAL[$P1] = _math
.const .Sub _math_abs = '_math_abs'
- $P1 = 'abs'
+ set $P1, 'abs'
_math[$P1] = _math_abs
.const .Sub _math_acos = '_math_acos'
- $P1 = 'acos'
+ set $P1, 'acos'
_math[$P1] = _math_acos
.const .Sub _math_asin = '_math_asin'
- $P1 = 'asin'
+ set $P1, 'asin'
_math[$P1] = _math_asin
.const .Sub _math_atan = '_math_atan'
- $P1 = 'atan'
+ set $P1, 'atan'
_math[$P1] = _math_atan
.const .Sub _math_atan2 = '_math_atan2'
- $P1 = 'atan2'
+ set $P1, 'atan2'
_math[$P1] = _math_atan2
.const .Sub _math_ceil = '_math_ceil'
- $P1 = 'ceil'
+ set $P1, 'ceil'
_math[$P1] = _math_ceil
.const .Sub _math_cos = '_math_cos'
- $P1 = 'cos'
+ set $P1, 'cos'
_math[$P1] = _math_cos
.const .Sub _math_deg = '_math_deg'
- $P1 = 'deg'
+ set $P1, 'deg'
_math[$P1] = _math_deg
.const .Sub _math_exp = '_math_exp'
- $P1 = 'exp'
+ set $P1, 'exp'
_math[$P1] = _math_exp
.const .Sub _math_floor = '_math_floor'
- $P1 = 'floor'
+ set $P1, 'floor'
_math[$P1] = _math_floor
.const .Sub _math_fmod = '_math_fmod'
- $P1 = 'fmod'
+ set $P1, 'fmod'
_math[$P1] = _math_fmod
# LUA_COMPAT_MOD
- $P1 = 'mod'
+ set $P1, 'mod'
_math[$P1] = _math_fmod
.const .Sub _math_frexp = '_math_frexp'
- $P1 = 'frexp'
+ set $P1, 'frexp'
_math[$P1] = _math_frexp
.const .Sub _math_ldexp = '_math_ldexp'
- $P1 = 'ldexp'
+ set $P1, 'ldexp'
_math[$P1] = _math_ldexp
.const .Sub _math_log = '_math_log'
- $P1 = 'log'
+ set $P1, 'log'
_math[$P1] = _math_log
.const .Sub _math_log10 = '_math_log10'
- $P1 = 'log10'
+ set $P1, 'log10'
_math[$P1] = _math_log10
.const .Sub _math_max = '_math_max'
- $P1 = 'max'
+ set $P1, 'max'
_math[$P1] = _math_max
.const .Sub _math_min = '_math_min'
- $P1 = 'min'
+ set $P1, 'min'
_math[$P1] = _math_min
.const .Sub _math_modf = '_math_modf'
- $P1 = 'modf'
+ set $P1, 'modf'
_math[$P1] = _math_modf
.const .Sub _math_pow = '_math_pow'
- $P1 = 'pow'
+ set $P1, 'pow'
_math[$P1] = _math_pow
.const .Sub _math_rad = '_math_rad'
- $P1 = 'rad'
+ set $P1, 'rad'
_math[$P1] = _math_rad
.const .Sub _math_random = '_math_random'
- $P1 = 'random'
+ set $P1, 'random'
_math[$P1] = _math_random
.const .Sub _math_randomseed = '_math_randomseed'
- $P1 = 'randomseed'
+ set $P1, 'randomseed'
_math[$P1] = _math_randomseed
.const .Sub _math_sin = '_math_sin'
- $P1 = 'sin'
+ set $P1, 'sin'
_math[$P1] = _math_sin
.const .Sub _math_sqrt = '_math_sqrt'
- $P1 = 'sqrt'
+ set $P1, 'sqrt'
_math[$P1] = _math_sqrt
.const .Sub _math_tan = '_math_tan'
- $P1 = 'tan'
+ set $P1, 'tan'
_math[$P1] = _math_tan
- $P0 = new .LuaNumber
- $P0 = 3.14159265358979323846
+ new $P0, .LuaNumber
+ set $P0, 3.14159265358979323846
$P1 = 'pi'
_math[$P1] = $P0
- $P0 = new .LuaNumber
- $P0 = 1.0
- $P2 = new .LuaNumber
- $P2 = 0.0
+ new $P0, .LuaNumber
+ set $P0, 1.0
+ new $P2, .LuaNumber
+ set $P2, 0.0
div $P0, $P2
$P1 = 'huge'
_math[$P1] = $P0
@@ -189,7 +189,7 @@
$N0 = checknumber(x)
$N1 = abs $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -200,7 +200,7 @@
$N0 = checknumber(x)
$N1 = acos $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -211,7 +211,7 @@
$N0 = checknumber(x)
$N1 = asin $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -222,7 +222,7 @@
$N0 = checknumber(x)
$N1 = atan $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -235,7 +235,7 @@
$N1 = checknumber(x)
$N2 = atan $N0, $N1
new ret, .LuaNumber
- ret = $N2
+ set ret, $N2
.return (ret)
.end
@@ -246,7 +246,7 @@
$N0 = checknumber(x)
$N1 = ceil $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -257,7 +257,7 @@
$N0 = checknumber(x)
$N1 = cos $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -269,7 +269,7 @@
$N1 = 3.14159265358979323846 / 180.0
$N2 = $N0 / $N1
new ret, .LuaNumber
- ret = $N2
+ set ret, $N2
.return (ret)
.end
@@ -280,7 +280,7 @@
$N0 = checknumber(x)
$N1 = exp $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -291,7 +291,7 @@
$N0 = checknumber(x)
$N1 = floor $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -304,7 +304,7 @@
$N1 = checknumber(y)
$N2 = cmod $N0, $N1
new ret, .LuaNumber
- ret = $N2
+ set ret, $N2
.return (ret)
.end
@@ -337,7 +337,7 @@
$N0 = checknumber(x)
$N1 = ln $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -348,7 +348,7 @@
$N0 = checknumber(x)
$N1 = log10 $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -357,30 +357,26 @@
.param pmc argv :slurpy
.local int argc
.local int i
- .local float dmax
- .local float d
- .local pmc curr
- .local pmc ret
+ .local pmc dmax
argc = argv
unless argc == 0 goto L0
tag_error("no value", 'number')
L0:
- curr = argv[0]
- dmax = checknumber(curr)
+ $P0 = argv[0]
+ dmax = checknumber($P0)
i = 1
L1:
if i >= argc goto L3
- curr = argv[i]
- d = checknumber(curr)
- if dmax > d goto L2
- dmax = d
+ $P0 = argv[i]
+ $P1 = checknumber($P0)
+ if dmax > $P1 goto L2
+ dmax = $P1
L2:
inc i
goto L1
L3:
- new ret, .LuaNumber
- ret = dmax
- .return (ret)
+ $P0 = clone dmax
+ .return ($P0)
.end
@@ -388,30 +384,26 @@
.param pmc argv :slurpy
.local int argc
.local int i
- .local float dmin
- .local float d
- .local pmc curr
- .local pmc ret
+ .local pmc dmin
argc = argv
unless argc == 0 goto L0
tag_error("no value", 'number')
L0:
- curr = argv[0]
- dmin = checknumber(curr)
+ $P0 = argv[0]
+ dmin = checknumber($P0)
i = 1
L1:
if i >= argc goto L3
- curr = argv[i]
- d = checknumber(curr)
- if dmin < d goto L2
- dmin = d
+ $P0 = argv[i]
+ $P1 = checknumber($P0)
+ if dmin < $P1 goto L2
+ dmin = $P1
L2:
inc i
goto L1
L3:
- new ret, .LuaNumber
- ret = dmin
- .return (ret)
+ $P0 = clone dmin
+ .return ($P0)
.end
@@ -433,7 +425,7 @@
$N1 = checknumber(y)
$N2 = pow $N0, $N1
new ret, .LuaNumber
- ret = $N2
+ set ret, $N2
.return (ret)
.end
@@ -445,7 +437,7 @@
$N1 = 3.14159265358979323846 / 180.0
$N2 = $N0 * $N1
new ret, .LuaNumber
- ret = $N2
+ set ret, $N2
.return (ret)
.end
@@ -461,7 +453,7 @@
$N0 = $P0
new ret, .LuaNumber
unless_null arg1, L1
- ret = $N0
+ set ret, $N0
goto L2
L1:
unless_null arg2, L3
@@ -470,7 +462,7 @@
mul $N0, u
$I0 = floor $N0
inc $I0
- ret = $I0
+ set ret, $I0
goto L2
L3:
if extra goto L5
@@ -482,7 +474,7 @@
mul $N0, $I0
$I0 = floor $N0
add $I0, l
- ret = $I0
+ set ret, $I0
goto L2
L4:
argerror("interval is empty")
@@ -497,7 +489,7 @@
.param pmc seed :optional
$I0 = checknumber(seed)
new $P0, .Random
- $P0 = $I0
+ set $P0, $I0
.end
@@ -507,7 +499,7 @@
$N0 = checknumber(x)
$N1 = sin $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -518,7 +510,7 @@
$N0 = checknumber(x)
$N1 = sqrt $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
@@ -529,7 +521,7 @@
$N0 = checknumber(x)
$N1 = tan $N0
new ret, .LuaNumber
- ret = $N1
+ set ret, $N1
.return (ret)
.end
Modified: trunk/languages/lua/lib/luaos.pir
==============================================================================
--- trunk/languages/lua/lib/luaos.pir (original)
+++ trunk/languages/lua/lib/luaos.pir Sat Feb 3 10:28:40 2007
@@ -27,55 +27,55 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _os
- _os = new .LuaTable
- $P1 = 'os'
+ new _os, .LuaTable
+ set $P1, 'os'
_lua__GLOBAL[$P1] = _os
.const .Sub _os_clock = '_os_clock'
- $P1 = 'clock'
+ set $P1, 'clock'
_os[$P1] = _os_clock
.const .Sub _os_date = '_os_date'
- $P1 = 'date'
+ set $P1, 'date'
_os[$P1] = _os_date
.const .Sub _os_difftime = '_os_difftime'
- $P1 = 'difftime'
+ set $P1, 'difftime'
_os[$P1] = _os_difftime
.const .Sub _os_execute = '_os_execute'
- $P1 = 'execute'
+ set $P1, 'execute'
_os[$P1] = _os_execute
.const .Sub _os_exit = '_os_exit'
- $P1 = 'exit'
+ set $P1, 'exit'
_os[$P1] = _os_exit
.const .Sub _os_getenv = '_os_getenv'
- $P1 = 'getenv'
+ set $P1, 'getenv'
_os[$P1] = _os_getenv
.const .Sub _os_remove = '_os_remove'
- $P1 = 'remove'
+ set $P1, 'remove'
_os[$P1] = _os_remove
.const .Sub _os_rename = '_os_rename'
- $P1 = 'rename'
+ set $P1, 'rename'
_os[$P1] = _os_rename
.const .Sub _os_setlocale = '_os_setlocale'
- $P1 = 'setlocale'
+ set $P1, 'setlocale'
_os[$P1] = _os_setlocale
.const .Sub _os_time = '_os_time'
- $P1 = 'time'
+ set $P1, 'time'
_os[$P1] = _os_time
.const .Sub _os_tmpname = '_os_tmpname'
- $P1 = 'tmpname'
+ set $P1, 'tmpname'
_os[$P1] = _os_tmpname
.end
@@ -213,7 +213,7 @@
.return (ret)
L0:
new ret, .LuaString
- ret = $S1
+ set ret, $S1
.return (ret)
.end
@@ -235,7 +235,7 @@
push_eh _handler
$P0.'rm'($S0)
new ret, .LuaBoolean
- ret = 1
+ set ret, 1
.return (ret)
_handler:
.local pmc nil
@@ -247,7 +247,7 @@
concat $S1, s
new nil, .LuaNil
new msg, .LuaString
- msg = $S1
+ set msg, $S1
.return (nil, msg)
.end
@@ -270,7 +270,7 @@
push_eh _handler
$P0.'rename'($S0, $S1)
new ret, .LuaBoolean
- ret = 1
+ set ret, 1
.return (ret)
_handler:
.local pmc nil
@@ -282,7 +282,7 @@
concat $S2, s
new nil, .LuaNil
new msg, .LuaString
- msg = $S2
+ set msg, $S2
.return (nil, msg)
.end
@@ -333,7 +333,7 @@
L0:
$I0 = time
new ret, .LuaNumber
- ret = $I0
+ set ret, $I0
.return (ret)
L1:
checktype(table, 'table')
Modified: trunk/languages/lua/lib/luapackage.pir
==============================================================================
--- trunk/languages/lua/lib/luapackage.pir (original)
+++ trunk/languages/lua/lib/luapackage.pir Sat Feb 3 10:28:40 2007
@@ -26,43 +26,43 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.const .Sub _lua_module = '_lua_module'
- $P1 = 'module'
+ set $P1, 'module'
_lua__GLOBAL[$P1] = _lua_module
.const .Sub _lua_require = '_lua_require'
- $P1 = 'require'
+ set $P1, 'require'
_lua__GLOBAL[$P1] = _lua_require
.local pmc _package
- _package = new .LuaTable
- $P1 = 'package'
+ new _package, .LuaTable
+ set $P1, 'package'
_lua__GLOBAL[$P1] = _package
- $P0 = new .LuaString
- $P1 = 'cpath'
+ new $P0, .LuaString
+ set $P1, 'cpath'
_package[$P1] = $P0
- $P0 = new .LuaTable
- $P1 = 'loaded'
+ new $P0, .LuaTable
+ set $P1, 'loaded'
_package[$P1] = $P0
.const .Sub _package_loadlib = '_package_loadlib'
- $P1 = 'loadlib'
+ set $P1, 'loadlib'
_package[$P1] = _package_loadlib
- $P0 = new .LuaString
- $P1 = 'path'
+ new $P0, .LuaString
+ set $P1, 'path'
_package[$P1] = $P0
- $P0 = new .LuaTable
- $P1 = 'preloaded'
+ new $P0, .LuaTable
+ set $P1, 'preloaded'
_package[$P1] = $P0
.const .Sub _package_seeall = '_package_seeall'
- $P1 = 'seeall'
+ set $P1, 'seeall'
_package[$P1] = _package_seeall
.end
Modified: trunk/languages/lua/lib/luastring.pir
==============================================================================
--- trunk/languages/lua/lib/luastring.pir (original)
+++ trunk/languages/lua/lib/luastring.pir Sat Feb 3 10:28:40 2007
@@ -38,74 +38,74 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _string
- _string = new .LuaTable
- $P1 = 'string'
+ new _string, .LuaTable
+ set $P1, 'string'
_lua__GLOBAL[$P1] = _string
.const .Sub _string_byte = '_string_byte'
- $P1 = 'byte'
+ set $P1, 'byte'
_string[$P1] = _string_byte
.const .Sub _string_char = '_string_char'
- $P1 = 'char'
+ set $P1, 'char'
_string[$P1] = _string_char
.const .Sub _string_dump = '_string_dump'
- $P1 = 'dump'
+ set $P1, 'dump'
_string[$P1] = _string_dump
.const .Sub _string_find = '_string_find'
- $P1 = 'find'
+ set $P1, 'find'
_string[$P1] = _string_find
.const .Sub _string_format = '_string_format'
- $P1 = 'format'
+ set $P1, 'format'
_string[$P1] = _string_format
.const .Sub _string_gmatch = '_string_gmatch'
- $P1 = 'gmatch'
+ set $P1, 'gmatch'
_string[$P1] = _string_gmatch
.const .Sub _string_gsub = '_string_gsub'
- $P1 = 'gsub'
+ set $P1, 'gsub'
_string[$P1] = _string_gsub
.const .Sub _string_len = '_string_len'
- $P1 = 'len'
+ set $P1, 'len'
_string[$P1] = _string_len
.const .Sub _string_lower = '_string_lower'
- $P1 = 'lower'
+ set $P1, 'lower'
_string[$P1] = _string_lower
.const .Sub _string_match = '_string_match'
- $P1 = 'match'
+ set $P1, 'match'
_string[$P1] = _string_match
.const .Sub _string_rep = '_string_rep'
- $P1 = 'rep'
+ set $P1, 'rep'
_string[$P1] = _string_rep
.const .Sub _string_reverse = '_string_reverse'
- $P1 = 'reverse'
+ set $P1, 'reverse'
_string[$P1] = _string_reverse
.const .Sub _string_sub = '_string_sub'
- $P1 = 'sub'
+ set $P1, 'sub'
_string[$P1] = _string_sub
.const .Sub _string_upper = '_string_upper'
- $P1 = 'upper'
+ set $P1, 'upper'
_string[$P1] = _string_upper
.local pmc _lua_mt_string
- _lua_mt_string = new .LuaTable
+ new _lua_mt_string, .LuaTable
global 'mt_string' = _lua_mt_string
- $P1 = '__index'
+ set $P1, '__index'
_lua_mt_string[$P1] = _string
.end
Modified: trunk/languages/lua/lib/luatable.pir
==============================================================================
--- trunk/languages/lua/lib/luatable.pir (original)
+++ trunk/languages/lua/lib/luatable.pir Sat Feb 3 10:28:40 2007
@@ -32,47 +32,47 @@
.local pmc _lua__GLOBAL
_lua__GLOBAL = global '_G'
- $P1 = new .LuaString
+ new $P1, .LuaString
.local pmc _table
- _table = new .LuaTable
- $P1 = 'table'
+ new _table, .LuaTable
+ set $P1, 'table'
_lua__GLOBAL[$P1] = _table
.const .Sub _table_concat = '_table_concat'
- $P1 = 'concat'
+ set $P1, 'concat'
_table[$P1] = _table_concat
.const .Sub _table_foreach = '_table_foreach'
- $P1 = 'foreach'
+ set $P1, 'foreach'
_table[$P1] = _table_foreach
.const .Sub _table_foreachi = '_table_foreachi'
- $P1 = 'foreachi'
+ set $P1, 'foreachi'
_table[$P1] = _table_foreachi
.const .Sub _table_getn = '_table_getn'
- $P1 = 'getn'
+ set $P1, 'getn'
_table[$P1] = _table_getn
.const .Sub _table_insert = '_table_insert'
- $P1 = 'insert'
+ set $P1, 'insert'
_table[$P1] = _table_insert
.const .Sub _table_maxn = '_table_maxn'
- $P1 = 'maxn'
+ set $P1, 'maxn'
_table[$P1] = _table_maxn
.const .Sub _table_remove = '_table_remove'
- $P1 = 'remove'
+ set $P1, 'remove'
_table[$P1] = _table_remove
.const .Sub _table_setn = '_table_setn'
- $P1 = 'setn'
+ set $P1, 'setn'
_table[$P1] = _table_setn
.const .Sub _table_sort = '_table_sort'
- $P1 = 'sort'
+ set $P1, 'sort'
_table[$P1] = _table_sort
.end
@@ -95,36 +95,36 @@
.param pmc j :optional
.local pmc idx
.local pmc value
- .local pmc ret
+ .local string ret
.local int last
- $S0 = optstring(sep, '')
+ $S2 = optstring(sep, '')
checktype(table, 'table')
- $I0 = optint(i, 1)
- $I1 = table.'len'()
- last = optint(j, $I1)
- $S1 = ''
+ $I3 = optint(i, 1)
+ $I0 = table.'len'()
+ last = optint(j, $I0)
+ ret = ''
new idx, .LuaNumber
-L2:
- unless $I0 <= last goto L3
- idx = $I0
+L1:
+ unless $I3 <= last goto L2
+ set idx, $I3
value = table.'rawget'(idx)
- $I2 = isa value, 'LuaString'
- if $I2 goto L4
- $I2 = isa value, 'LuaNumber'
- if $I2 goto L4
+ $I0 = isa value, 'LuaString'
+ if $I0 goto L3
+ $I0 = isa value, 'LuaNumber'
+ if $I0 goto L3
argerror("table contains non-strings")
-L4:
- $S2 = value
- concat $S1, $S2
- unless $I0 != last goto L5
- concat $S1, $S0
-L5:
- add $I0, 1
- goto L2
L3:
- new ret, .LuaString
- ret = $S1
- .return (ret)
+ $S0 = value
+ concat ret, $S0
+ unless $I3 != last goto L4
+ concat ret, $S2
+L4:
+ inc $I3
+ goto L1
+L2:
+ new $P0, .LuaString
+ set $P0, ret
+ .return ($P0)
.end
@@ -179,7 +179,7 @@
.sub '_table_foreachi' :anon
.param pmc table :optional
.param pmc f :optional
- .local pmc index
+ .local pmc idx
.local pmc value
.local pmc ret
.local int i
@@ -188,13 +188,13 @@
checktype(f, 'function')
n = table.'len'()
i = 0
- new index, .LuaNumber
+ new idx, .LuaNumber
L1:
- add i, 1
+ inc i
unless i <= n goto L2
- index = i
- value = table.'rawget'(index)
- (ret) = f(index, value)
+ set idx, i
+ value = table.'rawget'(idx)
+ (ret) = f(idx, value)
$I0 = defined ret
unless $I0 goto L1
.return (ret)
@@ -234,10 +234,10 @@
.param pmc arg2 :optional
.param pmc arg3 :optional
.local pmc value
- .local pmc index
+ .local pmc idx
.local int e
.local int pos
- new index, .LuaNumber
+ new idx, .LuaNumber
checktype(table, 'table')
e = table.'len'()
inc e
@@ -254,15 +254,14 @@
L4:
dec e
unless e >= pos goto L2
- index = e
- $P0 = table.'rawget'(index)
- $I0 = e + 1
- index = $I0
- table.'rawset'(index, $P0)
+ set idx, e
+ $P0 = table.'rawget'(idx)
+ inc idx
+ table.'rawset'(idx, $P0)
goto L4
L2:
- index = pos
- table.'rawset'(index, value)
+ set idx, pos
+ table.'rawset'(idx, value)
.end
@@ -280,7 +279,7 @@
.local pmc max
checktype(table, 'table')
new max, .LuaNumber
- max = 0
+ set max, 0
new idx, .LuaNil
L1:
$P0 = table.'next'(idx)
@@ -309,7 +308,7 @@
.sub '_table_remove' :anon
.param pmc table :optional
.param pmc pos :optional
- .local pmc index
+ .local pmc idx
.local pmc ret
.local int e
.local int ipos
@@ -317,30 +316,29 @@
e = table.'len'()
ipos = optint(pos, e)
unless e <= 0 goto L1
+ # table is `empty'
new ret, .LuaNil
.return (ret)
L1:
- $I1 = e - 1
- new index, .LuaNumber
- index = ipos
- ret = table.'rawget'(index)
+ new idx, .LuaNumber
+ set idx, ipos
+ ret = table.'rawget'(idx)
L2:
unless ipos < e goto L3
$I2 = ipos + 1
- index = $I2
- $P0 = table.'rawget'(index)
- index = ipos
- table.'rawset'(index, $P0)
+ set idx, $I2
+ $P0 = table.'rawget'(idx)
+ set idx, ipos
+ table.'rawset'(idx, $P0)
ipos = $I2
goto L2
L3:
new $P0, .LuaNil
- index = e
- table.'rawset'(index, $P0)
+ set idx, e
+ table.'rawset'(idx, $P0)
.return (ret)
.end
-
=item C<table.setn (table, n)>
B<OBSOLETE>
@@ -388,70 +386,64 @@
.param pmc comp
.param int l
.param int u
- .local pmc index
+ .local pmc idx1
+ .local pmc idx2
.local int i
.local int j
.local int tmp
- new index, .LuaNumber
+ new idx1, .LuaNumber
+ new idx2, .LuaNumber
L1:
unless l < u goto L2
# sort elements a[l], a[(l+u)/2] and a[u]
- set index, l
- $P1 = table.'rawget'(index)
- set index, u
- $P2 = table.'rawget'(index)
+ set idx1, l
+ set idx2, u
+ $P1 = table.'rawget'(idx1)
+ $P2 = table.'rawget'(idx2)
$I0 = sort_comp(comp, $P2, $P1) # a[u] < a[l]?
unless $I0 goto L3
# swap a[l] - a[u]
- set index, l
- table.'rawset'(index, $P2)
- set index, u
- table.'rawset'(index, $P1)
+ table.'rawset'(idx1, $P2)
+ table.'rawset'(idx2, $P1)
L3:
tmp = u - l
if tmp == 1 goto L2 # break: only 2 elements
i = l + u
i /= 2
- set index, i
- $P1 = table.'rawget'(index)
- set index, l
- $P2 = table.'rawget'(index)
+ set idx1, i
+ set idx2, l
+ $P1 = table.'rawget'(idx1)
+ $P2 = table.'rawget'(idx2)
$I0 = sort_comp(comp, $P1, $P2) # a[i]<a[l]?
unless $I0 goto L4
- set index, i
- table.'rawset'(index, $P2)
- set index, l
- table.'rawset'(index, $P1)
+ table.'rawset'(idx1, $P2)
+ table.'rawset'(idx2, $P1)
goto L5
L4:
- set index, u
- $P2 = table.'rawget'(index)
+ set idx2, u
+ $P2 = table.'rawget'(idx2)
$I0 = sort_comp(comp, $P2, $P1) # a[u]<a[i]?
unless $I0 goto L5
- set index, i
- table.'rawset'(index, $P2)
- set index, u
- table.'rawset'(index, $P1)
+ table.'rawset'(idx1, $P2)
+ table.'rawset'(idx2, $P1)
L5:
tmp = u - l
if tmp == 2 goto L2 # break: only 3 elements
- set index, i
- $P1 = table.'rawget'(index) # Pivot
+ set idx1, i
+ $P1 = table.'rawget'(idx1) # Pivot
tmp = u - 1
- set index, tmp
- $P2 = table.'rawget'(index)
- set index, i
- table.'rawset'(index, $P2)
- set index, tmp
- table.'rawset'(index, $P1)
+ set idx2, tmp
+ $P2 = table.'rawget'(idx2)
+ table.'rawset'(idx1, $P2)
+ table.'rawset'(idx2, $P1)
# a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
i = l
j = u - 1
L6: # invariant: a[l..i] <= P <= a[j..u]
# repeat ++i until a[i] >= P
inc i
- set index, i
- $P2 = table.'rawget'(index)
+ set idx2, i
+ $P2 = table.'rawget'(idx2)
$I0 = sort_comp(comp, $P2, $P1)
unless $I0 goto L7
unless i > u goto L6
@@ -460,8 +452,8 @@
L7:
# repeat --j until a[j] <= P
dec j
- set index, j
- $P3 = table.'rawget'(index)
+ set idx1, j
+ $P3 = table.'rawget'(idx1)
$I0 = sort_comp(comp, $P1, $P3)
unless $I0 goto L8
unless j < l goto L7
@@ -469,22 +461,18 @@
goto L7
L8:
if j < i goto L9
- set index, i
- table.'rawset'(index, $P3)
- set index, j
- table.'rawset'(index, $P2)
+ table.'rawset'(idx2, $P3)
+ table.'rawset'(idx1, $P2)
goto L6
L9:
tmp = u - 1
- set index, tmp
- $P1 = table.'rawget'(index)
- set index, i
- $P2 = table.'rawget'(index)
+ set idx1, tmp
+ set idx2, i
+ $P1 = table.'rawget'(idx1)
+ $P2 = table.'rawget'(idx2)
# swap pivot (a[u-1]) with a[i]
- set index, tmp
- table.'rawset'(index, $P2)
- set index, i
- table.'rawset'(index, $P1)
+ table.'rawset'(idx1, $P2)
+ table.'rawset'(idx2, $P1)
# a[l..i-1] <= a[i] == P <= a[i+1..u]
# adjust so that smaller half is in [j..i] and larger one in [l..u]
tmp += l
Modified: trunk/languages/lua/t/basic.t
==============================================================================
--- trunk/languages/lua/t/basic.t (original)
+++ trunk/languages/lua/t/basic.t Sat Feb 3 10:28:40 2007
@@ -25,7 +25,7 @@
use FindBin;
use lib "$FindBin::Bin";
-use Parrot::Test tests => 28;
+use Parrot::Test tests => 29;
use Test::More;
language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function assert' );
@@ -214,7 +214,7 @@
language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function rawset' );
t = {}
-rawset(t, "a", "letter a")
+assert(rawset(t, "a", "letter a") == t)
print(t.a)
CODE
letter a
@@ -367,6 +367,17 @@
false
OUTPUT
+language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function xpcall
(backtrace)' );
+function backtrace ()
+ return 'not a back trace'
+end
+
+r, m = xpcall(assert, backtrace)
+print(r, m)
+CODE
+false not a back trace
+OUTPUT
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4