aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-21 22:48:29 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-22 00:50:30 +1000
commit50323a75a96cfa095c1f968dd001b0f7107a722b (patch)
tree483be766d1dcba496b7aa205da8c972fc02c53fd /src
parentcc3e3c93585d81304954131a9a3982f0786426b7 (diff)
downloadfengari-50323a75a96cfa095c1f968dd001b0f7107a722b.tar.gz
fengari-50323a75a96cfa095c1f968dd001b0f7107a722b.tar.bz2
fengari-50323a75a96cfa095c1f968dd001b0f7107a722b.zip
src/lbaselib.js: Implement argument checking in collectgarbage
Diffstat (limited to 'src')
-rw-r--r--src/lbaselib.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index 8f0827e..bffe5a6 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -85,6 +85,15 @@ const luaB_rawset = function(L) {
return 1;
};
+const opts = ["stop", "restart", "collect",
+"count", "step", "setpause", "setstepmul",
+"isrunning"].map((e) => lua.to_luastring(e));
+const luaB_collectgarbage = function(L) {
+ lauxlib.luaL_checkoption(L, 1, lua.to_luastring("collect"), opts);
+ lauxlib.luaL_checkinteger(L, 2);
+ lauxlib.luaL_error(L, lua.to_luastring("lua_gc not implemented"));
+};
+
const luaB_type = function(L) {
let t = lua.lua_type(L, 1);
lauxlib.luaL_argcheck(L, t !== lua.LUA_TNONE, 1, lua.to_luastring("value expected", true));
@@ -308,8 +317,8 @@ const luaB_load = function(L) {
};
const base_funcs = {
- "collectgarbage": function () { return 0; },
"assert": luaB_assert,
+ "collectgarbage": luaB_collectgarbage,
"error": luaB_error,
"getmetatable": luaB_getmetatable,
"ipairs": luaB_ipairs,