summaryrefslogtreecommitdiff
path: root/src/lfunc.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/lfunc.js
parentbd6367e8f3162ff76628fa42948e66ba9e6ae281 (diff)
downloadfengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.tar.gz
fengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.tar.bz2
fengari-ad5cb0ddb6d4bd187cd4370711b1c9e34245fe07.zip
Upvalues
Diffstat (limited to 'src/lfunc.js')
-rw-r--r--src/lfunc.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lfunc.js b/src/lfunc.js
index 929dae8..2c33a7d 100644
--- a/src/lfunc.js
+++ b/src/lfunc.js
@@ -24,16 +24,25 @@ class Proto {
class UpVal {
constructor() {
- this.v = null;
+ this.v = null; /* if null, upval is closed, value is in u.value */
this.u = {
- open: {
- next: null,
- touched: false
+ open: { /* (when open) */
+ next: null, /* linked list */
+ touched: false /* mark to avoid cycles with dead threads */
},
- value: null
+ value: null /* the value (when closed) */
};
}
+ val(L) {
+ return this.v !== null ? L.stack[this.v] : this.u.value;
+ }
+
+ setval(L, ra) {
+ if (this.v !== null) this.v = ra;
+ else this.u.value = L.stack[ra];
+ }
+
}
module.exports = {