mjanicek / rembulan

Rembulan, an implementation of Lua 5.3 for the Java Virtual Machine
Apache License 2.0
163 stars 28 forks source link

Question: Is this project still alive? #21

Open io7m opened 7 years ago

io7m commented 7 years ago

Not seen any commits for over a year, and the author doesn't appear to be on GitHub anymore...

bensku commented 6 years ago

So it seems. It seems to be mostly complete, luckily. Most missing parts are in standard library, so adding them won't be black magic if they are needed.

JuKu commented 6 years ago

Is there a newer fork, maybe?

io7m commented 6 years ago

https://github.com/wizards-of-lua/rembulan

JuKu commented 6 years ago

I have also fixed the build errors and pushed it to maven central (some minutes ago) yet: https://github.com/JuKu/rembulan

Because i don't own the domain rembulan.sandius.net i had changed the groupId to com.jukusoft .

JuKu commented 6 years ago

I hope the maintainer will maintain the library longer, because it's really useful!

mkarneim commented 6 years ago

https://github.com/wizards-of-lua/rembulan

Yeah, I created that fork. I’m working on the unfinished functions of the io lib because I need them for the Wizards of Lua Mod. It‘s almost done, regarding the features, but it’s not finished since it still needs some strong cleanup and refactoring. So be warned if you plan to use that code!

And yes, it would be nice to see this beautiful project staying alive.

JuKu commented 6 years ago

@mkarneim If you implemented I/O, this also means your fork isn't in sandbox mode anymore, right?

mkarneim commented 6 years ago

@mkarneim If you implemented I/O, this also means your fork isn't in sandbox mode anymore, right?

Well, yes, but ...

The final decision about whether Rembulan is running sandboxed is made at runtime when you populate the StateContext with the libraries you are interested in.

For example, by calling StandardLibrary.installInto() (as demonstrated in Getting Started):

StateContext state = StateContexts.newDefaultInstance();
Table env = StandardLibrary.in(RuntimeEnvironments.system()).installInto(state);

you will break the sandbox since IoLib and OsLib are included by default.

If you want to stay in the sandbox, you must skip this call and instead add the libraries manually, but without IoLib and OsLib:

StateContext state = StateContexts.newDefaultInstance();

RuntimeEnvironment environment = RuntimeEnvironments.system();
Table env = state.newTable();
ChunkLoader chunkLoader = CompilerChunkLoader.of("MyDummyMainProgram");
ClassLoader moduleLoader = ClassLoader.getSystemClassLoader();

BasicLib.installInto(state, env, environment, chunkLoader);
ModuleLib.installInto(state, env, environment, chunkLoader, moduleLoader);
CoroutineLib.installInto(state, env);
StringLib.installInto(state, env);
MathLib.installInto(state, env);
TableLib.installInto(state, env);
// Exclude these libs to keep the sandbox intact
// IoLib.installInto(state, env, environment);
// OsLib.installInto(state, env, environment);
Utf8Lib.installInto(state, env);

Of course you also could add the IoLib with some restricted environment, for example with a special FileSystem instance like Jimfs.

mkarneim commented 6 years ago

Just got this idea: another option could be to change the IoLib implementation so that it checks whether the FileSystem is null and then conditionally skips the declaration of those functions that depend on it.

JuKu commented 6 years ago

@mkarneim You are right!

Other question: Is the lua function dofile("my-other-script.lua") implemented anywhere in the standard library?

mkarneim commented 6 years ago

Other question: Is the lua function dofile("my-other-script.lua") implemented anywhere in the standard library?

Yes, it's here: https://github.com/mjanicek/rembulan/blob/master/rembulan-stdlib/src/main/java/net/sandius/rembulan/lib/BasicLib.java#L819

JuKu commented 6 years ago

@mkarneim Hmmm... It doesn't work in my lua file and i don't know why. How are you executing your lua files? First read string content and execute it or is there a method to execute the script directly?

mkarneim commented 6 years ago

Perhaps you should better open a new issue for your question and give some more background information.

However, maybe it helps to have a look at a little example that shows how to execute a Lua program programmatically and at the main class of rembulan's standalone interpreter that can execute files.