diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 08:46:48 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-21 09:00:32 +0100 |
commit | 23d15010edc905a3b7c123e85ef6d1960d3da039 (patch) | |
tree | d66761315763ab9e00cbed78fed69a687e02f5e3 /src/lfunc.js | |
parent | 7d58c3b7314e4a63591fa375546cfc76a042e644 (diff) | |
download | fengari-23d15010edc905a3b7c123e85ef6d1960d3da039.tar.gz fengari-23d15010edc905a3b7c123e85ef6d1960d3da039.tar.bz2 fengari-23d15010edc905a3b7c123e85ef6d1960d3da039.zip |
luaG_ functions
Diffstat (limited to 'src/lfunc.js')
-rw-r--r-- | src/lfunc.js | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/lfunc.js b/src/lfunc.js index c309147..7057f2d 100644 --- a/src/lfunc.js +++ b/src/lfunc.js @@ -99,9 +99,26 @@ const luaF_initupvals = function(L, cl) { } }; -module.exports.Proto = Proto; -module.exports.UpVal = UpVal; -module.exports.findupval = findupval; -module.exports.luaF_close = luaF_close; -module.exports.MAXUPVAL = 255; -module.exports.luaF_initupvals = luaF_initupvals;
\ No newline at end of file +/* +** Look for n-th local variable at line 'line' in function 'func'. +** Returns null if not found. +*/ +const luaF_getlocalname = function(f, local_number, pc) { + for (let i = 0; i < f.locvars.length && f.locvars[i].startpc <= pc; i++) { + if (pc < f.locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return f.locvars[i].varname; + } + } + return null; /* not found */ +} + + +module.exports.Proto = Proto; +module.exports.UpVal = UpVal; +module.exports.findupval = findupval; +module.exports.luaF_close = luaF_close; +module.exports.MAXUPVAL = 255; +module.exports.luaF_initupvals = luaF_initupvals; +module.exports.luaF_getlocalname = luaF_getlocalname
\ No newline at end of file |