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

Leverage WASM_BIGINT for 64-bit integers #100

Merged
merged 2 commits into from
Dec 8, 2023
Merged

Leverage WASM_BIGINT for 64-bit integers #100

merged 2 commits into from
Dec 8, 2023

Conversation

Sapu94
Copy link
Contributor

@Sapu94 Sapu94 commented Dec 6, 2023

Setting WASM_BIGINT enables support for using the bigint type in JS to pass 64-bit integers. This allows compiling lua with full 64-bit integer/float support. I ran this against my (fairly large) lua application and it seemed to resolve all the issues I was previously having with large numbers in lua.

Copy link
Contributor

@tims-bsquare tims-bsquare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic. I'm very happily surprised that compiler option exists

package-lock.json Outdated Show resolved Hide resolved
@@ -164,7 +164,7 @@ class FunctionTypeExtension extends TypeExtension<FunctionType, FunctionDecorati
return
}

const internalType = thread.lua.lua_rawgeti(thread.address, LUA_REGISTRYINDEX, func)
const internalType = thread.lua.lua_rawgeti(thread.address, LUA_REGISTRYINDEX, BigInt(func))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conversion seems odd. Should luaL_ref now return bigint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem a bit strange, but this matches the lua function definitions:

LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
// ...
LUALIB_API int (luaL_ref) (lua_State *L, int t);

@ceifa ceifa merged commit f716b2f into ceifa:main Dec 8, 2023
3 checks passed
@Sapu94 Sapu94 deleted the bigint branch December 8, 2023 15:17
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