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

patterns: Added Lua 5.3 bytecode pattern #285

Merged
merged 1 commit into from
Aug 3, 2024
Merged

patterns: Added Lua 5.3 bytecode pattern #285

merged 1 commit into from
Aug 3, 2024

Conversation

qux-bbb
Copy link
Contributor

@qux-bbb qux-bbb commented Aug 3, 2024

No description provided.

@WerWolv
Copy link
Owner

WerWolv commented Aug 3, 2024

Thanks!
Would it make sense maybe to combine all these versions into a single pattern? The version information seems to be in the binary file and the format of all looks reasonably similar

@qux-bbb
Copy link
Contributor Author

qux-bbb commented Aug 3, 2024

There are some differences between these version, so it's difficult to combine them into a single pattern.

@WerWolv WerWolv merged commit 204599a into WerWolv:master Aug 3, 2024
2 checks passed
@WerWolv
Copy link
Owner

WerWolv commented Aug 3, 2024

Do you possibly also have a Lua 5.4 test file? That's one of the few test files we're missing still

@qux-bbb
Copy link
Contributor Author

qux-bbb commented Aug 4, 2024

Do you possibly also have a Lua 5.4 test file? That's one of the few test files we're missing still

I'll upload a Lua 5.4 test file.

@paxcut
Copy link
Contributor

paxcut commented Aug 4, 2024

i've noticed that in 5.3 and 5.4 the values of type that decide if value is int or floating point are reversed. Did they decide that swapping them provided some sort of advantage?

Lua 5.3

    } else if (type == 3) {  // LUA_TNUMFLT
        double data;
    } else if (type == 0x13) {  // LUA_TNUMINT
        u64 data;

Lua 5.4

    if (type == 3) {
        u64 data;
    } else if (type == 0x13) {
        double data;

@qux-bbb
Copy link
Contributor Author

qux-bbb commented Aug 4, 2024

I don't know why, here's the code.

Lua 5.3.6

/* Variant tags for numbers */
#define LUA_TNUMFLT	(LUA_TNUMBER | (0 << 4))  /* float numbers */
#define LUA_TNUMINT	(LUA_TNUMBER | (1 << 4))  /* integer numbers */

    case LUA_TNUMFLT:
      DumpNumber(fltvalue(o), D);
      break;
    case LUA_TNUMINT:
      DumpInteger(ivalue(o), D);
      break;

Lua 5.4.6

/* add variant bits to a type */
#define makevariant(t,v)	((t) | ((v) << 4))

#define LUA_TNUMBER		3

/* Variant tags for numbers */
#define LUA_VNUMINT	makevariant(LUA_TNUMBER, 0)  /* integer numbers */
#define LUA_VNUMFLT	makevariant(LUA_TNUMBER, 1)  /* float numbers */

      case LUA_VNUMFLT:
        dumpNumber(D, fltvalue(o));
        break;
      case LUA_VNUMINT:
        dumpInteger(D, ivalue(o));
        break;

https://www.lua.org/ftp/lua-5.3.6.tar.gz
https://www.lua.org/ftp/lua-5.4.6.tar.gz

@paxcut
Copy link
Contributor

paxcut commented Aug 7, 2024

I looked into combining all the lua versions into 1 pattern and I can probably do that if there is any interest.

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

Successfully merging this pull request may close these issues.

3 participants