aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:39:04 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:43:58 +0100
commite02fa80026ed5789e04ab865f238c8d184487dd2 (patch)
tree8b5771eb14d1a8bbd23a9027b8c71e73fc377ecd /src
parent0e7ae6679bc7950b93799500a7749fbe61690ffa (diff)
downloadfengari-e02fa80026ed5789e04ab865f238c8d184487dd2.tar.gz
fengari-e02fa80026ed5789e04ab865f238c8d184487dd2.tar.bz2
fengari-e02fa80026ed5789e04ab865f238c8d184487dd2.zip
JS closure
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js50
-rw-r--r--src/lua.js2
2 files changed, 29 insertions, 23 deletions
diff --git a/src/lapi.js b/src/lapi.js
index dd74552..2bef5a5 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -151,7 +151,7 @@ const lua_pushcclosure = function(L, fn, n) {
assert(n < L.top - L.ci.funcOff, "not enough elements in the stack");
assert(n <= MAXUPVAL, "upvalue index too large");
- let cl = new CClosure(L, fn, n);
+ let cl = new CClosure(fn, n);
L.top -= n;
while (n--) {
@@ -165,10 +165,14 @@ const lua_pushcclosure = function(L, fn, n) {
assert(L.top <= L.ci.top, "stack overflow");
};
+const lua_pushjsclosure = lua_pushcclosure;
+
const lua_pushcfunction = function(L, fn) {
lua_pushcclosure(L, fn, 0);
};
+const lua_pushjsfunction = lua_pushcfunction;
+
const lua_pushboolean = function(L, b) {
L.stack[L.top] = new TValue(CT.LUA_TBOOLEAN, b ? true : false);
@@ -307,24 +311,26 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) {
return status;
};
-module.exports.lua_pushvalue = lua_pushvalue;
-module.exports.lua_pushnil = lua_pushnil;
-module.exports.lua_pushnumber = lua_pushnumber;
-module.exports.lua_pushinteger = lua_pushinteger;
-module.exports.lua_pushlstring = lua_pushlstring;
-module.exports.lua_pushstring = lua_pushstring;
-module.exports.lua_pushboolean = lua_pushboolean;
-module.exports.lua_pushcclosure = lua_pushcclosure;
-module.exports.lua_pushcfunction = lua_pushcfunction;
-module.exports.lua_version = lua_version;
-module.exports.lua_atpanic = lua_atpanic;
-module.exports.lua_gettop = lua_gettop;
-module.exports.lua_typename = lua_typename;
-module.exports.lua_type = lua_type;
-module.exports.lua_tonumber = lua_tonumber;
-module.exports.lua_tointeger = lua_tointeger;
-module.exports.lua_toboolean = lua_toboolean;
-module.exports.lua_tolstring = lua_tolstring;
-module.exports.lua_tostring = lua_tostring;
-module.exports.lua_callk = lua_callk;
-module.exports.lua_call = lua_call; \ No newline at end of file
+module.exports.lua_pushvalue = lua_pushvalue;
+module.exports.lua_pushnil = lua_pushnil;
+module.exports.lua_pushnumber = lua_pushnumber;
+module.exports.lua_pushinteger = lua_pushinteger;
+module.exports.lua_pushlstring = lua_pushlstring;
+module.exports.lua_pushstring = lua_pushstring;
+module.exports.lua_pushboolean = lua_pushboolean;
+module.exports.lua_pushcclosure = lua_pushcclosure;
+module.exports.lua_pushcfunction = lua_pushcfunction;
+module.exports.lua_pushjsclosure = lua_pushjsclosure;
+module.exports.lua_pushjsfunction = lua_pushjsfunction;
+module.exports.lua_version = lua_version;
+module.exports.lua_atpanic = lua_atpanic;
+module.exports.lua_gettop = lua_gettop;
+module.exports.lua_typename = lua_typename;
+module.exports.lua_type = lua_type;
+module.exports.lua_tonumber = lua_tonumber;
+module.exports.lua_tointeger = lua_tointeger;
+module.exports.lua_toboolean = lua_toboolean;
+module.exports.lua_tolstring = lua_tolstring;
+module.exports.lua_tostring = lua_tostring;
+module.exports.lua_callk = lua_callk;
+module.exports.lua_call = lua_call; \ No newline at end of file
diff --git a/src/lua.js b/src/lua.js
index 58cc0cd..6ebf250 100644
--- a/src/lua.js
+++ b/src/lua.js
@@ -68,7 +68,7 @@ const LUA_MINSTACK = 20;
const LUA_REGISTRYINDEX = -luaconf.LUAI_MAXSTACK - 1000;
const lua_upvalueindex = function(i) {
- LUA_REGISTRYINDEX - i;
+ return LUA_REGISTRYINDEX - i;
};
/* predefined values in the registry */