summaryrefslogtreecommitdiff
path: root/src/lstate.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-06 15:58:11 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-13 11:03:24 +0100
commite96d75a87d879f7f455e4b9c6457bf6580743fa5 (patch)
treea468f1c71ef765b0fc6acbfb32a49dc8ad9a0d65 /src/lstate.js
parent342a7db19607446720770cd2cfc5d275ce3f2ca9 (diff)
downloadfengari-e96d75a87d879f7f455e4b9c6457bf6580743fa5.tar.gz
fengari-e96d75a87d879f7f455e4b9c6457bf6580743fa5.tar.bz2
fengari-e96d75a87d879f7f455e4b9c6457bf6580743fa5.zip
String are represented by Array of 8-bit numbers
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);
+ }
+
}