Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Access to the vm outside the handler #16

Open
Arnaz87 opened this issue Oct 10, 2018 · 2 comments
Open

Access to the vm outside the handler #16

Arnaz87 opened this issue Oct 10, 2018 · 2 comments

Comments

@Arnaz87
Copy link
Contributor

Arnaz87 commented Oct 10, 2018

I want to make a repl, but I'd need access to the internal vm to execute code. I saw pull #9 and it gives access to the vm on initialization, but it doesn't work for a repl.

One possibility would be to somehow make the LuaActor use another's vm, in with_vm instead of passing a reference of the vm to the function, make the function return a reference of a vm, so that the owner of the actor is also the owner of the vm, I don't know if that's even possible though.

Another would be to create a LuaMessage variant with a function which receives a reference to the vm.

I like the second most but I don't really like either that much.

@poga
Copy link
Owner

poga commented Oct 10, 2018

Have you tried https://github.com/hoelzro/lua-repl? It requires debug lib, so you need to create a Lua VM with rlua::Lua::new_with_debug, which is unsafe.

I'm not sure if you can make a repl without debug. nvm, you can

@poga
Copy link
Owner

poga commented Oct 10, 2018

Or you can have a simple REPL with something like this:

print("input>")
local exp = io.read()
local ret = assert(load("return " .. exp))()
if ret then
     print("ret " .. ret)
end

Making a REPL from the Rust side will be... complicated. I think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants