summaryrefslogtreecommitdiff
path: root/src/lua.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:28:36 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:28:36 +0100
commit0e7ae6679bc7950b93799500a7749fbe61690ffa (patch)
tree6ba3cae358f381468ea4d07ea85f40ce861aa582 /src/lua.js
parentbe0757bcfc96dc6146d72e9536fa8e32d9a3dec7 (diff)
downloadfengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.tar.gz
fengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.tar.bz2
fengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.zip
LUA_REGISTRYINDEX
Diffstat (limited to 'src/lua.js')
-rw-r--r--src/lua.js15
1 files changed, 12 insertions, 3 deletions
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