aboutsummaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-08 15:41:19 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-08 16:07:38 +1000
commite67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4 (patch)
treef42bc3854fe31ec86324dd55725d1d3ff963cf2e /src/lobject.js
parent41ad8917ca15b275c8aca20f6e3907a08ae7ad15 (diff)
downloadfengari-e67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4.tar.gz
fengari-e67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4.tar.bz2
fengari-e67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4.zip
Add accessors to TValue for TString values
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 905eed1..77c63d0 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -155,8 +155,21 @@ class TValue {
this.value = tv.value;
}
+ tsvalue() {
+ assert(this.ttisstring());
+ return this.value;
+ }
+
+ svalue() {
+ return this.tsvalue();
+ }
+
+ vslen() {
+ return this.tsvalue().length;
+ }
+
jsstring(from, to) {
- return defs.to_jsstring(this.value, from, to);
+ return defs.to_jsstring(this.svalue(), from, to);
}
}
@@ -465,7 +478,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
}
pushstr(L, fmt.slice(i));
if (n > 0) lvm.luaV_concat(L, n+1);
- return L.stack[L.top-1].value;
+ return L.stack[L.top-1].svalue();
};
const luaO_pushfstring = function(L, fmt, ...argp) {