summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 07:51:01 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 09:33:45 +0100
commitebbcbf8484d74cfccd0b39abf661dbc14fd2dc5d (patch)
tree48c6bc04cbe336a6f0ce44ec3a9a8ffd0ff6fae2 /src
parent3a77114269b53fc57ff00342af18e71f97dcf590 (diff)
downloadfengari-ebbcbf8484d74cfccd0b39abf661dbc14fd2dc5d.tar.gz
fengari-ebbcbf8484d74cfccd0b39abf661dbc14fd2dc5d.tar.bz2
fengari-ebbcbf8484d74cfccd0b39abf661dbc14fd2dc5d.zip
lua_pushnumber
Diffstat (limited to 'src')
-rw-r--r--src/ldo.js3
-rw-r--r--src/lvm.js15
2 files changed, 7 insertions, 11 deletions
diff --git a/src/ldo.js b/src/ldo.js
index 86a06e6..aa52b76 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -11,7 +11,6 @@ const CT = lua.constant_types;
const TS = lua.thread_status;
const LUA_MULTRET = lua.LUA_MULTRET;
const TValue = lobject.TValue;
-const CallInfo = lstate.CallInfo;
const TMS = ltm.TMS;
const nil = new TValue(CT.LUA_TNIL, null);
@@ -44,7 +43,7 @@ const luaD_precall = function(L, off, nresults) {
L.ci = L.ci.next;
ci = L.ci;
} else {
- ci = new CallInfo(off);
+ ci = new lstate.CallInfo(off);
L.ci.next = ci;
ci.previous = L.ci;
ci.next = null;
diff --git a/src/lvm.js b/src/lvm.js
index 5ba568d..f62e8f5 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -535,19 +535,19 @@ const luaV_execute = function(L) {
throw new Error("'for' limit must be a number");
plimit.type = CT.LUA_TNUMFLT;
- plimit.value = nlimit.value;
+ plimit.value = nlimit
if (nstep === false)
throw new Error("'for' step must be a number");
pstep.type = CT.LUA_TNUMFLT;
- pstep.value = nstep.value;
+ pstep.value = nstep
if (ninit === false)
throw new Error("'for' initial value must be a number");
init.type = CT.LUA_TNUMFLT;
- init.value = ninit.value - nstep.value;
+ init.value = ninit - nstep;
}
ci.pcOff += i.sBx;
@@ -787,14 +787,11 @@ const luaV_tointeger = function(obj, mode) {
};
const tonumber = function(v) {
- if (v.type === CT.LUA_TNUMFLT)
- return new TValue(v.type, v.value);
-
- if (v.type === CT.LUA_TNUMINT)
- return new TValue(CT.LUA_TNUMFLT, v.value);
+ if (v.type === CT.LUA_TNUMFLT || v.type === CT.LUA_TNUMINT)
+ return v.value;
if (v.type === CT.LUA_TSHRSTR || v.type === CT.LUA_TLNGSTR)
- return new TValue(CT.LUA_TNUMFLT, parseFloat(v.value)); // TODO: luaO_str2num
+ return parseFloat(v.value); // TODO: luaO_str2num
return false;
};