diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-08 15:41:19 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-08 16:07:38 +1000 |
commit | e67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4 (patch) | |
tree | f42bc3854fe31ec86324dd55725d1d3ff963cf2e /src/lobject.js | |
parent | 41ad8917ca15b275c8aca20f6e3907a08ae7ad15 (diff) | |
download | fengari-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.js | 17 |
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) { |