summaryrefslogtreecommitdiff
path: root/src/lfunc.js
diff options
context:
space:
mode:
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 = {