From e67fb5f4cb51fbf4061ab647ef08ef4893b7f0e4 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 8 May 2017 15:41:19 +1000 Subject: Add accessors to TValue for TString values --- src/lobject.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/lobject.js') 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) { -- cgit v1.2.3-54-g00ecf