accessing hidden code
Consider this complete module, named hidden.nelua:
local function hidden() <nodce> print('how did you find me?') endThe <nodce> (no dead code elimination) keeps this function from getting optimized out entirely, but how can you use it without a global or the file's return having any reference to the function?
Option 1.) go through the C ABI
$ nelua -i 'require("hidden") ## cemit "hidden_hidden();"'
how did you find me?
With predictable names, this at least isn't crazy, right?
Option 2.) read the file with Lua
##[[
function expose(file)
local f = io.open(file .. '.nelua', 'r')
local src = f:read('*a')
f:close()
local ast, errlabel, errpos = aster.syntaxes.nelua.patt:match(src)
assert(ast)
assert(ast.tag == "Block")
for i=1, #ast do inject_astnode(ast[i]) end
end
]]
## expose("hidden")
hidden()contrast include files