From 1dc893efcd664df86606b571d4b6bbee5b5868ca Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 5 May 2017 15:53:14 +1000 Subject: Need to copy to the stack if not coming from a stack --- src/ldo.js | 2 +- src/ltm.js | 6 +++--- src/lvm.js | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ldo.js b/src/ldo.js index 004c659..7c1f474 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -233,7 +233,7 @@ const tryfuncTM = function(L, off, func) { for (let p = L.top; p > off; p--) L.stack[p] = L.stack[p-1]; L.top++; /* slot ensured by caller */ - L.stack[off] = tm; /* tag method is the new function to be called */ + L.stack[off] = new lobject.TValue(tm.type, tm.value); /* tag method is the new function to be called */ }; /* diff --git a/src/ltm.js b/src/ltm.js index 76e7b0c..4bf37fe 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -83,9 +83,9 @@ const luaT_callTM = function(L, f, p1, p2, p3, hasres) { let result = p3; let func = L.top; - L.stack[L.top] = f; /* push function (assume EXTRA_STACK) */ - L.stack[L.top + 1] = p1; /* 1st argument */ - L.stack[L.top + 2] = p2; /* 2nd argument */ + L.stack[L.top] = new lobject.TValue(f.type, f.value); /* push function (assume EXTRA_STACK) */ + L.stack[L.top + 1] = new lobject.TValue(p1.type, p1.value); /* 1st argument */ + L.stack[L.top + 2] = new lobject.TValue(p2.type, p2.value); /* 2nd argument */ L.top += 3; if (!hasres) /* no result? 'p3' is third argument */ diff --git a/src/lvm.js b/src/lvm.js index e56374f..9748ab4 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -161,7 +161,8 @@ const luaV_execute = function(L) { break; } case OCi.OP_GETUPVAL: { - L.stack[ra] = cl.upvals[i.B].val(L); + let o = cl.upvals[i.B].val(L); + L.stack[ra] = new lobject.TValue(o.type, o.value); break; } case OCi.OP_SETUPVAL: { -- cgit v1.2.3-70-g09d2