implemented import system for modules

This commit is contained in:
Manuel Simon Hirsig
2016-08-19 17:09:44 +02:00
parent 37e789184b
commit e334a444df
4 changed files with 42 additions and 24 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
setglobal('aux', aux_module())
setglobal('aux', aux_module('core'))
public.version = '4.0.0'
@@ -15,7 +15,8 @@ function public.module(path)
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(), getfenv() end)()
(prefix and module_envs[prefix].public or public)[name], env = (function() return aux_module(qualified_name), getfenv() end)()
env.import 'util'
env.LOAD = nil
module_envs[qualified_name] = env
end