Lua, can I disable parts of the language from C ++?

Say I have Lua built into a C ++ application. The question may seem strange, but I wonder if there is a standard way to disable Lua functions from C ++?

For example, I would like to disable the creation of a new variable, except for a few defined ones, for example:

local time = 10
local size = 20
function test()
  return time * size
end

I would like to make Lua VM fail if I define anything else but time, sizeand test. Is it possible that it is impossible to hack a virtual machine?

Or, for example, I would like to disable loops (both operators forand while).

+4
source share
3 answers

, , : script __index __newindex.

, , , -.

, :

, luaX_tokens llex.c. , . , , for, while repeat. in until, . , . lua-l.

+5

, . " X-" .

lua for while , , , (, , , ) .

- metalua , .

+4

- Lua , . , : .

+3

All Articles