From 0e7ae6679bc7950b93799500a7749fbe61690ffa Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 17 Feb 2017 07:28:36 +0100 Subject: LUA_REGISTRYINDEX --- src/lua.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/lua.js') diff --git a/src/lua.js b/src/lua.js index 245c826..58cc0cd 100644 --- a/src/lua.js +++ b/src/lua.js @@ -1,8 +1,9 @@ /*jshint esversion: 6 */ "use strict"; -const assert = require('assert'); -const lualib = require('./lualib.js'); +const assert = require('assert'); +const lualib = require('./lualib.js'); +const luaconf = require('./luaconf.js'); const LUA_VERSION_MAJOR = "5"; const LUA_VERSION_MINOR = "3"; @@ -64,6 +65,12 @@ constant_types.LUA_TCCL = constant_types.LUA_TFUNCTION | (2 << 4); /* C closure const LUA_NUMTAGS = 9; const LUA_MINSTACK = 20; +const LUA_REGISTRYINDEX = -luaconf.LUAI_MAXSTACK - 1000; + +const lua_upvalueindex = function(i) { + LUA_REGISTRYINDEX - i; +}; + /* predefined values in the registry */ const LUA_RIDX_MAINTHREAD = 1; const LUA_RIDX_GLOBALS = 2; @@ -99,4 +106,6 @@ module.exports.LUA_NUMTAGS = LUA_NUMTAGS; module.exports.LUA_MINSTACK = LUA_MINSTACK; module.exports.LUA_RIDX_MAINTHREAD = LUA_RIDX_MAINTHREAD; module.exports.LUA_RIDX_GLOBALS = LUA_RIDX_GLOBALS; -module.exports.LUA_RIDX_LAST = LUA_RIDX_LAST; \ No newline at end of file +module.exports.LUA_RIDX_LAST = LUA_RIDX_LAST; +module.exports.LUA_REGISTRYINDEX = LUA_REGISTRYINDEX; +module.exports.lua_upvalueindex = lua_upvalueindex; \ No newline at end of file -- cgit v1.2.3-54-g00ecf