Open allquixotic opened 5 years ago
Hello Sean, thank you for taking the time to report this issue and writing a detailed description of it, I really appreciate this kind of contribution to the open-source ecosystem. Unfortunately CASTL was an experimental software I built for a start-up and I'm not actively maintaining it (besides trivial bugs). I actually remember some occurrences of this limitation and I think your proposed solution is reasonable but I'm sorry I won't have time to work on it (+ I haven't written any Lua for years).
I still had a look at your problem and there may be at least one thing you could give a try: I noticed that onigurumajs is only using a single function from lodash (omit
) what you could do is modify (patch like your did with castl) onigurumajs to directly use that smaller package lodash.omit which may help avoid this 200 local variables error.
Best of luck.
So I hit this with https://github.com/Olical/cljs-lua-experiment too. I was trying to compile a ClojureScript program that could compile all other ClojureScript programs to it though which is probably asking a bit too much. This is so that I can basically drive Neovim (which has LuaJIT built in) with ClojureScript in a kind of native way. Scary, right!
I am considering having a play with castl one day to see if I can break things up into deeper and deeper closures or something as the local variable limit is hit... kind of a hack but it might work! If I have a play with that concept I'll link it here. Thanks for your existing work, it's a great starting place for many people! :tada:
Thanks for sharing @Olical! Wish you the best of luck with your experiment ;)
Hello,
I'm trying to get a fully featured RegEx library for Lua that will run in a pure Lua environment (no
require
, no FFI, noos
orio
packages, etc.) -- specifically the Lua 5.1 interpreter baked into Elder Scrolls Online.For this I've set out to try to use onigurumajs, browserify, castl, and node-lua-distiller to get onigurumajs into a single Lua file with no dependencies.
Here's what I did, exactly (on macOS, but should work plus or minus a
sudo
on Linux, and probably even Windows Git Bash):The error:
or, unminified:
Line 25330 is basically a bunch of variable declarations inside the
lodash
library that is required by onigurumajs. The number of variable declarations definitely exceeds 200, hence the error.Notes about stuff in the script:
ffi
anddebug
modules (even when running fully privileged lua 5.3.5 locally), and because those modules aren't available in Elder Scrolls Online's extremely locked down lua interpreter anyway.ncu
was necessary to resolve a problem with browserify being unable to browserify the xregexp addons in version 3.x which oniguruma was asking for.There may still be deeper errors once these are resolved, but the issue with 200 variables must be resolved first.
Somehow your Lua code generator needs to detect >200 local variables in a scope, and stuff them into a table, then rewrite all the uses of them to use a table instead of direct local variable references. That sounds like a non-trivial effort, but anything that includes the
lodash
library, for starters, can't be used with castl as-is.FWIW, tessel has the same problem :( https://github.com/tessel/t1-runtime/issues/658
I will be "happy" (as far as castl is concerned) if the transpiled Lua code works with a desktop Lua interpreter, e.g. the reference implementation as available on MacOS or Linux. But I have a feeling I will hit a few more issues based on the limitations of the Havok Script Lua engine of ESO, which you can read more about here in case you're interested: https://wiki.esoui.com/Esolua