summaryrefslogtreecommitdiff
path: root/src/lstate.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lstate.js')
-rw-r--r--src/lstate.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lstate.js b/src/lstate.js
index 2e6ebbe..519abde 100644
--- a/src/lstate.js
+++ b/src/lstate.js
@@ -69,7 +69,7 @@ class global_State {
constructor(L) {
this.mainthread = L;
- this.strt = null; // TODO: string hash table
+ this.strt = new Map();
this.l_registry = nil;
this.panic = null;
this.version = null;
@@ -77,6 +77,15 @@ class global_State {
this.mt = new Array(LUA_NUMTAGS);
}
+ intern(stringArray) {
+ let key = stringArray.map(e => `${e}|`).join('');
+
+ if (!this.strt.has(key))
+ this.strt.set(key, new lobject.TValue(CT.LUA_TLNGSTR, stringArray));
+
+ return this.strt.get(key);
+ }
+
}