summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 13:35:01 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 13:35:01 +0100
commit290ec54e13d1dff301465cbfa2fd7b4e1e52962f (patch)
treeac1d4988da8cd15b567891294bf1ac94af90242d /src/lapi.js
parenta40719dc74b8dbb0d6c8fc0272c0d79ad8a7a9ea (diff)
downloadfengari-290ec54e13d1dff301465cbfa2fd7b4e1e52962f.tar.gz
fengari-290ec54e13d1dff301465cbfa2fd7b4e1e52962f.tar.bz2
fengari-290ec54e13d1dff301465cbfa2fd7b4e1e52962f.zip
lua_stringtonumber, tonumber
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index bc4dd54..19e3090 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -488,6 +488,13 @@ const lua_topointer = function(L, idx) {
}
};
+const lua_stringtonumber = function(L, s) {
+ let number = parseFloat(s);
+ L.stack[L.top++] = new TValue(number % 1 !== 0 ? CT.LUA_TNUMFLT : CT.LUA_TNUMINT, number);
+ assert(L.top <= L.ci.top, "stack overflow");
+ return s.length;
+};
+
const f_call = function(L, ud) {
ldo.luaD_callnoyield(L, ud.funcOff, ud.nresults);
};
@@ -705,4 +712,5 @@ module.exports.lua_error = lua_error;
module.exports.lua_insert = lua_insert;
module.exports.lua_gc = lua_gc;
module.exports.lua_getallocf = lua_getallocf;
-module.exports.lua_getextraspace = lua_getextraspace; \ No newline at end of file
+module.exports.lua_getextraspace = lua_getextraspace;
+module.exports.lua_stringtonumber = lua_stringtonumber; \ No newline at end of file