diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-11-21 16:57:19 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-11-21 16:57:19 +0100 |
commit | 8401067436d466b62459283139aa5f7bdf5be0c8 (patch) | |
tree | e4ba77b39dc3c3fe6eb5f3a66513afb32c5990ca /lualibs-util-sta.lua | |
parent | 13e578a1d0f803d8ec7d42d70bb6f773a44e84b0 (diff) | |
parent | 7d8afd6591e978a6a85bf29bbcdbeb3e3936d4d5 (diff) | |
download | lualibs-8401067436d466b62459283139aa5f7bdf5be0c8.tar.gz |
Merge pull request #27 from phi-gamma/master
latest changes
Diffstat (limited to 'lualibs-util-sta.lua')
-rw-r--r-- | lualibs-util-sta.lua | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lualibs-util-sta.lua b/lualibs-util-sta.lua index 1a61ec4..27ab5a6 100644 --- a/lualibs-util-sta.lua +++ b/lualibs-util-sta.lua @@ -81,6 +81,8 @@ end function stacker.new(name) + local report = logs.reporter("stacker",name or nil) + local s local stack = { } @@ -126,8 +128,18 @@ function stacker.new(name) end end - local tops = { } - local top, switch + local tops = { } + local top = nil + local switch = nil + + local function resolve_reset(mode) + if #tops > 0 then + report("resetting %s left-over states of %a",#tops,name) + end + tops = { } + top = nil + switch = nil + end local function resolve_begin(mode) if mode then @@ -206,8 +218,7 @@ function stacker.new(name) local function resolve_end() -- resolve_step(s.unset) - local noftop = #top - if noftop > 0 then + if #tops > 0 then -- was #top brrr local result = s.stop(s,top,1,#top) remove(tops) top = tops[#tops] @@ -224,8 +235,6 @@ function stacker.new(name) resolve_end() end - local report = logs.reporter("stacker",name or nil) - s = { name = name or "unknown", unset = -1, @@ -240,6 +249,7 @@ function stacker.new(name) resolve_begin = resolve_begin, resolve_step = resolve_step, resolve_end = resolve_end, + resolve_reset = resolve_reset, } return s -- we can overload functions |