diff options
author | daurnimator <quae@daurnimator.com> | 2017-04-27 14:36:54 +1000 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-28 14:15:58 +0200 |
commit | 6527126b549870eb1767dfc74e41d8e8eb7b62b5 (patch) | |
tree | e91659ab5240b75eff6d096aeb9a7129799a7c69 /src | |
parent | b45dc3dd1e3f9ef4548a5e422cb6f7daa9a3ba79 (diff) | |
download | fengari-6527126b549870eb1767dfc74e41d8e8eb7b62b5.tar.gz fengari-6527126b549870eb1767dfc74e41d8e8eb7b62b5.tar.bz2 fengari-6527126b549870eb1767dfc74e41d8e8eb7b62b5.zip |
src/lobject: Add setters to TValue class
Diffstat (limited to 'src')
-rw-r--r-- | src/lobject.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lobject.js b/src/lobject.js index 00f5ac6..d7751b3 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -117,6 +117,41 @@ class TValue { return this.ttisnil() || (this.ttisboolean() && this.value === false); } + setfltvalue(x) { + this.type = CT.LUA_TNUMFLT; + this.value = x; + } + + setivalue(x) { + this.type = CT.LUA_TNUMINT; + this.value = x; + } + + setnilvalue() { + this.type = CT.LUA_TNIL; + this.value = void 0; + } + + setfvalue(x) { + this.type = CT.LUA_TLCF; + this.value = x; + } + + setpvalue(x) { + this.type = CT.LUA_TLIGHTUSERDATA; + this.value = x; + } + + setbvalue(x) { + this.type = CT.LUA_TBOOLEAN; + this.value = x; + } + + setfrom(tv) { /* in lua C source setobj2t is often used for this */ + this.type = tv.type; + this.value = tv.value; + } + jsstring(from, to) { return defs.to_jsstring(this.value, from, to); } |