ppush/ppop

This commit is contained in:
p.kosyh 2009-10-23 12:39:21 +00:00
parent a3a55c14ad
commit 05528dfaab

View file

@ -8,15 +8,23 @@ stead = {
txt = {}, txt = {},
} }
function pstart() function ppush()
stead.txt_top = stead.txt_top + 1; stead.txt_top = stead.txt_top + 1;
end
function ppop()
stead.txt_top = stead.txt_top - 1;
if stead.txt_top < 0 then
error "pstart/pend mismatch"
end
end
function pstart()
stead.txt[stead.txt_top] = nil stead.txt[stead.txt_top] = nil
end end
function pend() function pend()
local r = stead.txt[stead.txt_top] return stead.txt[stead.txt_top]
stead.txt_top = stead.txt_top - 1;
return r
end end
function p(...) function p(...)
@ -558,13 +566,14 @@ function call(v, n, ...)
return v[n]; return v[n];
end end
if type(v[n]) == 'function' then if type(v[n]) == 'function' then
ppush()
pstart() pstart()
local a,b = v[n](v, unpack(arg)); local a,b = v[n](v, unpack(arg));
if a == nil and b == nil then if a == nil and b == nil then
return pend(); a = pend();
else b = nil;
pend();
end end
ppop()
return a,b return a,b
end end
error ("Method not string nor function:"..tostring(n)); error ("Method not string nor function:"..tostring(n));