webmcp

view framework/env/execute/_initializers.lua @ 309:4e69ce9a6365

Mechanism to load, compile, and cache Lua code from the filesystem
author jbe
date Sun Mar 22 22:25:37 2015 +0100 (2015-03-22)
parents 2ddbb44680f7
children a2c733535b8e
line source
1 function execute._initializers(initializer_path_element)
2 local yieldvalue1 = {}
3 local yieldvalue2 = {}
4 local coro = coroutine.wrap(function()
5 execute.multi_wrapped(
6 execute._create_sorted_execution_list(
7 function(add_by_path)
8 add_by_path(initializer_path_element)
9 if WEBMCP_APP_NAME then -- allow for interactive mode
10 add_by_path(WEBMCP_APP_NAME, initializer_path_element)
11 end
12 end,
13 function(full_path, relative_path)
14 execute.file_path{ file_path = full_path }
15 end
16 ),
17 function()
18 coroutine.yield(yieldvalue1)
19 end
20 )
21 return yieldvalue2
22 end)
23 local yieldvalue = coro()
24 if yieldvalue == yieldvalue2 then
25 error("Initializers failed to call execute.inner()")
26 elseif yieldvalue ~= yieldvalue1 then
27 error("Unexpected yield in initializers")
28 end
29 execute._finalizers[#execute._finalizers+1] = function()
30 assert(coro() == yieldvalue2, "Unexpected yield in finalizers")
31 end
32 end

Impressum / About Us