From 0e5585bd7078d6727382c0de51161fe377c1d81d Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 5 May 2017 17:08:04 +1000 Subject: Simplify UpVal structure No longer follows C api as closely (it is the way it is because C has unions) Instead, have a flat object. Also remove the 'setval' method, as it wasn't used from all call-sites and couldn't be extended to them (setval's body only worked with source TValue on a stack) --- src/lvm.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lvm.js') diff --git a/src/lvm.js b/src/lvm.js index bd38575..d45ecec 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -166,7 +166,12 @@ const luaV_execute = function(L) { break; } case OCi.OP_SETUPVAL: { - cl.upvals[i.B].setval(L, ra); + let uv = cl.upvals[i.B]; + if (uv.v !== null) { + uv.L.stack[uv.v] = L.stack[ra]; + } else { + uv.value.setfrom(L.stack[ra]); + } break; } case OCi.OP_GETTABUP: { -- cgit v1.2.3-54-g00ecf