summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 07:38:03 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 08:23:00 +0100
commita2031547aafbb07f6284cd10704435db23d9db60 (patch)
tree75677f2714f10cb6e7e298542af9d650e235c6d1 /src/lobject.js
parent364326b97450564d41d37cdc7b2c4fbb8049c62f (diff)
downloadfengari-a2031547aafbb07f6284cd10704435db23d9db60.tar.gz
fengari-a2031547aafbb07f6284cd10704435db23d9db60.tar.bz2
fengari-a2031547aafbb07f6284cd10704435db23d9db60.zip
callstatus, OP_LE, OP_JMP, tests use L.top
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 4cc8c4e..3781623 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -12,6 +12,96 @@ class TValue {
this.metatable = null;
}
+ /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
+ ttype() {
+ return this.type & 0x3F;
+ }
+
+ /* type tag of a TValue with no variants (bits 0-3) */
+ ttnov() {
+ return this.type & 0x0F;
+ }
+
+ checktag(t) {
+ return this.type === t;
+ }
+
+ checktype(t) {
+ return this.ttnov() === t;
+ }
+
+ ttisnumber() {
+ return this.checktype(CT.LUA_TNUMBER);
+ }
+
+ ttisfloat() {
+ return this.checktag(CT.LUA_TNUMFLT);
+ }
+
+ ttisinteger() {
+ return this.checktag(CT.LUA_TNUMINT);
+ }
+
+ ttisnil() {
+ return this.checktag(CT.LUA_TNIL);
+ }
+
+ ttisboolean() {
+ return this.checktag(CT.LUA_TBOOLEAN);
+ }
+
+ ttislightuserdata() {
+ return this.checktag(CT.LUA_TLIGHTUSERDATA);
+ }
+
+ ttisstring() {
+ return this.checktype(CT.LUA_TSTRING);
+ }
+
+ ttisshrstring() {
+ return this.checktag(ctb(CT.LUA_TSHRSTR));
+ }
+
+ ttislngstring() {
+ return this.checktag(ctb(CT.LUA_TLNGSTR));
+ }
+
+ ttistable() {
+ return this.checktag(ctb(CT.LUA_TTABLE));
+ }
+
+ ttisfunction() {
+ return this.checktype(CT.LUA_TFUNCTION);
+ }
+
+ ttisclosure() {
+ return (this.type & 0x1F) === CT.LUA_TFUNCTION;
+ }
+
+ ttisCclosure() {
+ return this.checktag(ctb(CT.LUA_TCCL));
+ }
+
+ ttisLclosure() {
+ return this.checktag(ctb(CT.LUA_TLCL));
+ }
+
+ ttislcf() {
+ return this.checktag(CT.LUA_TLCF);
+ }
+
+ ttisfulluserdata() {
+ return this.checktag(ctb(CT.LUA_TUSERDATA));
+ }
+
+ ttisthread() {
+ return this.checktag(ctb(CT.LUA_TTHREAD));
+ }
+
+ ttisdeadkey() {
+ return this.checktag(CT.LUA_TDEADKEY);
+ }
+
}