aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c4
-rw-r--r--lobject.h30
-rw-r--r--ltable.h6
3 files changed, 19 insertions, 21 deletions
diff --git a/lgc.c b/lgc.c
index 48a022e9..c8331b69 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.85 2001/02/02 15:13:05 roberto Exp roberto $ 2** $Id: lgc.c,v 1.86 2001/02/02 16:23:20 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -147,7 +147,7 @@ static void traversetable (GCState *st, Hash *h) {
147 Node *n = node(h, i); 147 Node *n = node(h, i);
148 if (ttype(val(n)) == LUA_TNIL) { 148 if (ttype(val(n)) == LUA_TNIL) {
149 if (ttype_key(n) != LUA_TNIL) 149 if (ttype_key(n) != LUA_TNIL)
150 n->key_value.v = NULL; /* dead key; remove it */ 150 n->key_value.ts = NULL; /* dead key; remove it */
151 } 151 }
152 else { 152 else {
153 lua_assert(ttype_key(n) != LUA_TNIL); 153 lua_assert(ttype_key(n) != LUA_TNIL);
diff --git a/lobject.h b/lobject.h
index 447b3622..215ab4a8 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.92 2001/02/01 17:40:48 roberto Exp roberto $ 2** $Id: lobject.h,v 1.93 2001/02/02 15:13:05 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -36,7 +36,10 @@
36 36
37 37
38typedef union { 38typedef union {
39 void *v; 39 struct TString *ts;
40 struct Closure *cl;
41 struct Hash *h;
42 struct CallInfo *info;
40 lua_Number n; /* LUA_TNUMBER */ 43 lua_Number n; /* LUA_TNUMBER */
41} Value; 44} Value;
42 45
@@ -50,10 +53,10 @@ typedef struct lua_TObject {
50/* Macros to access values */ 53/* Macros to access values */
51#define ttype(o) ((o)->tt) 54#define ttype(o) ((o)->tt)
52#define nvalue(o) ((o)->value.n) 55#define nvalue(o) ((o)->value.n)
53#define tsvalue(o) ((struct TString *)(o)->value.v) 56#define tsvalue(o) ((o)->value.ts)
54#define clvalue(o) ((struct Closure *)(o)->value.v) 57#define clvalue(o) ((o)->value.cl)
55#define hvalue(o) ((struct Hash *)(o)->value.v) 58#define hvalue(o) ((o)->value.h)
56#define infovalue(o) ((struct CallInfo *)(o)->value.v) 59#define infovalue(o) ((o)->value.info)
57#define svalue(o) (tsvalue(o)->str) 60#define svalue(o) (tsvalue(o)->str)
58 61
59 62
@@ -62,24 +65,19 @@ typedef struct lua_TObject {
62 { TObject *_o=(obj); _o->tt=LUA_TNUMBER; _o->value.n=(x); } 65 { TObject *_o=(obj); _o->tt=LUA_TNUMBER; _o->value.n=(x); }
63 66
64#define setsvalue(obj,x) \ 67#define setsvalue(obj,x) \
65 { TObject *_o=(obj); struct TString *_v=(x); \ 68 { TObject *_o=(obj); _o->tt=LUA_TSTRING; _o->value.ts=(x); }
66 _o->tt=LUA_TSTRING; _o->value.v=_v; }
67 69
68#define setuvalue(obj,x) \ 70#define setuvalue(obj,x) \
69 { TObject *_o=(obj); struct TString *_v=(x); \ 71 { TObject *_o=(obj); _o->tt=LUA_TUSERDATA; _o->value.ts=(x); }
70 _o->tt=LUA_TUSERDATA; _o->value.v=_v; }
71 72
72#define setclvalue(obj,x) \ 73#define setclvalue(obj,x) \
73 { TObject *_o=(obj); struct Closure *_v=(x); \ 74 { TObject *_o=(obj); _o->tt=LUA_TFUNCTION; _o->value.cl=(x); }
74 _o->tt=LUA_TFUNCTION; _o->value.v=_v; }
75 75
76#define sethvalue(obj,x) \ 76#define sethvalue(obj,x) \
77 { TObject *_o=(obj); struct Hash *_v=(x); \ 77 { TObject *_o=(obj); _o->tt=LUA_TTABLE; _o->value.h=(x); }
78 _o->tt=LUA_TTABLE; _o->value.v=_v; }
79 78
80#define setivalue(obj,x) \ 79#define setivalue(obj,x) \
81 { TObject *_o=(obj); struct CallInfo *_v=(x); \ 80 { TObject *_o=(obj); _o->tt=LUA_TMARK; _o->value.info=(x); }
82 _o->tt=LUA_TMARK; _o->value.v=_v; }
83 81
84#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) 82#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
85 83
diff --git a/ltable.h b/ltable.h
index 3757bd01..8de4c11b 100644
--- a/ltable.h
+++ b/ltable.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.h,v 1.30 2001/01/29 13:02:20 roberto Exp roberto $ 2** $Id: ltable.h,v 1.31 2001/01/29 17:17:26 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -15,13 +15,13 @@
15 15
16#define ttype_key(_n) ((_n)->key_tt) 16#define ttype_key(_n) ((_n)->key_tt)
17#define nvalue_key(_n) ((_n)->key_value.n) 17#define nvalue_key(_n) ((_n)->key_value.n)
18#define tsvalue_key(_n) ((TString *)(_n)->key_value.v) 18#define tsvalue_key(_n) ((_n)->key_value.ts)
19#define setkey2obj(_o,_k) \ 19#define setkey2obj(_o,_k) \
20 ((_o)->tt = ttype_key(_k), (_o)->value = (_k)->key_value) 20 ((_o)->tt = ttype_key(_k), (_o)->value = (_k)->key_value)
21#define setobj2key(_k,_o) \ 21#define setobj2key(_k,_o) \
22 (ttype_key(_k) = (_o)->tt, (_k)->key_value = (_o)->value) 22 (ttype_key(_k) = (_o)->tt, (_k)->key_value = (_o)->value)
23 23
24#define luaH_get(_t,_k) luaH_set(NULL,_t,_k) 24#define luaH_get(_t,_k) luaH_set(NULL,_t,_k)
25#define luaH_getnum(_t,_k) luaH_setnum(NULL,_t,_k) 25#define luaH_getnum(_t,_k) luaH_setnum(NULL,_t,_k)
26#define luaH_getstr(_t,_k) luaH_setstr(NULL,_t,_k) 26#define luaH_getstr(_t,_k) luaH_setstr(NULL,_t,_k)
27 27