Commit ad159400 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

deterministic dependency resolver

parent afe81387
--[[ --[[
Dependency order resolver for Alpine Wall Dependency order resolver for Alpine Wall
Copyright (C) 2012-2014 Kaarle Ritvanen Copyright (C) 2012-2018 Kaarle Ritvanen
See LICENSE file for license details See LICENSE file for license details
]]-- ]]--
local util = require('awall.util') local util = require('awall.util')
local contains = util.contains local contains = util.contains
local sortedkeys = util.sortedkeys
return function(items) return function(items)
local visited = {} local visited = {}
...@@ -17,8 +18,8 @@ return function(items) ...@@ -17,8 +18,8 @@ return function(items)
visited[key] = true visited[key] = true
local after = util.list(items[key].after) local after = util.list(items[key].after)
for k, v in pairs(items) do for _, k in sortedkeys(items) do
if contains(v.before, key) then table.insert(after, k) end if contains(items[k].before, key) then table.insert(after, k) end
end end
for i, k in ipairs(after) do for i, k in ipairs(after) do
if items[k] then if items[k] then
...@@ -30,7 +31,7 @@ return function(items) ...@@ -30,7 +31,7 @@ return function(items)
table.insert(res, key) table.insert(res, key)
end end
for i, k in util.sortedkeys(items) do for _, k in sortedkeys(items) do
local ek = visit(k) local ek = visit(k)
if ek ~= nil then return ek end if ek ~= nil then return ek end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment