diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-16 07:35:26 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-16 07:37:18 +0100 |
commit | 3a77114269b53fc57ff00342af18e71f97dcf590 (patch) | |
tree | e33feba1afb32d02c1684294362ac74b9e27007f /src/lapi.js | |
parent | 9d6afeba223c22163928557c69a102877223d3bd (diff) | |
download | fengari-3a77114269b53fc57ff00342af18e71f97dcf590.tar.gz fengari-3a77114269b53fc57ff00342af18e71f97dcf590.tar.bz2 fengari-3a77114269b53fc57ff00342af18e71f97dcf590.zip |
luaL_newstate, lua_pushnil, lua_gettop, luaL_typename
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js index 9e20d7f..0cb0a4b 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -5,6 +5,7 @@ const assert = require('assert'); const ldo = require('./ldo.js'); const lobject = require('./lobject.js'); +const ltm = require('./ltm.js'); const lfunc = require('./lfunc.js'); const lua = require('./lua.js'); const lstate = require('./lstate.js'); @@ -49,6 +50,14 @@ const index2addr = function(L, idx) { }; +/* +** basic stack manipulation +*/ + +const lua_gettop = function(L) { + return L.top - 1; +}; + const lua_pushvalue = function(L, idx) { L.stack[L.top] = L.stack[index2addr(L, idx)]; @@ -164,6 +173,16 @@ const f_call = function(L, ud) { ldo.luaD_callnoyield(L, ud.func, ud.nresults); }; +const lua_type = function(L, idx) { + let o = index2addr(L, idx); + return o.ttnov(); // TODO: isvalid ? luaO_nilobject != nil tvalue ? +}; + +const lua_typename = function(L, t) { + assert(CT.LUA_TNONE <= t && t < CT.LUA_NUMTAGS, "invalid tag"); + return ltm.ttypename(t); +}; + /* ** 'load' and 'call' functions (run Lua code) @@ -225,4 +244,7 @@ module.exports.lua_pushinteger = lua_pushinteger; module.exports.lua_pushlstring = lua_pushlstring; module.exports.lua_pushstring = lua_pushstring; module.exports.lua_version = lua_version; -module.exports.lua_atpanic = lua_atpanic;
\ No newline at end of file +module.exports.lua_atpanic = lua_atpanic; +module.exports.lua_gettop = lua_gettop; +module.exports.lua_typename = lua_typename; +module.exports.lua_type = lua_type;
\ No newline at end of file |