Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support recompile lualib with custom plugin? #1502

Open
pilaoda opened this issue Oct 17, 2023 · 3 comments
Open

Support recompile lualib with custom plugin? #1502

pilaoda opened this issue Oct 17, 2023 · 3 comments
Labels
feature request scope: lualib Lualib, polyfills scope: plugins Relating to tstl plugins

Comments

@pilaoda
Copy link
Contributor

pilaoda commented Oct 17, 2023

Here is the case, I want to implement a proxy for array in luajit environment with __index and __newindex that read write data in another table.
However, luajit which is lua5.1 doesn't support __len __ipair metamethod, and length operator #, global next function, global ipairs function would return wrong result on proxy.

Then I come up with an idea that write a printer plugin that print # next ipairs into some custom implementation, but this plugin would ignore code in lualib.

I think the problem is, the plugin doesn't give user enough power to modify the compilation process, since lualib are already compiled before plugin taking over.

@Z3rio
Copy link
Contributor

Z3rio commented Oct 17, 2023

Hello, I'm sadly having some trouble understanding what you are trying to achieve.

Would it perhaps be possible for you to send a code snippet explaining it? Or a playground link.
Or try to explain it in some other way, I guess

Thank you

@Perryvw
Copy link
Member

Perryvw commented Oct 17, 2023

Sounds like this is a duplicate of #973, I still think this would be a good idea to do. However, the design is not yet clear to me, and we need to decide on what the interface for this should be.

@Perryvw Perryvw added feature request scope: lualib Lualib, polyfills scope: tooling CLI, external API scope: plugins Relating to tstl plugins and removed scope: tooling CLI, external API labels Oct 17, 2023
@pilaoda
Copy link
Contributor Author

pilaoda commented Oct 18, 2023

Yes this is a duplicate, and sorry I didn't check it.

Currently, lualib are already precompiled into lua code and package in the npm package.
On user compile time, lualib just skip the compiling and use the precompiled code, and I know it is for performance reason.

What I am hoping is, there is an option to choose using precompiled lualib or not, so that the lualib code can be recompiled with user's plugin if user choose not to use precompiled code. Of course, those lualib ts source code should also be published to npm.

For example, we have code array.length compiled into #array. Now I have a plugin modify it into Len(array), and I implement this global Len function so I can call the __len metamethod if it exist.
Thus, those # length operator in lualib_bundle.lua, should also be recompiled to use Len since this is user expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request scope: lualib Lualib, polyfills scope: plugins Relating to tstl plugins
Projects
None yet
Development

No branches or pull requests

3 participants