]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
lualoader: rewrite try_include using lfs + dofile
authorkevans <kevans@FreeBSD.org>
Sat, 2 Nov 2019 04:01:39 +0000 (04:01 +0000)
committerkevans <kevans@FreeBSD.org>
Sat, 2 Nov 2019 04:01:39 +0000 (04:01 +0000)
commita4f7035c09eaddb6e1e7bacb159910f3bae2d8f7
tree411a9a54c72094cab614b710185306315a790bcf
parent075c88dbc1729a45fa1f4ba0dc76d66a1128bbad
lualoader: rewrite try_include using lfs + dofile

Actual modules get require()'d in, rather than try_include(). All instances
of try_include should be provided with proper hooks/API in the rest of
loader to do the work they need to do, since we can't rely on them to exist.
Convert this now to lfs + dofile since we won't really be treating them as
modules.

lfs is required because dofile will properly throw an error if the file
doesn't exist, which is not in the spirit of 'optionally included'.

Getting out of the pcall game allows us to provide a loader.exit() style
call that backs out to the common bits of loader (autoboot sequence unless
disabled with a loader.setenv("autoboot_delay", "NO")). The most ideal way
identified so far to implement loader.exit() is to throw a special
abort-style error that indicates to the caller in interp_lua that we've not
actually errored out, just continue execution. Otherwise, we have to hack in
logic to bubble up and return from loader.lua without continuing further,
which gets kind of ugly depending on the context in which we're aborting.

A compat shim is provided temporarily in case the executing loader doesn't
yet have loader.lua_path, which was just added in r354246.
stand/lua/core.lua