new type `boolean'

This commit is contained in:
Roberto Ierusalimschy
2001-12-11 20:48:44 -02:00
parent ed9be5e1f0
commit 9aff171f3b
18 changed files with 166 additions and 121 deletions

View File

@@ -37,7 +37,8 @@ typedef union {
union Closure *cl;
struct Table *h;
struct lua_TObject *v;
lua_Number n; /* LUA_TNUMBER */
lua_Number n;
int b;
} Value;
@@ -55,7 +56,10 @@ typedef struct lua_TObject {
#define clvalue(o) ((o)->value.cl)
#define hvalue(o) ((o)->value.h)
#define vvalue(o) ((o)->value.v)
#define bvalue(o) ((o)->value.b)
#define l_isfalse(o) (ttype(o) == LUA_TNIL || \
(ttype(o) == LUA_TBOOLEAN && bvalue(o) == 0))
/* Macros to set values */
#define setnvalue(obj,x) \
@@ -63,6 +67,9 @@ typedef struct lua_TObject {
#define chgnvalue(obj,x) ((obj)->value.n=(x))
#define setbvalue(obj,x) \
{ TObject *_o=(obj); _o->tt=LUA_TBOOLEAN; _o->value.b=(x); }
#define setsvalue(obj,x) \
{ TObject *_o=(obj); _o->tt=LUA_TSTRING; _o->value.ts=(x); }