Support recompile lualib with custom plugin? · Issue #1502 · TypeScriptToLua/TypeScriptToLua · GitHub
Skip to content

Support recompile lualib with custom plugin? #1502

Open

Description

@pilaoda

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.

Activity

  1. Z3rio commented on Oct 17, 2023

    @Z3rio
    Contributor

    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

  2. Perryvw commented on Oct 17, 2023

    @Perryvw
    Member

    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.

  3. pilaoda commented on Oct 18, 2023

    @pilaoda
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions