patrickfrey / mewa

Compiler-compiler for writing compiler frontends with Lua
https://github.com/patrickfrey/mewa
MIT License
23 stars 2 forks source link

Use luaL_ref references instead of custom hashtable for objects stored in C++ data structures of Mewa #2

Closed patrickfrey closed 3 years ago

patrickfrey commented 3 years ago

Check if int r = luaL_ref(L, LUA_REGISTRYINDEX);

can be used to store Lua objects (like constructors) in C structures of Mewa instead of storing them in hashtables. This can be especially useful in the case of set_instance.

patrickfrey commented 3 years ago

Use lua_pushvalue( ls, -1);

= luaL_ref( ls, LUA_REGISTRYINDEX); and lua_rawgeti( ls, LUA_REGISTRYINDEX, ); instead of Lua table with custom counters as keys for object references stored as integers in the C++ structures of Mewa.