summaryrefslogtreecommitdiff
path: root/src/lvm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 15:31:44 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-02-10 08:53:03 +0100
commitad5cb0ddb6d4bd187cd4370711b1c9e34245fe07 (patch)
tree3e8bccded1cd4625661fe9b06f66e11202c1dec2 /src/lvm.js
parentbd6367e8f3162ff76628fa42948e66ba9e6ae281 (diff)
downloadfengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.tar.gz
fengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.tar.bz2
fengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.zip
Upvalues
Diffstat (limited to 'src/lvm.js')
-rw-r--r--src/lvm.js54
1 files changed, 36 insertions, 18 deletions
diff --git a/src/lvm.js b/src/lvm.js
index fa79695..fed3d36 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -89,40 +89,58 @@ class LuaVM {
break;
}
case "OP_GETUPVAL": {
- L.stack[ra] = L.stack[cl.upvals[i.B].v];
+ L.stack[ra] = cl.upvals[i.B].val(L);
break;
}
case "OP_SETUPVAL": {
- L.stack[cl.upvals[i.B].v] = L.stack[ra];
+ cl.upvals[i.B].setval(L, ra);
break;
}
case "OP_GETTABUP": {
+ let table = cl.upvals[i.B].val(L);
+ let key = this.RKC(base, k, i);
+
+ // if (!table.ttistable() || !table.metatable.__index(table, key)) {
+ // // __index
+ // } else {
+ L.stack[ra] = table.metatable.__index(table, key);
+ // }
break;
}
case "OP_SETTABUP": {
+ let table = cl.upvals[i.A].val(L);
+ let key = this.RKB(base, k, i);
+ let v = this.RKC(base, k, i);
+
+ // if (!table.ttistable() || !table.metatable.__index(table, key)) {
+ // // __index
+ // } else {
+ table.metatable.__newindex(table, key, v);
+ // }
+
break;
}
case "OP_GETTABLE": {
- let t = L.stack[this.RKB(base, i)];
- let k = L.stack[this.RKC(base, i)];
+ let table = this.RKB(base, k, i);
+ let key = this.RKC(base, k, i);
- if (!t.ttistable() || !t.value.__index(t, k)) {
- // __index
- } else {
- L.stack[ra] = t.value.__index(t, k);
- }
+ // if (!table.ttistable() || !table.metatable.__index(table, key)) {
+ // // __index
+ // } else {
+ L.stack[ra] = table.metatable.__index(table, key);
+ // }
break;
}
case "OP_SETTABLE": {
- let t = L.stack[ra];
- let k = L.stack[this.RKB(base, i)];
- let v = L.stack[this.RKC(base, i)];
-
- if (!t.ttistable() || !t.value.__index(t, k)) {
- // __index
- } else {
- t.value.__newindex(t, k, v);
- }
+ let table = L.stack[ra];
+ let key = this.RKB(base, k, i);
+ let v = this.RKC(base, k, i);
+
+ // if (!table.ttistable() || !table.metatable.__index(table, key)) {
+ // // __index
+ // } else {
+ table.metatable.__newindex(table, key, v);
+ // }
break;
}