big refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
setglobal('aux', aux_module('core'))
|
||||
setglobal('aux', aux_module 'core')
|
||||
import 'util'
|
||||
|
||||
public.version = '5.0.0'
|
||||
@@ -15,52 +15,37 @@ do
|
||||
locked[t] = nil
|
||||
tinsert(table_pool, t)
|
||||
end
|
||||
local function temp()
|
||||
function public.temp()
|
||||
local t = tremove(table_pool)
|
||||
t = t and wipe(t) or {}
|
||||
locked[t] = true
|
||||
end
|
||||
public.temp = temp
|
||||
function public.static()
|
||||
local t = tremove(table_pool)
|
||||
t = t and wipe(t) or {}
|
||||
locked[t] = true
|
||||
end
|
||||
function public.array(...) locked[arg] = true end
|
||||
function public.set(...)
|
||||
local set = temp()
|
||||
for i=1,arg.n do self[arg[i]] = true end
|
||||
return set
|
||||
end
|
||||
end
|
||||
local temp = temp
|
||||
--do
|
||||
-- local table_pool = {}
|
||||
-- onupdate clear tables TODO
|
||||
-- local setn = g.table.setn
|
||||
|
||||
-- public.wipe = wipe
|
||||
--end
|
||||
|
||||
do
|
||||
local aux_module, getfenv, setfenv, gfind, tinsert = g.aux_module, g.getfenv, g.setfenv, g.string.gfind, g.tinsert
|
||||
local interface, env = (function() return aux_module('interfaces'), getfenv() end)()
|
||||
local root = (function() aux_module 'modules' return getfenv() end)()
|
||||
function public.module(path)
|
||||
local parts = gfind(path, '[%a_][%w_]*')
|
||||
local name = parts() or ''
|
||||
local env = root
|
||||
for part in parts do
|
||||
interface[(function() return aux_module(name), getfenv() end)()
|
||||
env.public[part], env = (function() return aux_module(name), getfenv() end)()
|
||||
env.import('modules', 'core', 'util')
|
||||
name = name..'.'..part
|
||||
end
|
||||
|
||||
local env
|
||||
if path == 'core' then
|
||||
env = getfenv()
|
||||
elseif module_envs[path] then
|
||||
env = module_envs[path]
|
||||
else
|
||||
local prefix
|
||||
for name in gfind(path, '[%a_][%w_]*') do
|
||||
local qualified_name = prefix and prefix..'.'..name or name
|
||||
env = module_envs[qualified_name]
|
||||
if not env then
|
||||
(prefix and module_envs[prefix].public or public)[name], env = (function() return aux_module(qualified_name), getfenv() end)()
|
||||
env.import('core', 'util')
|
||||
env.mutable.LOAD = nil
|
||||
module_envs[qualified_name] = env
|
||||
end
|
||||
prefix = qualified_name
|
||||
end
|
||||
end
|
||||
setfenv(2, env)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user